Tue, 15 May 2018 18:48:53 +0200
adds test suite to build system
--- a/src/server/Makefile Sun May 13 12:06:41 2018 +0200 +++ b/src/server/Makefile Tue May 15 18:48:53 2018 +0200 @@ -35,7 +35,9 @@ LIB_WSCFG = $(BUILD_ROOT)/build/lib/libwscfg$(LIB_EXT) -all: preparation $(MAIN_TARGET) $(LIB_WSCFG) $(PLUGINS) +TEST_TARGET = $(BUILD_ROOT)/build/bin/wstest + +all: preparation $(MAIN_TARGET) $(LIB_WSCFG) $(PLUGINS) $(TEST_TARGET) include util/objs.mk include safs/objs.mk @@ -43,6 +45,7 @@ include daemon/objs.mk include config/objs.mk include admin/objs.mk +include test/objs.mk include util/Makefile include safs/Makefile @@ -50,10 +53,13 @@ include daemon/Makefile include config/Makefile include admin/Makefile +include test/Makefile -MAINOBJS = $(UCXOBJS) $(UTILOBJS) $(SAFOBJS) $(DAVOBJS) $(DAEMONOBJS) $(CONFOBJS) $(ADMINOBJS) +MAINOBJS = $(UTILOBJS) $(SAFOBJS) $(DAVOBJS) $(DAEMONOBJS) $(CONFOBJS) $(ADMINOBJS) -OBJ_DIRS = daemon safs ucx util webdav config admin plugins +TESTOBJS += $(MAINOBJS) + +OBJ_DIRS = daemon safs ucx util webdav config admin plugins test MK_OBJ_DIRS = $(OBJ_DIRS:%=$(OBJ_DIR)server/%) CFLAGS += -I../ @@ -64,15 +70,14 @@ $(MK_OBJ_DIRS): mkdir -p $@ -$(MAIN_TARGET): $(MAINOBJS) - $(CXX) -o $(MAIN_TARGET) $(MAINOBJS) -L$(BUILD_ROOT)/build/lib $(LDFLAGS) +$(MAIN_TARGET): preparation $(MAINOBJS) $(DAEMON_STARTOBJ) + $(CXX) -o $(MAIN_TARGET) $(MAINOBJS) $(DAEMON_STARTOBJ) -L$(BUILD_ROOT)/build/lib $(LDFLAGS) $(LIB_WSCFG): $(CONFOBJS) $(CC) $(SHLIB_LDFLAGS) -o $@ $(CONFOBJS) - -../../build/server/ucx/%.o: %.c - $(CC) -o $@ -c $(CFLAGS) $< +$(TEST_TARGET): $(TESTOBJS) + $(CXX) -o $(TEST_TARGET) $(TESTOBJS) -L$(BUILD_ROOT)/build/lib $(LDFLAGS) $(PLUGINS): $(MAIN_TARGET) FORCE
--- a/src/server/daemon/objs.mk Sun May 13 12:06:41 2018 +0200 +++ b/src/server/daemon/objs.mk Tue May 15 18:48:53 2018 +0200 @@ -35,7 +35,6 @@ DAEMONOBJ += httplistener.o DAEMONOBJ += httpparser.o DAEMONOBJ += httprequest.o -DAEMONOBJ += main.o DAEMONOBJ += protocol.o DAEMONOBJ += http.o DAEMONOBJ += websocket.o @@ -65,3 +64,8 @@ DAEMONOBJS = $(DAEMONOBJ:%=$(DMN_OBJPRE)%) DAEMONSOURCE = $(DAEMONOBJ:%.o=daemon/%.c) +# add main.c +DAEMON_STARTOBJ = $(DMN_OBJPRE)main.o +DAEMONSOURCE += daemon/main.c + +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/server/test/Makefile Tue May 15 18:48:53 2018 +0200 @@ -0,0 +1,36 @@ +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. +# +# Copyright 2013 Olaf Wintermann. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# + +TEST_CFLAGS = + +$(TEST_OBJPRE)%.o: test/%.c + $(CC) -o $@ -c $(ADMIN_CFLAGS) $(CFLAGS) $< + +$(TEST_OBJPRE)%.o: test/%.cpp + $(CXX) -o $@ -c $(ADMIN_CFLAGS) $(CFLAGS) $< +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/server/test/main.c Tue May 15 18:48:53 2018 +0200 @@ -0,0 +1,65 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2013 Olaf Wintermann. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + + +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> +#include <signal.h> +#include <errno.h> +#include <pthread.h> + +#include "../util/pool.h" +#include "../public/nsapi.h" +#include "../util/plist.h" +#include "../util/date.h" + +#include "../../ucx/string.h" + +static int std_pipe_fds[2]; +static WSBool is_daemon; + +void test() { + +} + +// needed for linking +WSBool main_is_daemon(void) { + return is_daemon; +} + +int main(int argc, char **argv) { + pool_init(NULL, NULL, NULL); + + //test(); + + printf("%s", "Webserver Test Suite\n====================\n\n"); + + return EXIT_SUCCESS; +} +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/server/test/objs.mk Tue May 15 18:48:53 2018 +0200 @@ -0,0 +1,37 @@ +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. +# +# Copyright 2013 Olaf Wintermann. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, +# this list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# + +TEST_SRC_DIR = server/test/ + +TEST_OBJPRE = $(OBJ_DIR)$(TEST_SRC_DIR) + +TESTOBJ = main.o + +TESTOBJS = $(TESTOBJ:%=$(TEST_OBJPRE)%) +TESTSOURCE = $(TESTOBJ:%.o=test/%.c) +