Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 19d83fb

Browse files
committedSep 29, 2024··
ci(tests): Add linpack FPU tests
1 parent b05f18d commit 19d83fb

File tree

6 files changed

+2540
-0
lines changed

6 files changed

+2540
-0
lines changed
 
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"platforms": {
3+
"qemu": false,
4+
"wokwi": false
5+
}
6+
}

‎tests/performance/linpack_double/linpack_double.ino

Lines changed: 1195 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
import json
2+
import logging
3+
import os
4+
5+
6+
def test_linpack_double(dut, request):
7+
LOGGER = logging.getLogger(__name__)
8+
9+
# Match "Runs: %d"
10+
res = dut.expect(r"Runs: (\d+)", timeout=60)
11+
runs = int(res.group(0).decode("utf-8").split(" ")[1])
12+
LOGGER.info("Number of runs: {}".format(runs))
13+
assert runs > 0, "Invalid number of runs"
14+
15+
# Match "Type: %s"
16+
res = dut.expect(r"Type: (\w+)", timeout=60)
17+
data_type = res.group(0).decode("utf-8").split(" ")[1]
18+
LOGGER.info("Data type: {}".format(data_type))
19+
assert data_type == "double", "Invalid data type"
20+
21+
for i in range(runs):
22+
# Match "Run %d"
23+
res = dut.expect(r"Run (\d+)", timeout=120)
24+
run = int(res.group(0).decode("utf-8").split(" ")[1])
25+
LOGGER.info("Run {}".format(run))
26+
assert run == i, "Invalid run number"
27+
28+
# Match "Average MFLOPS: %f"
29+
res = dut.expect(r"Average MFLOPS: (\d+\.\d+)", timeout=120)
30+
avg_score = float(res.group(0).decode("utf-8").split(" ")[2])
31+
LOGGER.info("Average MFLOPS: {}".format(avg_score))
32+
assert avg_score > 0, "Invalid average MFLOPS"
33+
34+
# Match "Min MFLOPS: %f"
35+
res = dut.expect(r"Min MFLOPS: (\d+\.\d+)", timeout=120)
36+
min_score = float(res.group(0).decode("utf-8").split(" ")[2])
37+
LOGGER.info("Min MFLOPS: {}".format(min_score))
38+
assert min_score > 0 and min_score < 1000000000.0, "Invalid min MFLOPS"
39+
40+
# Match "Max MFLOPS: %f"
41+
res = dut.expect(r"Max MFLOPS: (\d+\.\d+)", timeout=120)
42+
max_score = float(res.group(0).decode("utf-8").split(" ")[2])
43+
LOGGER.info("Max MFLOPS: {}".format(max_score))
44+
assert max_score > 0, "Invalid max MFLOPS"
45+
46+
# Create JSON with results and write it to file
47+
# Always create a JSON with this format (so it can be merged later on):
48+
# { TEST_NAME_STR: TEST_RESULTS_DICT }
49+
results = {
50+
"linpack_double": {
51+
"runs": runs,
52+
"avg_score": avg_score,
53+
"min_score": min_score,
54+
"max_score": max_score
55+
}
56+
}
57+
58+
current_folder = os.path.dirname(request.path)
59+
file_index = 0
60+
report_file = os.path.join(current_folder, "result_linpack_double" + str(file_index) + ".json")
61+
while os.path.exists(report_file):
62+
report_file = report_file.replace(str(file_index) + ".json", str(file_index + 1) + ".json")
63+
file_index += 1
64+
65+
with open(report_file, "w") as f:
66+
try:
67+
f.write(json.dumps(results))
68+
except Exception as e:
69+
LOGGER.warning("Failed to write results to file: {}".format(e))
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"platforms": {
3+
"qemu": false,
4+
"wokwi": false
5+
}
6+
}

‎tests/performance/linpack_float/linpack_float.ino

Lines changed: 1195 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
import json
2+
import logging
3+
import os
4+
5+
6+
def test_linpack_float(dut, request):
7+
LOGGER = logging.getLogger(__name__)
8+
9+
# Match "Runs: %d"
10+
res = dut.expect(r"Runs: (\d+)", timeout=60)
11+
runs = int(res.group(0).decode("utf-8").split(" ")[1])
12+
LOGGER.info("Number of runs: {}".format(runs))
13+
assert runs > 0, "Invalid number of runs"
14+
15+
# Match "Type: %s"
16+
res = dut.expect(r"Type: (\w+)", timeout=60)
17+
data_type = res.group(0).decode("utf-8").split(" ")[1]
18+
LOGGER.info("Data type: {}".format(data_type))
19+
assert data_type == "float", "Invalid data type"
20+
21+
for i in range(runs):
22+
# Match "Run %d"
23+
res = dut.expect(r"Run (\d+)", timeout=120)
24+
run = int(res.group(0).decode("utf-8").split(" ")[1])
25+
LOGGER.info("Run {}".format(run))
26+
assert run == i, "Invalid run number"
27+
28+
# Match "Average MFLOPS: %f"
29+
res = dut.expect(r"Average MFLOPS: (\d+\.\d+)", timeout=120)
30+
avg_score = float(res.group(0).decode("utf-8").split(" ")[2])
31+
LOGGER.info("Average MFLOPS: {}".format(avg_score))
32+
assert avg_score > 0, "Invalid average MFLOPS"
33+
34+
# Match "Min MFLOPS: %f"
35+
res = dut.expect(r"Min MFLOPS: (\d+\.\d+)", timeout=120)
36+
min_score = float(res.group(0).decode("utf-8").split(" ")[2])
37+
LOGGER.info("Min MFLOPS: {}".format(min_score))
38+
assert min_score > 0 and min_score < 1000000000.0, "Invalid min MFLOPS"
39+
40+
# Match "Max MFLOPS: %f"
41+
res = dut.expect(r"Max MFLOPS: (\d+\.\d+)", timeout=120)
42+
max_score = float(res.group(0).decode("utf-8").split(" ")[2])
43+
LOGGER.info("Max MFLOPS: {}".format(max_score))
44+
assert max_score > 0, "Invalid max MFLOPS"
45+
46+
# Create JSON with results and write it to file
47+
# Always create a JSON with this format (so it can be merged later on):
48+
# { TEST_NAME_STR: TEST_RESULTS_DICT }
49+
results = {
50+
"linpack_float": {
51+
"runs": runs,
52+
"avg_score": avg_score,
53+
"min_score": min_score,
54+
"max_score": max_score
55+
}
56+
}
57+
58+
current_folder = os.path.dirname(request.path)
59+
file_index = 0
60+
report_file = os.path.join(current_folder, "result_linpack_float" + str(file_index) + ".json")
61+
while os.path.exists(report_file):
62+
report_file = report_file.replace(str(file_index) + ".json", str(file_index + 1) + ".json")
63+
file_index += 1
64+
65+
with open(report_file, "w") as f:
66+
try:
67+
f.write(json.dumps(results))
68+
except Exception as e:
69+
LOGGER.warning("Failed to write results to file: {}".format(e))

0 commit comments

Comments
 (0)
Please sign in to comment.