-
Notifications
You must be signed in to change notification settings - Fork 1
/
parse_tester.py
executable file
·54 lines (45 loc) · 1.14 KB
/
parse_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
44
45
46
47
48
49
50
51
52
53
54
#! /usr/bin/python3
import subprocess
import glob
#
# TODO:
# - log file
# - check if parsed correctly
#
class bcolors:
HEADER = '\033[95m'
OKBLUE = '\033[94m'
OKCYAN = '\033[96m'
OKGREEN = '\033[92m'
WARNING = '\033[93m'
FAIL = '\033[91m'
ENDC = '\033[0m'
BOLD = '\033[1m'
UNDERLINE = '\033[4m'
# f = open("log.txt", "w")
def test(path_to_config):
result = subprocess.run(['./plebserv', '-t', path_to_config], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
# res = result.stdout.decode('utf-8').split("\n")
return (result.returncode)
def main():
onlyfiles = glob.glob("parsing_configs/*.conf")
count = 0
error_count = 0
result = 0
for i in onlyfiles:
if (i.find('wr') != -1):
result = test(i) - 1
else:
result = test(i)
if (result == 0):
print('{:<40s} {:>20s}'.format(i, "\t\t" + bcolors.OKGREEN + "[ OK ]" + bcolors.ENDC))
else:
print('{:<40s} {:>20s}'.format(i, "\t\t" + bcolors.FAIL + "[ KO ]" + bcolors.ENDC))
error_count += 1
count += 1
print(str(count - error_count) + " out of " + str(count) + " OK")
if (error_count):
exit(1)
exit(0)
if __name__ == "__main__":
main()