1984-04-04 00:44:07 +00:00
# 'nettest' is currently broken. testserver is not receiving any of the
# packets that 'nc' is passing to it. this is a bug in the testing suite,
# not in the library. --lynX 2016
1984-04-04 00:44:06 +00:00
# depending on where the pwd is, one of the two should work:
export LD_LIBRARY_PATH = ../lib:lib
1984-04-04 00:44:06 +00:00
2011-04-30 13:42:48 +00:00
OPT = -O2
DEBUG = 2
2013-07-16 14:53:52 +00:00
# compilation fails if -std=c99 is provided!?
# (netdb.h refuses to export struct addrinfo)
1984-04-04 00:44:05 +00:00
CFLAGS = -I../include -I../src -Wall -Wno-unused-result ${ OPT }
2011-04-30 13:42:48 +00:00
LDFLAGS = -L../lib
2011-05-08 14:49:24 +00:00
LOADLIBES = -lpsyc -lm
2012-02-06 14:05:08 +00:00
TARGETS = test_psyc test_psyc_speed test_parser test_match test_render test_text var_routing var_type uniform_parse test_packet_id test_index test_update method
2011-05-14 17:59:08 +00:00
O = test.o
2011-04-30 13:42:48 +00:00
WRAPPER =
DIET = diet
PORT = 4440
2011-05-08 14:49:24 +00:00
NC = nc
DIFF = diff
2011-05-18 20:00:28 +00:00
TEE = tee
2011-04-30 13:42:48 +00:00
2011-05-08 02:11:36 +00:00
i f e q ( $( shell uname ) , S u n O S )
2011-05-15 19:20:58 +00:00
LOADLIBES_NET := -lsocket -lnsl
2011-05-08 14:49:24 +00:00
DIFF = gdiff
2011-05-08 02:11:36 +00:00
e n d i f
2011-04-30 14:41:30 +00:00
all : ${TARGETS }
2011-05-08 02:11:36 +00:00
it : all
1984-04-04 00:44:07 +00:00
check : test
2011-10-31 19:04:16 +00:00
test_psyc : LOADLIBES := ${LOADLIBES } ${LOADLIBES_NET }
test_psyc_speed : LOADLIBES := ${LOADLIBES } ${LOADLIBES_NET }
#test_psyc_speed: LOADLIBES := ${LOADLIBES_NET}
2011-05-16 22:27:26 +00:00
2011-10-31 19:04:16 +00:00
test_json : LOADLIBES := ${LOADLIBES_NET } -ljson
2011-05-16 22:27:26 +00:00
2011-10-31 19:04:16 +00:00
test_json_glib : CFLAGS := ${CFLAGS } -I /usr /include /json -glib -1.0 -I /usr /include /glib -2.0 -I /usr /lib /glib -2.0/include
test_json_glib : LOADLIBES := ${LOADLIBES_NET } -ljson -glib -1.0
2011-05-16 22:27:26 +00:00
2011-10-31 19:04:16 +00:00
test_strlen : LOADLIBES := ${LOADLIBES_NET }
2011-04-30 13:42:48 +00:00
diet : WRAPPER = ${DIET }
diet : all
debug : CFLAGS += -DDEBUG =${DEBUG } -g
debug : CFLAGS := $( subst $ {OPT },-O 0,$ {CFLAGS })
debug : all
2011-05-05 22:15:37 +00:00
clean :
2011-05-14 16:21:00 +00:00
rm -f ${ TARGETS } $O
2011-05-05 22:15:37 +00:00
2011-04-30 13:42:48 +00:00
test : ${TARGETS }
2011-10-31 19:04:16 +00:00
./test_render
./test_match
./test_text
2012-01-31 18:34:11 +00:00
./var_routing
2011-10-31 19:04:16 +00:00
./var_type
2012-02-06 14:05:08 +00:00
./method
2011-10-31 19:04:16 +00:00
./uniform_parse
2012-02-06 14:05:08 +00:00
# ./test_list
# ./test_table
2011-12-28 22:45:16 +00:00
./test_packet_id
2012-02-06 14:05:08 +00:00
./test_index
./test_update
2011-10-31 19:04:16 +00:00
x = 0; for f in packets/[ 0-9] *; do echo " >> $$ f " ; ./test_psyc -f $$ f | ${ DIFF } -u $$ f -; x = $$ ( ( x+$$ ?) ) ; done ; exit $$ x
x = 0; for f in packets/[ 0-9] *; do echo " >> $$ f " ; ./test_psyc -rf $$ f | ${ DIFF } -u $$ f -; x = $$ ( ( x+$$ ?) ) ; done ; exit $$ x
2011-04-27 17:18:17 +00:00
2011-05-08 21:08:00 +00:00
.NOTPARALLEL : nettestrun
2011-05-08 18:17:56 +00:00
nettest : nettestfull nettestsplit
2011-05-05 22:15:37 +00:00
1984-04-04 00:44:07 +00:00
nettestrun : start pkt stop
2011-05-08 18:17:56 +00:00
nettestfull :
2011-10-31 19:04:16 +00:00
${ MAKE } nettestrun; x = $$ ?; pkill -x test_psyc; exit $$ x
${ MAKE } nettestrun srv_args = -r; x = $$ ?; pkill -x test_psyc; exit $$ x
2011-05-08 18:17:56 +00:00
2011-05-08 20:53:45 +00:00
split_max = 10
2011-05-08 18:17:56 +00:00
nettestsplit :
2011-10-31 19:04:16 +00:00
x = 0; for n in ` seq 1 ${ split_max } ` ; do ${ MAKE } nettestrun srv_args = " -b $$ n " && ${ MAKE } nettestrun srv_args = " -r -b $$ n " || break; done ; x = $$ ?; pkill -x test_psyc; exit $$ x
2011-05-06 11:32:12 +00:00
pkt :
2011-05-08 18:17:56 +00:00
x = 0; for f in packets/[ 0-9] *; do echo " >> $$ f " ; cat $$ f | nc localhost ${ PORT } | ${ DIFF } -u $$ f -; x = $$ ( ( x+$$ ?) ) ; done ; exit $$ x
2011-05-05 22:15:37 +00:00
2011-05-06 11:32:12 +00:00
pktsplit :
2011-05-08 18:17:56 +00:00
x = 0; for f in packets/[ 0-9] *; do echo " >> $$ f " ; ./splittest.pl $$ f ${ PORT } | ${ DIFF } -u $$ f -; x = $$ ( ( x+$$ ?) ) ; done ; exit $$ x
2011-05-05 22:15:37 +00:00
2011-05-06 11:32:12 +00:00
pkterr :
2011-05-05 22:15:37 +00:00
for f in packets/err-*; do echo " >> $$ f " ; cat $$ f | nc localhost ${ PORT } ; done
2011-05-03 23:00:35 +00:00
1984-04-04 00:44:07 +00:00
start :
2011-10-31 19:04:16 +00:00
pkill -x test_psyc; exit 0
1984-04-04 00:44:07 +00:00
./test_psyc -p ${ PORT } -S ${ srv_args } -vvv &
2011-04-22 09:50:13 +00:00
1984-04-04 00:44:07 +00:00
stop :
2011-10-31 19:04:16 +00:00
pkill -x test_psyc
2011-05-24 15:37:00 +00:00
2011-05-24 20:59:49 +00:00
bench : bench -genpkts bench -psyc bench -psyc -bin bench -json bench -json -bin bench -xml
2011-05-24 15:37:00 +00:00
bench-dir :
@mkdir -p ../bench/results
2011-10-31 19:04:16 +00:00
bench-psyc : bench -dir test_strlen test_psyc_speed
for f in ../bench/packets/*.psyc; do bf = ` basename $$ f` ; echo strlen: $$ bf; ./test_strlen -sc 1000000 -f $$ f | ${ TEE } -a ../bench/results/$$ bf.strlen; done
for f in ../bench/packets/*.psyc; do bf = ` basename $$ f` ; echo libpsyc: $$ f; ./test_psyc_speed -sc 1000000 -f $$ f | ${ TEE } -a ../bench/results/$$ bf; done
2011-05-24 20:59:49 +00:00
2011-10-31 19:04:16 +00:00
bench-psyc-bin : bench -dir test_strlen test_psyc_speed
for f in ` ls ../bench/packets/binary/*.psyc | sort -r` ; do bf = ` basename $$ f` ; echo " libpsyc: $$ f * 1000000 " ; ./test_psyc_speed -sc 1000000 -f $$ f | ${ TEE } -a ../bench/results/$$ bf; done
c = 1000000; for f in ` ls ../bench/packets/binary/*.psyc | sort -r` ; do bf = ` basename $$ f` ; echo " strlen: $$ bf * $$ c " ; ./test_strlen -sc $$ c -f $$ f | ${ TEE } -a ../bench/results/$$ bf.strlen; c = $$ ( ( c/10) ) ; done
2011-05-24 15:37:00 +00:00
2011-10-31 19:04:16 +00:00
bench-json : bench -dir test_json test_json_glib
# for f in ../bench/packets/*.json; do bf=`basename $$f`; echo strlen: $$bf; ./test_strlen -sc 1000000 -f $$f | ${TEE} -a ../bench/results/$$bf.strlen; done
for f in ../bench/packets/*.json; do bf = ` basename $$ f` ; echo json-c: $$ bf; ./test_json -snc 1000000 -f $$ f | ${ TEE } -a ../bench/results/$$ bf; done
for f in ../bench/packets/*.json; do bf = ` basename $$ f` ; echo json-glib: $$ bf; ./test_json_glib -snc 1000000 -f $$ f | ${ TEE } -a ../bench/results/$$ bf-glib; done
2011-05-24 15:37:00 +00:00
2011-10-31 19:04:16 +00:00
bench-json-bin : bench -dir test_json test_json_glib
c = 1000000; for f in ` ls ../bench/packets/binary/*.json | sort -r` ; do bf = ` basename $$ f` ; echo " json-c: $$ bf * $$ c " ; ./test_json -snc $$ c -f $$ f | ${ TEE } -a ../bench/results/$$ bf; c = $$ ( ( c/10) ) ; done
c = 1000000; for f in ` ls ../bench/packets/binary/*.json | sort -r` ; do bf = ` basename $$ f` ; echo " json-glib: $$ bf * $$ c " ; ./test_json_glib -snc $$ c -f $$ f | ${ TEE } -a ../bench/results/$$ bf-glib; c = $$ ( ( c/10) ) ; done
2011-05-24 20:59:49 +00:00
bench-xml : bench -dir
@[ [ -n " ${ xmlbench } " ] ] || ( echo xmlbench path needs to be set with xmlbench = /path/to/xmlbench; exit 1)
2011-10-31 19:04:16 +00:00
# for f in ../bench/packets/*.xml; do bf=`basename $$f`; echo strlen: $$bf; ./test_strlen -sc 1000000 -f $$f | ${TEE} -a ../bench/results/$$bf.strlen; done
2011-05-24 20:59:49 +00:00
for f in ../bench/packets/*.xml; do bf = ` basename $$ f` ; echo libxml: $$ bf; ${ xmlbench } /parse/libxml 1000000 $$ f | ${ TEE } -a ../bench/results/$$ bf-libxml; done
for f in ../bench/packets/*.xml; do bf = ` basename $$ f` ; echo libxml-sax: $$ bf; ${ xmlbench } /parse/libxml-sax 1000000 $$ f | ${ TEE } -a ../bench/results/$$ bf-libxml-sax; done
for f in ../bench/packets/*.xml; do bf = ` basename $$ f` ; echo rapidxml: $$ bf; ${ xmlbench } /parse/rapidxml 1000000 $$ f | ${ TEE } -a ../bench/results/$$ bf-rapidxml; done
2011-05-24 15:37:00 +00:00
bench-genpkts :
@${ MAKE } genpkt header = ../bench/packets/binary/psyc-header content = ../bench/packets/binary/psyc-content bs = 7000 of = ../bench/packets/binary/7K.psyc
@${ MAKE } genpkt header = ../bench/packets/binary/psyc-header content = ../bench/packets/binary/psyc-content bs = 70000 of = ../bench/packets/binary/70K.psyc
@${ MAKE } genpkt header = ../bench/packets/binary/psyc-header content = ../bench/packets/binary/psyc-content bs = 700000 of = ../bench/packets/binary/700K.psyc
@${ MAKE } genpkt header = ../bench/packets/binary/psyc-header content = ../bench/packets/binary/psyc-content bs = 7000000 of = ../bench/packets/binary/7000K.psyc
@${ MAKE } genpkt header = ../bench/packets/binary/psyc-header content = ../bench/packets/binary/psyc-content bs = 7000000 count = 10 of = ../bench/packets/binary/70000K.psyc
# @${MAKE} genpkt header=../bench/packets/binary/psyc-header content=../bench/packets/binary/psyc-content bs=7000000 count=100 of=../bench/packets/binary/700000K.psyc
@${ MAKE } genb64 header = ../bench/packets/binary/json-header footer = ../bench/packets/binary/json-footer bs = 7000 of = ../bench/packets/binary/7K.json
@${ MAKE } genb64 header = ../bench/packets/binary/json-header footer = ../bench/packets/binary/json-footer bs = 70000 of = ../bench/packets/binary/70K.json
@${ MAKE } genb64 header = ../bench/packets/binary/json-header footer = ../bench/packets/binary/json-footer bs = 700000 of = ../bench/packets/binary/700K.json
@${ MAKE } genb64 header = ../bench/packets/binary/json-header footer = ../bench/packets/binary/json-footer bs = 7000000 of = ../bench/packets/binary/7000K.json
@${ MAKE } genb64 header = ../bench/packets/binary/json-header footer = ../bench/packets/binary/json-footer bs = 7000000 count = 10 of = ../bench/packets/binary/70000K.json
# @${MAKE} genb64 header=../bench/packets/binary/json-header footer=../bench/packets/binary/json-footer bs=7000000 count=100 of=../bench/packets/binary/700000K.json
@${ MAKE } genb64 header = ../bench/packets/binary/xml-header footer = ../bench/packets/binary/xml-footer bs = 7000 of = ../bench/packets/binary/7K.xml
@${ MAKE } genb64 header = ../bench/packets/binary/xml-header footer = ../bench/packets/binary/xml-footer bs = 70000 of = ../bench/packets/binary/70K.xml
@${ MAKE } genb64 header = ../bench/packets/binary/xml-header footer = ../bench/packets/binary/xml-footer bs = 700000 of = ../bench/packets/binary/700K.xml
@${ MAKE } genb64 header = ../bench/packets/binary/xml-header footer = ../bench/packets/binary/xml-footer bs = 7000000 of = ../bench/packets/binary/7000K.xml
@${ MAKE } genb64 header = ../bench/packets/binary/xml-header footer = ../bench/packets/binary/xml-footer bs = 7000000 count = 10 of = ../bench/packets/binary/70000K.xml
# @${MAKE} genb64 header=../bench/packets/binary/xml-header footer=../bench/packets/binary/xml-footer bs=7000000 count=100 of=../bench/packets/binary/700000K.xml
bs = 1
count = 1
genpkt :
@[ [ -n " ${ of } " ] ]
[ [ -f " ${ of } " ] ] || ( \
cat ${ header } >${ of } ; \
perl -le 'my @se=stat(q(' ${ content } ')); print $$se[7] + ${bs} * ${count} + 1' >>${ of } ; \
cat ${ content } >>${ of } ; \
dd if = /dev/urandom of = ${ of } bs = ${ bs } count = ${ count } oflag = append conv = notrunc; \
echo -ne "\n|\n" >>${ of } )
bs = 1
count = 1
genb64 :
@[ [ -n " ${ of } " ] ]
[ [ -f " ${ of } " ] ] || ( cat ${ header } >${ of } ; dd if = /dev/urandom bs = ${ bs } count = ${ count } | base64 -w0 >>${ of } ; cat ${ footer } >>${ of } )