summaryrefslogtreecommitdiffstats
path: root/glib2/rootfs-scripts
diff options
context:
space:
mode:
authorduerpei <duep.fnst@fujitsu.com>2022-07-14 14:17:13 +0800
committerduerpei <duep.fnst@fujitsu.com>2022-07-14 14:17:13 +0800
commit761c64f22b8a6c1202a2c9caafda36e154e81d41 (patch)
treebcde3881bed4d48b2b05aff9d8a2990d11445909 /glib2/rootfs-scripts
parent8e0004e1d751dce49b97b00d65519c92609a213a (diff)
qa-test-misc: demo code submissionneedlefish_13.93.0needlefish/13.93.013.93.0
Submit the test scripts of rpm and glib2, and the file of LICENSE and README Bug-AGL: SPEC-4345 Signed-off-by: duerpei <duep.fnst@fujitsu.com> Change-Id: I2e2311d2864285c4c5da3309486b2e1fa8adc2ec
Diffstat (limited to 'glib2/rootfs-scripts')
-rw-r--r--glib2/rootfs-scripts/__init__.py0
-rw-r--r--glib2/rootfs-scripts/parser.py7
-rw-r--r--glib2/rootfs-scripts/report.py26
-rw-r--r--glib2/rootfs-scripts/run_tests.py56
4 files changed, 89 insertions, 0 deletions
diff --git a/glib2/rootfs-scripts/__init__.py b/glib2/rootfs-scripts/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/glib2/rootfs-scripts/__init__.py
diff --git a/glib2/rootfs-scripts/parser.py b/glib2/rootfs-scripts/parser.py
new file mode 100644
index 0000000..33aded3
--- /dev/null
+++ b/glib2/rootfs-scripts/parser.py
@@ -0,0 +1,7 @@
+from plugins.agl_test_log import log_process_gnome_desktop_testing
+
+def log_process(TMP_LOGS_DIR,THIS_TEST):
+ log = TMP_LOGS_DIR + THIS_TEST + "/log/" + THIS_TEST + ".log"
+ test_cases_values_and_status = []
+ test_cases_values_and_status = log_process_gnome_desktop_testing(log)
+ return test_cases_values_and_status
diff --git a/glib2/rootfs-scripts/report.py b/glib2/rootfs-scripts/report.py
new file mode 100644
index 0000000..28f2ac5
--- /dev/null
+++ b/glib2/rootfs-scripts/report.py
@@ -0,0 +1,26 @@
+import plugins.agl_test_report as agl_test_report
+
+def log_report(test_cases_values_and_status,THIS_TEST):
+ #Get case_status, it's looks like : {'test_id': 'status',...}
+ case_status = {}
+ case_status = agl_test_report.get_case_status(test_cases_values_and_status)
+
+ #Get the summary of the test case status, the result is like that:
+ #Summary = [["collected",num1],["passed",num2],["failed",num3],["skipped",num4]]
+ summary = []
+ summary = agl_test_report.get_summary(case_status)
+
+ #Judge whether the test set passes
+ test_set_status = "null"
+ if (summary[1][1] == summary[0][1]):
+ test_set_status = "passed"
+ else:
+ test_set_status = "failed"
+
+ agl_test_report.write_date_to_json(test_set_status,THIS_TEST,summary,case_status)
+
+ #Package log file
+ agl_test_report.log_compress(THIS_TEST)
+
+ html = agl_test_report.get_report_html(THIS_TEST,test_set_status,summary,case_status)
+ agl_test_report.write_to_html_file(THIS_TEST,html)
diff --git a/glib2/rootfs-scripts/run_tests.py b/glib2/rootfs-scripts/run_tests.py
new file mode 100644
index 0000000..2387b95
--- /dev/null
+++ b/glib2/rootfs-scripts/run_tests.py
@@ -0,0 +1,56 @@
+import pytest
+import subprocess
+
+import plugins.agl_test_conf as agl_test_conf
+import plugins.agl_test_utils as agl_test_utils
+
+import glib2.parser as parser
+import glib2.report as report
+
+TMP_LOGS_DIR = agl_test_conf.TMP_LOGS_DIR
+
+THIS_TEST = "glib2"
+test_cases_values_and_status = []
+
+def setup_module():
+ agl_test_utils.create_dir(THIS_TEST)
+ run_test_fun()
+ global test_cases_values_and_status
+ test_cases_values_and_status = parser.log_process(TMP_LOGS_DIR,THIS_TEST)
+
+#Run test, and redirect the log into the file of THIS_TEST.log under TMP_LOGS_DIR/THIS_TEST/
+def run_test_fun():
+ log_file = agl_test_conf.get_log_file(THIS_TEST)
+ with open(log_file,'w') as log_f:
+ subprocess.run(['ptest-runner','glib-2.0'],stdout=log_f,stderr=log_f)
+ log_f.close()
+
+def check_status(test_name):
+ global test_cases_values_and_status
+ for item in test_cases_values_and_status:
+ if(item[0]==test_name):
+ if(item[1] == "PASS"):
+ item[2] = "passed"
+ return 1
+ if(item[1] == "FAIL"):
+ item[2] = "failed"
+ return 0
+
+def test_glib2_gdbus_names():
+ assert check_status("glib/gdbus-names.test")
+
+def test_glib2_rand():
+ assert check_status("glib/rand.test")
+
+def test_glib2_base64():
+ assert check_status("glib/base64.test")
+
+#TODO
+#Complete all test cases
+
+#Pack the log file and count the test results
+def teardown_module():
+ report.log_report(test_cases_values_and_status,THIS_TEST)
+
+if __name__ == '__main__':
+ pytest.main("run_tests")