Add designqr output check script
authorKwanghoon Son <k.son@samsung.com>
Tue, 22 Oct 2024 02:30:30 +0000 (11:30 +0900)
committerInki Dae <inki.dae@samsung.com>
Thu, 7 Nov 2024 05:26:11 +0000 (14:26 +0900)
TCT not check output quality.
This script will help when refactoring designqr.

Change-Id: I44b1d13a7ecf894a8fc851e972facbeeb0bce2d2
Signed-off-by: Kwanghoon Son <k.son@samsung.com>
script/cmp_designqr_output.py [new file with mode: 0644]

diff --git a/script/cmp_designqr_output.py b/script/cmp_designqr_output.py
new file mode 100644 (file)
index 0000000..de07589
--- /dev/null
@@ -0,0 +1,29 @@
+"""
+This script for comparing two sets of DesignQR code images generated from different sources.
+
+Please set
+#define SAVE_QR_IMG
+#define LARGE_COMB_SET
+in test/testsuites/barcode/test_designqr.cpp
+before running the test case. Then, run the test case and save the generated images in /tmp directory.
+"""
+import os
+
+def compare_images(org_dir, tmp_dir):
+    org_files = [f for f in os.listdir(org_dir) if f.endswith('.png')]
+
+    for file_name in org_files:
+        org_file_path = os.path.join(org_dir, file_name)
+        tmp_file_path = os.path.join(tmp_dir, file_name)
+
+        if os.path.exists(org_file_path) and os.path.exists(tmp_file_path):
+            with open(org_file_path, 'rb') as f1, open(tmp_file_path, 'rb') as f2:
+                if f1.read() != f2.read():
+                    print(f"{file_name}: different image.")
+
+# User needs to set the directories where original and temporary images are stored.
+org_directory = '/orig'
+tmp_directory = '/tmp'
+
+compare_images(org_directory, tmp_directory)
+print('done')