What changed, and why it matters
This commit only changes the project's automated testing setup. It adds a GitHub Actions job to run Rust unit tests on macOS, and adjusts the CMake build configuration so that CMocka-based C unit tests are skipped on macOS (because the macOS linker does not support the '--wrap' feature those tests need). There is no change to the actual firmware code that ships to users, and no security fix or vulnerability is present.
No security action needed. This is a routine CI portability improvement. Reviewers may optionally verify the new macOS job passes and that skipping C unit tests on macOS is acceptable test coverage policy.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The diff is purely CI/build plumbing. In .github/workflows/ci-common.yml a new rust-unit-tests-macos job is added using macos-14, installing cbindgen, bindgen, hidapi, protoc, and Rust, then running make run-rust-unit-tests. In test/unit-test/CMakeLists.txt the CMocka test generation is wrapped in a non-Darwin branch because Mach-O linkers lack –wrap support; the HIDAPI pkg-config check is moved after that branch but remains functionally identical. No firmware source, crypto, or memory-safety code is modified.
Changed components
.github/workflows/ci-common.ymltest/unit-test/CMakeLists.txtInspect captured patch +74 / −49
diff --git a/.github/workflows/ci-common.yml b/.github/workflows/ci-common.yml
index 861750c..da0a12e 100644
--- a/.github/workflows/ci-common.yml
+++ b/.github/workflows/ci-common.yml
@@ -115,6 +115,34 @@ jobs:
- name: run ATECC608 unit tests
run: (cd tools/atecc608; go test ./...)
+ # cmocka isn't compatible with Mach-O, so no point in running the C tests.
+ rust-unit-tests-macos:
+ runs-on: macos-14
+ steps:
+ - name: Clone the repo
+ uses: actions/checkout@v4
+ with:
+ fetch-depth: 0
+ fetch-tags: true
+ submodules: recursive
+
+ - name: Install system dependencies
+ run: brew install cbindgen bindgen hidapi
+
+ - name: Install protoc
+ uses: arduino/setup-protoc@v3
+ with:
+ version: "21.x"
+ repo-token: ${{ secrets.GITHUB_TOKEN }}
+
+ - name: Install rust
+ uses: actions-rust-lang/setup-rust-toolchain@v1
+ with:
+ rust-src-dir: src/rust
+
+ - name: Run rust unit-tests
+ run: make run-rust-unit-tests
+
leakcheck:
runs-on: ubuntu-22.04
container: ${{ inputs.container-repo }}:${{ inputs.container-version }}
diff --git a/test/unit-test/CMakeLists.txt b/test/unit-test/CMakeLists.txt
index 6bde497..4bc836b 100644
--- a/test/unit-test/CMakeLists.txt
+++ b/test/unit-test/CMakeLists.txt
@@ -19,61 +19,52 @@
# both linux and macos
find_package(PkgConfig REQUIRED)
-# Unit testing uses CMocka
-pkg_check_modules(CMOCKA REQUIRED cmocka)
+set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-parameter -Wno-missing-prototypes -Wno-missing-declarations -Wno-implicit-function-declaration -Wno-bad-function-cast")
-# u2f tests with hardware uses hidapi-hidraw
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
- pkg_check_modules(HIDAPI REQUIRED hidapi)
+ message("No linker for Mach-O supports --wrap, will not generate unit-tests")
else()
- pkg_check_modules(HIDAPI REQUIRED hidapi-hidraw)
-endif()
-
-set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-parameter -Wno-missing-prototypes -Wno-missing-declarations -Wno-implicit-function-declaration -Wno-bad-function-cast")
-
-add_library(mocks STATIC EXCLUDE_FROM_ALL
- framework/src/mock_gestures.c
- framework/src/mock_screen_stack.c
- framework/src/mock_qtouch.c
-)
-target_link_libraries(mocks PUBLIC c-unit-tests_rust_c ${CMOCKA_LDFLAGS})
-target_include_directories(mocks
- PUBLIC
- ${CMAKE_CURRENT_SOURCE_DIR}/framework/include
- ${CMOCKA_INCLUDE_DIRS}
-)
+ pkg_check_modules(CMOCKA REQUIRED cmocka)
+ add_library(mocks STATIC EXCLUDE_FROM_ALL
+ framework/src/mock_gestures.c
+ framework/src/mock_screen_stack.c
+ framework/src/mock_qtouch.c
+ )
+ target_link_libraries(mocks PUBLIC c-unit-tests_rust_c ${CMOCKA_LDFLAGS})
+ target_include_directories(mocks
+ PUBLIC
+ ${CMAKE_CURRENT_SOURCE_DIR}/framework/include
+ ${CMOCKA_INCLUDE_DIRS}
+ )
-#-----------------------------------------------------------------------------
-# Tests
+ #-----------------------------------------------------------------------------
+ # Tests
-set(TEST_LIST
- cleanup
- "-Wl,--wrap=util_cleanup_32"
- gestures
- ""
- random
- "-Wl,--wrap=rand,--wrap=rust_sha256"
- ui_components
- ""
- ui_util
- ""
- ui_component_gestures
- ""
- memory
- "-Wl,--wrap=memory_read_chunk_fake,--wrap=memory_write_chunk_fake,--wrap=rust_noise_generate_static_private_key,--wrap=memory_read_shared_bootdata_fake,--wrap=memory_write_to_address_fake,--wrap=random_32_bytes_mcu"
- memory_functional
- ""
- cipher
- "-Wl,--wrap=cipher_fake_iv"
- util
- ""
- ugui
- ""
-)
+ set(TEST_LIST
+ cleanup
+ "-Wl,--wrap=util_cleanup_32"
+ gestures
+ ""
+ random
+ "-Wl,--wrap=rand,--wrap=rust_sha256"
+ ui_components
+ ""
+ ui_util
+ ""
+ ui_component_gestures
+ ""
+ memory
+ "-Wl,--wrap=memory_read_chunk_fake,--wrap=memory_write_chunk_fake,--wrap=rust_noise_generate_static_private_key,--wrap=memory_read_shared_bootdata_fake,--wrap=memory_write_to_address_fake,--wrap=random_32_bytes_mcu"
+ memory_functional
+ ""
+ cipher
+ "-Wl,--wrap=cipher_fake_iv"
+ util
+ ""
+ ugui
+ ""
+ )
-if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
- message("No linker for Mach-O supports --wrap, will not generate unit-tests")
-else()
list(LENGTH TEST_LIST TEST_LIST_LEN)
math(EXPR TEST_LIST_LEN ${TEST_LIST_LEN}-1)
foreach(I RANGE 0 ${TEST_LIST_LEN} 2)
@@ -101,6 +92,12 @@ else()
endforeach()
endif()
+if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
+ pkg_check_modules(HIDAPI REQUIRED hidapi)
+else()
+ pkg_check_modules(HIDAPI REQUIRED hidapi-hidraw)
+endif()
+
add_library(u2f-util
STATIC
u2f/sha2.c
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.