Skip to content

Commit f1d2e31

Browse files
committed
Update demo_device_hid_mouse_rtos.c
1 parent 6dc0cf2 commit f1d2e31

9 files changed

Lines changed: 1046 additions & 490 deletions

File tree

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: USBX Samples Thredx Test
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches: [ master ]
7+
pull_request:
8+
branches: [ master ]
9+
10+
jobs:
11+
samples_threadx_tests:
12+
permissions:
13+
contents: read
14+
issues: read
15+
checks: write
16+
pull-requests: write
17+
pages: write
18+
id-token: write
19+
20+
uses: eclipse-threadx/threadx/.github/workflows/regression_template.yml@master
21+
with:
22+
cmake_path: ./test/cmake/usbx_samples_threadx
23+
build_script: bash ./scripts/build_samples_threadx.sh all
24+
test_script: bash ./scripts/test_samples_threadx.sh all
25+
coverage_name: default_build_coverage
26+
skip_coverage: false

samples/demo_device_hid_mouse_rtos.c

Lines changed: 429 additions & 490 deletions
Large diffs are not rendered by default.

scripts/build_samples_threadx.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/bin/bash
2+
bash $(dirname `realpath $0`)/../test/cmake/usbx_samples_threadx/run.sh build $@

scripts/test_samples_threadx.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/bin/bash
2+
CTEST_PARALLEL_LEVEL=4 bash $(dirname `realpath $0`)/../test/cmake/usbx_samples_threadx/run.sh test $@
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
cmake_minimum_required(VERSION 3.13 FATAL_ERROR)
2+
cmake_policy(SET CMP0054 NEW)
3+
cmake_policy(SET CMP0057 NEW)
4+
cmake_policy(SET CMP0077 NEW)
5+
6+
project(usbx_samples_threadx_test LANGUAGES C)
7+
8+
# Use the same ux_user.h as the main usbx test.
9+
set(UX_USER_FILE ${CMAKE_CURRENT_SOURCE_DIR}/../usbx/ux_user.h)
10+
11+
# Copy files instead of using symlink
12+
# libs/ -> ../libs/
13+
file(MAKE_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/libs)
14+
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/../libs/CMakeLists.txt
15+
${CMAKE_CURRENT_SOURCE_DIR}/libs/CMakeLists.txt COPYONLY)
16+
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/../libs/nx_user.h
17+
${CMAKE_CURRENT_SOURCE_DIR}/libs/nx_user.h COPYONLY)
18+
19+
set(BUILD_CONFIGURATIONS default_build_coverage)
20+
21+
set(CMAKE_CONFIGURATION_TYPES
22+
${BUILD_CONFIGURATIONS}
23+
CACHE STRING "list of supported configuration types" FORCE)
24+
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
25+
${CMAKE_CONFIGURATION_TYPES})
26+
list(GET CMAKE_CONFIGURATION_TYPES 0 BUILD_TYPE)
27+
if((NOT CMAKE_BUILD_TYPE) OR (NOT ("${CMAKE_BUILD_TYPE}" IN_LIST
28+
CMAKE_CONFIGURATION_TYPES)))
29+
set(CMAKE_BUILD_TYPE
30+
"${BUILD_TYPE}"
31+
CACHE STRING "Build Type of the project" FORCE)
32+
endif()
33+
34+
message(STATUS "Build for usbx sample ThreadX tests")
35+
message(STATUS "Build type: ${CMAKE_BUILD_TYPE}")
36+
message(STATUS "Using toolchain file: ${CMAKE_TOOLCHAIN_FILE}.")
37+
38+
add_compile_options(
39+
-std=c99
40+
-ggdb
41+
-g3
42+
-gdwarf-2
43+
-fdiagnostics-color
44+
-DUX_USE_IO_INSTRUCTIONS
45+
-DNX_PHYSICAL_HEADER=20
46+
-DUX_DISABLE_ASSERT)
47+
48+
# Control if it's for 64 bit or 32 bit.
49+
if($ENV{ENABLE_64})
50+
message(STATUS "Building for 64bit")
51+
else()
52+
add_compile_options(-m32)
53+
add_link_options(-m32)
54+
message(STATUS "Building for 32bit")
55+
endif()
56+
57+
enable_testing()
58+
59+
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/../../../ usbx)
60+
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/regression regression)
61+
62+
# Build ThreadX-related libs once and import them for tests.
63+
execute_process(COMMAND bash ${CMAKE_CURRENT_SOURCE_DIR}/run.sh build_libs)
64+
add_custom_target(build_libs ALL COMMAND bash ${CMAKE_CURRENT_SOURCE_DIR}/run.sh
65+
build_libs)
66+
67+
add_dependencies(usbx build_libs)
68+
target_include_directories(usbx PUBLIC ${CMAKE_BINARY_DIR}/../libs/inc)
69+
70+
add_library(threadx SHARED IMPORTED GLOBAL)
71+
add_library("azrtos::threadx" ALIAS threadx)
72+
set_target_properties(
73+
threadx PROPERTIES IMPORTED_LOCATION
74+
${CMAKE_BINARY_DIR}/../libs/threadx/libthreadx.so)
75+
76+
add_library(netxduo SHARED IMPORTED GLOBAL)
77+
add_library("azrtos::netxduo" ALIAS netxduo)
78+
set_target_properties(
79+
netxduo PROPERTIES IMPORTED_LOCATION
80+
${CMAKE_BINARY_DIR}/../libs/netxduo/libnetxduo.so)
81+
82+
add_library(filex SHARED IMPORTED GLOBAL)
83+
add_library("azrtos::filex" ALIAS filex)
84+
set_target_properties(
85+
filex PROPERTIES IMPORTED_LOCATION
86+
${CMAKE_BINARY_DIR}/../libs/filex/libfilex.so)
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
cmake_minimum_required(VERSION 3.13 FATAL_ERROR)
2+
cmake_policy(SET CMP0057 NEW)
3+
4+
project(usbx_samples_threadx_regression LANGUAGES C)
5+
6+
get_filename_component(SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/../../../regression_samples_threadx ABSOLUTE)
7+
get_filename_component(SAMPLE_SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/../../../../samples ABSOLUTE)
8+
9+
set(test_utility_files
10+
${SOURCE_DIR}/usbxtestcontrol.c)
11+
12+
add_library(test_utility ${test_utility_files})
13+
target_link_libraries(test_utility PUBLIC azrtos::usbx azrtos::threadx azrtos::netxduo azrtos::filex)
14+
target_compile_definitions(test_utility PUBLIC CTEST)
15+
16+
set(sample_test_case ${SOURCE_DIR}/usbx_hid_mouse_demo_device_rtos_test.c)
17+
set(sample_source_file ${SAMPLE_SOURCE_DIR}/demo_device_hid_mouse_rtos.c)
18+
set(test_name usbx_hid_mouse_demo_device_rtos_test)
19+
20+
add_executable(${test_name} ${sample_test_case} ${sample_source_file})
21+
target_link_libraries(${test_name} PRIVATE test_utility)
22+
target_compile_definitions(${test_name} PRIVATE DEMO_TEST EXTERNAL_MAIN)
23+
24+
add_test(default_build_coverage::${test_name} ${test_name})
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/bash
2+
3+
cd $(dirname $0)
4+
5+
# Checkout externals.
6+
[ -d externals ] || mkdir ../../externals
7+
git clone https://github.com/eclipse-threadx/threadx.git ../../externals/threadx
8+
git clone https://github.com/eclipse-threadx/netxduo.git ../../externals/netxduo
9+
git clone https://github.com/eclipse-threadx/filex.git ../../externals/filex
10+
11+
# Add junit output for ctest generation.
12+
if ! grep -q "\-\-output\-junit \$1.xml" ../../externals/threadx/scripts/cmake_bootstrap.sh; then
13+
sed -i 's/ctest $parallel --timeout 1000 -O $1.txt/& --output-junit $1.xml/g' ../../externals/threadx/scripts/cmake_bootstrap.sh
14+
fi
15+
16+
[ -f .run.sh ] || ln -sf ../../externals/threadx/scripts/cmake_bootstrap.sh .run.sh
17+
bash ./.run.sh $*

0 commit comments

Comments
 (0)