From 15687f6f6e0ca284dbe502f082ef3ab2f0b27b71 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 18 Oct 2021 18:21:15 +0200 Subject: [PATCH 1/5] this should have been in the PR.. --- src/fsfw/tmtcpacket/SpacePacket.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/fsfw/tmtcpacket/SpacePacket.h b/src/fsfw/tmtcpacket/SpacePacket.h index 677ba0235..166733192 100644 --- a/src/fsfw/tmtcpacket/SpacePacket.h +++ b/src/fsfw/tmtcpacket/SpacePacket.h @@ -77,12 +77,12 @@ constexpr uint16_t getSpacePacketIdFromApid(bool isTc, uint16_t apid, ((apid >> 8) & 0x07)) << 8 | (apid & 0x00ff); } -constexpr uint16_t getTcSpacketIdFromApid(uint16_t apid, +constexpr uint16_t getTcSpacePacketIdFromApid(uint16_t apid, bool secondaryHeaderFlag = true) { return getSpacePacketIdFromApid(true, apid, secondaryHeaderFlag); } -constexpr uint16_t getTmSpacketIdFromApid(uint16_t apid, +constexpr uint16_t getTmSpacePacketIdFromApid(uint16_t apid, bool secondaryHeaderFlag = true) { return getSpacePacketIdFromApid(false, apid, secondaryHeaderFlag); } From 190848d00e32274eb844e0f930669b65ffe7eb4e Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 18 Nov 2021 18:52:50 +0100 Subject: [PATCH 2/5] important fix for getter function --- src/fsfw/tmtcpacket/SpacePacket.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/fsfw/tmtcpacket/SpacePacket.h b/src/fsfw/tmtcpacket/SpacePacket.h index 166733192..a092712c6 100644 --- a/src/fsfw/tmtcpacket/SpacePacket.h +++ b/src/fsfw/tmtcpacket/SpacePacket.h @@ -73,7 +73,7 @@ namespace spacepacket { constexpr uint16_t getSpacePacketIdFromApid(bool isTc, uint16_t apid, bool secondaryHeaderFlag = true) { - return (((isTc << 5) & 0x10) | ((secondaryHeaderFlag << 4) & 0x08) | + return ((isTc << 4) | (secondaryHeaderFlag << 3) | ((apid >> 8) & 0x07)) << 8 | (apid & 0x00ff); } From 400eafcae74cc191d32ba0d9555286d9a4ad2bd8 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 18 Nov 2021 19:51:01 +0100 Subject: [PATCH 3/5] added first unittests space packets - Also added helper scripts --- scripts/coverage.py | 7 +++++++ scripts/gen-unittest.sh | 3 +++ tests/src/fsfw_tests/unit/tmtcpacket/CMakeLists.txt | 2 +- tests/src/fsfw_tests/unit/tmtcpacket/PusTmTest.cpp | 3 --- tests/src/fsfw_tests/unit/tmtcpacket/testCcsds.cpp | 11 +++++++++++ 5 files changed, 22 insertions(+), 4 deletions(-) create mode 100755 scripts/gen-unittest.sh delete mode 100644 tests/src/fsfw_tests/unit/tmtcpacket/PusTmTest.cpp create mode 100644 tests/src/fsfw_tests/unit/tmtcpacket/testCcsds.cpp diff --git a/scripts/coverage.py b/scripts/coverage.py index 71b6fb036..b5bd7745e 100755 --- a/scripts/coverage.py +++ b/scripts/coverage.py @@ -6,6 +6,7 @@ import platform import sys import time import argparse +import webbrowser from typing import List @@ -18,6 +19,10 @@ information how to set up the build folder. def main(): parser = argparse.ArgumentParser(description="Processing arguments for LCOV helper script.") + parser.add_argument( + '-o', '--open', action='store_true', help='Open coverage data in webbrowser' + ) + args = parser.parse_args() build_dir_list = [] if not os.path.isfile('README.md'): @@ -41,6 +46,8 @@ def main(): print("Multiple build directories found!") build_directory = determine_build_dir(build_dir_list) perform_lcov_operation(build_directory) + if os.path.isdir('fsfw-tests_coverage') and args.open: + webbrowser.open('fsfw-tests_coverage/index.html') def check_for_cmake_build_dir(build_dir_dict: list): diff --git a/scripts/gen-unittest.sh b/scripts/gen-unittest.sh new file mode 100755 index 000000000..9ca8c3990 --- /dev/null +++ b/scripts/gen-unittest.sh @@ -0,0 +1,3 @@ +#!/bin/sh +mkdir build-Unittest && cd build-Unittest +cmake -DFSFW_BUILD_UNITTESTS=ON -DFSFW_OSAL=host -DCMAKE_BUILD_TYPE=Debug .. diff --git a/tests/src/fsfw_tests/unit/tmtcpacket/CMakeLists.txt b/tests/src/fsfw_tests/unit/tmtcpacket/CMakeLists.txt index 36838b24b..958bda405 100644 --- a/tests/src/fsfw_tests/unit/tmtcpacket/CMakeLists.txt +++ b/tests/src/fsfw_tests/unit/tmtcpacket/CMakeLists.txt @@ -1,3 +1,3 @@ target_sources(${FSFW_TEST_TGT} PRIVATE - PusTmTest.cpp + testCcsds.cpp ) diff --git a/tests/src/fsfw_tests/unit/tmtcpacket/PusTmTest.cpp b/tests/src/fsfw_tests/unit/tmtcpacket/PusTmTest.cpp deleted file mode 100644 index b28b04f64..000000000 --- a/tests/src/fsfw_tests/unit/tmtcpacket/PusTmTest.cpp +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/tests/src/fsfw_tests/unit/tmtcpacket/testCcsds.cpp b/tests/src/fsfw_tests/unit/tmtcpacket/testCcsds.cpp new file mode 100644 index 000000000..1416a556a --- /dev/null +++ b/tests/src/fsfw_tests/unit/tmtcpacket/testCcsds.cpp @@ -0,0 +1,11 @@ +#include + +#include "fsfw/tmtcpacket/SpacePacket.h" + +TEST_CASE( "CCSDS Test" , "[ccsds]") { + REQUIRE(spacepacket::getTcSpacePacketIdFromApid(0x22) == 0x1822); + REQUIRE(spacepacket::getTmSpacePacketIdFromApid(0x22) == 0x0822); + + REQUIRE(spacepacket::getTcSpacePacketIdFromApid(0x7ff) == 0x1fff) + REQUIRE(spacepacket::getTmSpacePacketIdFromApid(0x7ff) == 0xfff); +} From 0a94f84f5a75a86a52a5731c4a8c7ac9a8d73f23 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 18 Nov 2021 19:52:27 +0100 Subject: [PATCH 4/5] update cmakelists files --- CMakeLists.txt | 16 ++++++++-------- src/CMakeLists.txt | 2 -- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 923d5cc5c..e78e89297 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -93,14 +93,6 @@ target_include_directories(${LIB_FSFW_NAME} INTERFACE ${CMAKE_CURRENT_BINARY_DIR} ) -if(FSFW_BUILD_UNITTESTS) - configure_file(src/fsfw/FSFW.h.in fsfw/FSFW.h) - configure_file(src/fsfw/FSFWVersion.h.in fsfw/FSFWVersion.h) -else() - configure_file(src/fsfw/FSFW.h.in FSFW.h) - configure_file(src/fsfw/FSFWVersion.h.in FSFWVersion.h) -endif() - if(NOT CMAKE_CXX_STANDARD) set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD_REQUIRED True) @@ -155,6 +147,14 @@ else() set(OS_FSFW "host") endif() +if(FSFW_BUILD_UNITTESTS) + configure_file(src/fsfw/FSFW.h.in fsfw/FSFW.h) + configure_file(src/fsfw/FSFWVersion.h.in fsfw/FSFWVersion.h) +else() + configure_file(src/fsfw/FSFW.h.in FSFW.h) + configure_file(src/fsfw/FSFWVersion.h.in FSFWVersion.h) +endif() + message(STATUS "Compiling FSFW for the ${FSFW_OS_NAME} operating system.") add_subdirectory(src) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 5a8f139ba..e4670807b 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -16,5 +16,3 @@ target_include_directories(${LIB_FSFW_NAME} PRIVATE target_include_directories(${LIB_FSFW_NAME} INTERFACE ${CMAKE_CURRENT_BINARY_DIR} ) - -configure_file(fsfw/FSFW.h.in fsfw/FSFW.h) From 1f7cc7a558941d8436aebc6bf32f9275dbdcd934 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 18 Nov 2021 19:54:52 +0100 Subject: [PATCH 5/5] tests running --- tests/src/fsfw_tests/unit/tmtcpacket/testCcsds.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/src/fsfw_tests/unit/tmtcpacket/testCcsds.cpp b/tests/src/fsfw_tests/unit/tmtcpacket/testCcsds.cpp index 1416a556a..8f5318052 100644 --- a/tests/src/fsfw_tests/unit/tmtcpacket/testCcsds.cpp +++ b/tests/src/fsfw_tests/unit/tmtcpacket/testCcsds.cpp @@ -6,6 +6,6 @@ TEST_CASE( "CCSDS Test" , "[ccsds]") { REQUIRE(spacepacket::getTcSpacePacketIdFromApid(0x22) == 0x1822); REQUIRE(spacepacket::getTmSpacePacketIdFromApid(0x22) == 0x0822); - REQUIRE(spacepacket::getTcSpacePacketIdFromApid(0x7ff) == 0x1fff) + REQUIRE(spacepacket::getTcSpacePacketIdFromApid(0x7ff) == 0x1fff); REQUIRE(spacepacket::getTmSpacePacketIdFromApid(0x7ff) == 0xfff); }