Skip to content

Commit 1b3cf0c

Browse files
Merge pull request #500 from Luos-io/fix/unit_test
Fix unit test failing on ubuntu 24.04LTS
2 parents 3d58fdd + 7011dc7 commit 1b3cf0c

File tree

3 files changed

+27
-24
lines changed

3 files changed

+27
-24
lines changed

.github/workflows/build.yml

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
runs-on: ${{ matrix.os }}
2121
strategy:
2222
matrix:
23-
os: [macos-latest, windows-latest, ubuntu-latest]
23+
os: [macos-latest, windows-latest, ubuntu-22.04]
2424
steps:
2525
- name: Check out Luos repository
2626
uses: actions/checkout@v3
@@ -44,26 +44,26 @@ jobs:
4444
# Run Unit tests
4545
platformio test -vvv
4646
47-
- if: matrix.os == 'ubuntu-latest'
47+
- if: matrix.os == 'ubuntu-22.04'
4848
run: |
4949
sudo apt-get install -y lcov
5050
lcov -d .pio/build/native/ -c -o lcov.info
51-
lcov --remove lcov.info '*/usr/*' '*/Platforms/*' '*/bootloader/*' '*/.pio/*' '*/HAL/*' '*/test/*' '*/network/*' -o lcov.info
51+
lcov --remove lcov.info '*/usr/*' '*/Platforms/*' '*/bootloader/*' '*/.pio/*' '*/HAL/*' '*/test/*' '*/network/*' -o lcov.info --ignore-errors empty
5252
53-
- if: matrix.os == 'ubuntu-latest'
53+
- if: matrix.os == 'ubuntu-22.04'
5454
name: Coveralls
5555
uses: coverallsapp/github-action@v2
5656

5757
unit-tests:
5858
name: Unit tests
5959
needs: tests-run
60-
runs-on: ubuntu-latest
60+
runs-on: ubuntu-22.04
6161
steps:
6262
- run: echo "Tests succeed!"
6363

6464
code-format:
6565
name: Code format
66-
runs-on: ubuntu-latest
66+
runs-on: ubuntu-22.04
6767
steps:
6868
- name: Check out Luos repository
6969
uses: actions/checkout@v3
@@ -89,8 +89,7 @@ jobs:
8989
runs-on: ${{ matrix.os }}
9090
strategy:
9191
matrix:
92-
project_folders:
93-
[
92+
project_folders: [
9493
examples/projects/l0,
9594
examples/projects/Arduino,
9695
examples/projects/NUCLEO-L432KC,
@@ -106,7 +105,7 @@ jobs:
106105
# examples/projects/ESP32,
107106
examples/projects/native,
108107
]
109-
os: [macos-latest, windows-latest, ubuntu-latest]
108+
os: [macos-latest, windows-latest, ubuntu-22.04]
110109

111110
steps:
112111
- name: Check out Luos repository
@@ -152,6 +151,6 @@ jobs:
152151
build-success:
153152
name: Build success
154153
needs: examples-build
155-
runs-on: ubuntu-latest
154+
runs-on: ubuntu-22.04
156155
steps:
157156
- run: echo "Build succeed!"

engine/core/src/routing_table.c

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -185,28 +185,18 @@ static void RoutingTB_AddNumToAlias(char *alias, uint8_t num)
185185
uint8_t intsize = 1;
186186
if (num > 9)
187187
{
188-
// The string size of num is 2
188+
// The string size of num have a size of 2
189189
intsize = 2;
190190
}
191-
if (num > 99) // only 2 digit are alowed when add alias number
192-
{
193-
// This is probably a mistake, put an error into the alias
194-
memset(alias, 0, MAX_ALIAS_SIZE - 1);
195-
memcpy(alias, "error", strlen("error"));
196-
return;
197-
}
191+
LUOS_ASSERT(num < 100); // only 2 digit are alowed when add alias number
198192
// Change size to fit into 15 characters
199193
if (strlen(alias) > (MAX_ALIAS_SIZE - 1 - intsize))
200194
{
201195
alias[(MAX_ALIAS_SIZE - 1 - intsize)] = '\0';
202196
}
203-
else
204-
{
205-
alias[strlen(alias)] = '\0';
206-
}
207197
// Add a number at the end of the alias
208-
char *alias_copy = alias;
209-
sprintf(alias, "%s%d", alias_copy, num);
198+
char *end_pointer = &alias[strlen(alias)];
199+
sprintf(end_pointer, "%d", num);
210200
}
211201

212202
/******************************************************************************

test/tests_core/test_routing_table/main.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,20 @@ void unittest_RoutingTB_AddNumToAlias(void)
197197
}
198198
TEST_ASSERT_TRUE(IS_ASSERT());
199199
END_TRY;
200+
TRY
201+
{
202+
char alias[MAX_ALIAS_SIZE] = "Dummy_App";
203+
RoutingTB_AddNumToAlias(alias, 100);
204+
}
205+
TEST_ASSERT_TRUE(IS_ASSERT());
206+
END_TRY;
207+
TRY
208+
{
209+
char alias[MAX_ALIAS_SIZE] = "Dummy_App";
210+
RoutingTB_AddNumToAlias(alias, 101);
211+
}
212+
TEST_ASSERT_TRUE(IS_ASSERT());
213+
END_TRY;
200214
}
201215

202216
NEW_TEST_CASE("check RoutingTB_AddNumToAlias return value");

0 commit comments

Comments
 (0)