summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVincent Sanders <vince@kyllikki.org>2015-09-01 22:56:23 (GMT)
committer Vincent Sanders <vince@kyllikki.org>2015-09-01 22:56:23 (GMT)
commit0c97f24173d461cd07e06da5f419bd1238cbd6e6 (patch)
tree62f438e88951e0bba01562cd7cb868bc2c7d6df7
parentf9ad837e326e72f5959e4a90787f48c805b4cb2b (diff)
downloadlibnsgif-0c97f24173d461cd07e06da5f419bd1238cbd6e6.tar.gz
libnsgif-0c97f24173d461cd07e06da5f419bd1238cbd6e6.tar.bz2
add a basic decode test
-rw-r--r--Makefile6
-rwxr-xr-xexamples/gif_display (renamed from gif_display)0
-rw-r--r--test/Makefile3
-rw-r--r--test/data/waves.gif (renamed from examples/waves.gif)bin186913 -> 186913 bytes
-rw-r--r--test/decode_gif.c (renamed from examples/decode_gif.c)6
-rwxr-xr-xtest/runtest.sh18
6 files changed, 32 insertions, 1 deletions
diff --git a/Makefile b/Makefile
index 8504332..c78ee16 100644
--- a/Makefile
+++ b/Makefile
@@ -15,6 +15,9 @@ PREFIX ?= /opt/netsurf
NSSHARED ?= $(PREFIX)/share/netsurf-buildsystem
include $(NSSHARED)/makefiles/Makefile.tools
+# Reevaluate when used, as BUILDDIR won't be defined yet
+TESTRUNNER = test/runtest.sh $(BUILDDIR) $(EXEEXT)
+
# Toolchain flags
WARNFLAGS := -Wall -W -Wundef -Wpointer-arith -Wcast-align \
-Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes \
@@ -34,6 +37,9 @@ else
CFLAGS := $(CFLAGS) -Dinline="__inline__"
endif
+TESTCFLAGS := -g -O2
+TESTLDFLAGS := -lm -l$(COMPONENT) $(TESTLDFLAGS)
+
include $(NSBUILD)/Makefile.top
# Extra installation rules
diff --git a/gif_display b/examples/gif_display
index 7e50b8c..7e50b8c 100755
--- a/gif_display
+++ b/examples/gif_display
diff --git a/test/Makefile b/test/Makefile
new file mode 100644
index 0000000..f067d81
--- a/dev/null
+++ b/test/Makefile
@@ -0,0 +1,3 @@
+DIR_TEST_ITEMS := decode_gif:decode_gif.c
+
+include $(NSBUILD)/Makefile.subdir
diff --git a/examples/waves.gif b/test/data/waves.gif
index 46a7da3..46a7da3 100644
--- a/examples/waves.gif
+++ b/test/data/waves.gif
Binary files differ
diff --git a/examples/decode_gif.c b/test/decode_gif.c
index 34d2e9d..2d2f37a 100644
--- a/examples/decode_gif.c
+++ b/test/decode_gif.c
@@ -14,7 +14,8 @@
#include <stdio.h>
#include <string.h>
#include <sys/stat.h>
-#include "../libnsgif.h"
+
+#include "../include/libnsgif.h"
unsigned char *load_file(const char *path, size_t *data_size);
void warning(const char *context, int code);
@@ -178,12 +179,14 @@ void *bitmap_create(int width, int height)
void bitmap_set_opaque(void *bitmap, bool opaque)
{
(void) opaque; /* unused */
+ (void) bitmap; /* unused */
assert(bitmap);
}
bool bitmap_test_opaque(void *bitmap)
{
+ (void) bitmap; /* unused */
assert(bitmap);
return false;
}
@@ -205,6 +208,7 @@ void bitmap_destroy(void *bitmap)
void bitmap_modified(void *bitmap)
{
+ (void) bitmap; /* unused */
assert(bitmap);
return;
}
diff --git a/test/runtest.sh b/test/runtest.sh
new file mode 100755
index 0000000..063db28
--- a/dev/null
+++ b/test/runtest.sh
@@ -0,0 +1,18 @@
+#!/bin/sh
+
+TEST_PATH=$1
+TEST_OUT=${TEST_PATH}/ppm
+
+mkdir -p ${TEST_OUT}
+
+gifdecode()
+{
+ OUTF=$(basename ${1} .gif)
+ ${TEST_PATH}/test_decode_gif ${1} > ${TEST_OUT}/${OUTF}.ppm
+}
+
+
+for GIF in $(ls test/data/*.gif);do
+ gifdecode ${GIF}
+done
+