Skip to content

Commit

Permalink
Move test code into script of its own.
Browse files Browse the repository at this point in the history
  • Loading branch information
sobomax committed Mar 16, 2023
1 parent 393c62d commit 0e62690
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 39 deletions.
19 changes: 2 additions & 17 deletions GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ CFLAGS?= -O2 -pipe
OBJS = $(SRCS_C:.c=.o)
OBJS_PIC = $(SRCS_C:.c=.So)

TEST_OUT_FILES= test.raw test.raw.16k pcminb.g722 pcminb.raw.16k \
test.g722.out fullscale.raw

all: libg722.a libg722.so.0 libg722.so

libg722.a: $(OBJS) $(SRCS_H)
Expand All @@ -35,23 +32,11 @@ libg722.so: libg722.so.0
$(CC) -fpic -DPIC -c $(CFLAGS) $< -o $@

clean:
rm -f libg722.a libg722.so.0 $(OBJS) $(OBJS_PIC) test $(TEST_OUT_FILES)
rm -f libg722.a libg722.so.0 $(OBJS) $(OBJS_PIC) test *.out

test: test.c libg722.a libg722.so.0
${CC} ${CFLAGS} -o $@ test.c -lm -L. -lg722
LD_LIBRARY_PATH=. ./$@ test.g722 test.raw
LD_LIBRARY_PATH=. ./$@ --sln16k test.g722 \
test.raw.16k
LD_LIBRARY_PATH=. ./$@ --enc --sln16k --bend \
pcminb.dat pcminb.g722
LD_LIBRARY_PATH=. ./$@ --sln16k --bend \
pcminb.g722 pcminb.raw.16k
LD_LIBRARY_PATH=. ./$@ --enc test.raw \
test.g722.out
LD_LIBRARY_PATH=. ./$@ --sln16k \
fullscale.g722 fullscale.raw
sha256sum ${TEST_OUT_FILES} | \
diff test.checksum -
LD_LIBRARY_PATH=. ./scripts/do-test.sh ./$@

install:
install -d ${DESTDIR}${LIBDIR}
Expand Down
21 changes: 4 additions & 17 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,13 @@ VERSION_DEF= ${.CURDIR}/ld_sugar/Versions.def
SYMBOL_MAPS= ${.CURDIR}/ld_sugar/Symbol.map
CFLAGS+= -DSYMBOL_VERSIONING

TEST_OUT_FILES= test.raw test.raw.16k pcminb.g722 pcminb.raw.16k \
test.g722.out fullscale.raw
CLEANFILES+=test *.out

CLEANFILES+=test ${TEST_OUT_FILES}
TDDIR= ${.CURDIR}/test_data

test: test.c lib${LIB}.a lib${LIB}.so.${SHLIB_MAJOR} test.g722 fullscale.raw pcminb.dat Makefile
test: test.c lib${LIB}.a lib${LIB}.so.${SHLIB_MAJOR} ${TDDIR}/fullscale.g722 ${TDDIR}/pcminb.dat ${TDDIR}/test.checksum ${TDDIR}/test.g722 Makefile
rm -f ${TEST_OUT_FILES}
${CC} ${CFLAGS} -o ${.TARGET} test.c -lm -L. -l${LIB}
LD_LIBRARY_PATH=${.CURDIR} ${.CURDIR}/${.TARGET} test.g722 test.raw
LD_LIBRARY_PATH=${.CURDIR} ${.CURDIR}/${.TARGET} --sln16k test.g722 \
test.raw.16k
LD_LIBRARY_PATH=${.CURDIR} ${.CURDIR}/${.TARGET} --enc --sln16k --bend \
pcminb.dat pcminb.g722
LD_LIBRARY_PATH=${.CURDIR} ${.CURDIR}/${.TARGET} --sln16k --bend \
pcminb.g722 pcminb.raw.16k
LD_LIBRARY_PATH=${.CURDIR} ${.CURDIR}/${.TARGET} --enc test.raw \
test.g722.out
LD_LIBRARY_PATH=${.CURDIR} ${.CURDIR}/${.TARGET} --sln16k \
fullscale.g722 fullscale.raw
sha256sum ${TEST_OUT_FILES} | \
diff test.checksum -
LD_LIBRARY_PATH=${.CURDIR} ${.CURDIR}/scripts/do-test.sh ${.CURDIR}/${.TARGET}

.include <bsd.lib.mk>
17 changes: 17 additions & 0 deletions scripts/do-test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/sh

set -e
set -x

TEST_CMD="${1:-"./test"}"
MDIR="${2:-"`dirname ${0}`/.."}"
TDDIR="${MDIR}/test_data"

${TEST_CMD} ${TDDIR}/test.g722 test.raw.out
${TEST_CMD} --sln16k ${TDDIR}/test.g722 test.raw.16k.out
${TEST_CMD} --enc --sln16k --bend ${TDDIR}/pcminb.dat pcminb.g722.out
${TEST_CMD} --sln16k --bend pcminb.g722.out pcminb.raw.16k.out
${TEST_CMD} --enc test.raw.out test.g722.out
${TEST_CMD} --sln16k ${TDDIR}/fullscale.g722 fullscale.raw.out
sha256sum test.raw.out test.raw.16k.out pcminb.g722.out pcminb.raw.16k.out \
test.g722.out fullscale.raw.out | diff ${TDDIR}/test.checksum -
File renamed without changes.
File renamed without changes.
10 changes: 5 additions & 5 deletions test.checksum → test_data/test.checksum
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
8eb29e8e9feb9709d96c7bbda37cbb2f77510fcfab2d1f48a495178cd2231253 test.raw
a886f22d37ecd356e1963072bc481ed2c5dd12539428188d9779d33a520f3ff8 test.raw.16k
15570a43acb0ff0f30aced265973eeb7733023be3697cdff0df36c41e88385c6 pcminb.g722
1d3f23110538d25b96631db4aff3eff84f99b0859140302a99b323b259b24b89 pcminb.raw.16k
8eb29e8e9feb9709d96c7bbda37cbb2f77510fcfab2d1f48a495178cd2231253 test.raw.out
a886f22d37ecd356e1963072bc481ed2c5dd12539428188d9779d33a520f3ff8 test.raw.16k.out
15570a43acb0ff0f30aced265973eeb7733023be3697cdff0df36c41e88385c6 pcminb.g722.out
1d3f23110538d25b96631db4aff3eff84f99b0859140302a99b323b259b24b89 pcminb.raw.16k.out
cb8edfaa7b5a85384dde8e0c9976f5247294732d6caf32c07b94510fc8844403 test.g722.out
e70c92cd2068d112839db12bfaa787cc0ea9a809b64fbf62fd78b6041cd9fbcc fullscale.raw
e70c92cd2068d112839db12bfaa787cc0ea9a809b64fbf62fd78b6041cd9fbcc fullscale.raw.out
File renamed without changes.

0 comments on commit 0e62690

Please sign in to comment.