Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix unit test failing on ubuntu 24.04LTS #500

Merged
merged 2 commits into from
Jan 31, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 9 additions & 10 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [macos-latest, windows-latest, ubuntu-latest]
os: [macos-latest, windows-latest, ubuntu-22.04]
steps:
- name: Check out Luos repository
uses: actions/checkout@v3
Expand All @@ -44,26 +44,26 @@ jobs:
# Run Unit tests
platformio test -vvv

- if: matrix.os == 'ubuntu-latest'
- if: matrix.os == 'ubuntu-22.04'
run: |
sudo apt-get install -y lcov
lcov -d .pio/build/native/ -c -o lcov.info
lcov --remove lcov.info '*/usr/*' '*/Platforms/*' '*/bootloader/*' '*/.pio/*' '*/HAL/*' '*/test/*' '*/network/*' -o lcov.info
lcov --remove lcov.info '*/usr/*' '*/Platforms/*' '*/bootloader/*' '*/.pio/*' '*/HAL/*' '*/test/*' '*/network/*' -o lcov.info --ignore-errors empty

- if: matrix.os == 'ubuntu-latest'
- if: matrix.os == 'ubuntu-22.04'
name: Coveralls
uses: coverallsapp/github-action@v2

unit-tests:
name: Unit tests
needs: tests-run
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
steps:
- run: echo "Tests succeed!"

code-format:
name: Code format
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
steps:
- name: Check out Luos repository
uses: actions/checkout@v3
Expand All @@ -89,8 +89,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
project_folders:
[
project_folders: [
examples/projects/l0,
examples/projects/Arduino,
examples/projects/NUCLEO-L432KC,
Expand All @@ -106,7 +105,7 @@ jobs:
# examples/projects/ESP32,
examples/projects/native,
]
os: [macos-latest, windows-latest, ubuntu-latest]
os: [macos-latest, windows-latest, ubuntu-22.04]

steps:
- name: Check out Luos repository
Expand Down Expand Up @@ -152,6 +151,6 @@ jobs:
build-success:
name: Build success
needs: examples-build
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
steps:
- run: echo "Build succeed!"
18 changes: 4 additions & 14 deletions engine/core/src/routing_table.c
Original file line number Diff line number Diff line change
Expand Up @@ -185,28 +185,18 @@ static void RoutingTB_AddNumToAlias(char *alias, uint8_t num)
uint8_t intsize = 1;
if (num > 9)
{
// The string size of num is 2
// The string size of num have a size of 2
intsize = 2;
}
if (num > 99) // only 2 digit are alowed when add alias number
{
// This is probably a mistake, put an error into the alias
memset(alias, 0, MAX_ALIAS_SIZE - 1);
memcpy(alias, "error", strlen("error"));
return;
}
LUOS_ASSERT(num < 100); // only 2 digit are alowed when add alias number
// Change size to fit into 15 characters
if (strlen(alias) > (MAX_ALIAS_SIZE - 1 - intsize))
{
alias[(MAX_ALIAS_SIZE - 1 - intsize)] = '\0';
}
else
{
alias[strlen(alias)] = '\0';
}
// Add a number at the end of the alias
char *alias_copy = alias;
sprintf(alias, "%s%d", alias_copy, num);
char *end_pointer = &alias[strlen(alias)];
sprintf(end_pointer, "%d", num);
}

/******************************************************************************
Expand Down
14 changes: 14 additions & 0 deletions test/tests_core/test_routing_table/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,20 @@ void unittest_RoutingTB_AddNumToAlias(void)
}
TEST_ASSERT_TRUE(IS_ASSERT());
END_TRY;
TRY
{
char alias[MAX_ALIAS_SIZE] = "Dummy_App";
RoutingTB_AddNumToAlias(alias, 100);
}
TEST_ASSERT_TRUE(IS_ASSERT());
END_TRY;
TRY
{
char alias[MAX_ALIAS_SIZE] = "Dummy_App";
RoutingTB_AddNumToAlias(alias, 101);
}
TEST_ASSERT_TRUE(IS_ASSERT());
END_TRY;
}

NEW_TEST_CASE("check RoutingTB_AddNumToAlias return value");
Expand Down
Loading