mirror of
https://github.com/ntop/n2n.git
synced 2024-09-19 16:41:11 +02:00
Attempt to simplify adding new tests
This commit is contained in:
parent
1f501c70ac
commit
ecaba980ba
|
@ -313,12 +313,12 @@ enable_testing()
|
||||||
add_test(NAME unit
|
add_test(NAME unit
|
||||||
COMMAND ${CMAKE_COMMAND} -E env
|
COMMAND ${CMAKE_COMMAND} -E env
|
||||||
TOPDIR=${PROJECT_SOURCE_DIR} BINDIR=${PROJECT_BINARY_DIR}
|
TOPDIR=${PROJECT_SOURCE_DIR} BINDIR=${PROJECT_BINARY_DIR}
|
||||||
${PROJECT_SOURCE_DIR}/scripts/test_units.sh
|
${PROJECT_SOURCE_DIR}/scripts/test_harness.sh ${PROJECT_SOURCE_DIR}/tests/tests_units.list
|
||||||
)
|
)
|
||||||
add_test(NAME integration
|
add_test(NAME integration
|
||||||
COMMAND ${CMAKE_COMMAND} -E env
|
COMMAND ${CMAKE_COMMAND} -E env
|
||||||
TOPDIR=${PROJECT_SOURCE_DIR} BINDIR=${PROJECT_BINARY_DIR}
|
TOPDIR=${PROJECT_SOURCE_DIR} BINDIR=${PROJECT_BINARY_DIR}
|
||||||
${PROJECT_SOURCE_DIR}/scripts/test_integration.sh
|
${PROJECT_SOURCE_DIR}/scripts/test_harness.sh ${PROJECT_SOURCE_DIR}/tests/tests_integration.list
|
||||||
)
|
)
|
||||||
|
|
||||||
endif(DEFINED UNIX)
|
endif(DEFINED UNIX)
|
||||||
|
|
|
@ -205,10 +205,10 @@ win32/n2n_win32.a: win32
|
||||||
test: test.units test.integration
|
test: test.units test.integration
|
||||||
|
|
||||||
test.units: tools
|
test.units: tools
|
||||||
scripts/test_units.sh
|
scripts/test_harness.sh tests/tests_units.list
|
||||||
|
|
||||||
test.integration: $(APPS)
|
test.integration: $(APPS)
|
||||||
scripts/test_integration.sh
|
scripts/test_harness.sh tests/tests_integration.list
|
||||||
|
|
||||||
.PHONY: lint lint.python lint.ccode lint.shell lint.yaml
|
.PHONY: lint lint.python lint.ccode lint.shell lint.yaml
|
||||||
lint: lint.python lint.ccode lint.shell lint.yaml
|
lint: lint.python lint.ccode lint.shell lint.yaml
|
||||||
|
|
|
@ -98,21 +98,18 @@ Manually test fetching and config:
|
||||||
### `test_harness.sh`
|
### `test_harness.sh`
|
||||||
|
|
||||||
This shell script is used to run automated tests during development. It is
|
This shell script is used to run automated tests during development. It is
|
||||||
run with the name of one or more other scripts, which are then run with their
|
run with a testlist filename - pointing at a file containing the list of
|
||||||
output being sent to `*.out` files in the `tests` directory and compared with
|
tests to run.
|
||||||
the matching `*.expected` file in that same dir.
|
|
||||||
|
|
||||||
### `scripts/test_units.sh`
|
Each test needs a file containing the expected output `${TESTNAME}.expected`
|
||||||
|
which is expected to exist in the same directory as the testlist (this dir is
|
||||||
|
referred to as `${listdir}` below).
|
||||||
|
|
||||||
This runs all the unit tests via the `test_harness.sh`. Unit tests are those
|
Each test is a program, searched for in several locations, including the
|
||||||
that are testing a small and isolated bit of code. In this project, the unit
|
`${listdir}/../scripts` dir.
|
||||||
tests are the only ones that contribute towards the code coverage report.
|
|
||||||
|
|
||||||
### `scripts/test_integration.sh`
|
Each test is run with its output being sent to `*.out` files in the `listdir`
|
||||||
|
and compared with the expected output.
|
||||||
This runs all the integration tests via the `test_harness.sh`. These are
|
|
||||||
tests that interact with multiple features and the test is mainly concerned
|
|
||||||
about the interactions between them (eg, testing an API interface)
|
|
||||||
|
|
||||||
### `scripts/test_integration_supernode.sh`
|
### `scripts/test_integration_supernode.sh`
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
#
|
#
|
||||||
|
# Run with the name of a test list file.
|
||||||
|
#
|
||||||
# This expects to find the tests in the tools dir or scripts dir and the
|
# This expects to find the tests in the tools dir or scripts dir and the
|
||||||
# expected results in the tests dir.
|
# expected results in the tests dir.
|
||||||
#
|
|
||||||
# Run with the name(s) of the tests on the commandline
|
|
||||||
|
|
||||||
# boilerplate so we can support whaky cmake dirs
|
# boilerplate so we can support whaky cmake dirs
|
||||||
[ -z "$TOPDIR" ] && TOPDIR="."
|
[ -z "$TOPDIR" ] && TOPDIR="."
|
||||||
|
@ -11,40 +11,37 @@
|
||||||
export TOPDIR
|
export TOPDIR
|
||||||
export BINDIR
|
export BINDIR
|
||||||
|
|
||||||
if [ -d "$BINDIR/tools" ]; then
|
if [ -z "$1" ]; then
|
||||||
TOOLSDIR="$BINDIR/tools"
|
echo need test list filename
|
||||||
else
|
|
||||||
TOOLSDIR="$BINDIR"
|
|
||||||
fi
|
|
||||||
|
|
||||||
TESTS=$*
|
|
||||||
|
|
||||||
SCRIPTSDIR="$TOPDIR/scripts"
|
|
||||||
TESTDATA="$TOPDIR/tests"
|
|
||||||
|
|
||||||
# Confirm we have all the tools and data
|
|
||||||
for i in $TESTS; do
|
|
||||||
if [ ! -e "$TOOLSDIR/$i" ] && [ ! -e "$SCRIPTSDIR/$i" ]; then
|
|
||||||
echo "Could not find test $i"
|
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
if [ ! -e "$TESTDATA/$i.expected" ]; then
|
TESTLIST="$1"
|
||||||
echo "Could not find testdata $TESTDATA/$i.expected"
|
LISTDIR=$(dirname "$TESTLIST")
|
||||||
exit 1
|
|
||||||
fi
|
TESTS=$(sed -e "s/#.*//" "$TESTLIST")
|
||||||
done
|
|
||||||
|
|
||||||
# Actually run the tests
|
# Actually run the tests
|
||||||
for i in $TESTS; do
|
for i in $TESTS; do
|
||||||
if [ -e "$TOOLSDIR/$i" ]; then
|
# Look in several places for the test program
|
||||||
TEST="$TOOLSDIR/$i"
|
if [ -e "$BINDIR/$i" ]; then
|
||||||
elif [ -e "$SCRIPTSDIR/$i" ]; then
|
TEST="$BINDIR/$i"
|
||||||
TEST="$SCRIPTSDIR/$i"
|
elif [ -e "$BINDIR/tools/$i" ]; then
|
||||||
|
TEST="$BINDIR/tools/$i"
|
||||||
|
elif [ -e "$LISTDIR/../scripts/$i" ]; then
|
||||||
|
TEST="$LISTDIR/../scripts/$i"
|
||||||
|
else
|
||||||
|
echo "Could not find test $i"
|
||||||
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "$TEST >$TESTDATA/$i.out"
|
if [ ! -e "$LISTDIR/$i.expected" ]; then
|
||||||
|
echo "Could not find testdata $LISTDIR/$i.expected"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "$TEST >$LISTDIR/$i.out"
|
||||||
set -e
|
set -e
|
||||||
"$TEST" >"$TESTDATA/$i.out"
|
"$TEST" >"$LISTDIR/$i.out"
|
||||||
cmp "$TESTDATA/$i.expected" "$TESTDATA/$i.out"
|
cmp "$LISTDIR/$i.expected" "$LISTDIR/$i.out"
|
||||||
set +e
|
set +e
|
||||||
done
|
done
|
||||||
|
|
|
@ -1,11 +0,0 @@
|
||||||
#!/bin/sh
|
|
||||||
#
|
|
||||||
# Run all the integration tests via the test harness
|
|
||||||
|
|
||||||
# boilerplate so we can support whaky cmake dirs
|
|
||||||
[ -z "$TOPDIR" ] && TOPDIR=.
|
|
||||||
[ -z "$BINDIR" ] && BINDIR=.
|
|
||||||
export TOPDIR
|
|
||||||
export BINDIR
|
|
||||||
|
|
||||||
${TOPDIR}/scripts/test_harness.sh test_integration_supernode.sh
|
|
|
@ -1,21 +0,0 @@
|
||||||
#!/bin/sh
|
|
||||||
#
|
|
||||||
# Run all the unit tests via the test harness
|
|
||||||
|
|
||||||
# boilerplate so we can support whaky cmake dirs
|
|
||||||
[ -z "$TOPDIR" ] && TOPDIR=.
|
|
||||||
[ -z "$BINDIR" ] && BINDIR=.
|
|
||||||
export TOPDIR
|
|
||||||
export BINDIR
|
|
||||||
|
|
||||||
TESTS="
|
|
||||||
tests-auth
|
|
||||||
tests-compress
|
|
||||||
tests-elliptic
|
|
||||||
tests-hashing
|
|
||||||
tests-transform
|
|
||||||
tests-wire
|
|
||||||
"
|
|
||||||
|
|
||||||
# shellcheck disable=SC2086
|
|
||||||
${TOPDIR}/scripts/test_harness.sh $TESTS
|
|
4
tests/tests_integration.list
Normal file
4
tests/tests_integration.list
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
#
|
||||||
|
# The integration tests
|
||||||
|
|
||||||
|
test_integration_supernode.sh
|
9
tests/tests_units.list
Normal file
9
tests/tests_units.list
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
#
|
||||||
|
# The unit tests
|
||||||
|
|
||||||
|
tests-auth
|
||||||
|
tests-compress
|
||||||
|
tests-elliptic
|
||||||
|
tests-hashing
|
||||||
|
tests-transform
|
||||||
|
tests-wire
|
Loading…
Reference in New Issue
Block a user