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