39 lines
1.0 KiB
Python
39 lines
1.0 KiB
Python
#!/usr/bin/env python3
|
|
|
|
import glob
|
|
import os.path
|
|
import subprocess
|
|
import re
|
|
|
|
SDIR = "@abs_top_srcdir@"
|
|
BDIR = "@abs_top_builddir@"
|
|
|
|
TOOL = os.path.join(BDIR, "tools/json-schema")
|
|
|
|
TEST_EXTRACT = re.compile("(.*?)_(\d{4})_(pass|fail).json")
|
|
|
|
SCHEMA_DIR = os.path.join(SDIR, "test/json/schema")
|
|
SCHEMAS = glob.iglob(os.path.join(SCHEMA_DIR, "*.schema"))
|
|
|
|
EXPECTED = {
|
|
"pass": 0,
|
|
"fail": 1
|
|
}
|
|
|
|
|
|
print("1..%s" % len(glob.glob(os.path.join(SCHEMA_DIR, "*.json"))))
|
|
|
|
for schema in SCHEMAS:
|
|
(name, _) = os.path.splitext(os.path.basename(schema))
|
|
test_glob = name + "_*.json"
|
|
|
|
for test in glob.iglob(os.path.join(SCHEMA_DIR, test_glob)):
|
|
command = [TOOL, schema, test]
|
|
(name, seq, success) = TEST_EXTRACT.match(test).groups()
|
|
res = subprocess.call(command, stdout=subprocess.DEVNULL,stderr=subprocess.STDOUT)
|
|
|
|
if res != EXPECTED[success]:
|
|
print('not ok -', os.path.basename(test), '#', ' '.join(command))
|
|
else:
|
|
print('ok -', os.path.basename(test))
|