Imported the first test

This commit is contained in:
Pierre Pronchery 2012-10-18 00:19:37 +00:00
parent fda7e616ee
commit 593a7ab2bc
7 changed files with 159 additions and 2 deletions

View File

@ -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 \

View File

@ -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

2
tests/.cvsignore Normal file
View File

@ -0,0 +1,2 @@
tests.log
udp

43
tests/Makefile Normal file
View File

@ -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

19
tests/project.conf Normal file
View File

@ -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

52
tests/tests.sh Executable file
View File

@ -0,0 +1,52 @@
#!/usr/bin/env sh
#$Id$
#Copyright (c) 2012 Pierre Pronchery <khorben@defora.org>
#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 <http://www.gnu.org/licenses/>.
#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

37
tests/udp.c Normal file
View File

@ -0,0 +1,37 @@
/* $Id$ */
/* Copyright (c) 2012 Pierre Pronchery <khorben@defora.org> */
/* 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 <http://www.gnu.org/licenses/>. */
#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;
}