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
working-directory: test_app/build
run: |
pip install esptool
python -m esptool --chip esp32 merge_bin --fill-flash-size 4MB -o flash_image.bin @flash_args
. ${IDF_PATH}/export.sh
esptool.py --chip ${{ matrix.idf_target }} merge_bin --fill-flash-size 4MB -o flash_image.bin @flash_args
- uses: actions/upload-artifact@v2
with:
name: test_app_bin_${{ matrix.idf_target }}_${{ matrix.idf_ver }}
path: |
test_app/build/flash_image.bin
path: 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
# needs: build
# strategy:
@ -63,6 +63,7 @@ jobs:
name: Run Test App on target
needs: build
strategy:
fail-fast: false
matrix:
idf_ver: ["release-v4.3", "release-v4.4", "latest"]
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
container:
image: python:3.7-slim-buster
options: --privileged
options: --privileged # Privileged mode has access to serial ports
steps:
- uses: actions/checkout@v2
with:
@ -89,4 +90,24 @@ jobs:
run: python -m esptool --chip ${{ matrix.idf_target }} write_flash 0x0 test_app/build/flash_image.bin
- name: Run Test App on target
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-License-Identifier: Apache-2.0
*/
#include <expat.h>
#include <string.h>
#include "unity.h"
typedef struct {
int depth;
char output[512];
int output_off;
} user_data_t;
static void insert_space(user_data_t *user_data)
{
const char align_str[] = " ";
TEST_ASSERT(sizeof(user_data->output) >= user_data->output_off);
user_data->output[user_data->output_off++] = '\n';
for (int i = 0; i < user_data->depth; i++) {
for (int j = 0; j < strlen(align_str); ++j) {
TEST_ASSERT(sizeof(user_data->output) >= user_data->output_off);
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)
{
user_data_t *user_data = (user_data_t *) userData;
insert_space(user_data);
const int ret = snprintf(user_data->output + user_data->output_off,
sizeof(user_data->output) - user_data->output_off,
"<%s>", name);
TEST_ASSERT_EQUAL(strlen(name) + 2, ret); // 2 are the tag characters: "<>"
user_data->output_off += ret;
++user_data->depth;
}
static void XMLCALL end_element(void *userData, const XML_Char *name)
{
user_data_t *user_data = (user_data_t *) userData;
--user_data->depth;
insert_space(user_data);
int ret = snprintf(user_data->output + user_data->output_off, sizeof(user_data->output) - user_data->output_off,
"</%s>", name);
TEST_ASSERT_EQUAL(strlen(name) + 3, ret); // 3 are the tag characters: "</>"
user_data->output_off += ret;
}
static void data_handler(void *userData, const XML_Char *s, int len)
{
user_data_t *user_data = (user_data_t *) userData;
insert_space(user_data);
// s is not zero-terminated
char tmp_str[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,
"%s", tmp_str);
TEST_ASSERT_EQUAL(strlen(tmp_str), ret);
user_data->output_off += ret;
}
TEST_CASE("Expat parses XML", "[expat]")
{
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>";
const char test_expected[] = "\n"\
"<html>\n"\
" <title>\n"\
" Page title\n"\
" </title>\n"\
" <body>\n"\
" <h>\n"\
" header\n"\
" </h>\n"\
" <ol>\n"\
" <li>\n"\
" A\n"\
" </li>\n"\
" <li>\n"\
" B\n"\
" </li>\n"\
" <li>\n"\
" C\n"\
" </li>\n"\
" </ol>\n"\
" </body>\n"\
"</html>";
user_data_t user_data = {
.depth = 0,
.output = { '\0' },
.output_off = 0
};
XML_Parser parser = XML_ParserCreate(NULL);
XML_SetUserData(parser, &user_data);
XML_SetElementHandler(parser, start_element, end_element);
XML_SetCharacterDataHandler(parser, data_handler);
TEST_ASSERT_NOT_EQUAL(XML_STATUS_ERROR, XML_Parse(parser, test_in, strlen(test_in), 1));
XML_ParserFree(parser);
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_STRING(test_expected, user_data.output);
}
/*
* SPDX-FileCopyrightText: 2018-2022 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <expat.h>
#include <string.h>
#include "unity.h"
typedef struct {
int depth;
char output[512];
int output_off;
} user_data_t;
static void insert_space(user_data_t *user_data)
{
const char align_str[] = " ";
TEST_ASSERT(sizeof(user_data->output) >= user_data->output_off);
user_data->output[user_data->output_off++] = '\n';
for (int i = 0; i < user_data->depth; i++) {
for (int j = 0; j < strlen(align_str); ++j) {
TEST_ASSERT(sizeof(user_data->output) >= user_data->output_off);
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)
{
user_data_t *user_data = (user_data_t *) userData;
insert_space(user_data);
const int ret = snprintf(user_data->output + user_data->output_off,
sizeof(user_data->output) - user_data->output_off,
"<%s>", name);
TEST_ASSERT_EQUAL(strlen(name) + 2, ret); // 2 are the tag characters: "<>"
user_data->output_off += ret;
++user_data->depth;
}
static void XMLCALL end_element(void *userData, const XML_Char *name)
{
user_data_t *user_data = (user_data_t *) userData;
--user_data->depth;
insert_space(user_data);
int ret = snprintf(user_data->output + user_data->output_off, sizeof(user_data->output) - user_data->output_off,
"</%s>", name);
TEST_ASSERT_EQUAL(strlen(name) + 3, ret); // 3 are the tag characters: "</>"
user_data->output_off += ret;
}
static void data_handler(void *userData, const XML_Char *s, int len)
{
user_data_t *user_data = (user_data_t *) userData;
insert_space(user_data);
// s is not zero-terminated
char tmp_str[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,
"%s", tmp_str);
TEST_ASSERT_EQUAL(strlen(tmp_str), ret);
user_data->output_off += ret;
}
TEST_CASE("Expat parses XML", "[expat]")
{
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>";
const char test_expected[] = "\n"\
"<html>\n"\
" <title>\n"\
" Page title\n"\
" </title>\n"\
" <body>\n"\
" <h>\n"\
" header\n"\
" </h>\n"\
" <ol>\n"\
" <li>\n"\
" A\n"\
" </li>\n"\
" <li>\n"\
" B\n"\
" </li>\n"\
" <li>\n"\
" C\n"\
" </li>\n"\
" </ol>\n"\
" </body>\n"\
"</html>";
user_data_t user_data = {
.depth = 0,
.output = { '\0' },
.output_off = 0
};
XML_Parser parser = XML_ParserCreate(NULL);
XML_SetUserData(parser, &user_data);
XML_SetElementHandler(parser, start_element, end_element);
XML_SetCharacterDataHandler(parser, data_handler);
TEST_ASSERT_NOT_EQUAL(XML_STATUS_ERROR, XML_Parse(parser, test_in, strlen(test_in), 1));
XML_ParserFree(parser);
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_STRING(test_expected, user_data.output);
}

View File

@ -1,25 +1,30 @@
# The following lines of boilerplate have to be in your project's
# CMakeLists in this exact order for cmake to work correctly
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")
list(APPEND EXTRA_COMPONENT_DIRS ../pid_ctrl)
list(APPEND EXTRA_COMPONENT_DIRS ../pid_ctrl ../esp_encrypted_img)
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")
list(APPEND EXTRA_COMPONENT_DIRS ../sh2lib ../nghttp)
endif()
# Set the components to include the tests for.
set(TEST_COMPONENTS libsodium expat esp_encrypted_img CACHE STRING "List of components to test")
include($ENV{IDF_PATH}/tools/cmake/version.cmake) # $ENV{IDF_VERSION} was added after v4.3...
if("${IDF_VERSION_MAJOR}.${IDF_VERSION_MINOR}" VERSION_LESS "4.4")
set(EXCLUDE_COMPONENTS esp_encrypted_img)
endif()
# !This section should NOT be touched when adding new component!
# Take all components in EXTRA_COMPONENT_DIRS, strip leading '../' and add it to TEST_COMPONENTS
# 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")
foreach (CMP_DIR ${EXTRA_COMPONENT_DIRS})
string(SUBSTRING ${CMP_DIR} 3 100 STRIPPED_CMP) # There should be no component name longer than 100 bytes...
list(APPEND TEST_COMPONENTS ${STRIPPED_CMP})
endforeach()
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
project(idf_extra_test_app)

View File

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

View File

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