1
0
Fork 0
mirror of git://git.psyc.eu/libpsyc synced 2024-08-15 03:19:02 +00:00
libpsyc/test/Makefile

139 lines
6.6 KiB
Makefile
Raw Normal View History

2011-04-30 13:42:48 +00:00
OPT = -O2
DEBUG = 2
2011-05-20 00:53:56 +00:00
CFLAGS = -I../include -I../src -Wall -std=c99 ${OPT}
2011-04-30 13:42:48 +00:00
LDFLAGS = -L../lib
2011-05-08 14:49:24 +00:00
LOADLIBES = -lpsyc -lm
TARGETS = testPsyc testPsycSpeed testParser testMatch testRender testText isRoutingVar getVarType
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
TEE = tee
2011-04-30 13:42:48 +00:00
2011-05-08 02:11:36 +00:00
ifeq ($(shell uname),SunOS)
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
endif
2011-04-30 14:41:30 +00:00
all: ${TARGETS}
2011-05-08 02:11:36 +00:00
it: all
2011-05-15 19:20:58 +00:00
testPsyc: LOADLIBES := ${LOADLIBES} ${LOADLIBES_NET}
testPsycSpeed: LOADLIBES := ${LOADLIBES} ${LOADLIBES_NET}
#testPsycSpeed: LOADLIBES := ${LOADLIBES_NET}
testJson: LOADLIBES := ${LOADLIBES_NET} -ljson
2011-05-20 00:53:56 +00:00
testJsonGlib: CFLAGS := ${CFLAGS} -I/usr/include/json-glib-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include
testJsonGlib: LOADLIBES := ${LOADLIBES_NET} -ljson-glib-1.0
testStrlen: 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},-O0,${CFLAGS})
debug: all
clean:
2011-05-14 16:21:00 +00:00
rm -f ${TARGETS} $O
2011-04-30 13:42:48 +00:00
test: ${TARGETS}
2011-04-25 21:58:07 +00:00
./testRender
./testMatch
./testText
2011-04-25 21:58:07 +00:00
./isRoutingVar
2011-04-29 21:11:48 +00:00
./getVarType
2011-05-14 19:16:11 +00:00
x=0; for f in packets/[0-9]*; do echo ">> $$f"; ./testPsyc -f $$f | ${DIFF} -u $$f -; x=$$((x+$$?)); done; exit $$x
x=0; for f in packets/[0-9]*; do echo ">> $$f"; ./testPsyc -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-08 18:17:56 +00:00
nettestrun: srvstart pkt srvkill
nettestfull:
${MAKE} nettestrun; x=$$?; pkill -x testPsyc; exit $$x
2011-05-14 19:16:11 +00:00
${MAKE} nettestrun srv_args=-r; x=$$?; pkill -x testPsyc; 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-05-14 19:16:11 +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 testPsyc; 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-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-06 11:32:12 +00:00
pkterr:
for f in packets/err-*; do echo ">> $$f"; cat $$f | nc localhost ${PORT}; done
2011-05-06 11:32:12 +00:00
srvstart:
pkill -x testPsyc; exit 0
2011-05-15 19:20:58 +00:00
./testPsyc -p ${PORT} -S ${srv_args} &
2011-04-22 09:50:13 +00:00
2011-05-06 11:32:12 +00:00
srvkill:
pkill -x testPsyc
bench: bench-genpkts bench-psyc bench-json bench-xml
bench-dir:
@mkdir -p ../bench/results
bench-psyc: bench-dir testStrlen testPsycSpeed
for f in ../bench/packets/*.psyc ../bench/packets/binary/*.psyc; do bf=`basename $$f`; echo strlen: $$bf; ./testStrlen -sc 1000000 -f $$f | ${TEE} -a ../bench/results/$$bf.strlen; done
for f in ../bench/packets/*.psyc ../bench/packets/binary/*.psyc; do bf=`basename $$f`; echo libpsyc: $$f; ./testPsycSpeed -sc 1000000 -f $$f | ${TEE} -a ../bench/results/$$bf; done
bench-json: bench-dir testStrlen testJson testJsonGlib
for f in ../bench/packets/*.json ../bench/packets/binary/*.json; do bf=`basename $$f`; echo strlen: $$bf; ./testStrlen -sc 1000000 -f $$f | ${TEE} -a ../bench/results/$$bf.strlen; done
for f in ../bench/packets/*.json ../bench/packets/binary/*.json; do bf=`basename $$f`; echo json-c: $$bf; ./testJson -snc 1000000 -f $$f | ${TEE} -a ../bench/results/$$bf; done
for f in ../bench/packets/*.json; do bf=`basename $$f`; echo json-glib: $$bf; ./testJsonGlib -snc 1000000 -f $$f | ${TEE} -a ../bench/results/$$bf-glib; done
bench-xml: bench-dir testStrlen
for f in ../bench/packets/*.xml ../bench/packets/binary/*.xml; do bf=`basename $$f`; echo strlen: $$bf; ./testStrlen -sc 1000000 -f $$f | ${TEE} -a ../bench/results/$$bf.strlen; done
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})