blob: 1bb0286f662ad88caf990f6d8dd37e5d4bd7a6b1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
#!/usr/bin/env python3
# ############################################################################ #
# #
# ::: :::::::: #
# run :+: :+: :+: #
# +:+ +:+ +:+ #
# By: charles <me@cacharle.xyz> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2020/09/27 11:36:34 by charles #+# #+# #
# Updated: 2020/09/27 11:36:34 by charles ### ########.fr #
# #
# ############################################################################ #
# [x] invalid state switch
# [x] none existant fork
# [x] timestamp not in order
# [ ] crash
# [ ] should be infinity
# [x] argument error
# [x] print lines after died
# [x] bad output format
# [x] should be dead
import sys
import subprocess
import config
from test import Test
from args import parse_args
from suite import suite
from helper import blue
def main():
args = parse_args()
if config.BUILD_BEFORE or args.build:
try:
print(blue("=====================================BUILD======================================"))
subprocess.run(
config.BUILD_CMD.format(path=config.PHILO_PATHS[0]).split(' '),
check=True
)
print(blue("================================================================================"))
except subprocess.CalledProcessError:
sys.exit(1)
if args.build:
sys.exit(0)
config.TIMEOUT = args.timeout
suite()
try:
if args.philo == 0:
for philo in range(3):
Test.run_all(config.PHILO_EXEC_PATHS[philo])
else:
Test.run_all(config.PHILO_EXEC_PATHS[args.philo - 1])
except KeyboardInterrupt:
pass
finally:
Test.write_failed()
if args.pager:
subprocess.run([*config.PAGER_CMD, config.RESULT_FILE])
else:
print()
Test.print_summary()
print("Read {} for more information".format(config.RESULT_FILE))
if __name__ == "__main__":
main()
|