diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/Makefile | 36 | ||||
-rw-r--r-- | tests/test-command.c | 38 |
2 files changed, 27 insertions, 47 deletions
diff --git a/tests/Makefile b/tests/Makefile index c35a2f2..2a5e2b6 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -1,27 +1,41 @@ -REQ_PKGS = libsoup-2.4 gthread-2.0 glib-2.0 - # gtk2 REQ_PKGS += gtk+-2.0 webkit-1.0 -CPPFLAGS = +CPPFLAGS = -I ../ -DERRORCHECK_MUTEXES # gtk3 #REQ_PKGS += gtk+-3.0 webkitgtk-3.0 -#CPPFLAGS = -DGTK3 +#CPPFLAGS = -I ../ -DERRORCHECK_MUTEXES -DG_DISABLE_DEPRECATED -DGTK_DISABLE_DEPRECATED + +# --- configuration ends here --- + +REQ_PKGS += libsoup-2.4 gthread-2.0 glib-2.0 + +ARCH:=$(shell uname -m) +ARCH!=echo `uname -m` -CFLAGS:=-std=c99 -I$(shell pwd)/../ -L$(shell pwd) -luzbl-core $(shell pkg-config --cflags $(REQ_PKGS)) -ggdb -Wall -W -DARCH="\"$(shell uname -m)\"" -lgthread-2.0 -DG_ERRORCHECK_MUTEXES -DCOMMIT="\"$(shell git log | head -n1 | sed "s/.* //")\"" $(CPPFLAGS) -CFLAGS!=echo -std=c99 `pkg-config --cflags $(REQ_PKGS)` -ggdb -Wall -W -DARCH='"\""'`uname -m`'"\""' -lgthread-2.0 -DG_ERRORCHECK_MUTEXES -DCOMMIT='"\""'`git log | head -n1 | sed "s/.* //"`'"\""' $(CPPFLAGS) +COMMIT_HASH:=$(shell cd .. && ./misc/hash.sh) +COMMIT_HASH!=echo `cd .. && ./misc/hash.sh` -LDFLAGS:=$(shell pkg-config --libs $(REQ_PKGS)) -pthread $(LDFLAGS) -LDFLAGS!=echo `pkg-config --libs $(REQ_PKGS)` -pthread $(LDFLAGS) +CPPFLAGS += -DARCH=\"$(ARCH)\" -DCOMMIT=\"$(COMMIT_HASH)\" -GTESTER:=gtester -GTESTER_REPORT:=gtester-report +PKG_CFLAGS:=$(shell pkg-config --cflags $(REQ_PKGS)) +PKG_CFLAGS!=echo pkg-config --cflags $(REQ_PKGS) -TEST_PROGS:=test-expand test-command +LDLIBS:=$(shell pkg-config --libs $(REQ_PKGS) x11) +LDLIBS!=echo pkg-config --libs $(REQ_PKGS) x11 + +CFLAGS += -std=c99 $(PKG_CFLAGS) -ggdb -fPIC -W -Wall -Wextra -pedantic -pthread + +GTESTER = gtester +GTESTER_REPORT = gtester-report + +TEST_PROGS = test-expand test-command all: $(TEST_PROGS) LD_LIBRARY_PATH="$(LD_LIBRARY_PATH):." $(GTESTER) --verbose $(TEST_PROGS) +${TEST_PROGS}: libuzbl-core.so + clean: rm -f $(TEST_PROGS) rm -f libuzbl-core.so diff --git a/tests/test-command.c b/tests/test-command.c index 6194081..7b33405 100644 --- a/tests/test-command.c +++ b/tests/test-command.c @@ -29,33 +29,6 @@ extern UzblCore uzbl; #define INSTANCE_NAME "testing" -gchar* -assert_str_beginswith(GString *expected, gchar *actual) { - gchar *actual_beginning = g_strndup(actual, expected->len); - g_assert_cmpstr(expected->str, ==, actual_beginning); - g_free(actual_beginning); - - /* return the part of the actual string that hasn't been compared yet */ - return &actual[expected->len]; -} - -/* compare the contents of uzbl.comm.sync_stdout to the standard arguments that - * should have been passed. This is meant to be called after something like "sync echo". */ -gchar* -assert_sync_beginswith_stdarg() { - GString *stdargs = g_string_new(""); - - g_string_append_printf(stdargs, "%s %d %d ", uzbl.state.config_file, getpid(), (int)uzbl.xwin); - g_string_append_printf(stdargs, "%s %s ", uzbl.comm.fifo_path, uzbl.comm.socket_path); - g_string_append_printf(stdargs, "%s %s ", uzbl.state.uri, uzbl.gui.main_title); - - gchar *rest = assert_str_beginswith(stdargs, uzbl.comm.sync_stdout); - - g_string_free(stdargs, TRUE); - - return rest; -} - #define ASSERT_EVENT(EF, STR) { read_event(ef); \ g_assert_cmpstr("EVENT [" INSTANCE_NAME "] " STR "\n", ==, ef->event_buffer); } @@ -314,13 +287,10 @@ test_run_handler_arg_order (void) { assert(uzbl.comm.sync_stdout); - /* the result should begin with the standard handler arguments */ - gchar *rest = assert_sync_beginswith_stdarg(); - /* the rest of the result should be the arguments passed to run_handler. */ /* the arguments in the second argument to run_handler should be placed before any * included in the first argument to run handler. */ - g_assert_cmpstr("abc def uvw xyz\n", ==, rest); + g_assert_cmpstr("abc def uvw xyz\n", ==, uzbl.comm.sync_stdout); } void @@ -330,12 +300,8 @@ test_run_handler_expand (void) { assert(uzbl.comm.sync_stdout); - /* the result should begin with the standard handler arguments */ - gchar *rest = assert_sync_beginswith_stdarg(); - - /* the rest of the result should be the arguments passed to run_handler. */ /* the user-specified arguments to the handler should have been expanded */ - g_assert_cmpstr("result: Test uzbl uzr agent\n", ==, rest); + g_assert_cmpstr("result: Test uzbl uzr agent\n", ==, uzbl.comm.sync_stdout); } int |