X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=test%2Funit_test.sh;h=fd6f2e24aa57597ec014c5da0ed4c2fe4d4ac9ad;hb=23d0e614733c0305738d8c70d2e4c3e56beb6473;hp=2f30686d344780f5e4964eb04b59e249dcd1ec6e;hpb=97204c8a0eb213af5f4c656cd30f1ecf82c8a520;p=ric-plt%2Fxapp-frame-cpp.git diff --git a/test/unit_test.sh b/test/unit_test.sh index 2f30686..fd6f2e2 100755 --- a/test/unit_test.sh +++ b/test/unit_test.sh @@ -1,6 +1,5 @@ #!/usr/bin/env bash # vim: ts=4 sw=4 noet: - #================================================================================== # Copyright (c) 2020 Nokia # Copyright (c) 2020 AT&T Intellectual Property. @@ -60,6 +59,16 @@ function abort_if_error { spew="cat" # default to dumping all make output on failure (-q turns it to ~40 lines) +if [[ -d ../.build ]] +then + build_dir="../.build" +else + if [[ -d ../build ]] + then + build_dir="../build" + fi +fi + while [[ $1 == "-"* ]] do case $1 in @@ -70,8 +79,36 @@ do shift done -export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH -export LIBRARY_PATH=/usr/local/lib:$LIBRARY_PATH +while [[ $1 == *"="* ]] +do + case ${1%%=*} in + CMBUILD) + export build_dir=${1##*=} + ;; + esac + + shift +done + +echo "## INFO ##" +echo "build dir=$build_dir" +if ! find $build_dir | grep "libricxfcpp.*" # find returns good even if none; must grep to see error +then + echo "building first..." + ( + cd $build_dir + make package + ) + + echo "build finished" + find $build_dir -name "libricxfcpp.*" +fi +echo "## INFO ##" + +export LD_LIBRARY_PATH=$build_dir:/usr/local/lib:$LD_LIBRARY_PATH +export LIBRARY_PATH=$build_dir:/usr/local/lib:$LIBRARY_PATH + +cp config1.json config-file.json # ensure default named file is there too make nuke >/dev/null make tests >/tmp/PID$$.log 2>&1 @@ -80,10 +117,22 @@ echo "tests successfully built" >&2 spew="cat" -for x in unit_test jhash_test +# order here is important to ensure coverage files accumulate +tests="metrics_test jhash_test config_test unit_test" + +#run everything, then generate coverage stats after all have run +for x in $tests do ./$x >/tmp/PID$$.log 2>&1 abort_if_error $? "test failed: $x" + grep SUMMARY /tmp/PID$$.log +done + +# it seems that we loose coverage reporting if metrics_test's gcov file is generated +# after unit test. Very strange. To be safe, run unit_test last. +# +for x in $tests +do gcov $x.c >/dev/null 2>&1 done