-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest.py
More file actions
executable file
·41 lines (34 loc) · 1.12 KB
/
test.py
File metadata and controls
executable file
·41 lines (34 loc) · 1.12 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
#!/usr/bin/python
import os, sys
import fnmatch
import subprocess
import filecmp
def testCode( retcode, msg ):
if retcode > 0:
print msg
sys.exit( 1 )
testDir = os.path.join( os.getcwd(), 'cases')
if not os.path.isdir( testDir ):
print testDir, "isn't a directory"
sys.exit( 1 )
executable = os.path.join(os.getcwd(), "run")
if not os.path.isfile( executable ):
retcode = subprocess.call("make",shell=True)
testCode( retcode, "\tFAILED to make the scanner" )
files = os.listdir( testDir )
for x in files:
if fnmatch.fnmatch(x, "*.py"):
testcase = os.path.join(testDir, x)
retcode = subprocess.call("./run < "+testcase+"> /tmp/out",shell=True)
if retcode != 0:
testCode( retcode, "\tFAILED to run test case "+x)
else:
output = testcase[:-3]+".out"
if not os.path.isfile( output ):
print "test case", x[:-3]+'.out', "doesn't exist"
sys.exit( 1 )
if not filecmp.cmp("/tmp/out", output):
print "\tTEST CASE FAILED\033[1;31;5m", x, "\033[0;0m"
else :
print "testcase:\033[1;32;5m", x, "\033[0;0mpassed"
# os.system("cat -n "+testcase)