Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame^] | 1 | From 78dbd4c09d617a9cb730d796f94ee4d93840d3cc Mon Sep 17 00:00:00 2001 |
| 2 | From: Peter Kjellerstedt <pkj@axis.com> |
| 3 | Date: Fri, 9 Jun 2017 17:50:46 +0200 |
| 4 | Subject: [PATCH] Make ptest run the python tests if python is enabled |
| 5 | |
| 6 | One of the tests (tstLastError.py) needed a minor correction. It might |
| 7 | be due to the fact that the tests are forced to run with Python 3. |
| 8 | |
| 9 | Upstream-Status: Inappropriate [OE specific] |
| 10 | Signed-off-by: Peter Kjellerstedt <peter.kjellerstedt@axis.com> |
| 11 | --- |
| 12 | Makefile.am | 2 +- |
| 13 | python/Makefile.am | 9 +++++++++ |
| 14 | python/tests/Makefile.am | 12 ++++++++++-- |
| 15 | python/tests/tstLastError.py | 2 +- |
| 16 | 4 files changed, 21 insertions(+), 4 deletions(-) |
| 17 | |
| 18 | diff --git a/Makefile.am b/Makefile.am |
| 19 | index e181ee0..7960e7d 100644 |
| 20 | --- a/Makefile.am |
| 21 | +++ b/Makefile.am |
| 22 | @@ -207,9 +207,9 @@ install-ptest: |
| 23 | install $(noinst_PROGRAMS) $(DESTDIR)) |
| 24 | cp -r $(srcdir)/test $(DESTDIR) |
| 25 | cp -r $(srcdir)/result $(DESTDIR) |
| 26 | - cp -r $(srcdir)/python $(DESTDIR) |
| 27 | cp Makefile $(DESTDIR) |
| 28 | sed -i -e 's|^Makefile:|_Makefile:|' $(DESTDIR)/Makefile |
| 29 | + $(MAKE) -C python install-ptest |
| 30 | |
| 31 | runtests: |
| 32 | [ -d test ] || $(LN_S) $(srcdir)/test . |
| 33 | diff --git a/python/Makefile.am b/python/Makefile.am |
| 34 | index 34aed96..ba3ec6a 100644 |
| 35 | --- a/python/Makefile.am |
| 36 | +++ b/python/Makefile.am |
| 37 | @@ -48,7 +48,16 @@ GENERATED = libxml2class.py libxml2class.txt $(BUILT_SOURCES) |
| 38 | |
| 39 | $(GENERATED): $(srcdir)/generator.py $(API_DESC) |
| 40 | $(PYTHON) $(srcdir)/generator.py $(srcdir) |
| 41 | + |
| 42 | +install-ptest: |
| 43 | + cp -r $(srcdir) $(DESTDIR) |
| 44 | + sed -e 's|^Makefile:|_Makefile:|' \ |
| 45 | + -e 's|^\(tests test:\) all|\1|' Makefile >$(DESTDIR)/python/Makefile |
| 46 | + $(MAKE) -C tests install-ptest |
| 47 | +else |
| 48 | +install-ptest: |
| 49 | endif |
| 50 | |
| 51 | +.PHONY: tests test |
| 52 | tests test: all |
| 53 | cd tests && $(MAKE) tests |
| 54 | diff --git a/python/tests/Makefile.am b/python/tests/Makefile.am |
| 55 | index 95ebead..418e21e 100644 |
| 56 | --- a/python/tests/Makefile.am |
| 57 | +++ b/python/tests/Makefile.am |
| 58 | @@ -59,6 +59,11 @@ XMLS= \ |
| 59 | CLEANFILES = core tmp.xml *.pyc |
| 60 | |
| 61 | if WITH_PYTHON |
| 62 | +install-ptest: |
| 63 | + cp -r $(srcdir) $(DESTDIR)/python |
| 64 | + sed -e 's|^Makefile:|_Makefile:|' \ |
| 65 | + -e 's|^\(srcdir = \).*|\1.|' Makefile >$(DESTDIR)/python/tests/Makefile |
| 66 | + |
| 67 | tests: $(PYTESTS) |
| 68 | @for f in $(XMLS) ; do test -f $$f || $(LN_S) $(srcdir)/$$f . ; done |
| 69 | @echo "## running Python regression tests" |
| 70 | @@ -68,8 +73,11 @@ tests: $(PYTESTS) |
| 71 | export LD_LIBRARY_PATH; \ |
| 72 | for test in $(PYTESTS) ; \ |
| 73 | do log=`$(PYTHON) $(srcdir)/$$test` ; \ |
| 74 | - if [ "`echo $$log | grep OK`" = "" ] ; then \ |
| 75 | - echo "-- $$test" ; echo "$$log" ; fi ; done) |
| 76 | + if [ "`echo $$log | grep OK`" ]; then \ |
| 77 | + echo "PASS: $$test"; else \ |
| 78 | + echo "$$log"; echo "FAIL: $$test"; fi; done) |
| 79 | else |
| 80 | +install-ptest: |
| 81 | + |
| 82 | tests: |
| 83 | endif |
| 84 | diff --git a/python/tests/tstLastError.py b/python/tests/tstLastError.py |
| 85 | index d5f9be7..3e5bef8 100755 |
| 86 | --- a/python/tests/tstLastError.py |
| 87 | +++ b/python/tests/tstLastError.py |
| 88 | @@ -25,7 +25,7 @@ class TestCase(unittest.TestCase): |
| 89 | when the exception is raised, check the libxml2.lastError for |
| 90 | expected values.""" |
| 91 | # disable the default error handler |
| 92 | - libxml2.registerErrorHandler(None,None) |
| 93 | + libxml2.registerErrorHandler(lambda ctx,str: None,None) |
| 94 | try: |
| 95 | f(*args) |
| 96 | except exc: |
| 97 | -- |
| 98 | 2.12.0 |
| 99 | |