ci: Publish test results

This commit is contained in:
Tomas Rezucha 2022-02-28 17:02:41 +01:00
parent 2019d71fd4
commit 06bd5dcbe3
5 changed files with 162 additions and 141 deletions

View File

@ -31,15 +31,15 @@ jobs:
- name: Merge binaries - name: Merge binaries
working-directory: test_app/build working-directory: test_app/build
run: | run: |
pip install esptool . ${IDF_PATH}/export.sh
python -m esptool --chip esp32 merge_bin --fill-flash-size 4MB -o flash_image.bin @flash_args esptool.py --chip ${{ matrix.idf_target }} merge_bin --fill-flash-size 4MB -o flash_image.bin @flash_args
- uses: actions/upload-artifact@v2 - uses: actions/upload-artifact@v2
with: with:
name: test_app_bin_${{ matrix.idf_target }}_${{ matrix.idf_ver }} name: test_app_bin_${{ matrix.idf_target }}_${{ matrix.idf_ver }}
path: | path: test_app/build/flash_image.bin
test_app/build/flash_image.bin
#run-qemu: # Keeping this here for future reference. QEMU tests are not passing now # Keeping this here for future reference. QEMU tests are not passing now
#run-qemu:
# name: Run Test App in QEMU # name: Run Test App in QEMU
# needs: build # needs: build
# strategy: # strategy:
@ -63,6 +63,7 @@ jobs:
name: Run Test App on target name: Run Test App on target
needs: build needs: build
strategy: strategy:
fail-fast: false
matrix: matrix:
idf_ver: ["release-v4.3", "release-v4.4", "latest"] idf_ver: ["release-v4.3", "release-v4.4", "latest"]
idf_target: ["esp32", "esp32c3", "esp32s3"] idf_target: ["esp32", "esp32c3", "esp32s3"]
@ -72,7 +73,7 @@ jobs:
runs-on: [self-hosted, linux, docker, esp32] # Unfortunately `${{ matrix.idf_target }}` is not accepted here runs-on: [self-hosted, linux, docker, esp32] # Unfortunately `${{ matrix.idf_target }}` is not accepted here
container: container:
image: python:3.7-slim-buster image: python:3.7-slim-buster
options: --privileged options: --privileged # Privileged mode has access to serial ports
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
with: with:
@ -89,4 +90,24 @@ jobs:
run: python -m esptool --chip ${{ matrix.idf_target }} write_flash 0x0 test_app/build/flash_image.bin run: python -m esptool --chip ${{ matrix.idf_target }} write_flash 0x0 test_app/build/flash_image.bin
- name: Run Test App on target - name: Run Test App on target
working-directory: test_app working-directory: test_app
run: pytest -s --junit-xml=./test_app_results.xml --embedded-services esp --target=${{ matrix.idf_target }} run: pytest -s --junit-xml=./test_app_results_${{ matrix.idf_target }}_${{ matrix.idf_ver }}.xml --embedded-services esp --target=${{ matrix.idf_target }}
- uses: actions/upload-artifact@v2
if: always()
with:
name: test_app_results_${{ matrix.idf_target }}_${{ matrix.idf_ver }}
path: test_app/*.xml
publish-results:
name: Publish Test App results
needs: run-target
if: always() # Run even if the previous step failed
runs-on: ubuntu-20.04
steps:
- name: Download Test results
uses: actions/download-artifact@v2
with:
path: test_results
- name: Publish Test Results
uses: EnricoMi/publish-unit-test-result-action@v1
with:
files: test_results/**/*.xml

View File

@ -1,119 +1,119 @@
/* /*
* SPDX-FileCopyrightText: 2018-2022 Espressif Systems (Shanghai) CO LTD * SPDX-FileCopyrightText: 2018-2022 Espressif Systems (Shanghai) CO LTD
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */
#include <expat.h> #include <expat.h>
#include <string.h> #include <string.h>
#include "unity.h" #include "unity.h"
typedef struct { typedef struct {
int depth; int depth;
char output[512]; char output[512];
int output_off; int output_off;
} user_data_t; } user_data_t;
static void insert_space(user_data_t *user_data) static void insert_space(user_data_t *user_data)
{ {
const char align_str[] = " "; const char align_str[] = " ";
TEST_ASSERT(sizeof(user_data->output) >= user_data->output_off); TEST_ASSERT(sizeof(user_data->output) >= user_data->output_off);
user_data->output[user_data->output_off++] = '\n'; user_data->output[user_data->output_off++] = '\n';
for (int i = 0; i < user_data->depth; i++) { for (int i = 0; i < user_data->depth; i++) {
for (int j = 0; j < strlen(align_str); ++j) { for (int j = 0; j < strlen(align_str); ++j) {
TEST_ASSERT(sizeof(user_data->output) >= user_data->output_off); TEST_ASSERT(sizeof(user_data->output) >= user_data->output_off);
user_data->output[user_data->output_off++] = align_str[j]; user_data->output[user_data->output_off++] = align_str[j];
} }
} }
} }
static void XMLCALL start_element(void *userData, const XML_Char *name, const XML_Char **atts) static void XMLCALL start_element(void *userData, const XML_Char *name, const XML_Char **atts)
{ {
user_data_t *user_data = (user_data_t *) userData; user_data_t *user_data = (user_data_t *) userData;
insert_space(user_data); insert_space(user_data);
const int ret = snprintf(user_data->output + user_data->output_off, const int ret = snprintf(user_data->output + user_data->output_off,
sizeof(user_data->output) - user_data->output_off, sizeof(user_data->output) - user_data->output_off,
"<%s>", name); "<%s>", name);
TEST_ASSERT_EQUAL(strlen(name) + 2, ret); // 2 are the tag characters: "<>" TEST_ASSERT_EQUAL(strlen(name) + 2, ret); // 2 are the tag characters: "<>"
user_data->output_off += ret; user_data->output_off += ret;
++user_data->depth; ++user_data->depth;
} }
static void XMLCALL end_element(void *userData, const XML_Char *name) static void XMLCALL end_element(void *userData, const XML_Char *name)
{ {
user_data_t *user_data = (user_data_t *) userData; user_data_t *user_data = (user_data_t *) userData;
--user_data->depth; --user_data->depth;
insert_space(user_data); insert_space(user_data);
int ret = snprintf(user_data->output + user_data->output_off, sizeof(user_data->output) - user_data->output_off, int ret = snprintf(user_data->output + user_data->output_off, sizeof(user_data->output) - user_data->output_off,
"</%s>", name); "</%s>", name);
TEST_ASSERT_EQUAL(strlen(name) + 3, ret); // 3 are the tag characters: "</>" TEST_ASSERT_EQUAL(strlen(name) + 3, ret); // 3 are the tag characters: "</>"
user_data->output_off += ret; user_data->output_off += ret;
} }
static void data_handler(void *userData, const XML_Char *s, int len) static void data_handler(void *userData, const XML_Char *s, int len)
{ {
user_data_t *user_data = (user_data_t *) userData; user_data_t *user_data = (user_data_t *) userData;
insert_space(user_data); insert_space(user_data);
// s is not zero-terminated // s is not zero-terminated
char tmp_str[len + 1]; char tmp_str[len + 1];
strlcpy(tmp_str, s, len + 1); strlcpy(tmp_str, s, len + 1);
int ret = snprintf(user_data->output + user_data->output_off, sizeof(user_data->output) - user_data->output_off, int ret = snprintf(user_data->output + user_data->output_off, sizeof(user_data->output) - user_data->output_off,
"%s", tmp_str); "%s", tmp_str);
TEST_ASSERT_EQUAL(strlen(tmp_str), ret); TEST_ASSERT_EQUAL(strlen(tmp_str), ret);
user_data->output_off += ret; user_data->output_off += ret;
} }
TEST_CASE("Expat parses XML", "[expat]") TEST_CASE("Expat parses XML", "[expat]")
{ {
const char test_in[] = "<html><title>Page title</title><body><h>header</h><ol><li>A</li>"\ const char test_in[] = "<html><title>Page title</title><body><h>header</h><ol><li>A</li>"\
"<li>B</li><li>C</li></ol></body></html>"; "<li>B</li><li>C</li></ol></body></html>";
const char test_expected[] = "\n"\ const char test_expected[] = "\n"\
"<html>\n"\ "<html>\n"\
" <title>\n"\ " <title>\n"\
" Page title\n"\ " Page title\n"\
" </title>\n"\ " </title>\n"\
" <body>\n"\ " <body>\n"\
" <h>\n"\ " <h>\n"\
" header\n"\ " header\n"\
" </h>\n"\ " </h>\n"\
" <ol>\n"\ " <ol>\n"\
" <li>\n"\ " <li>\n"\
" A\n"\ " A\n"\
" </li>\n"\ " </li>\n"\
" <li>\n"\ " <li>\n"\
" B\n"\ " B\n"\
" </li>\n"\ " </li>\n"\
" <li>\n"\ " <li>\n"\
" C\n"\ " C\n"\
" </li>\n"\ " </li>\n"\
" </ol>\n"\ " </ol>\n"\
" </body>\n"\ " </body>\n"\
"</html>"; "</html>";
user_data_t user_data = { user_data_t user_data = {
.depth = 0, .depth = 0,
.output = { '\0' }, .output = { '\0' },
.output_off = 0 .output_off = 0
}; };
XML_Parser parser = XML_ParserCreate(NULL); XML_Parser parser = XML_ParserCreate(NULL);
XML_SetUserData(parser, &user_data); XML_SetUserData(parser, &user_data);
XML_SetElementHandler(parser, start_element, end_element); XML_SetElementHandler(parser, start_element, end_element);
XML_SetCharacterDataHandler(parser, data_handler); XML_SetCharacterDataHandler(parser, data_handler);
TEST_ASSERT_NOT_EQUAL(XML_STATUS_ERROR, XML_Parse(parser, test_in, strlen(test_in), 1)); TEST_ASSERT_NOT_EQUAL(XML_STATUS_ERROR, XML_Parse(parser, test_in, strlen(test_in), 1));
XML_ParserFree(parser); XML_ParserFree(parser);
TEST_ASSERT_EQUAL(0, user_data.depth); // all closing tags have been found TEST_ASSERT_EQUAL(0, user_data.depth); // all closing tags have been found
TEST_ASSERT_EQUAL(strlen(test_expected), strlen(user_data.output)); TEST_ASSERT_EQUAL(strlen(test_expected), strlen(user_data.output));
TEST_ASSERT_EQUAL_STRING(test_expected, user_data.output); TEST_ASSERT_EQUAL_STRING(test_expected, user_data.output);
} }

View File

@ -1,25 +1,30 @@
# The following lines of boilerplate have to be in your project's # The following lines of boilerplate have to be in your project's
# CMakeLists in this exact order for cmake to work correctly # CMakeLists in this exact order for cmake to work correctly
cmake_minimum_required(VERSION 3.5) cmake_minimum_required(VERSION 3.5)
include($ENV{IDF_PATH}/tools/cmake/version.cmake)
set(EXTRA_COMPONENT_DIRS ../libsodium ../expat ../esp_encrypted_img ../cbor ../jsmn ../qrcode) # Add newly added components to one of these lines:
# 1. Add here if the component is compatible with IDF >= v4.3
set(EXTRA_COMPONENT_DIRS ../libsodium ../expat ../cbor ../jsmn ../qrcode)
# 2. Add here if the component is compatible with IDF >= v4.4
if("${IDF_VERSION_MAJOR}.${IDF_VERSION_MINOR}" VERSION_GREATER_EQUAL "4.4") if("${IDF_VERSION_MAJOR}.${IDF_VERSION_MINOR}" VERSION_GREATER_EQUAL "4.4")
list(APPEND EXTRA_COMPONENT_DIRS ../pid_ctrl) list(APPEND EXTRA_COMPONENT_DIRS ../pid_ctrl ../esp_encrypted_img)
endif() endif()
# 3. Add here if the component is compatible with IDF >= v5.0
if("${IDF_VERSION_MAJOR}.${IDF_VERSION_MINOR}" VERSION_GREATER_EQUAL "5.0") if("${IDF_VERSION_MAJOR}.${IDF_VERSION_MINOR}" VERSION_GREATER_EQUAL "5.0")
list(APPEND EXTRA_COMPONENT_DIRS ../sh2lib ../nghttp) list(APPEND EXTRA_COMPONENT_DIRS ../sh2lib ../nghttp)
endif() endif()
# !This section should NOT be touched when adding new component!
# Set the components to include the tests for. # Take all components in EXTRA_COMPONENT_DIRS, strip leading '../' and add it to TEST_COMPONENTS
set(TEST_COMPONENTS libsodium expat esp_encrypted_img CACHE STRING "List of components to test") # The build system will build and link unit tests, if the component contains 'test' subdirectory
set(TEST_COMPONENTS "" CACHE STRING "List of components to test")
include($ENV{IDF_PATH}/tools/cmake/version.cmake) # $ENV{IDF_VERSION} was added after v4.3... foreach (CMP_DIR ${EXTRA_COMPONENT_DIRS})
if("${IDF_VERSION_MAJOR}.${IDF_VERSION_MINOR}" VERSION_LESS "4.4") string(SUBSTRING ${CMP_DIR} 3 100 STRIPPED_CMP) # There should be no component name longer than 100 bytes...
set(EXCLUDE_COMPONENTS esp_encrypted_img) list(APPEND TEST_COMPONENTS ${STRIPPED_CMP})
endif() endforeach()
include($ENV{IDF_PATH}/tools/cmake/project.cmake) include($ENV{IDF_PATH}/tools/cmake/project.cmake)
project(idf_extra_test_app) project(idf_extra_test_app)

View File

@ -4,15 +4,11 @@
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */
#include <stdio.h>
#include <string.h>
#include "unity.h" #include "unity.h"
void app_main(void) void app_main(void)
{ {
UNITY_BEGIN(); UNITY_BEGIN();
//unity_run_tests_by_tag("[libsodium]", false);
unity_run_all_tests(); unity_run_all_tests();
//unity_run_menu();
UNITY_END(); UNITY_END();
} }

View File

@ -1 +0,0 @@
CONFIG_ESP32C3_REV_MIN_0=y