summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntti Ajanki <antti.ajanki@iki.fi>2011-04-17 13:29:41 +0300
committerAntti Ajanki <antti.ajanki@iki.fi>2011-04-17 13:29:41 +0300
commitcff257c3a082608e4b91313b79f73020f14e6e53 (patch)
treecdc7295a510fe3f6cf9057a949ec2cf244f04364
parent195747fe7a354bbd9b439203b3fb9a0f56bd1ebe (diff)
downloadvdr-plugin-webvideo-cff257c3a082608e4b91313b79f73020f14e6e53.tar.gz
vdr-plugin-webvideo-cff257c3a082608e4b91313b79f73020f14e6e53.tar.bz2
Fix testdownload, "make check" executes unittests
-rw-r--r--Makefile7
-rw-r--r--src/libwebvi/Makefile2
-rw-r--r--src/unittest/Makefile24
-rwxr-xr-xsrc/unittest/runtests.sh7
-rw-r--r--src/unittest/testdownload.c11
5 files changed, 39 insertions, 12 deletions
diff --git a/Makefile b/Makefile
index 4e54ee6..8d411e7 100644
--- a/Makefile
+++ b/Makefile
@@ -89,6 +89,11 @@ dist: clean
@-rm -rf $(TMPDIR)/$(ARCHIVE)
@echo Distribution package created as $(PACKAGE).tgz
+check:
+ make -C src/unittest check
+
+test: check
+
clean:
$(MAKE) -C src/vdr-plugin clean
$(MAKE) -C src/libwebvi clean
@@ -97,4 +102,4 @@ clean:
find . -name "*~" -exec rm {} \;
find . -name "*.pyc" -exec rm {} \;
-.PHONY: vdr-plugin libwebvi build-python install install-vdr-plugin install-webvi dist clean
+.PHONY: vdr-plugin libwebvi build-python install install-vdr-plugin install-webvi dist clean check test
diff --git a/src/libwebvi/Makefile b/src/libwebvi/Makefile
index 895478f..d5a2ff1 100644
--- a/src/libwebvi/Makefile
+++ b/src/libwebvi/Makefile
@@ -20,6 +20,8 @@ $(LIBMINOR): libwebvi.o
ln -sf $(LIBMINOR) $(LIBSONAME)
ln -sf $(LIBSONAME) $(LIBNAME)
+libwebvi.so: $(LIBMINOR)
+
libwebvi.a: libwebvi.o
ar rsc libwebvi.a libwebvi.o
diff --git a/src/unittest/Makefile b/src/unittest/Makefile
index 81b0ea2..9d82fb4 100644
--- a/src/unittest/Makefile
+++ b/src/unittest/Makefile
@@ -1,11 +1,33 @@
CFLAGS=-O2 -g -Wall -I../libwebvi
LDFLAGS=-L../libwebvi -Wl,-rpath=../libwebvi -lwebvi
+.PHONY: all clean check test
+
all: testlibwebvi testdownload
testlibwebvi: testlibwebvi.o ../libwebvi/libwebvi.so
-
testdownload: testdownload.o ../libwebvi/libwebvi.so
+../libwebvi/libwebvi.so:
+ make -C ../libwebvi libwebvi.so
+
clean:
rm -f testlibwebvi testlibwebvi.o testdownload testdownload.o
+
+# testdownload and testwebvi.py require network access
+check: testlibwebvi testdownload
+ FAILED_TESTS=; \
+ PYTHONPATH=../libwebvi ./testlibwebvi; \
+ if [ $$? -ne 0 ]; then echo "$$?"; FAILED_TESTS="$$FAILED_TESTS testlibwebvi"; fi; \
+ PYTHONPATH=../libwebvi ./testdownload; \
+ if [ $$? -ne 0 ]; then FAILED_TESTS="$$FAILED_TESTS testdownload"; fi; \
+ PYTHONPATH=../libwebvi python ./testwebvi.py; \
+ if [ $$? -ne 0 ]; then FAILED_TESTS="$$FAILED_TESTS testwebvi.py"; fi; \
+ echo "================================================"; \
+ if [ -n $$FAILED_TEST ]; then \
+ echo "The following tests failed:$$FAILED_TESTS"; \
+ else \
+ echo "Tests completed successfully!"; \
+ fi
+
+test: check
diff --git a/src/unittest/runtests.sh b/src/unittest/runtests.sh
deleted file mode 100755
index 9afc7a5..0000000
--- a/src/unittest/runtests.sh
+++ /dev/null
@@ -1,7 +0,0 @@
-#!/bin/sh
-
-export PYTHONPATH=../libwebvi
-
-./testlibwebvi
-#./testdownload
-#./testwebvi.py
diff --git a/src/unittest/testdownload.c b/src/unittest/testdownload.c
index 134150a..07cd124 100644
--- a/src/unittest/testdownload.c
+++ b/src/unittest/testdownload.c
@@ -23,7 +23,7 @@
#include "libwebvi.h"
-#define WVTREFERENCE "wvt:///youtube/video.xsl?srcurl=http%3A//www.youtube.com/watch%3Fv%3Dk5LmKNYTqvk"
+#define WVTREFERENCE "wvt:///www.youtube.com/videopage.xsl?srcurl=http%3A//www.youtube.com/watch%3Fv%3Dk5LmKNYTqvk"
#define CHECK_WEBVI_CALL(err, funcname) \
if (err != WEBVIERR_OK) { \
@@ -180,8 +180,13 @@ int main(int argc, const char* argv[]) {
} while (msg_remaining > 0);
} while (!done);
- printf("\nRead %ld bytes.\n"
- "Test successful.\n", callback_data.bytes_downloaded);
+ if (donemsg->status_code != 0) {
+ printf("Error: Unexpected status code %d\n", donemsg->status_code);
+ returncode = 127;
+ } else {
+ printf("\nRead %ld bytes.\n"
+ "Test successful.\n", callback_data.bytes_downloaded);
+ }
cleanup:
if (ctx != 0) {