-
Notifications
You must be signed in to change notification settings - Fork 11
/
test.py
67 lines (56 loc) · 2.43 KB
/
test.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
55
56
57
58
59
60
61
62
63
64
65
66
67
# detect if running on a supported beagle or not
supported_models = [
'TI AM335x BeagleBone Black Wireless',
'TI AM335x BeagleBone Black',
'TI AM335x PocketBeagle',
'BeagleBoard.org BeagleBone AI'
]
running_on_beagle = False
try:
with open("/proc/device-tree/model") as file:
model = file.read(100).strip()
if model in supported_models:
print("Detected: ", model)
running_on_beagle = True
except OSError:
print("Not running on a BeagleBone")
# run_anywhere tests
import subprocess
from fnmatch import fnmatch
import os
import sys
for file in os.listdir("tests/run_anywhere"):
if fnmatch(file, "*.sim"):
print(f" ")
print("Running test ", file)
transpile_output = subprocess.run(f"bin/simppru --preprocess -t tests/run_anywhere/{file}", shell=True, capture_output=True)
if transpile_output.returncode != 0:
print(f"**** ****TEST FAILED**** ****: {file}")
print("stdout:\n", transpile_output.stdout.decode("utf-8"), sep='')
print("stderr:\n", transpile_output.stderr.decode("utf-8"), sep='')
sys.exit(1)
compile_output = subprocess.run(f"gcc -o tests/run_anywhere/{file}.out /tmp/temp.c", shell=True, capture_output=True)
if compile_output.returncode != 0:
print(f"**** ****TEST FAILED**** ****: {file}")
print("stdout:\n", compile_output.stdout.decode("utf-8"), sep='')
print("stderr:\n", compile_output.stderr.decode("utf-8"), sep='')
sys.exit(1)
run_output = subprocess.run(f"tests/run_anywhere/{file}.out", shell=True, capture_output=True)
if run_output.returncode != 0:
print(f"**** ****TEST FAILED**** ****: {file}")
print("stdout:\n", run_output.stdout.decode("utf-8"), sep='')
print("stderr:\n", run_output.stderr.decode("utf-8"), sep='')
sys.exit(1)
else:
output = run_output.stdout
with open(f"tests/run_anywhere/{file}.output", 'r+b') as out:
expected_output = out.read()
if output != expected_output:
print(f"**** ****TEST FAILED**** ****: {file}")
print(f"Standard Output:{output}")
print(f"Expected Output:{expected_output}")
sys.exit(1)
else:
print(f"Test {file} passed")
print(f"Standard Output:{output}")
print(f"Expected Output:{expected_output}")