From b661aa0320168d739ee769b1824f39d2ec64d9fe Mon Sep 17 00:00:00 2001 From: Radoslaw Wicik Date: Fri, 5 Feb 2021 16:09:52 +0100 Subject: [PATCH] [EGD-4763] Update tests add missing corner cases Some tests where not added during the initial setup, and there where few more corner cases that need to fixed like line wrapping by `catch2 -l` and need of escaping some characters [], --- enabled_unittests | 41 ++++++++++++++++++++++--- module-db/tests/ContactGroups_tests.cpp | 4 +-- tools/get_unittests.sh | 22 +++++++++++-- tools/run_unittests.sh | 9 +++++- 4 files changed, 65 insertions(+), 11 deletions(-) diff --git a/enabled_unittests b/enabled_unittests index 514e73e1f98d2fe929c2aa5b5a80190d5624aa5c..c83717dcf973e7aed0ff5f6229097ca7b975b708 100644 --- a/enabled_unittests +++ b/enabled_unittests @@ -9,6 +9,10 @@ # each test is in separate line # to disable test just rem it by putting # in front of it # +# folowing caracters have to be escaped: +# [], +# \[ \] \, + declare -A TESTS_LIST TESTS_LIST["catch2-audio-test"]=" @@ -29,7 +33,14 @@ TESTS_LIST["catch2-cellular-datatransfer"]=" Quectel AT DataTransfer commands; " #--------- -TESTS_LIST["catch2-cellular-mmi"]=" +TESTS_LIST["catch2-cellular-parse-result"]=" + CSCA parser test; + CSCA set data; + QECCNUM parser; +" +#--------- +TESTS_LIST["catch2-cellular-request-factory"]=" + Emergency handling; MMI requests; " #--------- @@ -77,7 +88,6 @@ TESTS_LIST["catch2-db"]=" Contacts Ringtones Table tests; Contacts address Table tests; Contact Groups tests; - [Groups]; Alarms Table tests; SMS Templates Table tests; Calllog Table tests; @@ -139,7 +149,7 @@ TESTS_LIST["catch2-gui-text"]=" Text block - get width; Text BlockCursor Ctor/Dtor ; TextDocument <-> BlockCursor fencing tests; - TextDocument <-> BlockCursor operators: +, ++, -, -- tests; + TextDocument <-> BlockCursor operators: +\, ++\, -\, -- tests; add Char to empty; add Char; remove Char in empty; @@ -186,6 +196,20 @@ TESTS_LIST["catch2-service-evtmgr"]=" ScreenLightControlFunctions; " #--------- +TESTS_LIST["catch2-StatefulController-tests"]=" + Given StatefulController when turn on then turned on; + Given StatefulController when error during device registration then turned off; + Given StatefulController when error during driver init then turned off; + Given StatefulController when error during driver run then turned off; + Given StatefulController when restart then don't init twice; + Given StatefulController when turn off in off state then turned off; + Given StatefulController when turn off in on state then turned off; + Given StatefulController when shutdown in off state then terminated; + Given StatefulController when shutdown in on state then terminated; + Given StatefulController when process command successfully then turned on; + Given StatefulController when processing command failed then restarted and turned on; +" +#--------- TESTS_LIST["catch2-unittest_parse_CSCA"]=" CSCA parser test; CSCA set data; @@ -234,6 +258,10 @@ TESTS_LIST["catch2-utils-phonenumber"]=" Number matcher - match incoming (loose); " #--------- +TESTS_LIST["catch2-utils-time_display"]=" + Time display parser; +" +#--------- TESTS_LIST["catch2-utils-ucs2"]=" UCS2 to UTF8 conversion; UCS2 from UTF8 emoji 😁; @@ -276,8 +304,11 @@ TESTS_LIST["catch2-utils-utf8"]=" UTF8: removeChar returns propper string; UTF8: getChar; UTF8: encode / decode / how it works; - UTF8 bad case scenario - operator[] returns; + UTF8 bad case scenario - operator\[\] returns; U8char && UTF8: encode; + UTF8: insert whole string which doesn't work; + UTF8: Convert to ascii if is ascii combination; + UTF8: Not ASCII combination; " #--------- TESTS_LIST["catch2-vfs"]=" @@ -290,7 +321,7 @@ TESTS_LIST["catch2-vfs"]=" TESTS_LIST["catch2-vfs-core-fs"]=" Corefs: Registering and unregistering block device; Corefs: Basic API test; - Corefs: Create new file, write, read from it; + Corefs: Create new file\, write\, read from it; Corefs: Register null filesystem; Corefs: Mount empty strings; Corefs: Write to not valid file descriptor; diff --git a/module-db/tests/ContactGroups_tests.cpp b/module-db/tests/ContactGroups_tests.cpp index 2b8c644f2e652b0240bebbb501bf83a178ab843e..5e8b4fbab7f6bd9f552e0579aea199a8bb97acdd 100644 --- a/module-db/tests/ContactGroups_tests.cpp +++ b/module-db/tests/ContactGroups_tests.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved. +// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved. // For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md #include @@ -24,7 +24,7 @@ namespace consts void addSomeContacts(ContactsDB &contactsDb); -TEST_CASE("Contact Groups tests", "[Groups]") +TEST_CASE("Contact Groups tests") { vfs.Init(); INFO("sqlite Init"); diff --git a/tools/get_unittests.sh b/tools/get_unittests.sh index 2cb8d91e8cba9b2eefcbb9e2ed658c8437f43bff..15464343706426d1d4bc571f7fa8173e3426b9c0 100755 --- a/tools/get_unittests.sh +++ b/tools/get_unittests.sh @@ -34,6 +34,10 @@ cat <<- EOF # each test is in separate line # to disable test just rem it by putting # in front of it # + # folowing caracters have to be escaped: + # [], + # \[ \] \, + declare -A ${TESTS_LIST_VAR} EOF @@ -46,12 +50,24 @@ for TEST_BINARY in catch2-* do echo "${TEST_BINARY}" echo "${TESTS_LIST_VAR}[\"${TEST_BINARY}\"]=\"" >> ${TESTS_FILE} - - readarray -t TESTS_LIST < <(./${TEST_BINARY} -l | grep -e "^ " | xargs -i{} echo {} ) + + #sed explaind + #:a - lablel 'a' current pattern space to jump to + #N - append next line to pattern space (wiht \n) + #/\n / - search for this pattern + #s/\n // - delete "\n " (can be "replace") + #ta - if we changed something, jump to lable 'a' + #P - print part until new line + #D - delete part until new line + TESTS_LIST_STR=$(./${TEST_BINARY} -l | grep -E "^ .*" | cut -f3- -d\ | sed -e ':a;N;/\n /s/\n //;ta;P;D' ) + + readarray -t TESTS_LIST < <( echo -e "$TESTS_LIST_STR" | tr "\n" "\0" | xargs -0 -i{} echo {} ) + I=0 while [[ $I -lt ${#TESTS_LIST[@]} ]] do - echo -e " ${TESTS_LIST[$I]};" >> ${TESTS_FILE} + #sed cannot search for single ] to search for it we use ][ patter (and also look for closing ]) + echo -e " ${TESTS_LIST[$I]};" | sed -e 's#[][,]#\\&#g' >> ${TESTS_FILE} I=$(( $I + 1 )) done echo "\"" >> ${TESTS_FILE} diff --git a/tools/run_unittests.sh b/tools/run_unittests.sh index 7f3ce5cbd4331e86d26c7aed611be13c971c1cec..35df51f6ba8be33ed45c1744e95a3017bf117000 100755 --- a/tools/run_unittests.sh +++ b/tools/run_unittests.sh @@ -5,6 +5,7 @@ root_dir="$(realpath $(dirname $(realpath $0))/..)" build_dir="${root_dir}/build-linux-Debug" +run_logs=${build_dir}/ut_run_logs function help() { cat <<- EOF @@ -50,7 +51,13 @@ do CUR_TEST=$( trim ${TESTS[$I]}) if [[ -n "${CUR_TEST}" ]]; then echo ${TEST_BINARY} \"${CUR_TEST}\" - ./${TEST_BINARY} "${CUR_TEST}" + ./${TEST_BINARY} "${CUR_TEST}" | tee ${run_logs} + CHK_IF_RUN=`cat ${run_logs} | grep "No tests ran" || true` + echo "---$CHK_IF_RUN---" + if [[ -n "${CHK_IF_RUN}" ]]; then + echo "no such test: ${TEST_BINARY} ${CUR_TEST}" + exit 1 + fi fi I=$(( $I + 1 )) done