forked from includeos/IncludeOS
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvalidate_tests.py
More file actions
executable file
·56 lines (43 loc) · 1.45 KB
/
validate_tests.py
File metadata and controls
executable file
·56 lines (43 loc) · 1.45 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
#!/usr/bin/env python
import sys
sys.path.insert(0, ".")
sys.path.insert(0, "..")
import subprocess
import os
from vmrunner import validate_vm
from vmrunner.prettify import color
# Verify if a given path is a valid integration test
def validate_test(path, verb = False):
try:
# Load any valid configs in path
valid_configs = validate_vm.load_config(path)
if not valid_configs:
raise Exception("No valid JSON config in path")
# Additional requirements for tests
required_files = ["CMakeLists.txt", "test.py"]
for f in required_files:
if not os.path.isfile(path + "/" + f):
raise Exception("Required file " + f + " missing")
if verb:
print "<validate_test> \tPASS: ",path
return True, "PASS"
except Exception as err:
if verb:
print "<validate_test> \tFAIL: ", path, ": " , err.message
return False, err.message
def valid_tests(verb = False):
tests = []
dirs = os.walk('.').next()[1]
for directory in dirs:
subdirs = os.walk(directory).next()[1]
if "integration" in subdirs:
subdirs = os.walk(directory + "/integration").next()[1]
if subdirs:
for d in subdirs:
path = directory + "/integration/" + d
passed, err = validate_test(path, verb)
if passed:
tests.append(path)
return tests
if __name__ == "__main__":
valid_tests(verb = True)