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