M .github/workflows/main.yml => .github/workflows/main.yml +62 -12
@@ 80,13 80,19 @@ jobs:
popd
- name: Check for statics
run: ./tools/find_global_data.py build-linux-Debug/PurePhone.elf
- - name: run unit tests
+ - name: build unit tests
run: |
pushd build-linux-Debug && \
export JOBS=${JOBS:-`nproc`} && \
echo "JOBS=${JOBS}" && \
- make -j ${JOBS} check && \
+ make -j ${JOBS} unittests && \
popd
+ - name: run unit tests
+ run: |
+ ./tools/run_unittests.sh enabled_unittests
+ - name: store build artefact
+ run: |
+ tar cf /artefacts/build-$(git rev-parse --short HEAD).tar build-linux-Debug
- name: start emulator
run: |
./run_emulator_on_filesystem_image.sh 2>&1 > emulator.log &
@@ 103,16 109,60 @@ jobs:
run: cat emulator.log
if: always()
- emulator_on_off_test:
- name: emulator on-off test
- if: github.event.pull_request.draft == false
- runs-on: self-hosted
+ #emulator_on_off_test:
+ #Enable this test in "Clean artefacts"
+ # name: emulator on-off test
+ # if: github.event.pull_request.draft == false
+ # runs-on: self-hosted
+ # needs:
+ # - build_linux_binary_and_run_tests
+ # steps:
+ # - name: clone repository
+ # uses: actions/checkout@v2
+ # with:
+ # token: ${{ secrets.GitHub_PAT }}
+ # submodules: recursive
+ # - name: get artefacts
+ # run: |
+ # tar xf /artefacts/build-$(git rev-parse --short HEAD).tar
+ # - name: start emulator on-off test
+ # run: ./phone_on_off_test.sh
+ # working-directory: test
+ # - name: print emulator logs
+ # run: cat emulator.log
+ # if: always()
+
+ check_run_unit_tests:
+ name: Check run unit tests
needs:
- build_linux_binary_and_run_tests
+ runs-on: self-hosted
steps:
- - name: start emulator on-off test
- run: ./phone_on_off_test.sh
- working-directory: test
- - name: print emulator logs
- run: cat emulator.log
- if: always()
+ - name: clone repository
+ uses: actions/checkout@v2
+ with:
+ token: ${{ secrets.GitHub_PAT }}
+ submodules: recursive
+ - name: get artefacts
+ run: |
+ tar xf /artefacts/build-$(git rev-parse --short HEAD).tar
+ - name: check if all Unit Tests where run
+ run: |
+ ./tools/check_unittests.sh enabled_unit_tests
+
+ clean_artefacts:
+ name: Clean Artefacts
+ if: always()
+ #needs: [ build_linux_binary_and_run_tests, emulator_on_off_test, check_run_unit_tests ]
+ needs: [ build_linux_binary_and_run_tests, check_run_unit_tests ]
+ runs-on: self-hosted
+ steps:
+ - name: clone repository
+ uses: actions/checkout@v2
+ with:
+ token: ${{ secrets.GitHub_PAT }}
+ submodules: recursive
+ - name: Delete Artefact
+ run: |
+ rm -f /artefacts/build-$(git rev-parse --short HEAD).tar
+
A enabled_unittests => enabled_unittests +320 -0
@@ 0,0 1,320 @@
+# Enabled test list
+# test format
+# TESTS_LIST["catch2-<binary-name>"]="
+# test 1;
+# test 1;
+# test 3;
+#"
+#
+# each test is in separate line
+# to disable test just rem it by putting # in front of it
+#
+declare -A TESTS_LIST
+
+TESTS_LIST["catch2-audio-test"]="
+ Test audio tags;
+ Audio settings string creation;
+ Test AudioMux;
+"
+#---------
+TESTS_LIST["catch2-calculator"]="
+ Calculator utilities;
+"
+#---------
+TESTS_LIST["catch2-callback-storage-test"]="
+ CallbackStorageTests;
+"
+#---------
+TESTS_LIST["catch2-cellular-datatransfer"]="
+ Quectel AT DataTransfer commands;
+"
+#---------
+TESTS_LIST["catch2-cellular-mmi"]="
+ MMI requests;
+"
+#---------
+TESTS_LIST["catch2-cellular-response"]="
+ Response COPS;
+ Response CLIR;
+ Response CLIP;
+ Response CLCK;
+ Response CCWA?;
+"
+#---------
+TESTS_LIST["catch2-cellular-simcard"]="
+ SimCard functionality test;
+"
+#---------
+TESTS_LIST["catch2-cellular-URC"]="
+ +Qind: csq;
+ +Qind: FOTA;
+ +Cusd;
+ +Ctze;
+ +Creg;
+ +Cmti;
+ +CLIP;
+ +CPIN;
+ POWERED DOWN;
+ Urc RESPONSE;
+ +Qind: SMS DONE;
+ +Qiurc: TCP Context and connection message;
+"
+#---------
+TESTS_LIST["catch2-commands-queue-tests"]="
+ DrawCommandsQueueTests;
+"
+#---------
+TESTS_LIST["catch2-context-pool-tests"]="
+ ContextPoolTests;
+"
+#---------
+TESTS_LIST["catch2-db"]="
+ SMS Table tests;
+ Threads Table tests;
+ Contacts Table tests;
+ Contacts Name Table tests;
+ Contacts Number Table tests;
+ Contacts Ringtones Table tests;
+ Contacts address Table tests;
+ Contact Groups tests;
+ [Groups];
+ Alarms Table tests;
+ SMS Templates Table tests;
+ Calllog Table tests;
+# Notifications Table tests;
+# Events Table tests;
+ Notes Record tests;
+ Notes Table tests;
+ Calllog Record tests;
+ Contact Record db tests;
+ Test contact name formatting;
+ Test converting contact data to string;
+ Contact record numbers update;
+ SMS Record tests;
+ Thread Record tests;
+ Alarms Record tests;
+ SMS templates Record tests;
+# Notifications Record tests;
+ Events Record tests;
+ Query interface;
+"
+#---------
+TESTS_LIST["catch2-db-initializer"]="
+ Create and destroy simple database;
+ Database initialization scripts;
+"
+#---------
+TESTS_LIST["catch2-gui"]="
+ Test BoundingBox intersect;
+ Are fonts loaded;
+ Draw window with labels;
+ Draw window with box layouts;
+ test context size and position;
+ insertContextTest;
+ gui::Item on input flow test;
+ gui::Window on input flow test;
+ Set size tests;
+ Parsing English input language;
+ Parsing numeric keyboard;
+ Getting charKey after clicking button twice;
+"
+#---------
+TESTS_LIST["catch2-gui-text"]="
+ Text ctor;
+ Text drawLines;
+ Text buildDrawList;
+ handle input mode ABC/abc/1234;
+ handle longpress for digit in ABC mode;
+ handle text expand;
+ handle newline;
+ handle text block - moved cursor to end;
+ Text backup and restore tests;
+ Text addition bounds - text sings count restricted;
+ Text addition bounds - text widget size restricted;
+ Text addition bounds - text widget line size restricted;
+ Text addition bounds - multiple limits tests;
+ TextBlock Ctor/Dtor ;
+ Text block - set/update/get text;
+ Text block - remove text;
+ Text block - get width;
+ Text BlockCursor Ctor/Dtor ;
+ TextDocument <-> BlockCursor fencing tests;
+ TextDocument <-> BlockCursor operators: +, ++, -, -- tests;
+ add Char to empty;
+ add Char;
+ remove Char in empty;
+ remove Char;
+ add newline;
+ add newline at the end;
+ atEOL();
+ operator-> for Text block with text;
+ operator* for TextBlock;
+ TextDocument ctor;
+ TextDocument getBlockCursor;
+ TextLine - ctor;
+ TextLine - non fitting text;
+ TextLine - multiple styles text;
+ TextLine - elements sizes checkup;
+ TextParse;
+ Testo Font;
+ TextLineCursor - navigation without scroll;
+ TextLineCursor - navigation with scroll;
+ TextLineCursor - addition and deletion with scroll;
+"
+#---------
+TESTS_LIST["catch2-service-db"]="
+ DB_API;
+ Settings Messages;
+# FileIndexer;
+"
+#---------
+TESTS_LIST["catch2-service-db-settings"]="
+ SettingsApi;
+"
+#---------
+TESTS_LIST["catch2-service-desktop"]="
+ System Update Tests;
+ Parser Test;
+ DB Helpers test - json decoding;
+ DB Helpers test - json encoding (contacts);
+ DB Helpers test - json encoding (messages);
+ Context class test;
+ Endpoint Factory test;
+"
+#---------
+TESTS_LIST["catch2-service-evtmgr"]="
+ ScreenLightControlFunctions;
+"
+#---------
+TESTS_LIST["catch2-unittest_parse_CSCA"]="
+ CSCA parser test;
+ CSCA set data;
+"
+#---------
+TESTS_LIST["catch2-utils"]="
+ Split tests;
+ toNumeric tests;
+ findAndReplaceAll tests;
+ Converts enum to string;
+ Get value from string;
+ Swap endianness;
+ Floating point to string;
+ Fill leading digit in string;
+ Read file length;
+"
+#---------
+TESTS_LIST["catch2-utils-clipboard"]="
+ Clipboard;
+"
+#---------
+TESTS_LIST["catch2-utils-duration"]="
+ Duration - creation;
+ Duration - arithemtics;
+ Duration - comparision;
+ Duration - display;
+"
+#---------
+TESTS_LIST["catch2-utils-loggerbuffer"]="
+ LoggerBuffer tests;
+"
+#---------
+TESTS_LIST["catch2-utils-math"]="
+ Math;
+"
+#---------
+TESTS_LIST["catch2-utils-phonenumber"]="
+ PhoneNumber - parsing;
+ PhoneNumber - formatting;
+ PhoneNumber - views;
+ PhoneNumber - equality;
+ PhoneNumber - matching;
+ PhoneNumber - record validation;
+ Number matcher - basics;
+ Number matcher - match incoming (full list);
+ Number matcher - match incoming (loose);
+"
+#---------
+TESTS_LIST["catch2-utils-ucs2"]="
+ UCS2 to UTF8 conversion;
+ UCS2 from UTF8 emoji 😁;
+ UCS2 from UTF8 emoji 🍣;
+ UTF8 to UCS2 conversion;
+ TEST special input characters from UTF8;
+ TEST special input characters from std::string;
+ UTF8 emoji 🍣 from UCS2 code;
+ UTF8 emoji 😁 and text ęą from UCS2 code;
+ UTF8 emoji 😁 and text abc from UCS2 code;
+ UCS2 to UTF8 long string conversion;
+ UTF8 to UCS2 long string conversion;
+"
+#---------
+TESTS_LIST["catch2-utils-utf8"]="
+ UTF8: operator index returns value;
+ UTF8: operator index exceeds string size;
+ UTF8: operator== returns properly;
+ UTF8: substr returns empty string when zero length is passed;
+ UTF8: substr returns empty string when length is exceeded;
+ UTF8: substr returns proper begin char;
+ UTF8: substr returns proper string length;
+ UTF8: find returns npos if not found;
+ UTF8: find returns npos if pos exceeds string length;
+ UTF8: find returns position of passed string;
+ UTF8: find returns position of passed string when pos is passed;
+ UTF8: findLast returns npos if not found;
+ UTF8: findLast returns npos if pos exceeds string length;
+ UTF8: findLast returns position of passed string;
+ UTF8: findLast returns position of passed string when pos is passed;
+ UTF8: split returns empty object if idx exceeds string length;
+ UTF8: split returns propper string;
+ UTF8: split strings have propper length after split;
+ UTF8: split summary length is equal after split;
+ UTF8: getLine returns empty string if its not line;
+ UTF8: getLine returns proper string when line ends with n;
+ UTF8: getLine returns proper string when line ends with r;
+ UTF8: removeChar returns false when string to remove exceed;
+ UTF8: removeChar returns false when pos to remove exceed;
+ UTF8: removeChar returns propper string;
+ UTF8: getChar;
+ UTF8: encode / decode / how it works;
+ UTF8 bad case scenario - operator[] returns;
+ U8char && UTF8: encode;
+"
+#---------
+TESTS_LIST["catch2-vfs"]="
+ Test vfs case 1;
+ VFS lseek check;
+ Simple file notifier init;
+ Simple file notifier write;
+"
+#---------
+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: Register null filesystem;
+ Corefs: Mount empty strings;
+ Corefs: Write to not valid file descriptor;
+ Corefs: Directory operations;
+ Unititest integrated subsystem;
+"
+#---------
+TESTS_LIST["catch2-vfs-disk"]="
+ Registering and unregistering device;
+ Parsing and checking partititons;
+ RW boundary checking;
+ Null pointer passed to disk manager functions;
+ Boundary checks for partitions;
+ Disk sectors out of range for partition;
+"
+#---------
+TESTS_LIST["catch2-vfs-littlefs"]="
+ Littlefs: Basic mount and functionality;
+ littlefs: Basic API test;
+"
+#---------
+TESTS_LIST["catch2-utils-parserIcs"]="
+"
+#---------
+TESTS_LIST["catch2-utils-time_display"]="
+ Time display parser;
+"
M module-apps/application-calendar/data/dateCommon.hpp => module-apps/application-calendar/data/dateCommon.hpp +3 -3
@@ 1,4 1,4 @@
-// Copyright (c) 2017-2021, 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
#ifndef DATECOMMON_H
@@ 176,7 176,7 @@ inline std::string TimePointToString(const TimePoint &tp, date::months months)
}
}
timePoint += tpHourMinuteSecond;
- return date::format("%F %T", time_point_cast<seconds>(timePoint));
+ return date::format("%F %T", std::chrono::time_point_cast<std::chrono::seconds>(timePoint));
}
inline std::string TimePointToString(const TimePoint &tp, date::years years)
@@ 187,7 187,7 @@ inline std::string TimePointToString(const TimePoint &tp, date::years years)
yearMonthDay += years;
TimePoint timePoint = date::sys_days{yearMonthDay.year() / yearMonthDay.month() / yearMonthDay.day()};
timePoint += tpHourMinuteSecond;
- return date::format("%F %T", time_point_cast<seconds>(timePoint));
+ return date::format("%F %T", std::chrono::time_point_cast<std::chrono::seconds>(timePoint));
}
inline std::string TimePointToLocalizedDateString(const TimePoint &tp, const std::string format = "")
M module-db/CMakeLists.txt => module-db/CMakeLists.txt +2 -3
@@ 1,4 1,4 @@
-cmake_minimum_required(VERSION 3.12)
+cmake_minimum_required(VERSION 3.12)
project(module-db VERSION 1.0
DESCRIPTION "Database module library")
@@ 175,8 175,7 @@ target_link_libraries(${PROJECT_NAME} module-utils module-vfs )
# Host target configuration(mainly used for unit testing)
if (${ENABLE_TESTS})
- message(WARNING "Unit tests for module-db are disabled until they're fixed (EGD-5583).")
-# add_subdirectory(tests)
+ add_subdirectory(tests)
endif ()
third_party_source_optimization(${SQLITE3_SOURCE})
M module-db/tests/EventsRecord_tests.cpp => module-db/tests/EventsRecord_tests.cpp +1 -2
@@ 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 <catch2/catch.hpp>
@@ 130,7 130,6 @@ TEST_CASE("Events Record tests")
.provider_iCalUid = "test6"};
auto check_record = [](const EventsRecord &actual, const EventsRecord &expected) {
- // CHECK(actual.ID == expected.ID);
CHECK(actual.UID == expected.UID);
CHECK(actual.title == expected.title);
CHECK(TimePointToString(actual.date_from) == TimePointToString(expected.date_from));
M module-db/tests/NotesTable_tests.cpp => module-db/tests/NotesTable_tests.cpp +2 -3
@@ 1,7 1,6 @@
-// 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 "vfs.hpp"
#include <catch2/catch.hpp>
#include <Tables/NotesTable.hpp>
@@ 75,4 74,4 @@ TEST_CASE("Notes Table tests")
}
Database::deinitialize();
-}>
\ No newline at end of file
+}
M module-db/tests/QueryInterface.cpp => module-db/tests/QueryInterface.cpp +3 -1
@@ 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 <catch2/catch.hpp>
@@ 19,6 19,8 @@
#include <module-utils/json/json11.hpp>
#include <purefs/filesystem_paths.hpp>
+#include <vfs.hpp>
+
namespace db
{
M module-gui/test/test-catch-text/test-gui-Text.cpp => module-gui/test/test-catch-text/test-gui-Text.cpp +10 -11
@@ 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 "BoundingBox.hpp"
@@ 201,16 201,15 @@ TEST_CASE("handle input mode ABC/abc/1234")
}
}
-// this test hangs - disabling
-// TEST_CASE("handle longpress for digit in ABC mode")
-//{
-// auto text = gui::TestText();
-// auto str = text.getText() + "1";
-// auto key_1 = gui::InputEvent({}, gui::InputEvent::State::keyReleasedLong, gui::KeyCode::KEY_1);
-// text.setInputMode(new InputMode({InputMode::ABC}));
-// text.onInput(key_1);
-// REQUIRE(str == text.getText());
-//}
+TEST_CASE("handle longpress for digit in ABC mode")
+{
+ auto text = gui::TestText();
+ auto str = text.getText() + "1";
+ auto key_1 = gui::InputEvent({}, gui::InputEvent::State::keyReleasedLong, gui::KeyCode::KEY_1);
+ text.setInputMode(new InputMode({InputMode::ABC}));
+ text.onInput(key_1);
+ REQUIRE(str == text.getText());
+}
TEST_CASE("handle text expand")
{
M module-gui/test/test-catch/CMakeLists.txt => module-gui/test/test-catch/CMakeLists.txt +1 -0
@@ 14,6 14,7 @@ add_catch2_executable(
..
LIBS
module-gui
+ module-vfs
iosyscalls
DEPS
assets
M module-gui/test/test-catch/test-language-input-parser.cpp => module-gui/test/test-catch/test-language-input-parser.cpp +13 -1
@@ 1,9 1,13 @@
-// 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 <catch2/catch.hpp>
#include <Translator.hpp>
+#include <vfs.hpp>
+
+extern class vfs vfs;
+
TEST_CASE("Parsing English input language")
{
@@ 12,6 16,8 @@ TEST_CASE("Parsing English input language")
SECTION("Getting charKey from lower letters")
{
+ vfs.Init();
+
key.key_code = bsp::KeyCodes::NumericKey1;
REQUIRE(translator.handle(key, "English_lower") == 46);
key.key_code = bsp::KeyCodes::NumericKey2;
@@ 36,6 42,8 @@ TEST_CASE("Parsing English input language")
SECTION("Getting charKey from upper letters")
{
+ vfs.Init();
+
key.key_code = bsp::KeyCodes::NumericKey1;
REQUIRE(translator.handle(key, "English_upper") == 46);
key.key_code = bsp::KeyCodes::NumericKey2;
@@ 61,6 69,8 @@ TEST_CASE("Parsing English input language")
TEST_CASE("Parsing numeric keyboard")
{
+ vfs.Init();
+
gui::KeyInputMappedTranslation translator;
RawKey key;
@@ 88,6 98,8 @@ TEST_CASE("Parsing numeric keyboard")
TEST_CASE("Getting charKey after clicking button twice")
{
+ vfs.Init();
+
gui::KeyInputMappedTranslation translator;
gui::KeyBaseTranslation baseTranslation;
RawKey key;
M module-services/service-db/CMakeLists.txt => module-services/service-db/CMakeLists.txt +1 -2
@@ 35,7 35,6 @@ target_link_libraries(${PROJECT_NAME}
)
if (${ENABLE_TESTS})
- message(WARNING "Unit tests for service-db are disabled until they're fixed (EGD-5583).")
-# add_subdirectory(test)
+ add_subdirectory(test)
endif ()
M module-services/service-db/agents/settings/SettingsAgent.cpp => module-services/service-db/agents/settings/SettingsAgent.cpp +2 -2
@@ 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 "SettingsAgent.hpp"
@@ 231,7 231,7 @@ auto SettingsAgent::handleRegisterOnVariableChange(sys::Message *req) -> sys::Me
if (dbRegisterValueChange(path)) {
auto it = variableChangeRecipents.find(path.variable);
if (variableChangeRecipents.end() == it || it->second.end() == it->second.find(path)) {
- variableChangeRecipents[path.variable] = {path.service};
+ variableChangeRecipents[path.to_string()] = {path};
auto currentValue = dbGetValue(path).value_or("");
auto msgValue = std::make_shared<::settings::Messages::VariableChanged>(path, currentValue, "");
sys::Bus::SendUnicast(std::move(msgValue), msg->sender, parentService);
M module-utils/test/CMakeLists.txt => module-utils/test/CMakeLists.txt +10 -10
@@ 1,4 1,4 @@
-cmake_minimum_required(VERSION 3.12)
+cmake_minimum_required(VERSION 3.12)
# Phone number tests
add_catch2_executable(
@@ 102,15 102,15 @@ add_catch2_executable(
#)
# time display tests
-#add_catch2_executable(
-# NAME
-# utils-time_display
-# SRCS
-# unittest_TimeRangeParser.cpp
-# LIBS
-# module-utils
-# module-db
-#)
+add_catch2_executable(
+ NAME
+ utils-time_display
+ SRCS
+ unittest_TimeRangeParser.cpp
+ LIBS
+ module-utils
+ module-db
+)
###########################################
# Log functional tests project
A tools/check_unittests.sh => tools/check_unittests.sh +121 -0
@@ 0,0 1,121 @@
+#!/bin/bash
+# Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
+# For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
+
+root_dir="$(realpath $(dirname $(realpath $0))/..)"
+build_dir="${root_dir}/build-linux-Debug"
+
+ALL_TESTS_FILE=all_unittests
+ALL_TESTS_PATH=${build_dir}/${ALL_TESTS_FILE}
+ENABLED_TESTS_PATH=${root_dir}/enabled_unittests
+
+END=0
+
+trim() {
+ local var="$*"
+ # remove leading whitespace characters
+ var="${var#"${var%%[![:space:]]*}"}"
+ # remove trailing whitespace characters
+ var="${var%"${var##*[![:space:]]}"}"
+ printf '%s' "$var"
+}
+
+
+# get all tests
+${root_dir}/tools/get_unittests.sh ${ALL_TESTS_FILE} CHECK_OUT > /dev/null
+TEMP_SOURCE=$(mktemp)
+sed -e '/^[[:space:]]*#.*/d' ${ALL_TESTS_PATH} > $TEMP_SOURCE
+source ${TEMP_SOURCE}
+
+# get enabled tests
+sed -e '/^[[:space:]]*#.*/d' ${ENABLED_TESTS_PATH} > $TEMP_SOURCE
+source ${TEMP_SOURCE}
+
+declare -a BINARY_NOT_RUN
+declare -A TESTS_NOT_RUN
+echo "--tests--"
+for BINARY in ${!CHECK_OUT[@]}
+do
+ #echo BINARY:$BINARY
+ #echo "TESTS_LIST[${BINARY}]: ${TESTS_LIST[${BINARY}]}"
+ if [[ -n "${TESTS_LIST[${BINARY}]}" ]]; then
+ #echo ""
+ readarray -d\; -t TESTS_FROM_ALL < <(echo ${CHECK_OUT["${BINARY}"]} | tr "\n" " ")
+ #declare -p TESTS_FROM_ALL
+ #echo "NO: ${#TESTS_FROM_ALL[@]}"
+ I=0
+ declare -a TEST_NOT_RUN
+ while [[ ${I} -lt ${#TESTS_FROM_ALL[@]} ]];
+ do
+ CURRENT_TEST=$(trim ${TESTS_FROM_ALL[${I}]})
+ if [[ -n "$CURRENT_TEST" ]]; then
+ #if [[ ${BINARY} == "catch2-gui-text" ]]; then
+ # echo "--- CURRENT_TEST: ${CURRENT_TEST}"
+ #fi
+ CHK=$(echo ${TESTS_LIST["${BINARY}"]} | grep -F "${CURRENT_TEST}")
+ #echo "#@#@#@# $CHK #@#@##"
+ if [[ -z "${CHK}" ]]; then
+ #echo "!!!!!!!!!!${CURRENT_TEST}!!!!!!!!!"
+ TEST_NOT_RUN+=("${CURRENT_TEST}")
+ fi
+ fi
+ I=$(( $I + 1 ))
+ done
+ if [[ "${#TEST_NOT_RUN[@]}" -gt 0 ]]; then
+ #echo "!@@!@!@!@!@! ${#TEST_NOT_RUN[@]} @!#!@#!@#!"
+ #declare -p TEST_NOT_RUN
+ I=0
+ TEST_NOT_RUN_STR=""
+ while [[ $I -lt ${#TEST_NOT_RUN[@]} ]]
+ do
+ #TEST_NOT_RUN_STR="${TEST_NOT_RUN[${I}]};${TEST_NOT_RUN_STR}"
+ TEST_NOT_RUN_STR="${TEST_NOT_RUN_STR};${TEST_NOT_RUN[${I}]}"
+ I=$(( I + 1 ))
+ done
+ TESTS_NOT_RUN["${BINARY}"]="${TEST_NOT_RUN_STR}"
+ unset TEST_NOT_RUN
+ fi
+ else
+ #echo "######## $BINARY ########"
+ BINARY_NOT_RUN+=($BINARY)
+ fi
+done
+
+if [[ -n "${BINARY_NOT_RUN}" ]]; then
+ END=1
+ I=0
+ echo "binaries not run:"
+ while [[ $I -lt ${#BINARY_NOT_RUN[@]} ]]
+ do
+ echo " - ${BINARY_NOT_RUN[$I]}"
+ I=$(( $I + 1 ))
+ done
+fi
+pushd ${build_dir} > /dev/null
+BINARIES_IN_BUILD=( `ls -1 catch2*` )
+popd > /dev/null
+BINARIES_IN_DECLARED=( ${!TESTS_LIST[@]} )
+
+if [[ ${#BINARIES_IN_BUILD[@]} -ne ${#BINARIES_IN_DECLARED[@]} ]]; then
+ END=1
+ echo "not all binaries were build:"
+ printf '\t- %s\n' ${BINARIES_IN_BUILD[@]} ${BINARIES_IN_DECLARED[@]} | sort | uniq -u
+fi
+#declare -p TESTS_NOT_RUN
+#echo ${#TESTS_NOT_RUN[@]}
+if [[ "${#TESTS_NOT_RUN[@]}" -gt 0 ]]; then
+ END=1
+ echo "Tests not run:"
+ for BINARY in ${!TESTS_NOT_RUN[@]}
+ do
+ echo -n " - Binary: ${BINARY}"
+ echo "${TESTS_NOT_RUN[${BINARY}]}" | sed 's/;/\n\t- /g'
+ done
+fi
+
+case $END in
+ "0") echo "OK";;
+ "*") echo "ERROR";;
+esac
+
+exit $END
A tools/get_unittests.sh => tools/get_unittests.sh +61 -0
@@ 0,0 1,61 @@
+#!/bin/bash
+# Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
+# For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
+
+root_dir="$(realpath $(dirname $(realpath $0))/..)"
+build_dir="${root_dir}/build-linux-Debug"
+
+function help() {
+ cat <<- EOF
+ Usage: $0 tests_list [VAR_NAME]
+ EOF
+}
+
+
+if [[ $# -lt 1 ]]; then
+ help
+ exit 1
+fi
+
+TESTS_FILE=$1
+
+TESTS_LIST_VAR=${2:-TESTS_LIST}
+
+function addHeader() {
+cat <<- EOF
+ # Enabled test list
+ # test format
+ # TESTS_LIST["catch2-<binary-name>"]="
+ # test 1;
+ # test 1;
+ # test 3;
+ #"
+ #
+ # each test is in separate line
+ # to disable test just rem it by putting # in front of it
+ #
+ declare -A ${TESTS_LIST_VAR}
+
+EOF
+}
+
+pushd ${build_dir}
+addHeader > ${TESTS_FILE}
+
+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 {} )
+ I=0
+ while [[ $I -lt ${#TESTS_LIST[@]} ]]
+ do
+ echo -e " ${TESTS_LIST[$I]};" >> ${TESTS_FILE}
+ I=$(( $I + 1 ))
+ done
+ echo "\"" >> ${TESTS_FILE}
+ echo "#---------" >> ${TESTS_FILE}
+done
+popd
+
A tools/run_unittests.sh => tools/run_unittests.sh +58 -0
@@ 0,0 1,58 @@
+#!/bin/bash -e
+# Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
+# For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
+
+root_dir="$(realpath $(dirname $(realpath $0))/..)"
+build_dir="${root_dir}/build-linux-Debug"
+
+
+function help() {
+ cat <<- EOF
+ Usage: $0 tests_list
+ EOF
+}
+
+trim() {
+ local var="$*"
+ # remove leading whitespace characters
+ var="${var#"${var%%[![:space:]]*}"}"
+ # remove trailing whitespace characters
+ var="${var%"${var##*[![:space:]]}"}"
+ printf '%s' "$var"
+}
+
+if [[ $# -ne 1 ]]; then
+ help
+ exit 1
+fi
+
+TESTS_FILE=$1
+
+if [[ ! -r ${TESTS_FILE} ]]; then
+ echo "Cannot read: \"${TESTS_FILE}\""
+ exit 2
+fi
+
+TEMP_SOURCE=$(mktemp)
+
+sed -e '/^[[:space:]]*#.*/d' ${TESTS_FILE} > $TEMP_SOURCE
+
+source ${TEMP_SOURCE}
+
+pushd ${build_dir}
+for TEST_BINARY in catch2-*
+do
+ echo "= ${TEST_BINARY} ="
+ readarray -d\; -t TESTS < <(echo ${TESTS_LIST["${TEST_BINARY}"]} | tr "\n" " " )
+ I=0
+ while [[ $I -lt ${#TESTS[@]} ]]
+ do
+ CUR_TEST=$( trim ${TESTS[$I]})
+ if [[ -n "${CUR_TEST}" ]]; then
+ echo ${TEST_BINARY} \"${CUR_TEST}\"
+ ./${TEST_BINARY} "${CUR_TEST}"
+ fi
+ I=$(( $I + 1 ))
+ done
+done
+popd