test scripts: added sum.sh

This commit is contained in:
Olof hagsand 2019-02-02 13:19:49 +01:00
parent 936ae389e8
commit 376b75328c
4 changed files with 53 additions and 25 deletions

View file

@ -76,7 +76,8 @@
* Note CLIXON_DATADIR (=/usr/local/share/clixon) need to be in the list
* CLICON_YANG_MAIN_FILE Provides a filename with a single module filename.
* CLICON_YANG_MAIN_DIR Provides a directory where all yang modules should be loaded.
* NACM (RFC8341) experimental
* NACM (RFC8341)
* Experimental support, no performance enhancements and need further testing
* Incoming RPC Message validation is supported (3.4.4)
* Data Node Access validation is supported (3.4.5), except:
* rule-type data-node path is not supported

View file

@ -3,7 +3,9 @@
This directory contains testing code for clixon and the example
application. Assumes setup of http daemon as describe under apps/restonf
- Jenkinsfile Makefile for Jenkins tests. Build clixon and run tests.
- all.sh Run through all tests named 'test*.sh' in this directory. Therefore, if you place a test in this directory matching 'test*.sh' it will be run automatically. By default the script will exit on first error. Run as `all.sh summary` to continue and print a summary on all tests.
- all.sh Run through all tests with detailed output, and stop on first error.
- sum.sh Run though all tests and print summary
- mem.sh Make valgrind
- site.sh Add your site-specific modifications here
- test_nacm.sh Auth tests using internal NACM
- test_nacm_ext.sh Auth tests using external NACM (separate file)
@ -18,14 +20,20 @@ application. Assumes setup of http daemon as describe under apps/restonf
- test_datastore.sh Datastore tests
- and many more...
Example runs:
```
> run.sh
# Runs through all tests matching 'test_*.sh' in the directory. Prints test output
# and stops on first error
Tests called 'test*.sh' and placed in this directory will be automatically run as part of the all.sh, sum.sh tests etc.
> run.sh summary
# Same as above but continues after errors and does not print test output.
You can prefix a test with `BE=0` if you want to run your own backend.
To run with debug flags, use the `DBG=<number>` environment variable.
You can run an individual test by itself, or run through all tests matching 'test_*.sh' in the directory. Prints test output and stops on first error:
```
all.sh
```
Run all tests but continue after errors and only print a summary test output identifying which tests succeeded and which failed:
```
all.sh summary
```

View file

@ -1,14 +1,9 @@
#!/bin/bash
# Run, eg as:
# ./all.sh 2>&1 | tee test.log # break on first test
# ./all.sh summary # to run all tests and print
summary=0
if [ $# -gt 0 ]; then
summary=1
fi
if [ $# -gt 1 ]; then
echo "usage: $0 [summary] # pipe to dev/null and continue on error"
echo "usage: $0 # detailed logs and stopon first error"
exit -1
fi
@ -17,20 +12,13 @@ fi
err=0
for test in test*.sh; do
echo "Running $test"
if [ $summary -ne 0 ]; then
./$test > /dev/null 2>&1
errcode=$?
else
./$test
errcode=$?
fi
./$test
errcode=$?
if [ $errcode -ne 0 ]; then
err=1
echo -e "\e[31mError in $test errcode=$errcode"
echo -ne "\e[0m"
if [ $summary -eq 0 ]; then
exit $errcode
fi
exit $errcode
fi
done
if [ $err -eq 0 ]; then

31
test/sum.sh Executable file
View file

@ -0,0 +1,31 @@
#!/bin/bash
# Run, eg as:
# ./sum.sh # to run all tests and print
if [ $# -gt 0 ]; then
echo "usage: $0 # pipe to dev/null and continue on error"
exit -1
fi
# include err() and new() functions
. ./lib.sh
err=0
for test in test*.sh; do
echo "Running $test"
./$test > /dev/null 2>&1
errcode=$?
if [ $errcode -ne 0 ]; then
err=1
echo -e "\e[31mError in $test errcode=$errcode"
echo -ne "\e[0m"
fi
done
if [ $err -eq 0 ]; then
echo OK
else
echo -e "\e[31mError"
echo -ne "\e[0m"
exit -1
fi