From 593a7ab2bc4cc4b50258ee84ee6f55695f045135 Mon Sep 17 00:00:00 2001 From: Pierre Pronchery Date: Thu, 18 Oct 2012 00:19:37 +0000 Subject: [PATCH] Imported the first test --- Makefile | 6 +++++- project.conf | 2 +- tests/.cvsignore | 2 ++ tests/Makefile | 43 ++++++++++++++++++++++++++++++++++++++ tests/project.conf | 19 +++++++++++++++++ tests/tests.sh | 52 ++++++++++++++++++++++++++++++++++++++++++++++ tests/udp.c | 37 +++++++++++++++++++++++++++++++++ 7 files changed, 159 insertions(+), 2 deletions(-) create mode 100644 tests/.cvsignore create mode 100644 tests/Makefile create mode 100644 tests/project.conf create mode 100755 tests/tests.sh create mode 100644 tests/udp.c diff --git a/Makefile b/Makefile index f4a3b32..072e039 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ PACKAGE = libApp VERSION = 0.1.5 -SUBDIRS = data doc include src src/transport tools +SUBDIRS = data doc include src src/transport tests tools RM ?= rm -f LN ?= ln -f TAR ?= tar -czvf @@ -56,6 +56,10 @@ dist: $(PACKAGE)-$(VERSION)/src/transport/udp.c \ $(PACKAGE)-$(VERSION)/src/transport/Makefile \ $(PACKAGE)-$(VERSION)/src/transport/project.conf \ + $(PACKAGE)-$(VERSION)/tests/udp.c \ + $(PACKAGE)-$(VERSION)/tests/Makefile \ + $(PACKAGE)-$(VERSION)/tests/tests.sh \ + $(PACKAGE)-$(VERSION)/tests/project.conf \ $(PACKAGE)-$(VERSION)/tools/appbroker.c \ $(PACKAGE)-$(VERSION)/tools/appclient.c \ $(PACKAGE)-$(VERSION)/tools/Makefile \ diff --git a/project.conf b/project.conf index 6bfd8f3..2a508b5 100644 --- a/project.conf +++ b/project.conf @@ -3,4 +3,4 @@ version=0.1.5 config=h,sh dist=Makefile,COPYING,config.h,config.sh -subdirs=data,doc,include,src,src/transport,tools +subdirs=data,doc,include,src,src/transport,tests,tools diff --git a/tests/.cvsignore b/tests/.cvsignore new file mode 100644 index 0000000..15e29f5 --- /dev/null +++ b/tests/.cvsignore @@ -0,0 +1,2 @@ +tests.log +udp diff --git a/tests/Makefile b/tests/Makefile new file mode 100644 index 0000000..3b1b336 --- /dev/null +++ b/tests/Makefile @@ -0,0 +1,43 @@ +TARGETS = tests.log udp +PREFIX = /usr/local +DESTDIR = +BINDIR = $(PREFIX)/bin +CC ?= cc +CPPFLAGSF?= +CPPFLAGS= -I ../include +CFLAGSF = -W +CFLAGS = -Wall -g -O2 +LDFLAGSF= -lApp +LDFLAGS = -L../src -Wl,-rpath,../src +RM ?= rm -f +LN ?= ln -f +MKDIR ?= mkdir -p +INSTALL ?= install + + +all: $(TARGETS) + +tests.log: udp + ./tests.sh -P "$(PREFIX)" -- "tests.log" + +udp_OBJS = udp.o +udp_CFLAGS = $(CPPFLAGSF) $(CPPFLAGS) $(CFLAGSF) $(CFLAGS) +udp_LDFLAGS = $(LDFLAGSF) $(LDFLAGS) + +udp: $(udp_OBJS) + $(CC) -o udp $(udp_OBJS) $(udp_LDFLAGS) + +udp.o: udp.c ../src/libApp.a + $(CC) $(udp_CFLAGS) -c udp.c + +clean: + $(RM) -- $(tests.log_OBJS) $(udp_OBJS) + +distclean: clean + $(RM) -- $(TARGETS) + +install: $(TARGETS) + +uninstall: + +.PHONY: all clean distclean install uninstall diff --git a/tests/project.conf b/tests/project.conf new file mode 100644 index 0000000..a46dc62 --- /dev/null +++ b/tests/project.conf @@ -0,0 +1,19 @@ +targets=tests.log,udp +cppflags=-I ../include +cflags_force=-W +cflags=-Wall -g -O2 +ldflags_force=-lApp +ldflags=-L../src -Wl,-rpath,../src +dist=Makefile,tests.sh + +[tests.log] +type=script +script=./tests.sh +depends=udp + +[udp] +type=binary +sources=udp.c + +[udp.c] +depends=../src/libApp.a diff --git a/tests/tests.sh b/tests/tests.sh new file mode 100755 index 0000000..bd73e6d --- /dev/null +++ b/tests/tests.sh @@ -0,0 +1,52 @@ +#!/usr/bin/env sh +#$Id$ +#Copyright (c) 2012 Pierre Pronchery +#This file is part of DeforaOS System libApp +#This program is free software: you can redistribute it and/or modify +#it under the terms of the GNU General Public License as published by +#the Free Software Foundation, version 3 of the License. +# +#This program is distributed in the hope that it will be useful, +#but WITHOUT ANY WARRANTY; without even the implied warranty of +#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +#GNU General Public License for more details. +# +#You should have received a copy of the GNU General Public License +#along with this program. If not, see . + + +#functions +#usage +_usage() +{ + echo "Usage: tests.sh target" 1>&2 + return 1 +} + + +#main +while getopts "P:" "name"; do + case "$name" in + P) + #XXX ignored + ;; + ?) + _usage + exit $? + ;; + esac +done +shift $((OPTIND - 1)) +if [ $# -ne 1 ]; then + _usage + exit $? +fi +target="$1" + +> "$target" +FAILED= +./udp >> "$target" || FAILED="$FAILED udp(error $?)" +[ -z "$FAILED" ] && exit 0 +echo "Failed tests:$FAILED" 1>&2 +#XXX ignore errors for now +#exit 2 diff --git a/tests/udp.c b/tests/udp.c new file mode 100644 index 0000000..320dded --- /dev/null +++ b/tests/udp.c @@ -0,0 +1,37 @@ +/* $Id$ */ +/* Copyright (c) 2012 Pierre Pronchery */ +/* This file is part of DeforaOS System libApp */ +/* This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 3 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ + + + +#include "App.h" + + +/* private */ +/* functions */ +/* udp */ +static int _udp(void) +{ + /* FIXME really implement */ + return -1; +} + + +/* public */ +/* functions */ +/* main */ +int main(int argc, char * argv[]) +{ + return (_udp() == 0) ? 0 : 2; +}