forked from mcminickpt/mcmini
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_script
More file actions
executable file
·139 lines (125 loc) · 15 KB
/
test_script
File metadata and controls
executable file
·139 lines (125 loc) · 15 KB
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
#!/usr/bin/env python3
# Script for the execution of test program
import os
import argparse
program_msg = "Specify which program do you wish to run without saying whether its a deadlock version or not? If not specified the script will run all program deadlock or non-deadlock based on the deadlock flag"
deadlock_msg = "An optional flag for running a deadlock version of the program(s)."
directory_msg = "Path for the directory in which you want to store the output of the program(s)."
parser = argparse.ArgumentParser()
parser.add_argument('-p', '--program', type = str, help = program_msg) #args.program
parser.add_argument('-d', '--deadlock', action = 'store_true', help = deadlock_msg) #args.deadlock
parser.add_argument('-dir', '--directory', type = str, help = directory_msg) #args.directory
args = parser.parse_args()
print(args)
'''
DEADLOCK program
'''
# Running a specified deadlock program with a defualt output path
if (args.deadlock and args.program != "" and args.directory == ""):
os.system("(time ./mcmini ../test/deadlock_program/" + args.program + ") 2>&1 | tee ../test/output_deadlock/" + args.program)
# Running a specified deadlock program with a custom output path
if (args.deadlock and args.program != "" and args.directory != ""):
os.system("(time ./mcmini ../test/deadlock_program" + args.program + ") 2>&1 | tee " + args.directory)
# Running all deadlock program with a default output path
if (args.deadlock and args.program == "" and args.directory == ""):
os.system("(time ./mcmini ../test/deadlock_program/barber_shop_deadlock) 2>&1 | tee ../test/output_deadlock/barber_shop_deadlock")
os.system("(time ./mcmini ../test/deadlock_program/producer_consumer_deadlock) 2>&1 | tee ../test/output_deadlock/producer_consumer_deadlock")
os.system("(time ./mcmini ../test/deadlock_program/philosophers_semaphores_deadlock) 2>&1 | tee ../test/output_deadlock/philosophers_semaphores_deadlock")
os.system("(time ./mcmini ../test/deadlock_program/philosophers_mutex_deadlock) 2>&1 | tee ../test/output_deadlock/philosophers_mutex_deadlock")
os.system("(time ./mcmini ../test/deadlock_program/simple_cond_braodcast_with_semaphore_deadlock1) 2>&1 | tee ../test/output_deadlock/simple_cond_braodcast_with_semaphore_deadlock1")
os.system("(time ./mcmini ../test/deadlock_program/simple_barrier_with_threads_deadlock) 2>&1 | tee ../test/output_deadlock/simple_barrier_with_threads_deadlock")
os.system("(time ./mcmini ../test/deadlock_program/simple_barrier_deadlock) 2>&1 | tee ../test/output_deadlock/simple_barrier_deadlock")
os.system("(time ./mcmini ../test/deadlock_program/reader_writer/reader_writer_writer_preferred_deadlock) 2>&1 | tee ../test/output_deadlock/reader_writer_writer_preferred_deadlock")
os.system("(time ./mcmini ../test/deadlock_program/reader_writer/reader_writer__reader_preferred_deadlock) 2>&1 | tee ../test/output_deadlock/reader_writer__reader_preferred_deadlock")
os.system("(time ./mcmini ../test/deadlock_program/reader_writer/reader_writer_mostly_writer_preferred_deadlock) 2>&1 | tee ../test/output_deadlock/reader_writer_mostly_writer_preferred_deadlock")
os.system("(time ./mcmini ../test/deadlock_program/reader_writer/reader_writer_fifo_deadlock) 2>&1 | tee ../test/output_deadlock/reader_writer_fifo_deadlock")
os.system("(time ./mcmini ../test/deadlock_program/reader_writer/reader_writer_cond_deadlock) 2>&1 | tee ../test/output_deadlock/reader_writer_cond_deadlock")
os.system("(time ./mcmini ../test/deadlock_program/simple_mutex_deadlock) 2>&1 | tee ../test/output_deadlock/simple_mutex_deadlock")
os.system("(time ./mcmini ../test/deadlock_program/simple_cond_deadlock) 2>&1 | tee ../test/output_deadlock/simple_cond_deadlock")
os.system("(time ./mcmini ../test/deadlock_program/simple_cond_broadcast_deadlock) 2>&1 | tee ../test/output_deadlock/simple_cond_broadcast_deadlock")
os.system("(time ./mcmini ../test/deadlock_program/simple_cond_braodcast_with_semaphore_deadlock2) 2>&1 | tee ../test/output_deadlock/simple_cond_braodcast_with_semaphore_deadlock2")
os.system("(time ./mcmini ../test/deadlock_program/simple_semaphores_with_threads_deadlock) 2>&1 | tee ../test/output_deadlock/simple_semaphores_with_threads_deadlock")
os.system("(time ./mcmini ../test/deadlock_program/simple_semaphores_deadlock) 2>&1 | tee ../test/output_deadlock/simple_semaphores_deadlock")
os.system("(time ./mcmini ../test/deadlock_program/simple_semaphore_deadlock) 2>&1 | tee ../test/output_deadlock/simple_semaphore_deadlock")
os.system("(time ./mcmini ../test/deadlock_program/simple_mutex_with_threads_deadlock) 2>&1 | tee ../test/output_deadlock/simple_mutex_with_threads_deadlock")
os.system("(time ./mcmini ../test/deadlock_program/custom/philosophers_custom_semaphore_deadlock) 2>&1 | tee ../test/output_deadlock/philosophers_custom_semaphore_deadlock")
os.system("(time ./mcmini ../test/deadlock_program/custom/simple_custom_cond_broadcast_deadlock) 2>&1 | tee ../test/output_deadlock/simple_custom_cond_broadcast_deadlock")
# Running all deadlock program and putting their output in a specified directory by providing its path
if (args.deadlock and args.program == "" and args.directory == ""):
os.system("(time ./mcmini ../test/deadlock_program/barber_shop_deadlock) 2>&1 | tee " + args.directory + "/barber_shop_deadlock")
os.system("(time ./mcmini ../test/deadlock_program/producer_consumer_deadlock) 2>&1 | tee " + args.directory + "/producer_consumer_deadlock")
os.system("(time ./mcmini ../test/deadlock_program/philosophers_semaphores_deadlock) 2>&1 | tee " + args.directory + "/philosophers_semaphores_deadlock")
os.system("(time ./mcmini ../test/deadlock_program/philosophers_mutex_deadlock) 2>&1 | tee " + args.directory + "/philosophers_mutex_deadlock")
os.system("(time ./mcmini ../test/deadlock_program/simple_cond_braodcast_with_semaphore_deadlock1) 2>&1 | tee " + args.directory + "/simple_cond_braodcast_with_semaphore_deadlock1")
os.system("(time ./mcmini ../test/deadlock_program/simple_barrier_with_threads_deadlock) 2>&1 | tee " + args.directory + "/simple_barrier_with_threads_deadlock")
os.system("(time ./mcmini ../test/deadlock_program/simple_barrier_deadlock) 2>&1 | tee " + args.directory + "/simple_barrier_deadlock")
os.system("(time ./mcmini ../test/deadlock_program/reader_writer/reader_writer_writer_preferred_deadlock) 2>&1 | tee " + args.directory + "/reader_writer_writer_preferred_deadlock")
os.system("(time ./mcmini ../test/deadlock_program/reader_writer/reader_writer__reader_preferred_deadlock) 2>&1 | tee " + args.directory + "/reader_writer__reader_preferred_deadlock")
os.system("(time ./mcmini ../test/deadlock_program/reader_writer/reader_writer_mostly_writer_preferred_deadlock) 2>&1 | tee " + args.directory + "/reader_writer_mostly_writer_preferred_deadlock")
os.system("(time ./mcmini ../test/deadlock_program/reader_writer/reader_writer_fifo_deadlock) 2>&1 | tee " + args.directory + "/reader_writer_fifo_deadlock")
os.system("(time ./mcmini ../test/deadlock_program/reader_writer/reader_writer_cond_deadlock) 2>&1 | tee " + args.directory + "/reader_writer_cond_deadlock")
os.system("(time ./mcmini ../test/deadlock_program/simple_mutex_deadlock) 2>&1 | tee " + args.directory + "/simple_mutex_deadlock")
os.system("(time ./mcmini ../test/deadlock_program/simple_cond_deadlock) 2>&1 | tee " + args.directory + "/simple_cond_deadlock")
os.system("(time ./mcmini ../test/deadlock_program/simple_cond_broadcast_deadlock) 2>&1 | tee " + args.directory + "/simple_cond_broadcast_deadlock")
os.system("(time ./mcmini ../test/deadlock_program/simple_cond_braodcast_with_semaphore_deadlock2) 2>&1 | tee " + args.directory + "/simple_cond_braodcast_with_semaphore_deadlock2")
os.system("(time ./mcmini ../test/deadlock_program/simple_semaphores_with_threads_deadlock) 2>&1 | tee " + args.directory + "/simple_semaphores_with_threads_deadlock")
os.system("(time ./mcmini ../test/deadlock_program/simple_semaphores_deadlock) 2>&1 | tee " + args.directory + "/simple_semaphores_deadlock")
os.system("(time ./mcmini ../test/deadlock_program/simple_semaphore_deadlock) 2>&1 | tee " + args.directory + "/simple_semaphore_deadlock")
os.system("(time ./mcmini ../test/deadlock_program/simple_mutex_with_threads_deadlock) 2>&1 | tee " + args.directory + "/simple_mutex_with_threads_deadlock")
os.system("(time ./mcmini ../test/deadlock_program/custom/philosophers_custom_semaphore_deadlock) 2>&1 | tee " + args.directory + "/philosophers_custom_semaphore_deadlock")
os.system("(time ./mcmini ../test/deadlock_program/custom/simple_custom_cond_broadcast_deadlock) 2>&1 | tee " + args.directory + "/simple_custom_cond_broadcast_deadlock")
'''
NON-DEADLOCK program
'''
# Running a specified non-deadlock program with a defualt output path
if ((not (args.deadlock)) and args.program != "" and args.directory == ""):
os.system("(time ./mcmini ../test/program/" + args.program + ") 2>&1 | tee ../test/output_non_deadlock/" + args.program)
# Running a specified non-deadlock program with a custom output path
if ((not (args.deadlock)) and args.program != "" and args.directory != ""):
os.system("(time ./mcmini ../test/program/" + args.program + ") 2>&1 | tee " + args.directory)
# Running all non-deadlock program with a default output path
if ((not (args.deadlock)) and args.program == "" and args.directory == ""):
os.system("(time ./mcmini ../test/program/barber_shop) 2>&1 | tee ../test/output_non_deadlock/barber_shop")
os.system("(time ./mcmini ../test/program/philosophers_semaphores) 2>&1 | tee ../test/output_non_deadlock/philosophers_semaphores")
os.system("(time ./mcmini ../test/program/philosophers_mutex) 2>&1 | tee ../test/output_non_deadlock/philosophers_mutex")
os.system("(time ./mcmini ../test/program/reader_writer/reader_writer_writer_preferred) 2>&1 | tee ../test/output_non_deadlock/reader_writer_writer_preferred")
os.system("(time ./mcmini ../test/program/reader_writer/reader_writer__reader_preferred) 2>&1 | tee ../test/output_non_deadlock/reader_writer__reader_preferred")
os.system("(time ./mcmini ../test/program/reader_writer/reader_writer_fifo) 2>&1 | tee ../test/output_non_deadlock/reader_writer_fifo")
os.system("(time ./mcmini ../test/program/reader_writer/reader_writer_cond) 2>&1 | tee ../test/output_non_deadlock/reader_writer_cond")
os.system("(time ./mcmini ../test/program/producer_consumer) 2>&1 | tee ../test/output_non_deadlock/producer_consumer")
os.system("(time ./mcmini ../test/program/simple_cond_braodcast) 2>&1 | tee ../test/output_non_deadlock/simple_cond_braodcast")
os.system("(time ./mcmini ../test/program/simple_barrier_with_threads) 2>&1 | tee ../test/output_non_deadlock/simple_barrier_with_threads")
os.system("(time ./mcmini ../test/program/simple_barrier) 2>&1 | tee ../test/output_non_deadlock/simple_barrier")
os.system("(time ./mcmini ../test/program/simple_mutex) 2>&1 | tee ../test/output_non_deadlock/simple_mutex")
os.system("(time ./mcmini ../test/program/simple_cond) 2>&1 | tee ../test/output_non_deadlock/simple_cond")
os.system("(time ./mcmini ../test/program/simple_cond_broadcast_with_semaphore) 2>&1 | tee ../test/output_non_deadlock/simple_cond_broadcast_with_semaphore")
os.system("(time ./mcmini ../test/program/simple_semaphores_with_threads) 2>&1 | tee ../test/output_non_deadlock/simple_semaphores_with_threads")
os.system("(time ./mcmini ../test/program/simple_semaphores) 2>&1 | tee ../test/output_non_deadlock/simple_semaphores")
os.system("(time ./mcmini ../test/program/simple_mutex_with_threads) 2>&1 | tee ../test/output_non_deadlock/simple_mutex_with_threads")
os.system("(time ./mcmini ../test/program/simple_threads) 2>&1 | tee ../test/output_non_deadlock/simple_threads")
os.system("(time ./mcmini ../test/program/custom/philosophers_custom_semaphores) 2>&1 | tee ../test/output_non_deadlock/philosophers_custom_semaphores")
os.system("(time ./mcmini ../test/program/custom/simple_custom_barrier_with_threads) 2>&1 | tee ../test/output_non_deadlock/simple_custom_barrier_with_threads")
os.system("(time ./mcmini ../test/program/custom/simple_custom_cond_broadcast) 2>&1 | tee ../test/output_non_deadlock/simple_custom_cond_broadcast")
# Running all non-deadlock program and putting them in a specified directory by providing its path
if ((not (args.deadlock)) and args.program == "" and args.directory != ""):
os.system("(time ./mcmini ../test/program/barber_shop) 2>&1 | tee " + args.directory + "/barber_shop")
os.system("(time ./mcmini ../test/program/philosophers_semaphores) 2>&1 | tee " + args.directory + "/philosophers_semaphores")
os.system("(time ./mcmini ../test/program/philosophers_mutex) 2>&1 | tee " + args.directory + "/philosophers_mutex")
os.system("(time ./mcmini ../test/program/reader_writer/reader_writer_writer_preferred) 2>&1 | tee " + args.directory + "/reader_writer_writer_preferred")
os.system("(time ./mcmini ../test/program/reader_writer/reader_writer__reader_preferred) 2>&1 | tee " + args.directory + "/reader_writer__reader_preferred")
os.system("(time ./mcmini ../test/program/reader_writer/reader_writer_fifo) 2>&1 | tee " + args.directory + "/reader_writer_fifo")
os.system("(time ./mcmini ../test/program/reader_writer/reader_writer_cond) 2>&1 | tee " + args.directory + "/reader_writer_cond")
os.system("(time ./mcmini ../test/program/producer_consumer) 2>&1 | tee " + args.directory + "/producer_consumer")
os.system("(time ./mcmini ../test/program/simple_cond_braodcast) 2>&1 | tee " + args.directory + "/simple_cond_braodcast")
os.system("(time ./mcmini ../test/program/simple_barrier_with_threads) 2>&1 | tee " + args.directory + "/simple_barrier_with_threads")
os.system("(time ./mcmini ../test/program/simple_barrier) 2>&1 | tee " + args.directory + "/simple_barrier")
os.system("(time ./mcmini ../test/program/simple_mutex) 2>&1 | tee " + args.directory + "/simple_mutex")
os.system("(time ./mcmini ../test/program/simple_cond) 2>&1 | tee " + args.directory + "/simple_cond")
os.system("(time ./mcmini ../test/program/simple_cond_broadcast_with_semaphore) 2>&1 | tee " + args.directory + "/simple_cond_broadcast_with_semaphore")
os.system("(time ./mcmini ../test/program/simple_semaphores_with_threads) 2>&1 | tee " + args.directory + "/simple_semaphores_with_threads")
os.system("(time ./mcmini ../test/program/simple_semaphores) 2>&1 | tee " + args.directory + "/simple_semaphores")
os.system("(time ./mcmini ../test/program/simple_mutex_with_threads) 2>&1 | tee " + args.directory + "/simple_mutex_with_threads")
os.system("(time ./mcmini ../test/program/simple_threads) 2>&1 | tee " + args.directory + "/simple_threads")
os.system("(time ./mcmini ../test/program/custom/philosophers_custom_semaphores) 2>&1 | tee " + args.directory + "/philosophers_custom_semaphores")
os.system("(time ./mcmini ../test/program/custom/simple_custom_barrier_with_threads) 2>&1 | tee " + args.directory + "/simple_custom_barrier_with_threads")
os.system("(time ./mcmini ../test/program/custom/simple_custom_cond_broadcast) 2>&1 | tee " + args.directory + "/simple_custom_cond_broadcast")