|
|
4b6aa8 |
From e1a064810f56b34d78ca9d000120b8a93323b501 Mon Sep 17 00:00:00 2001
|
|
|
4b6aa8 |
From: Jakub Filak <jfilak@redhat.com>
|
|
|
4b6aa8 |
Date: Wed, 23 Jul 2014 11:00:28 +0200
|
|
|
4b6aa8 |
Subject: [LIBREPORT PATCH 56/93] testsuite: report python sanity tests
|
|
|
4b6aa8 |
|
|
|
4b6aa8 |
Signed-off-by: Jakub Filak <jfilak@redhat.com>
|
|
|
4b6aa8 |
---
|
|
|
4b6aa8 |
tests/Makefile.am | 3 ++-
|
|
|
4b6aa8 |
tests/local.at | 13 +++++++++++++
|
|
|
4b6aa8 |
tests/osinfo.at | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++
|
|
|
4b6aa8 |
tests/report_python.at | 33 ++++++++++++++++++++++++++++++++
|
|
|
4b6aa8 |
tests/testsuite.at | 1 +
|
|
|
4b6aa8 |
5 files changed, 101 insertions(+), 1 deletion(-)
|
|
|
4b6aa8 |
create mode 100644 tests/report_python.at
|
|
|
4b6aa8 |
|
|
|
4b6aa8 |
diff --git a/tests/Makefile.am b/tests/Makefile.am
|
|
|
4b6aa8 |
index 8ec40e1..750fa16 100644
|
|
|
4b6aa8 |
--- a/tests/Makefile.am
|
|
|
4b6aa8 |
+++ b/tests/Makefile.am
|
|
|
4b6aa8 |
@@ -38,7 +38,8 @@ TESTSUITE_AT = \
|
|
|
4b6aa8 |
reported_to.at \
|
|
|
4b6aa8 |
make_description.at \
|
|
|
4b6aa8 |
libreport_types.at \
|
|
|
4b6aa8 |
- xml_definition.at
|
|
|
4b6aa8 |
+ xml_definition.at \
|
|
|
4b6aa8 |
+ report_python.at
|
|
|
4b6aa8 |
|
|
|
4b6aa8 |
EXTRA_DIST += $(TESTSUITE_AT)
|
|
|
4b6aa8 |
TESTSUITE = $(srcdir)/testsuite
|
|
|
4b6aa8 |
diff --git a/tests/local.at b/tests/local.at
|
|
|
4b6aa8 |
index 758906d..b5fae97 100644
|
|
|
4b6aa8 |
--- a/tests/local.at
|
|
|
4b6aa8 |
+++ b/tests/local.at
|
|
|
4b6aa8 |
@@ -24,4 +24,17 @@ AT_COMPILE([$1])
|
|
|
4b6aa8 |
AT_CHECK([./$1], 0, [ignore], [ignore])
|
|
|
4b6aa8 |
AT_CLEANUP])
|
|
|
4b6aa8 |
|
|
|
4b6aa8 |
+# ------------------------
|
|
|
4b6aa8 |
+# AT_PYTESTFUN(NAME, SOURCE)
|
|
|
4b6aa8 |
+# ------------------------
|
|
|
4b6aa8 |
+
|
|
|
4b6aa8 |
+# Create a test named NAME by running Python file with contents SOURCE. The
|
|
|
4b6aa8 |
+# stdout and stderr output of the Python program is ignored by Autotest.
|
|
|
4b6aa8 |
+
|
|
|
4b6aa8 |
+m4_define([AT_PYTESTFUN],
|
|
|
4b6aa8 |
+[AT_SETUP([$1])
|
|
|
4b6aa8 |
+AT_DATA([$1], [$2])
|
|
|
4b6aa8 |
+AT_CHECK([PYTHONPATH=../../../src python ./$1], 0, [ignore], [ignore])
|
|
|
4b6aa8 |
+AT_CLEANUP])
|
|
|
4b6aa8 |
+
|
|
|
4b6aa8 |
AT_INIT
|
|
|
4b6aa8 |
diff --git a/tests/osinfo.at b/tests/osinfo.at
|
|
|
4b6aa8 |
index 529ca13..b57452d 100644
|
|
|
4b6aa8 |
--- a/tests/osinfo.at
|
|
|
4b6aa8 |
+++ b/tests/osinfo.at
|
|
|
4b6aa8 |
@@ -393,3 +393,55 @@ int main(void)
|
|
|
4b6aa8 |
return 0;
|
|
|
4b6aa8 |
}
|
|
|
4b6aa8 |
]])
|
|
|
4b6aa8 |
+
|
|
|
4b6aa8 |
+## ------------------- ##
|
|
|
4b6aa8 |
+## parse_osinfo_python ##
|
|
|
4b6aa8 |
+## ------------------- ##
|
|
|
4b6aa8 |
+
|
|
|
4b6aa8 |
+AT_PYTESTFUN([parse_osinfo_python],
|
|
|
4b6aa8 |
+[[import sys
|
|
|
4b6aa8 |
+
|
|
|
4b6aa8 |
+sys.path.insert(0, "../../../src/report-python/.libs")
|
|
|
4b6aa8 |
+
|
|
|
4b6aa8 |
+report = __import__("report-python", globals(), locals(), [], -1)
|
|
|
4b6aa8 |
+sys.modules["report"] = report
|
|
|
4b6aa8 |
+
|
|
|
4b6aa8 |
+lines = [
|
|
|
4b6aa8 |
+ 'NAME=fedora',
|
|
|
4b6aa8 |
+ 'VERSION="20 (Heisenbug)"',
|
|
|
4b6aa8 |
+ 'ID=fedora',
|
|
|
4b6aa8 |
+ 'VERSION_ID=20',
|
|
|
4b6aa8 |
+ 'PRETTY_NAME="Fedora 20 (Heisenbug)"',
|
|
|
4b6aa8 |
+ 'ANSI_COLOR="0;34"',
|
|
|
4b6aa8 |
+ 'CPE_NAME="cpe:/o:fedoraproject:fedora:20"',
|
|
|
4b6aa8 |
+ 'HOME_URL="https://fedoraproject.org/"',
|
|
|
4b6aa8 |
+ 'BUG_REPORT_URL="https://bugzilla.redhat.com/"',
|
|
|
4b6aa8 |
+ 'REDHAT_BUGZILLA_PRODUCT="Fedora"',
|
|
|
4b6aa8 |
+ 'REDHAT_BUGZILLA_PRODUCT_VERSION=20',
|
|
|
4b6aa8 |
+ 'REDHAT_SUPPORT_PRODUCT="Fedora"',
|
|
|
4b6aa8 |
+ 'REDHAT_SUPPORT_PRODUCT_VERSION=20',
|
|
|
4b6aa8 |
+]
|
|
|
4b6aa8 |
+
|
|
|
4b6aa8 |
+expected = {
|
|
|
4b6aa8 |
+ 'NAME':'fedora',
|
|
|
4b6aa8 |
+ 'VERSION':'20 (Heisenbug)',
|
|
|
4b6aa8 |
+ 'ID':'fedora',
|
|
|
4b6aa8 |
+ 'VERSION_ID':'20',
|
|
|
4b6aa8 |
+ 'PRETTY_NAME':'Fedora 20 (Heisenbug)',
|
|
|
4b6aa8 |
+ 'ANSI_COLOR':'0;34',
|
|
|
4b6aa8 |
+ 'CPE_NAME':'cpe:/o:fedoraproject:fedora:20',
|
|
|
4b6aa8 |
+ 'HOME_URL':'https://fedoraproject.org/',
|
|
|
4b6aa8 |
+ 'BUG_REPORT_URL':'https://bugzilla.redhat.com/',
|
|
|
4b6aa8 |
+ 'REDHAT_BUGZILLA_PRODUCT':'Fedora',
|
|
|
4b6aa8 |
+ 'REDHAT_BUGZILLA_PRODUCT_VERSION':'20',
|
|
|
4b6aa8 |
+ 'REDHAT_SUPPORT_PRODUCT':'Fedora',
|
|
|
4b6aa8 |
+ 'REDHAT_SUPPORT_PRODUCT_VERSION':'20'
|
|
|
4b6aa8 |
+}
|
|
|
4b6aa8 |
+
|
|
|
4b6aa8 |
+osrel = report.parse_os_release_lines(lines)
|
|
|
4b6aa8 |
+
|
|
|
4b6aa8 |
+print sorted(expected.items())
|
|
|
4b6aa8 |
+print sorted(osrel.items())
|
|
|
4b6aa8 |
+
|
|
|
4b6aa8 |
+sys.exit(not bool(osrel == expected))
|
|
|
4b6aa8 |
+]])
|
|
|
4b6aa8 |
diff --git a/tests/report_python.at b/tests/report_python.at
|
|
|
4b6aa8 |
new file mode 100644
|
|
|
4b6aa8 |
index 0000000..17e4fb3
|
|
|
4b6aa8 |
--- /dev/null
|
|
|
4b6aa8 |
+++ b/tests/report_python.at
|
|
|
4b6aa8 |
@@ -0,0 +1,33 @@
|
|
|
4b6aa8 |
+# -*- Autotest -*-
|
|
|
4b6aa8 |
+
|
|
|
4b6aa8 |
+AT_BANNER([report_python])
|
|
|
4b6aa8 |
+
|
|
|
4b6aa8 |
+## ----------------------- ##
|
|
|
4b6aa8 |
+## get_from_etc_os_release ##
|
|
|
4b6aa8 |
+## ----------------------- ##
|
|
|
4b6aa8 |
+
|
|
|
4b6aa8 |
+AT_PYTESTFUN([get_from_etc_os_release],
|
|
|
4b6aa8 |
+[[import sys
|
|
|
4b6aa8 |
+
|
|
|
4b6aa8 |
+sys.path.insert(0, "../../../src/report-python/.libs")
|
|
|
4b6aa8 |
+
|
|
|
4b6aa8 |
+report = __import__("report-python", globals(), locals(), [], -1)
|
|
|
4b6aa8 |
+sys.modules["report"] = report
|
|
|
4b6aa8 |
+
|
|
|
4b6aa8 |
+import os
|
|
|
4b6aa8 |
+
|
|
|
4b6aa8 |
+if not os.path.exists("/etc/os-release"):
|
|
|
4b6aa8 |
+ print "Cannot run the test: '/etc/os-release' does not exist"
|
|
|
4b6aa8 |
+ sys.exit(1)
|
|
|
4b6aa8 |
+
|
|
|
4b6aa8 |
+exit_code = 0
|
|
|
4b6aa8 |
+if report.getProduct_fromOSRELEASE() != report.getProduct():
|
|
|
4b6aa8 |
+ print "getProduct() did not return PRODUCT from /etc/os-release"
|
|
|
4b6aa8 |
+ exit_code += 1
|
|
|
4b6aa8 |
+
|
|
|
4b6aa8 |
+if report.getVersion_fromOSRELEASE() != report.getVersion():
|
|
|
4b6aa8 |
+ print "getVersion() did not return PRODUCT from /etc/os-release"
|
|
|
4b6aa8 |
+ exit_code += 1
|
|
|
4b6aa8 |
+
|
|
|
4b6aa8 |
+sys.exit(exit_code)
|
|
|
4b6aa8 |
+]])
|
|
|
4b6aa8 |
diff --git a/tests/testsuite.at b/tests/testsuite.at
|
|
|
4b6aa8 |
index 97b2442..a569457 100644
|
|
|
4b6aa8 |
--- a/tests/testsuite.at
|
|
|
4b6aa8 |
+++ b/tests/testsuite.at
|
|
|
4b6aa8 |
@@ -13,3 +13,4 @@ m4_include([reported_to.at])
|
|
|
4b6aa8 |
m4_include([make_description.at])
|
|
|
4b6aa8 |
m4_include([libreport_types.at])
|
|
|
4b6aa8 |
m4_include([xml_definition.at])
|
|
|
4b6aa8 |
+m4_include([report_python.at])
|
|
|
4b6aa8 |
--
|
|
|
4b6aa8 |
1.8.3.1
|
|
|
4b6aa8 |
|