From 302bcc9b1958c8feeb2289ac1603c6b80766a702 Mon Sep 17 00:00:00 2001 From: kartikey1306 Date: Mon, 9 Nov 2026 16:30:27 +0530 Subject: [PATCH] test(lifecycle): compile the app checks into test_app_lifecycle test_app_lifecycle.c checks each category under #ifdef EAPPS_BUILD_, but tests/CMakeLists.txt only used those names as CMake options and never passed them to the compiler. The test compiled to an empty main(), ran 0 assertions and always passed. Pass each enabled category as a compile definition, and link esettings and ebot (the test references both, so the link fails without them). CMake also counts the enabled categories from the options themselves and passes that count in; the test fails if it checked a different number of categories, or if no check ran at all. The test is skipped, with a status message, when every category is off. --- CHANGELOG.md | 9 +++++++++ tests/CMakeLists.txt | 41 +++++++++++++++++++++++++++++++------- tests/test_app_lifecycle.c | 22 ++++++++++++++++++++ 3 files changed, 65 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 79f39c7..d1d89ea 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,14 @@ # Changelog +## [Unreleased] + +### Fixed +- `test_app_lifecycle` now checks the apps. It guarded every check with `#ifdef EAPPS_BUILD_`, + but `tests/CMakeLists.txt` never passed those defines, so it ran 0 assertions and always passed. + The enabled categories are now compiled in and `esettings` and `ebot` are linked. The test fails + when no check runs, and when the number of categories it checked differs from the number of + `EAPPS_BUILD_` options that are ON. + ## [3.0.1] - 2026-05-16 ### Production Release — Unified EmbeddedOS-org v3.0.1 diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index ce65bb9..c7612cd 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -44,28 +44,55 @@ endif() add_test(NAME test_ewifi_shellsafe COMMAND test_ewifi_shellsafe) # App lifecycle tests — needs all app libraries +# test_app_lifecycle.c checks each category only under #ifdef EAPPS_BUILD_, +# so every enabled category must also be passed as a compile definition. Without +# them the test compiled to an empty main() and passed with 0 assertions. +# esettings is a system app (always built, top-level CMakeLists.txt), so it is +# linked whenever the productivity checks that reference it are compiled. +# LIFECYCLE_EXPECTED counts the enabled categories straight from the options, not +# from LIFECYCLE_DEFS, so the test fails if a category's define is ever dropped. set(LIFECYCLE_LIBS eapps_common eapps_ui) +set(LIFECYCLE_DEFS) +set(LIFECYCLE_EXPECTED 0) +foreach(category PRODUCTIVITY MEDIA GAMES CONNECTIVITY SECURITY WEB) + if(EAPPS_BUILD_${category}) + math(EXPR LIFECYCLE_EXPECTED "${LIFECYCLE_EXPECTED} + 1") + endif() +endforeach() if(EAPPS_BUILD_PRODUCTIVITY) - list(APPEND LIFECYCLE_LIBS ecal enote econverter ebuffer efiles ecleaner eclock etools etimer epdf ezip eviewer esession) + list(APPEND LIFECYCLE_LIBS ecal enote econverter ebuffer efiles ecleaner eclock etools etimer epdf ezip eviewer esession esettings) + list(APPEND LIFECYCLE_DEFS EAPPS_BUILD_PRODUCTIVITY) endif() if(EAPPS_BUILD_MEDIA) list(APPEND LIFECYCLE_LIBS emusic evideo egallery eplay epaint) + list(APPEND LIFECYCLE_DEFS EAPPS_BUILD_MEDIA) endif() if(EAPPS_BUILD_GAMES) list(APPEND LIFECYCLE_LIBS snake tetris minesweeper dice erunner esurfer echess ebirds eslice eblocks ecrush) + list(APPEND LIFECYCLE_DEFS EAPPS_BUILD_GAMES) endif() if(EAPPS_BUILD_CONNECTIVITY) list(APPEND LIFECYCLE_LIBS eftp eserial essh evnc etunnel echat eremote ewifi) + list(APPEND LIFECYCLE_DEFS EAPPS_BUILD_CONNECTIVITY) endif() if(EAPPS_BUILD_SECURITY) - list(APPEND LIFECYCLE_LIBS evpn eguard evirustower) + list(APPEND LIFECYCLE_LIBS evpn eguard evirustower ebot) + list(APPEND LIFECYCLE_DEFS EAPPS_BUILD_SECURITY) endif() if(EAPPS_BUILD_WEB) list(APPEND LIFECYCLE_LIBS eweb) + list(APPEND LIFECYCLE_DEFS EAPPS_BUILD_WEB) endif() -add_executable(test_app_lifecycle test_app_lifecycle.c) -target_link_libraries(test_app_lifecycle PRIVATE ${LIFECYCLE_LIBS}) -if(NOT MSVC) - target_link_libraries(test_app_lifecycle PRIVATE m) +# With every category switched off there is nothing to check, so no test. +if(LIFECYCLE_EXPECTED GREATER 0) + add_executable(test_app_lifecycle test_app_lifecycle.c) + target_link_libraries(test_app_lifecycle PRIVATE ${LIFECYCLE_LIBS}) + target_compile_definitions(test_app_lifecycle PRIVATE ${LIFECYCLE_DEFS} + EAPPS_LIFECYCLE_EXPECTED_CATEGORIES=${LIFECYCLE_EXPECTED}) + if(NOT MSVC) + target_link_libraries(test_app_lifecycle PRIVATE m) + endif() + add_test(NAME test_app_lifecycle COMMAND test_app_lifecycle) +else() + message(STATUS "test_app_lifecycle skipped: every EAPPS_BUILD_ option is OFF") endif() -add_test(NAME test_app_lifecycle COMMAND test_app_lifecycle) diff --git a/tests/test_app_lifecycle.c b/tests/test_app_lifecycle.c index 057c87c..d5ff98d 100644 --- a/tests/test_app_lifecycle.c +++ b/tests/test_app_lifecycle.c @@ -3,6 +3,10 @@ #include "eapps_test.h" #include "../core/common/include/eapps/types.h" +#ifndef EAPPS_LIFECYCLE_EXPECTED_CATEGORIES +#error "EAPPS_LIFECYCLE_EXPECTED_CATEGORIES must be set by tests/CMakeLists.txt" +#endif + /* ================================================================ * Extern declarations for all app infos and lifecycles. * Grouped by build category, matching the pattern in suite.c. @@ -172,24 +176,42 @@ static void test_web_apps(void) { #endif int main(void) { + int categories_checked = 0; + #ifdef EAPPS_BUILD_PRODUCTIVITY test_productivity_apps(); + categories_checked++; #endif #ifdef EAPPS_BUILD_MEDIA test_media_apps(); + categories_checked++; #endif #ifdef EAPPS_BUILD_GAMES test_games_apps(); + categories_checked++; #endif #ifdef EAPPS_BUILD_CONNECTIVITY test_connectivity_apps(); + categories_checked++; #endif #ifdef EAPPS_BUILD_SECURITY test_security_apps(); + categories_checked++; #endif #ifdef EAPPS_BUILD_WEB test_web_apps(); + categories_checked++; #endif + /* No checks at all means the EAPPS_BUILD_* category defines did not reach + * this file (see tests/CMakeLists.txt). Fail instead of passing empty. */ + ASSERT_TRUE(t_passes + t_failures > 0, "at least one app check ran"); + + /* tests/CMakeLists.txt counts the categories enabled by the CMake options, + * separately from the defines it passes, so a category whose define goes + * missing fails here instead of silently dropping its checks. */ + ASSERT_EQ(categories_checked, EAPPS_LIFECYCLE_EXPECTED_CATEGORIES, + "app categories checked match the categories enabled in CMake"); + TEST_EXIT(); }