-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'dev' into astra/3934-alarm-improvements
- Loading branch information
Showing
115 changed files
with
3,468 additions
and
1,342 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ on: | |
env: | ||
TARGETS: f7 | ||
DEFAULT_TARGET: f7 | ||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
jobs: | ||
check-secret: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ on: | |
|
||
env: | ||
FBT_TOOLCHAIN_PATH: /runner/_work | ||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
jobs: | ||
merge_report: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,73 +1,39 @@ | ||
name: 'Updater test' | ||
on: | ||
pull_request: | ||
|
||
env: | ||
TARGETS: f7 | ||
DEFAULT_TARGET: f7 | ||
FBT_TOOLCHAIN_PATH: /opt | ||
FBT_TOOLCHAIN_PATH: /opt/ | ||
FBT_GIT_SUBMODULE_SHALLOW: 1 | ||
|
||
jobs: | ||
test_updater_on_bench: | ||
runs-on: [self-hosted, FlipperZeroUpdaterTest] | ||
runs-on: [self-hosted, FlipperZeroTest ] | ||
steps: | ||
- name: 'Wipe workspace' | ||
run: find ./ -mount -maxdepth 1 -exec rm -rf {} \; | ||
|
||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 1 | ||
submodules: false | ||
ref: ${{ github.event.pull_request.head.sha }} | ||
|
||
- name: 'Get flipper from device manager (mock)' | ||
id: device | ||
run: | | ||
echo "flipper=auto" >> $GITHUB_OUTPUT | ||
echo "stlink=0F020D026415303030303032" >> $GITHUB_OUTPUT | ||
- name: 'Flashing target firmware' | ||
id: first_full_flash | ||
timeout-minutes: 10 | ||
timeout-minutes: 20 | ||
run: | | ||
source scripts/toolchain/fbtenv.sh | ||
./fbt flash_usb_full PORT=${{steps.device.outputs.flipper}} FORCE=1 | ||
python3 scripts/testops.py -p=${{steps.device.outputs.flipper}} -t=180 await_flipper | ||
python3 scripts/testops.py -t=180 await_flipper | ||
./fbt flash_usb_full FORCE=1 | ||
- name: 'Validating updater' | ||
id: second_full_flash | ||
timeout-minutes: 10 | ||
if: success() | ||
run: | | ||
source scripts/toolchain/fbtenv.sh | ||
./fbt flash_usb PORT=${{steps.device.outputs.flipper}} FORCE=1 | ||
python3 scripts/testops.py -p=${{steps.device.outputs.flipper}} -t=180 await_flipper | ||
- name: 'Get last release tag' | ||
id: release_tag | ||
if: failure() | ||
run: | | ||
echo "tag=$(git tag -l --sort=-version:refname | grep -v "rc\|RC" | head -1)" >> $GITHUB_OUTPUT | ||
- name: 'Wipe workspace' | ||
run: find ./ -mount -maxdepth 1 -exec rm -rf {} \; | ||
python3 scripts/testops.py -t=180 await_flipper | ||
./fbt flash_usb FORCE=1 | ||
python3 scripts/testops.py -t=180 await_flipper | ||
- name: 'Checkout latest release' | ||
uses: actions/checkout@v4 | ||
if: failure() | ||
with: | ||
fetch-depth: 1 | ||
ref: ${{ steps.release_tag.outputs.tag }} | ||
|
||
- name: 'Flash last release' | ||
if: failure() | ||
run: | | ||
./fbt flash SWD_TRANSPORT_SERIAL=${{steps.device.outputs.stlink}} FORCE=1 | ||
- name: 'Wait for flipper and format ext' | ||
if: failure() | ||
run: | | ||
source scripts/toolchain/fbtenv.sh | ||
python3 scripts/testops.py -p=${{steps.device.outputs.flipper}} -t=180 await_flipper | ||
python3 scripts/storage.py -p ${{steps.device.outputs.flipper}} format_ext |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
108 changes: 108 additions & 0 deletions
108
applications/debug/unit_tests/tests/furi/furi_stdio_test.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
#include <furi.h> | ||
#include <errno.h> | ||
#include <stdio.h> | ||
#include "../test.h" // IWYU pragma: keep | ||
|
||
#define TAG "StdioTest" | ||
|
||
#define CONTEXT_MAGIC ((void*)0xDEADBEEF) | ||
|
||
// stdin | ||
|
||
static char mock_in[256]; | ||
static size_t mock_in_len, mock_in_pos; | ||
|
||
static void set_mock_in(const char* str) { | ||
size_t len = strlen(str); | ||
strcpy(mock_in, str); | ||
mock_in_len = len; | ||
mock_in_pos = 0; | ||
} | ||
|
||
static size_t mock_in_cb(char* buffer, size_t size, FuriWait wait, void* context) { | ||
UNUSED(wait); | ||
furi_check(context == CONTEXT_MAGIC); | ||
size_t remaining = mock_in_len - mock_in_pos; | ||
size = MIN(remaining, size); | ||
memcpy(buffer, mock_in + mock_in_pos, size); | ||
mock_in_pos += size; | ||
return size; | ||
} | ||
|
||
void test_stdin(void) { | ||
FuriThreadStdinReadCallback in_cb = furi_thread_get_stdin_callback(); | ||
furi_thread_set_stdin_callback(mock_in_cb, CONTEXT_MAGIC); | ||
char buf[256]; | ||
|
||
// plain in | ||
set_mock_in("Hello, World!\n"); | ||
fgets(buf, sizeof(buf), stdin); | ||
mu_assert_string_eq("Hello, World!\n", buf); | ||
mu_assert_int_eq(EOF, getchar()); | ||
|
||
// ungetc | ||
ungetc('i', stdin); | ||
ungetc('H', stdin); | ||
fgets(buf, sizeof(buf), stdin); | ||
mu_assert_string_eq("Hi", buf); | ||
mu_assert_int_eq(EOF, getchar()); | ||
|
||
// ungetc + plain in | ||
set_mock_in(" World"); | ||
ungetc('i', stdin); | ||
ungetc('H', stdin); | ||
fgets(buf, sizeof(buf), stdin); | ||
mu_assert_string_eq("Hi World", buf); | ||
mu_assert_int_eq(EOF, getchar()); | ||
|
||
// partial plain in | ||
set_mock_in("Hello, World!\n"); | ||
fgets(buf, strlen("Hello") + 1, stdin); | ||
mu_assert_string_eq("Hello", buf); | ||
mu_assert_int_eq(',', getchar()); | ||
fgets(buf, sizeof(buf), stdin); | ||
mu_assert_string_eq(" World!\n", buf); | ||
|
||
furi_thread_set_stdin_callback(in_cb, CONTEXT_MAGIC); | ||
} | ||
|
||
// stdout | ||
|
||
static FuriString* mock_out; | ||
FuriThreadStdoutWriteCallback original_out_cb; | ||
|
||
static void mock_out_cb(const char* data, size_t size, void* context) { | ||
furi_check(context == CONTEXT_MAGIC); | ||
// there's no furi_string_cat_strn :( | ||
for(size_t i = 0; i < size; i++) { | ||
furi_string_push_back(mock_out, data[i]); | ||
} | ||
} | ||
|
||
static void assert_and_clear_mock_out(const char* expected) { | ||
// return the original stdout callback for the duration of the check | ||
// if the check fails, we don't want the error to end up in our buffer, | ||
// we want to be able to see it! | ||
furi_thread_set_stdout_callback(original_out_cb, CONTEXT_MAGIC); | ||
mu_assert_string_eq(expected, furi_string_get_cstr(mock_out)); | ||
furi_thread_set_stdout_callback(mock_out_cb, CONTEXT_MAGIC); | ||
|
||
furi_string_reset(mock_out); | ||
} | ||
|
||
void test_stdout(void) { | ||
original_out_cb = furi_thread_get_stdout_callback(); | ||
furi_thread_set_stdout_callback(mock_out_cb, CONTEXT_MAGIC); | ||
mock_out = furi_string_alloc(); | ||
|
||
puts("Hello, World!"); | ||
assert_and_clear_mock_out("Hello, World!\n"); | ||
|
||
printf("He"); | ||
printf("llo!"); | ||
fflush(stdout); | ||
assert_and_clear_mock_out("Hello!"); | ||
|
||
furi_string_free(mock_out); | ||
furi_thread_set_stdout_callback(original_out_cb, CONTEXT_MAGIC); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.