Skip to content

Commit

Permalink
Add CI specific jobs
Browse files Browse the repository at this point in the history
  • Loading branch information
eandersson committed Jan 10, 2025
1 parent 5e666da commit 81d2bd7
Show file tree
Hide file tree
Showing 9 changed files with 69 additions and 11 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/unittest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ jobs:
esp_idf_version: v5.4
target: esp32s3
command: GITHUB_ACTIONS="true" idf.py build
path: 'test'
path: 'test-ci'
- name: Run tests and show result
uses: bitaxeorg/esp32-qemu-test-action@main
with:
path: 'test'
path: 'test-ci'
- name: Inspect log
run: cat report.xml
- name: Publish Unit Test Results
Expand Down
6 changes: 3 additions & 3 deletions components/stratum/test/test_mining.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ TEST_CASE("Validate version mask incrementing", "[mining]")
// TEST_ASSERT_EQUAL_UINT8(0x6a, job.merkle_root[31]);
// }

TEST_CASE("Test extranonce 2 generation", "[mining extranonce2]")
TEST_CASE("Test extranonce 2 generation", "[mining extranonce2][fails]")
{
char *first = extranonce_2_generate(0, 4);
TEST_ASSERT_EQUAL_STRING("00000000", first);
Expand All @@ -138,7 +138,7 @@ TEST_CASE("Test extranonce 2 generation", "[mining extranonce2]")
free(fifth);
}

TEST_CASE("Test nonce diff checking", "[mining test_nonce]")
TEST_CASE("Test nonce diff checking", "[mining test_nonce][not-on-qemu]")
{
mining_notify notify_message;
notify_message.prev_block_hash = "d02b10fc0d4711eae1a805af50a8a83312a2215e00017f2b0000000000000000";
Expand All @@ -153,7 +153,7 @@ TEST_CASE("Test nonce diff checking", "[mining test_nonce]")
TEST_ASSERT_EQUAL_INT(18, (int)diff);
}

TEST_CASE("Test nonce diff checking 2", "[mining test_nonce]")
TEST_CASE("Test nonce diff checking 2", "[mining test_nonce][not-on-qemu]")
{
mining_notify notify_message;
notify_message.prev_block_hash = "0c859545a3498373a57452fac22eb7113df2a465000543520000000000000000";
Expand Down
21 changes: 21 additions & 0 deletions test-ci/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# This is the project CMakeLists.txt file for the test subproject
cmake_minimum_required(VERSION 3.16)

# Include the components directory of the main application:
#
set(EXTRA_COMPONENT_DIRS "../components")

# Set the components to include the tests for.
# This can be overriden from CMake cache:
# - when invoking CMake directly: cmake -D TEST_COMPONENTS="xxxxx" ..
# - when using idf.py: idf.py -T xxxxx build
#
set(TEST_COMPONENTS "bm1397 stratum" CACHE STRING "List of components to test")

include($ENV{IDF_PATH}/tools/cmake/project.cmake)

set(IDF_TARGET "esp32s3")

idf_build_set_property(COMPILE_DEFINITIONS "-DCONFIG_ASIC_FREQUENCY=100" APPEND)

project(unit_test_stratum)
9 changes: 9 additions & 0 deletions test-ci/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env bash
set -e
CODE_PATH="$1"
. $IDF_PATH/export.sh
cd test/build
esptool.py --chip esp32s3 merge_bin --fill-flash-size 16MB -o flash_image.bin @flash_args
/opt/qemu/bin/qemu-system-xtensa -nographic -no-reboot -machine esp32 -drive file=flash_image.bin,if=mtd,format=raw -serial file:output.log
grep -q -E '[[:digit:]]+ Tests [[:digit:]]+ Failures [[:digit:]]+ Ignored' output.log && ruby /opt/Unity-*/auto/parse_output.rb -xml output.log || exit 1
mv report.xml /github/workspace
2 changes: 2 additions & 0 deletions test-ci/main/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
idf_component_register(SRCS "unit_test_all.c"
INCLUDE_DIRS ".")
26 changes: 26 additions & 0 deletions test-ci/main/unit_test_all.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#include <stdio.h>
#include <string.h>
#include "unity.h"

static void print_banner(const char *text);

void app_main(void)
{
print_banner("Running all the registered tests");
UNITY_BEGIN();
unity_run_tests_by_tag("[not-on-qemu]", true);
UNITY_END();

// print_banner("Starting interactive test menu");
/* This function will not return, and will be busy waiting for UART input.
* Make sure that task watchdog is disabled if you use this function.
*/
// unity_run_menu();

exit(0);
}

static void print_banner(const char *text)
{
printf("\n#### %s #####\n\n", text);
}
3 changes: 3 additions & 0 deletions test-ci/sdkconfig.defaults
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
CONFIG_ESP_INT_WDT=n
CONFIG_ESP_TASK_WDT=n
CONFIG_MBEDTLS_HARDWARE_SHA=n
8 changes: 3 additions & 5 deletions test/main/unit_test_all.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,14 @@ void app_main(void)
unity_run_all_tests();
UNITY_END();

// print_banner("Starting interactive test menu");
print_banner("Starting interactive test menu");
/* This function will not return, and will be busy waiting for UART input.
* Make sure that task watchdog is disabled if you use this function.
*/
// unity_run_menu();

exit(0);
unity_run_menu();
}

static void print_banner(const char *text)
{
printf("\n#### %s #####\n\n", text);
}
}
1 change: 0 additions & 1 deletion test/sdkconfig.defaults
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
CONFIG_ESP_INT_WDT=n
CONFIG_ESP_TASK_WDT=n
CONFIG_MBEDTLS_HARDWARE_SHA=n

0 comments on commit 81d2bd7

Please sign in to comment.