Enable Unit Test CI (#634)

* Enable Unit Test CI

* Remove non-functional entrypoint

* symlink CMakeLists.txt
This commit is contained in:
Erik Olof Gunnar Andersson
2025-01-27 18:25:38 +01:00
committed by GitHub
parent 7e2d690c64
commit c8671cf69c
13 changed files with 86 additions and 5 deletions

28
.github/workflows/unittest.yml vendored Normal file
View File

@@ -0,0 +1,28 @@
name: Unit Test
on: [push, pull_request]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v4
with:
submodules: 'recursive'
- name: esp-idf build
uses: espressif/esp-idf-ci-action@v1
with:
esp_idf_version: v5.4
target: esp32s3
command: GITHUB_ACTIONS="true" idf.py build
path: 'test-ci'
- name: Run tests and show result
uses: bitaxeorg/esp32-qemu-test-action@main
with:
path: 'test-ci'
- name: Inspect log
run: cat report.xml
- name: Publish Unit Test Results
uses: EnricoMi/publish-unit-test-result-action@v1
if: always()
with:
files: report.xml

View File

@@ -15,7 +15,11 @@
#include <stdlib.h>
#include <string.h>
#ifdef CONFIG_GPIO_ASIC_RESET
#define GPIO_ASIC_RESET CONFIG_GPIO_ASIC_RESET
#else
#define GPIO_ASIC_RESET 1
#endif
#define TYPE_JOB 0x20
#define TYPE_CMD 0x40

View File

@@ -15,7 +15,11 @@
#include <stdlib.h>
#include <string.h>
#ifdef CONFIG_GPIO_ASIC_RESET
#define GPIO_ASIC_RESET CONFIG_GPIO_ASIC_RESET
#else
#define GPIO_ASIC_RESET 1
#endif
#define TYPE_JOB 0x20
#define TYPE_CMD 0x40

View File

@@ -15,7 +15,11 @@
#include <stdlib.h>
#include <string.h>
#ifdef CONFIG_GPIO_ASIC_RESET
#define GPIO_ASIC_RESET CONFIG_GPIO_ASIC_RESET
#else
#define GPIO_ASIC_RESET 1
#endif
#define TYPE_JOB 0x20
#define TYPE_CMD 0x40

View File

@@ -15,7 +15,11 @@
#include "mining.h"
#include "global_state.h"
#ifdef CONFIG_GPIO_ASIC_RESET
#define GPIO_ASIC_RESET CONFIG_GPIO_ASIC_RESET
#else
#define GPIO_ASIC_RESET 1
#endif
#define TYPE_JOB 0x20
#define TYPE_CMD 0x40

View File

@@ -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";
@@ -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";

View File

@@ -222,7 +222,12 @@ void midstate_sha256_bin(const uint8_t *data, const size_t data_len, uint8_t *de
mbedtls_sha256_update(&midstate, data, 64);
// memcpy(dest, midstate.state, 32);
flip32bytes(dest, midstate.state);
#ifdef CONFIG_MBEDTLS_HARDWARE_SHA
flip32bytes(dest, midstate.state);
#else
memcpy(dest, midstate.MBEDTLS_PRIVATE(state), 32);
#endif
}
void swap_endian_words(const char *hex_words, uint8_t *output)

1
test-ci/CMakeLists.txt Symbolic link
View File

@@ -0,0 +1 @@
../test/CMakeLists.txt

View File

@@ -0,0 +1,2 @@
idf_component_register(SRCS "unit_test_all.c"
INCLUDE_DIRS ".")

View File

@@ -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);
}

View File

@@ -0,0 +1,3 @@
CONFIG_ESP_INT_WDT=n
CONFIG_ESP_TASK_WDT=n
CONFIG_MBEDTLS_HARDWARE_SHA=n

View File

@@ -21,4 +21,4 @@ void app_main(void)
static void print_banner(const char *text)
{
printf("\n#### %s #####\n\n", text);
}
}

View File

@@ -1,2 +1,2 @@
CONFIG_ESP_INT_WDT=n
CONFIG_ESP_TASK_WDT=n
CONFIG_ESP_TASK_WDT=n