summaryrefslogtreecommitdiff
path: root/.gitlab-ci
diff options
context:
space:
mode:
authorRohan Garg <rohan.garg@collabora.com>2020-04-01 18:06:49 +0200
committerRohan Garg <rohan@garg.io>2020-04-07 18:21:32 +0000
commitefbbf8bb81e97a2b2d2e6e018750ef36cd460676 (patch)
treed8ee2abd304618a46d42b022345370df81d869b8 /.gitlab-ci
parent1618159772a087b0914828bdcdfc0e95a2def350 (diff)
tracie: Print results in a machine readable format
Signed-off-by: Rohan Garg <rohan.garg@collabora.com> Reviewed-by: Alexandros Frantzis <alexandros.frantzis@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4435>
Diffstat (limited to '.gitlab-ci')
-rwxr-xr-x.gitlab-ci/tracie/tests/test.sh16
-rw-r--r--.gitlab-ci/tracie/tracie.py27
2 files changed, 37 insertions, 6 deletions
diff --git a/.gitlab-ci/tracie/tests/test.sh b/.gitlab-ci/tracie/tests/test.sh
index cd0f08e4efd..5030e31e049 100755
--- a/.gitlab-ci/tracie/tests/test.sh
+++ b/.gitlab-ci/tracie/tests/test.sh
@@ -56,9 +56,24 @@ run_test() {
cleanup
}
+assert_results_yaml_contains() {
+ grep -q "actual: $1" $4
+ assert "[ $? = 0 ]"
+
+ grep -q "expected: $2" $4
+ assert "[ $? = 0 ]"
+
+ if [ $3 != "" ]; then
+ grep -q $3 $4
+ fi
+
+ assert "[ $? = 0 ]"
+}
+
tracie_succeeds_if_all_images_match() {
run_tracie
assert "[ $? = 0 ]"
+ assert_results_yaml_contains 5efda83854befe0155ff8517a58d5b51 5efda83854befe0155ff8517a58d5b51 "" "$PWD/results/results.yml"
}
tracie_fails_on_image_mismatch() {
@@ -67,6 +82,7 @@ tracie_fails_on_image_mismatch() {
run_tracie
assert "[ $? != 0 ]"
+ assert_results_yaml_contains 5efda83854befe0155ff8517a58d5b51 8e0a801367e1714463475a824dab363b "trace2/test/vk-test-device/olive.testtrace-0.png" "$PWD/results/results.yml"
}
tracie_skips_traces_without_checksum() {
diff --git a/.gitlab-ci/tracie/tracie.py b/.gitlab-ci/tracie/tracie.py
index efedcbc4880..7ed54cb179e 100644
--- a/.gitlab-ci/tracie/tracie.py
+++ b/.gitlab-ci/tracie/tracie.py
@@ -112,6 +112,9 @@ def ensure_trace(repo_url, repo_commit, trace):
def check_trace(repo_url, repo_commit, device_name, trace, expectation):
ensure_trace(repo_url, repo_commit, trace)
+ result = {}
+ result[trace['path']] = {}
+
trace_path = Path(TRACES_DB_PATH + trace['path'])
checksum, image_file, log_file = replay(trace_path, device_name)
if checksum is None:
@@ -127,13 +130,19 @@ def check_trace(repo_url, repo_commit, device_name, trace, expectation):
ok = False
trace_dir = os.path.split(trace['path'])[0]
- results_path = os.path.join(RESULTS_PATH, trace_dir, "test", device_name)
+ dir_in_results = os.path.join(trace_dir, "test", device_name)
+ results_path = os.path.join(RESULTS_PATH, dir_in_results)
os.makedirs(results_path, exist_ok=True)
shutil.move(log_file, os.path.join(results_path, os.path.split(log_file)[1]))
if not ok or os.environ.get('TRACIE_STORE_IMAGES', '0') == '1':
- shutil.move(image_file, os.path.join(results_path, os.path.split(image_file)[1]))
+ image_name = os.path.split(image_file)[1]
+ shutil.move(image_file, os.path.join(results_path, image_name))
+ result[trace['path']]['image'] = os.path.join(dir_in_results, image_name)
+
+ result[trace['path']]['expected'] = expectation['checksum']
+ result[trace['path']]['actual'] = checksum
- return ok
+ return ok, result
def main():
parser = argparse.ArgumentParser()
@@ -156,11 +165,17 @@ def main():
traces = y['traces']
all_ok = True
+ results = {}
for trace in traces:
for expectation in trace['expectations']:
- if expectation['device'] == args.device_name:
- ok = check_trace(repo, commit_id, args.device_name, trace, expectation)
- all_ok = all_ok and ok
+ if expectation['device'] == args.device_name:
+ ok, result = check_trace(repo, commit_id, args.device_name, trace, expectation)
+ all_ok = all_ok and ok
+ results.update(result)
+
+ with open(os.path.join(RESULTS_PATH, 'results.yml'), 'w') as f:
+ yaml.safe_dump(results, f, default_flow_style=False)
+
sys.exit(0 if all_ok else 1)