-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontrol.py
109 lines (72 loc) · 3.04 KB
/
control.py
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
import subprocess
import time
import sys
small_case = [
"python3 config.py 64 18",
"python3 config.py 64 20",
"python3 config.py 1024 14",
"python3 config.py 1024 16",
"python3 config.py 4096 12",
"python3 config.py 4096 14",
]
medium_case = [
"python3 config.py 64 22",
"python3 config.py 64 24",
"python3 config.py 1024 18",
"python3 config.py 1024 20",
"python3 config.py 4096 16",
"python3 config.py 4096 18",
]
large_case = [
"python3 config.py 64 26",
"python3 config.py 64 28",
"python3 config.py 1024 22",
"python3 config.py 1024 24",
"python3 config.py 4096 20",
"python3 config.py 4096 22",
]
build = "cargo build --release"
prep = "./target/release/helper"
pirex_server = "./target/release/pirex_sread"
pirex_client = "./target/release/pirex_uread"
pirexx_server = "./target/release/pirexx_sread"
pirexx_client = "./target/release/pirexx_uread"
find_port = "lsof -t -i :8111"
def pirex_test(case):
PID = subprocess.run(find_port, capture_output=True, shell=True, text=True).stdout.strip()
if PID: subprocess.run(f"kill -9 {PID}", shell=True, check=True)
for test in case:
subprocess.run(test, shell=True, check=True)
subprocess.run(build, shell=True, check=True)
subprocess.run(prep, shell=True, check=True)
process = subprocess.Popen(pirex_server, shell=True)
subprocess.run(pirex_client, shell=True, check=True)
PID = subprocess.run(find_port, capture_output=True, shell=True, text=True).stdout.strip()
if PID: subprocess.run(f"kill -9 {PID}", shell=True, check=True)
def pirexx_test(case):
PID = subprocess.run(find_port, capture_output=True, shell=True, text=True).stdout.strip()
if PID: subprocess.run(f"kill -9 {PID}", shell=True, check=True)
for test in case:
subprocess.run(test, shell=True, check=True)
subprocess.run(build, shell=True, check=True)
server = subprocess.Popen(pirexx_server, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
client = subprocess.run(pirexx_client, capture_output=True, shell=True, check=True)
PID = subprocess.run(find_port, capture_output=True, shell=True, text=True).stdout.strip()
if PID: subprocess.run(f"kill -9 {PID}", shell=True, check=True)
client_out = client.stdout
server_out, stderr = server.communicate()
with open("results/pirexx_client_online.txt", "ab") as file:
file.write(client_out)
with open("results/pirexx_server_online.txt", "ab") as file:
file.write(server_out)
if len(sys.argv) > 1:
sch = sys.argv[1]
inp = sys.argv[2]
if sch == "pirex":
if inp == "small": pirex_test(small_case)
if inp == "medium": pirex_test(medium_case)
if inp == "large": pirex_test(large_case)
if sch == "pirexx":
if inp == "small": pirexx_test(small_case)
if inp == "medium": pirexx_test(medium_case)
if inp == "large": pirexx_test(large_case)