System Test: Hardware test infrastructure

pull/64/head
Kyle Johannes 2024-04-05 21:10:49 +00:00
parent 63f0516318
commit 46e244fbab
18 changed files with 150 additions and 64 deletions

1
.gitignore vendored
View File

@ -14,3 +14,4 @@ third-party/concurrentqueue/tests
*.orig *.orig
examples/csharp/bin examples/csharp/bin
examples/csharp/obj examples/csharp/obj
test/system

View File

@ -3,7 +3,8 @@ variables:
stages: stages:
- build - build
- test - unit_test
- hardware_test
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
# Windows # Windows
@ -21,10 +22,10 @@ build windows/x64:
tags: tags:
- icsneo-windows - icsneo-windows
test windows/x64: unit_test windows/x64:
stage: test stage: unit_test
script: script:
- build\libicsneo-tests.exe - build\libicsneo-unit-tests.exe
dependencies: dependencies:
- build windows/x64 - build windows/x64
needs: needs:
@ -45,10 +46,10 @@ build windows/x86:
tags: tags:
- icsneo-windows - icsneo-windows
test windows/x86: unit_test windows/x86:
stage: test stage: unit_test
script: script:
- build\libicsneo-tests.exe - build\libicsneo-unit-tests.exe
dependencies: dependencies:
- build windows/x86 - build windows/x86
needs: needs:
@ -66,7 +67,7 @@ test windows/x86:
script: script:
- apt update -y - apt update -y
- apt upgrade -y - apt upgrade -y
- apt install -y g++ ninja-build cmake libusb-1.0-0-dev libpcap-dev - apt install -y g++ ninja-build cmake libusb-1.0-0-dev libpcap-dev git
- sh ci/build-posix.sh - sh ci/build-posix.sh
artifacts: artifacts:
when: always when: always
@ -77,12 +78,12 @@ test windows/x86:
- linux-build - linux-build
.test_linux_ubuntu_gcc: &test_linux_ubuntu_gcc .test_linux_ubuntu_gcc: &test_linux_ubuntu_gcc
stage: test stage: unit_test
script: script:
- apt update -y - apt update -y
- apt upgrade -y - apt upgrade -y
- apt install -y libusb-1.0-0-dev libpcap-dev - apt install -y libusb-1.0-0-dev libpcap-dev
- build/libicsneo-tests - build/libicsneo-unit-tests
tags: tags:
- linux-build - linux-build
timeout: 5m timeout: 5m
@ -92,7 +93,7 @@ test windows/x86:
script: script:
- apt update -y - apt update -y
- apt upgrade -y - apt upgrade -y
- apt install -y clang lld ninja-build cmake libusb-1.0-0-dev libpcap-dev - apt install -y clang lld ninja-build cmake libusb-1.0-0-dev libpcap-dev git
- CC=clang CXX=clang++ LDFLAGS=-fuse-ld=lld sh ci/build-posix.sh - CC=clang CXX=clang++ LDFLAGS=-fuse-ld=lld sh ci/build-posix.sh
artifacts: artifacts:
when: always when: always
@ -103,12 +104,12 @@ test windows/x86:
- linux-build - linux-build
.test_linux_ubuntu_clang: &test_linux_ubuntu_clang .test_linux_ubuntu_clang: &test_linux_ubuntu_clang
stage: test stage: unit_test
script: script:
- apt update -y - apt update -y
- apt upgrade -y - apt upgrade -y
- apt install -y libusb-1.0-0-dev libpcap-dev - apt install -y libusb-1.0-0-dev libpcap-dev
- build/libicsneo-tests - build/libicsneo-unit-tests
tags: tags:
- linux-build - linux-build
timeout: 5m timeout: 5m
@ -117,7 +118,7 @@ build linux/ubuntu/2004/amd64/gcc:
<<: *build_linux_ubuntu_gcc <<: *build_linux_ubuntu_gcc
image: ubuntu:20.04 image: ubuntu:20.04
test linux/ubuntu/2004/amd64/gcc: unit_test linux/ubuntu/2004/amd64/gcc:
<<: *test_linux_ubuntu_gcc <<: *test_linux_ubuntu_gcc
image: ubuntu:20.04 image: ubuntu:20.04
dependencies: dependencies:
@ -129,7 +130,7 @@ build linux/ubuntu/2004/amd64/clang:
<<: *build_linux_ubuntu_clang <<: *build_linux_ubuntu_clang
image: ubuntu:20.04 image: ubuntu:20.04
test linux/ubuntu/2004/amd64/clang: unit_test linux/ubuntu/2004/amd64/clang:
<<: *test_linux_ubuntu_clang <<: *test_linux_ubuntu_clang
image: ubuntu:20.04 image: ubuntu:20.04
dependencies: dependencies:
@ -141,7 +142,7 @@ build linux/ubuntu/2204/amd64/gcc:
<<: *build_linux_ubuntu_gcc <<: *build_linux_ubuntu_gcc
image: ubuntu:22.04 image: ubuntu:22.04
test linux/ubuntu/2204/amd64/gcc: unit_test linux/ubuntu/2204/amd64/gcc:
<<: *test_linux_ubuntu_gcc <<: *test_linux_ubuntu_gcc
image: ubuntu:22.04 image: ubuntu:22.04
dependencies: dependencies:
@ -153,7 +154,7 @@ build linux/ubuntu/2204/amd64/clang:
<<: *build_linux_ubuntu_clang <<: *build_linux_ubuntu_clang
image: ubuntu:22.04 image: ubuntu:22.04
test linux/ubuntu/2204/amd64/clang: unit_test linux/ubuntu/2204/amd64/clang:
<<: *test_linux_ubuntu_clang <<: *test_linux_ubuntu_clang
image: ubuntu:22.04 image: ubuntu:22.04
dependencies: dependencies:
@ -174,7 +175,7 @@ test linux/ubuntu/2204/amd64/clang:
- echo max_parallel_downloads=10 >>/etc/dnf/dnf.conf - echo max_parallel_downloads=10 >>/etc/dnf/dnf.conf
- echo fastestmirror=True >>/etc/dnf/dnf.conf - echo fastestmirror=True >>/etc/dnf/dnf.conf
- dnf upgrade -y - dnf upgrade -y
- dnf install -y g++ libpcap-devel cmake ninja-build libusb1-devel - dnf install -y g++ libpcap-devel cmake ninja-build libusb1-devel git
- sh ci/build-posix.sh - sh ci/build-posix.sh
artifacts: artifacts:
when: always when: always
@ -185,7 +186,7 @@ test linux/ubuntu/2204/amd64/clang:
- linux-build - linux-build
.test_linux_fedora_gcc: &test_linux_fedora_gcc .test_linux_fedora_gcc: &test_linux_fedora_gcc
stage: test stage: unit_test
cache: cache:
paths: paths:
- /var/cache/dnf - /var/cache/dnf
@ -194,7 +195,7 @@ test linux/ubuntu/2204/amd64/clang:
- echo fastestmirror=True >>/etc/dnf/dnf.conf - echo fastestmirror=True >>/etc/dnf/dnf.conf
- dnf upgrade -y - dnf upgrade -y
- dnf install -y libpcap-devel libusb1-devel - dnf install -y libpcap-devel libusb1-devel
- build/libicsneo-tests - build/libicsneo-unit-tests
tags: tags:
- linux-build - linux-build
timeout: 5m timeout: 5m
@ -208,7 +209,7 @@ test linux/ubuntu/2204/amd64/clang:
- echo max_parallel_downloads=10 >>/etc/dnf/dnf.conf - echo max_parallel_downloads=10 >>/etc/dnf/dnf.conf
- echo fastestmirror=True >>/etc/dnf/dnf.conf - echo fastestmirror=True >>/etc/dnf/dnf.conf
- dnf upgrade -y - dnf upgrade -y
- dnf install -y clang lld libpcap-devel cmake ninja-build libusb1-devel - dnf install -y clang lld libpcap-devel cmake ninja-build libusb1-devel git
- CC=clang CXX=clang++ LDFLAGS=-fuse-ld=lld sh ci/build-posix.sh - CC=clang CXX=clang++ LDFLAGS=-fuse-ld=lld sh ci/build-posix.sh
artifacts: artifacts:
when: always when: always
@ -219,7 +220,7 @@ test linux/ubuntu/2204/amd64/clang:
- linux-build - linux-build
.test_linux_fedora_clang: &test_linux_fedora_clang .test_linux_fedora_clang: &test_linux_fedora_clang
stage: test stage: unit_test
cache: cache:
paths: paths:
- /var/cache/dnf - /var/cache/dnf
@ -228,7 +229,7 @@ test linux/ubuntu/2204/amd64/clang:
- echo fastestmirror=True >>/etc/dnf/dnf.conf - echo fastestmirror=True >>/etc/dnf/dnf.conf
- dnf upgrade -y - dnf upgrade -y
- dnf install -y libpcap-devel libusb1-devel - dnf install -y libpcap-devel libusb1-devel
- build/libicsneo-tests - build/libicsneo-unit-tests
tags: tags:
- linux-build - linux-build
timeout: 5m timeout: 5m
@ -237,7 +238,7 @@ build linux/fedora/37/amd64/gcc:
<<: *build_linux_fedora_gcc <<: *build_linux_fedora_gcc
image: fedora:37 image: fedora:37
test linux/fedora/37/amd64/gcc: unit_test linux/fedora/37/amd64/gcc:
<<: *test_linux_fedora_gcc <<: *test_linux_fedora_gcc
image: fedora:37 image: fedora:37
dependencies: dependencies:
@ -249,7 +250,7 @@ build linux/fedora/37/amd64/clang:
<<: *build_linux_fedora_clang <<: *build_linux_fedora_clang
image: fedora:37 image: fedora:37
test linux/fedora/37/amd64/clang: unit_test linux/fedora/37/amd64/clang:
<<: *test_linux_fedora_clang <<: *test_linux_fedora_clang
image: fedora:37 image: fedora:37
dependencies: dependencies:
@ -261,7 +262,7 @@ build linux/fedora/38/amd64/gcc:
<<: *build_linux_fedora_gcc <<: *build_linux_fedora_gcc
image: fedora:38 image: fedora:38
test linux/fedora/38/amd64/gcc: unit_test linux/fedora/38/amd64/gcc:
<<: *test_linux_fedora_gcc <<: *test_linux_fedora_gcc
image: fedora:38 image: fedora:38
dependencies: dependencies:
@ -273,7 +274,7 @@ build linux/fedora/38/amd64/clang:
<<: *build_linux_fedora_clang <<: *build_linux_fedora_clang
image: fedora:38 image: fedora:38
test linux/fedora/38/amd64/clang: unit_test linux/fedora/38/amd64/clang:
<<: *test_linux_fedora_clang <<: *test_linux_fedora_clang
image: fedora:38 image: fedora:38
dependencies: dependencies:
@ -285,7 +286,7 @@ build linux/fedora/39/amd64/gcc:
<<: *build_linux_fedora_gcc <<: *build_linux_fedora_gcc
image: fedora:39 image: fedora:39
test linux/fedora/39/amd64/gcc: unit_test linux/fedora/39/amd64/gcc:
<<: *test_linux_fedora_gcc <<: *test_linux_fedora_gcc
image: fedora:39 image: fedora:39
dependencies: dependencies:
@ -297,10 +298,77 @@ build linux/fedora/39/amd64/clang:
<<: *build_linux_fedora_clang <<: *build_linux_fedora_clang
image: fedora:39 image: fedora:39
test linux/fedora/39/amd64/clang: unit_test linux/fedora/39/amd64/clang:
<<: *test_linux_fedora_clang <<: *test_linux_fedora_clang
image: fedora:39 image: fedora:39
dependencies: dependencies:
- build linux/fedora/39/amd64/clang - build linux/fedora/39/amd64/clang
needs: needs:
- build linux/fedora/39/amd64/clang - build linux/fedora/39/amd64/clang
.hw_test: &hw_test
stage: hardware_test
tags:
- libicsneo_hil
timeout: 5m
script:
- echo $GUEST_OS_TAG
- echo $DEVICE_PORT
- /opt/libvirt-driver/prepare.sh
- /opt/libvirt-driver/run.sh
after_script:
- /opt/libvirt-driver/cleanup.sh
hardware_test system-test-fedora38-red2:
<<: *hw_test
variables:
GUEST_OS_TAG: fedora38
DEVICE_PORT: ETH_A
needs:
- job: build linux/fedora/38/amd64/clang
artifacts: true
hardware_test system-test-fedora38-vcan42:
<<: *hw_test
variables:
GUEST_OS_TAG: fedora38
DEVICE_PORT: USB_D
needs:
- job: build linux/fedora/38/amd64/clang
artifacts: true
hardware_test system-test-ubuntu2204-red2:
<<: *hw_test
variables:
GUEST_OS_TAG: ubuntu22.04
DEVICE_PORT: ETH_A
needs:
- job: build linux/ubuntu/2204/amd64/clang
artifacts: true
hardware_test system-test-ubuntu2204-vcan42:
<<: *hw_test
variables:
GUEST_OS_TAG: ubuntu22.04
DEVICE_PORT: USB_D
needs:
- job: build linux/ubuntu/2204/amd64/clang
artifacts: true
hardware_test system-test-win10-red2:
<<: *hw_test
variables:
GUEST_OS_TAG: win10
DEVICE_PORT: ETH_A
needs:
- job: build windows/x64
artifacts: true
hardware_test system-test-win10-vcan42:
<<: *hw_test
variables:
GUEST_OS_TAG: win10
DEVICE_PORT: USB_D
needs:
- job: build windows/x64
artifacts: true

View File

@ -6,7 +6,8 @@ if(POLICY CMP0135)
cmake_policy(SET CMP0135 NEW) cmake_policy(SET CMP0135 NEW)
endif() endif()
option(LIBICSNEO_BUILD_TESTS "Build all tests." OFF) option(LIBICSNEO_BUILD_UNIT_TESTS "Build unit tests." OFF)
option(LIBICSNEO_BUILD_SYSTEM_TESTS "Build system tests." OFF)
option(LIBICSNEO_BUILD_DOCS "Build documentation. Don't use in Visual Studio." OFF) option(LIBICSNEO_BUILD_DOCS "Build documentation. Don't use in Visual Studio." OFF)
option(LIBICSNEO_BUILD_EXAMPLES "Build examples." ON) option(LIBICSNEO_BUILD_EXAMPLES "Build examples." ON)
option(LIBICSNEO_BUILD_ICSNEOC "Build dynamic C library" ON) option(LIBICSNEO_BUILD_ICSNEOC "Build dynamic C library" ON)
@ -491,7 +492,7 @@ if(LIBICSNEO_BUILD_ICSNEOLEGACY_STATIC)
endif() endif()
# googletest # googletest
if(LIBICSNEO_BUILD_TESTS) if(LIBICSNEO_BUILD_UNIT_TESTS)
if(WIN32) if(WIN32)
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
endif() endif()
@ -504,28 +505,44 @@ if(LIBICSNEO_BUILD_TESTS)
include_directories("${gtest_SOURCE_DIR}/include") include_directories("${gtest_SOURCE_DIR}/include")
endif() endif()
add_executable(libicsneo-tests add_executable(libicsneo-unit-tests
test/main.cpp test/unit/main.cpp
test/diskdriverreadtest.cpp test/unit/diskdriverreadtest.cpp
test/diskdriverwritetest.cpp test/unit/diskdriverwritetest.cpp
test/eventmanagertest.cpp test/unit/eventmanagertest.cpp
test/ethernetpacketizertest.cpp test/unit/ethernetpacketizertest.cpp
test/i2cencoderdecodertest.cpp test/unit/i2cencoderdecodertest.cpp
test/linencoderdecodertest.cpp test/unit/linencoderdecodertest.cpp
test/a2bencoderdecodertest.cpp test/unit/a2bencoderdecodertest.cpp
test/mdioencoderdecodertest.cpp test/unit/mdioencoderdecodertest.cpp
test/livedataencoderdecodertest.cpp test/unit/livedataencoderdecodertest.cpp
test/ringbuffertest.cpp test/unit/ringbuffertest.cpp
) )
target_link_libraries(libicsneo-tests gtest gtest_main) target_link_libraries(libicsneo-unit-tests gtest gtest_main)
target_link_libraries(libicsneo-tests icsneocpp) target_link_libraries(libicsneo-unit-tests icsneocpp)
target_include_directories(libicsneo-tests PUBLIC ${gtest_SOURCE_DIR}/include ${gtest_SOURCE_DIR}) target_include_directories(libicsneo-unit-tests PUBLIC ${gtest_SOURCE_DIR}/include ${gtest_SOURCE_DIR})
enable_testing() enable_testing()
add_test(NAME libicsneo-test-suite COMMAND libicsneo-tests) add_test(NAME libicsneo-unit-test-suite COMMAND libicsneo-unit-tests)
endif()
if(LIBICSNEO_BUILD_SYSTEM_TESTS)
if(DEFINED ENV{LIBICSNEO_SYSTEM_TESTS})
include(FetchContent)
file(MAKE_DIRECTORY test/system)
FetchContent_Declare(
SystemTests
GIT_REPOSITORY $ENV{LIBICSNEO_SYSTEM_TESTS}
GIT_TAG main
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/test/system
)
FetchContent_MakeAvailable(SystemTests)
else()
message("System test repo not defined!")
endif()
endif() endif()
set(CPACK_PROJECT_NAME ${PROJECT_NAME}) set(CPACK_PROJECT_NAME ${PROJECT_NAME})

View File

@ -1,7 +1,7 @@
#!/bin/sh #!/bin/sh
cmake -GNinja -Bbuild -DCMAKE_BUILD_TYPE=Release -DLIBICSNEO_BUILD_EXAMPLES=ON \ cmake -GNinja -Bbuild -DCMAKE_BUILD_TYPE=Release -DLIBICSNEO_BUILD_EXAMPLES=ON \
-DLIBICSNEO_BUILD_TESTS=ON -DLIBICSNEO_ENABLE_TCP=ON || exit 1 -DLIBICSNEO_BUILD_UNIT_TESTS=ON -DLIBICSNEO_BUILD_SYSTEM_TESTS=ON -DLIBICSNEO_ENABLE_TCP=OFF || exit 1
cmake --build build || exit 1 cmake --build build || exit 1

View File

@ -6,7 +6,7 @@ REM build
cd build cd build
set CFLAGS=/WX set CFLAGS=/WX
set CXXFLAGS=/WX set CXXFLAGS=/WX
cmake -GNinja -DCMAKE_BUILD_TYPE=RelWithDebInfo -DLIBICSNEO_BUILD_TESTS=ON -DLIBICSNEO_ENABLE_TCP=ON .. cmake -GNinja -DCMAKE_BUILD_TYPE=RelWithDebInfo -DLIBICSNEO_BUILD_UNIT_TESTS=ON -DLIBICSNEO_BUILD_SYSTEM_TESTS=ON -DLIBICSNEO_ENABLE_TCP=ON ..
if %errorlevel% neq 0 exit /b %errorlevel% if %errorlevel% neq 0 exit /b %errorlevel%
cmake --build . cmake --build .
if %errorlevel% neq 0 exit /b %errorlevel% if %errorlevel% neq 0 exit /b %errorlevel%

View File

@ -109,19 +109,19 @@ public:
switch(net.getNetID()) { switch(net.getNetID()) {
case Network::NetID::HSCAN: case Network::NetID::HSCAN:
return &(cfg->can1); return &(cfg->can1);
case Network::NetID::MSCAN:
return &(cfg->can2);
case Network::NetID::HSCAN2: case Network::NetID::HSCAN2:
return &(cfg->can3); return &(cfg->can2);
case Network::NetID::HSCAN3: case Network::NetID::HSCAN3:
return &(cfg->can4); return &(cfg->can3);
case Network::NetID::HSCAN4: case Network::NetID::HSCAN4:
return &(cfg->can5); return &(cfg->can4);
case Network::NetID::HSCAN5: case Network::NetID::HSCAN5:
return &(cfg->can6); return &(cfg->can5);
case Network::NetID::HSCAN6: case Network::NetID::HSCAN6:
return &(cfg->can7); return &(cfg->can6);
case Network::NetID::HSCAN7: case Network::NetID::HSCAN7:
return &(cfg->can7);
case Network::NetID::MSCAN:
return &(cfg->can8); return &(cfg->can8);
default: default:
return nullptr; return nullptr;
@ -134,19 +134,19 @@ public:
switch(net.getNetID()) { switch(net.getNetID()) {
case Network::NetID::HSCAN: case Network::NetID::HSCAN:
return &(cfg->canfd1); return &(cfg->canfd1);
case Network::NetID::MSCAN:
return &(cfg->canfd2);
case Network::NetID::HSCAN2: case Network::NetID::HSCAN2:
return &(cfg->canfd3); return &(cfg->canfd2);
case Network::NetID::HSCAN3: case Network::NetID::HSCAN3:
return &(cfg->canfd4); return &(cfg->canfd3);
case Network::NetID::HSCAN4: case Network::NetID::HSCAN4:
return &(cfg->canfd5); return &(cfg->canfd4);
case Network::NetID::HSCAN5: case Network::NetID::HSCAN5:
return &(cfg->canfd6); return &(cfg->canfd5);
case Network::NetID::HSCAN6: case Network::NetID::HSCAN6:
return &(cfg->canfd7); return &(cfg->canfd6);
case Network::NetID::HSCAN7: case Network::NetID::HSCAN7:
return &(cfg->canfd7);
case Network::NetID::MSCAN:
return &(cfg->canfd8); return &(cfg->canfd8);
default: default:
return nullptr; return nullptr;