-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtester.py
44 lines (40 loc) · 1.43 KB
/
tester.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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import difflib, os
###########################################################
### NOTE: ###
### If you are using the official testing files, ###
### Rename them from WRR to RR. ###
###########################################################
FOLDER_SRC = './IO_files'
FOLDER_DST = './our_files'
tests = [[['DRR', 1, 2],
['DRR', 3, 2],
['RR' , 1, 0],
['RR' , 3, 0]],
[['DRR', 1, 10],
['DRR', 8, 10],
['RR' , 1, 0],
['RR' , 8, 0]],
[['DRR', 1, 40],
['DRR', 30, 40],
['RR' , 1, 0],
['RR' , 30, 0]]]
GREEN = '\033[92m'
RED = '\033[91m'
ENDC = '\033[0m'
for indx in range(len(tests)):
for test in tests[indx]:
file_src = '{}/inp{}.txt'.format(FOLDER_SRC, indx+1)
file_cmpr = '{src}/out{indx}_{algo}_w{weight}_q{quantum}.txt'.format(algo=test[0], weight=test[1], quantum=test[2], src=FOLDER_SRC, dst=FOLDER_DST, indx=indx+1)
file_dst = '{dst}/test{indx}_{algo}_w{weight}_q{quantum}.txt'.format(algo=test[0], weight=test[1], quantum=test[2], src=FOLDER_SRC, dst=FOLDER_DST, indx=indx+1)
command = './sch {algo} {src} {dst} {weight} {quantum}'.format(algo=test[0], src=file_src, dst=file_dst, weight=test[1], quantum=test[2])
os.system(command)
try:
if difflib.SequenceMatcher(None, open(file_cmpr).read(), open(file_dst).read()).ratio() == 1.0:
res = GREEN
else:
res = RED
except:
res = RED
print('{}{}{}'.format(res, command, ENDC))