Skip to content

Commit

Permalink
feat(ci): add run test
Browse files Browse the repository at this point in the history
  • Loading branch information
Lzw655 committed Oct 27, 2024
1 parent d236328 commit 52bef7e
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build Test Application
name: Build and Run Test Application

on:
workflow_dispatch:
Expand All @@ -11,7 +11,7 @@ on:
jobs:
build:
runs-on: ubuntu-22.04
name: Build Test Application
name: Build and Run Test Application

container:
image: ubuntu:22.04
Expand All @@ -36,4 +36,10 @@ jobs:
- name: Build Application
working-directory: ./
run: |
cmake -B ./build && make -C ./build
cmake -DRUN_TEST=1 -B ./build
make -C ./build
- name: Run Application
working-directory: ./
run: |
./bin/esp_brookesia_simulator_vscode
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ set(DISP_DEF "-DDISP_HOR_RES=1024 -DDISP_VER_RES=600") # Resolution of the disp
set(LVGL_DEF "-DLV_CONF_INCLUDE_SIMPLE") # Used for LVGL related codes
set(LV_DRIVERS_DEF "-DUSE_SDL") # Used for lv_drivers related codes
set(ESP_BROOKESIA_DEF "-DESP_BROOKESIA_KCONFIG_IGNORE") # Used for ESP-Brookesia related codes
if(RUN_TEST)
set(SIMULATOR_DEF "${SIMULATOR_DEF} -DRUN_TEST=1") # Flag for simulator
endif()
# Set C/CXX toolchain
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
set(CMAKE_C_COMPILER /usr/bin/gcc)
Expand Down Expand Up @@ -37,6 +40,7 @@ set(CMAKE_C_FLAGS "-O0 -g -Wall -Wextra -Wshadow -Wundef -Wno-unused-function")
set(CMAKE_CXX_FLAGS "-O0 -g -Wall -Wextra -Wshadow -Wundef -Wno-unused-function -Wno-unused-parameter \
-Wno-missing-field-initializers")
# Set cmake options
set(CMAKE_OBJECT_PATH_MAX 512) # Avoid long path error in Windows
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(EXECUTABLE_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/bin)
# Set componets directory
Expand Down
23 changes: 20 additions & 3 deletions main/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
/*********************
* DEFINES
*********************/
/**
* Use the stylesheet corresponding to the resolution; otherwise, another built-in stylesheet will be used.
*/
#if (DISP_HOR_RES == 320) && (DISP_VER_RES == 240)
#define EXAMPLE_ESP_BROOKESIA_PHONE_DARK_STYLESHEET() ESP_BROOKESIA_PHONE_320_240_DARK_STYLESHEET()
#elif (DISP_HOR_RES == 320) && (DISP_VER_RES == 480)
Expand All @@ -44,6 +47,12 @@
#define EXAMPLE_ESP_BROOKESIA_PHONE_DARK_STYLESHEET() ESP_BROOKESIA_PHONE_1280_800_DARK_STYLESHEET()
#endif

#define LVGL_TIMER_HANDLER_PERIOD_US (5 * 1000)

#ifdef RUN_TEST
#define RUN_TEST_TIMEOUT_S (5)
#endif

/**********************
* TYPEDEFS
**********************/
Expand Down Expand Up @@ -124,7 +133,7 @@ int main(int argc, char **argv)
ESP_Brookesia_PhoneStylesheet_t *stylesheet = new ESP_Brookesia_PhoneStylesheet_t EXAMPLE_ESP_BROOKESIA_PHONE_DARK_STYLESHEET();
ESP_BROOKESIA_CHECK_NULL_RETURN(stylesheet, 1, "Create phone stylesheet failed");

printf("Using stylesheet (%s)", stylesheet->core.name);
ESP_BROOKESIA_LOGI("Using stylesheet (%s)", stylesheet->core.name);
ESP_BROOKESIA_CHECK_FALSE_RETURN(phone->addStylesheet(stylesheet), 1, "Add phone stylesheet failed");
ESP_BROOKESIA_CHECK_FALSE_RETURN(phone->activateStylesheet(stylesheet), 1, "Activate phone stylesheet failed");
delete stylesheet;
Expand Down Expand Up @@ -153,11 +162,19 @@ int main(int argc, char **argv)
/* Periodically call the lv_task handler.
* It could be done in a timer interrupt or an OS task too.*/
lv_timer_handler();
usleep(5 * 1000);
usleep(LVGL_TIMER_HANDLER_PERIOD_US);

#ifdef RUN_TEST
static uint32_t loop_cnt = 0;
if (++loop_cnt >= RUN_TEST_TIMEOUT_S * 1000 * 1000 / LVGL_TIMER_HANDLER_PERIOD_US) {
ESP_BROOKESIA_LOGW("Run test timeout");
break;
}
#endif
}

// hal_deinit();
return 0;
return 1;
}

/**********************
Expand Down

0 comments on commit 52bef7e

Please sign in to comment.