Testing the TCP and UDP transports alike
This commit is contained in:
parent
a6da501b9d
commit
15ebf43c9e
2
Makefile
2
Makefile
|
@ -56,7 +56,7 @@ dist:
|
||||||
$(PACKAGE)-$(VERSION)/src/transport/udp.c \
|
$(PACKAGE)-$(VERSION)/src/transport/udp.c \
|
||||||
$(PACKAGE)-$(VERSION)/src/transport/Makefile \
|
$(PACKAGE)-$(VERSION)/src/transport/Makefile \
|
||||||
$(PACKAGE)-$(VERSION)/src/transport/project.conf \
|
$(PACKAGE)-$(VERSION)/src/transport/project.conf \
|
||||||
$(PACKAGE)-$(VERSION)/tests/udp.c \
|
$(PACKAGE)-$(VERSION)/tests/transport.c \
|
||||||
$(PACKAGE)-$(VERSION)/tests/Makefile \
|
$(PACKAGE)-$(VERSION)/tests/Makefile \
|
||||||
$(PACKAGE)-$(VERSION)/tests/tests.sh \
|
$(PACKAGE)-$(VERSION)/tests/tests.sh \
|
||||||
$(PACKAGE)-$(VERSION)/tests/project.conf \
|
$(PACKAGE)-$(VERSION)/tests/project.conf \
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
tests.log
|
tests.log
|
||||||
udp
|
transport
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
TARGETS = tests.log udp
|
TARGETS = tests.log transport
|
||||||
PREFIX = /usr/local
|
PREFIX = /usr/local
|
||||||
DESTDIR =
|
DESTDIR =
|
||||||
BINDIR = $(PREFIX)/bin
|
BINDIR = $(PREFIX)/bin
|
||||||
|
@ -17,21 +17,21 @@ INSTALL ?= install
|
||||||
|
|
||||||
all: $(TARGETS)
|
all: $(TARGETS)
|
||||||
|
|
||||||
tests.log: udp
|
tests.log: transport
|
||||||
./tests.sh -P "$(PREFIX)" -- "tests.log"
|
./tests.sh -P "$(PREFIX)" -- "tests.log"
|
||||||
|
|
||||||
udp_OBJS = udp.o
|
transport_OBJS = transport.o
|
||||||
udp_CFLAGS = $(CPPFLAGSF) $(CPPFLAGS) $(CFLAGSF) $(CFLAGS)
|
transport_CFLAGS = $(CPPFLAGSF) $(CPPFLAGS) $(CFLAGSF) $(CFLAGS)
|
||||||
udp_LDFLAGS = $(LDFLAGSF) $(LDFLAGS)
|
transport_LDFLAGS = $(LDFLAGSF) $(LDFLAGS)
|
||||||
|
|
||||||
udp: $(udp_OBJS)
|
transport: $(transport_OBJS)
|
||||||
$(CC) -o udp $(udp_OBJS) $(udp_LDFLAGS)
|
$(CC) -o transport $(transport_OBJS) $(transport_LDFLAGS)
|
||||||
|
|
||||||
udp.o: udp.c ../src/libApp.a
|
transport.o: transport.c ../src/libApp.a
|
||||||
$(CC) $(udp_CFLAGS) -c udp.c
|
$(CC) $(transport_CFLAGS) -c transport.c
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
$(RM) -- $(tests.log_OBJS) $(udp_OBJS)
|
$(RM) -- $(tests.log_OBJS) $(transport_OBJS)
|
||||||
|
|
||||||
distclean: clean
|
distclean: clean
|
||||||
$(RM) -- $(TARGETS)
|
$(RM) -- $(TARGETS)
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
targets=tests.log,udp
|
targets=tests.log,transport
|
||||||
cppflags=-I ../include
|
cppflags=-I ../include
|
||||||
cflags_force=-W `pkg-config --cflags libSystem`
|
cflags_force=-W `pkg-config --cflags libSystem`
|
||||||
cflags=-Wall -g -O2
|
cflags=-Wall -g -O2
|
||||||
|
@ -9,11 +9,11 @@ dist=Makefile,tests.sh
|
||||||
[tests.log]
|
[tests.log]
|
||||||
type=script
|
type=script
|
||||||
script=./tests.sh
|
script=./tests.sh
|
||||||
depends=udp
|
depends=transport
|
||||||
|
|
||||||
[udp]
|
[transport]
|
||||||
type=binary
|
type=binary
|
||||||
sources=udp.c
|
sources=transport.c
|
||||||
|
|
||||||
[udp.c]
|
[transport.c]
|
||||||
depends=../src/libApp.a
|
depends=../src/libApp.a
|
||||||
|
|
|
@ -45,7 +45,8 @@ target="$1"
|
||||||
|
|
||||||
> "$target"
|
> "$target"
|
||||||
FAILED=
|
FAILED=
|
||||||
./udp >> "$target" || FAILED="$FAILED udp(error $?)"
|
./transport -p tcp >> "$target" || FAILED="$FAILED tcp(error $?)"
|
||||||
|
./transport -p udp >> "$target" || FAILED="$FAILED udp(error $?)"
|
||||||
[ -z "$FAILED" ] && exit 0
|
[ -z "$FAILED" ] && exit 0
|
||||||
echo "Failed tests:$FAILED" 1>&2
|
echo "Failed tests:$FAILED" 1>&2
|
||||||
#XXX ignore errors for now
|
#XXX ignore errors for now
|
||||||
|
|
|
@ -26,14 +26,14 @@
|
||||||
|
|
||||||
/* private */
|
/* private */
|
||||||
/* prototypes */
|
/* prototypes */
|
||||||
static int _udp(char const * name);
|
static int _transport(char const * protocol, char const * name);
|
||||||
|
|
||||||
static int _usage(void);
|
static int _usage(void);
|
||||||
|
|
||||||
|
|
||||||
/* functions */
|
/* functions */
|
||||||
/* udp */
|
/* transport */
|
||||||
static int _udp(char const * name)
|
static int _transport(char const * protocol, char const * name)
|
||||||
{
|
{
|
||||||
char * cwd;
|
char * cwd;
|
||||||
Plugin * plugin;
|
Plugin * plugin;
|
||||||
|
@ -44,16 +44,16 @@ static int _udp(char const * name)
|
||||||
|
|
||||||
/* load the transport plug-in */
|
/* load the transport plug-in */
|
||||||
if((cwd = getcwd(NULL, 0)) == NULL)
|
if((cwd = getcwd(NULL, 0)) == NULL)
|
||||||
return error_set_print("udp", 2, "%s", strerror(errno));
|
return error_set_print("transport", 2, "%s", strerror(errno));
|
||||||
/* XXX rather ugly but does the trick */
|
/* XXX rather ugly but does the trick */
|
||||||
plugin = plugin_new(cwd, "../src", "transport", "udp");
|
plugin = plugin_new(cwd, "../src", "transport", protocol);
|
||||||
free(cwd);
|
free(cwd);
|
||||||
if(plugin == NULL)
|
if(plugin == NULL)
|
||||||
return error_print("udp");
|
return error_print("transport");
|
||||||
if((plugind = plugin_lookup(plugin, "transport")) == NULL)
|
if((plugind = plugin_lookup(plugin, "transport")) == NULL)
|
||||||
{
|
{
|
||||||
plugin_delete(plugin);
|
plugin_delete(plugin);
|
||||||
return error_print("udp");
|
return error_print("transport");
|
||||||
}
|
}
|
||||||
/* initialize the helper */
|
/* initialize the helper */
|
||||||
memset(&helper, 0, sizeof(helper));
|
memset(&helper, 0, sizeof(helper));
|
||||||
|
@ -69,7 +69,7 @@ static int _udp(char const * name)
|
||||||
if(server != NULL)
|
if(server != NULL)
|
||||||
plugind->destroy(server);
|
plugind->destroy(server);
|
||||||
plugin_delete(plugin);
|
plugin_delete(plugin);
|
||||||
return error_print("udp");
|
return error_print("transport");
|
||||||
}
|
}
|
||||||
/* FIXME really implement */
|
/* FIXME really implement */
|
||||||
plugind->destroy(client);
|
plugind->destroy(client);
|
||||||
|
@ -83,7 +83,7 @@ static int _udp(char const * name)
|
||||||
/* usage */
|
/* usage */
|
||||||
static int _usage(void)
|
static int _usage(void)
|
||||||
{
|
{
|
||||||
fputs("Usage: udp name\n", stderr);
|
fputs("Usage: transport -p protocol name\n", stderr);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -93,12 +93,16 @@ static int _usage(void)
|
||||||
/* main */
|
/* main */
|
||||||
int main(int argc, char * argv[])
|
int main(int argc, char * argv[])
|
||||||
{
|
{
|
||||||
|
char const * protocol = "udp";
|
||||||
char const * name = "127.0.0.1:4242";
|
char const * name = "127.0.0.1:4242";
|
||||||
int o;
|
int o;
|
||||||
|
|
||||||
while((o = getopt(argc, argv, "")) != -1)
|
while((o = getopt(argc, argv, "p:")) != -1)
|
||||||
switch(o)
|
switch(o)
|
||||||
{
|
{
|
||||||
|
case 'p':
|
||||||
|
protocol = optarg;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
return _usage();
|
return _usage();
|
||||||
}
|
}
|
||||||
|
@ -106,5 +110,5 @@ int main(int argc, char * argv[])
|
||||||
name = argv[optind];
|
name = argv[optind];
|
||||||
else if(optind != argc)
|
else if(optind != argc)
|
||||||
return _usage();
|
return _usage();
|
||||||
return (_udp(name) == 0) ? 0 : 2;
|
return (_transport(protocol, name) == 0) ? 0 : 2;
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user