From 376b75328c762c2b0ddbb718977edb44629d82eb Mon Sep 17 00:00:00 2001 From: Olof hagsand Date: Sat, 2 Feb 2019 13:19:49 +0100 Subject: [PATCH] test scripts: added sum.sh --- CHANGELOG.md | 3 ++- test/README.md | 24 ++++++++++++++++-------- test/all.sh | 20 ++++---------------- test/sum.sh | 31 +++++++++++++++++++++++++++++++ 4 files changed, 53 insertions(+), 25 deletions(-) create mode 100755 test/sum.sh diff --git a/CHANGELOG.md b/CHANGELOG.md index 925c295d..adc11905 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/test/README.md b/test/README.md index 0c278c9d..31a55880 100644 --- a/test/README.md +++ b/test/README.md @@ -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=` 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 ``` diff --git a/test/all.sh b/test/all.sh index 1e036ab1..23d5424f 100755 --- a/test/all.sh +++ b/test/all.sh @@ -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 diff --git a/test/sum.sh b/test/sum.sh new file mode 100755 index 00000000..257c2bff --- /dev/null +++ b/test/sum.sh @@ -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 + +