What changed, and why it matters
This commit fixes a test-only setup problem. The unit tests for on-screen UI components were not initializing the graphics library (ugui) before running. Because label sizing now depends on ugui being set up, the tests could fail or hit debug assertions. The change adds a minimal fake graphics setup so the tests run correctly. It does not change the firmware that runs on the actual device.
No action required for device security. Treat as a normal test reliability fix. If reviewing related firmware code, verify that production UI code always initializes ugui before label creation and that the debug-assertion behavior is acceptable for release builds.
Security signals we found
Test-only fix with no device firmware change
Mentions that ugui null guards are debug assertions, not release-time early returns
Evidence from the diff
The patch modifies test/unit-test/test_ui_components.c to initialize a UG_GUI instance via UG_Init before cmocka tests execute. It provides a no-op _set_pixel callback and uses font_font_a_11X10. The stated reason is that label sizing now requires ugui to be initialized, and ugui’s null guards are debug assertions rather than release-time checks, so tests that create labels need this setup to avoid assertion failures or undefined behavior during testing.
Changed components
test/unit-test/test_ui_components.cInspect captured patch +19 / −1
diff --git a/test/unit-test/test_ui_components.c b/test/unit-test/test_ui_components.c
index c1dad49..008490f 100644
--- a/test/unit-test/test_ui_components.c
+++ b/test/unit-test/test_ui_components.c
@@ -15,12 +15,30 @@
#include <ui/components/left_arrow.h>
#include <ui/components/right_arrow.h>
#include <ui/components/status.h>
+#include <ui/fonts/arial_fonts.h>
#include <ui/fonts/monogram_5X9.h>
+#include <ui/ugui/ugui.h>
#include <ui/ui_util.h>
#include "fake_component.h"
#include "mock_qtouch.h"
+static UG_GUI gui;
+
+static void _set_pixel(UG_S16 x, UG_S16 y, UG_COLOR color)
+{
+ (void)x;
+ (void)y;
+ (void)color;
+}
+
+static int _setup(void** state)
+{
+ (void)state;
+ UG_Init(&gui, _set_pixel, &font_font_a_11X10, 128, 64);
+ return 0;
+}
+
static void _cb(void* user_data)
{
(void)user_data;
@@ -158,5 +176,5 @@ int main(void)
cmocka_unit_test(test_ui_components_status),
cmocka_unit_test(test_ui_components_confirm)};
- return cmocka_run_group_tests(tests, NULL, NULL);
+ return cmocka_run_group_tests(tests, _setup, NULL);
}
Why this scored 14/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.