Skip to content

Commit ff2b867

Browse files
committed
Merge remote-tracking branch 'origin/2.8' into 2.9
* origin/2.8: mb2hal: wait for threads to stop before deallocating the memory they're using mb2hal tests: accept any comp id
2 parents 142cf8f + 74d1e8f commit ff2b867

5 files changed

Lines changed: 59 additions & 26 deletions

File tree

src/hal/user_comps/mb2hal/mb2hal.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@ int main(int argc, char **argv)
9191

9292
/* Each link has it's own thread */
9393
pthread_attr_init(&thrd_attr);
94-
pthread_attr_setdetachstate(&thrd_attr, PTHREAD_CREATE_DETACHED);
9594
for (counter = 0; counter < gbl.tot_mb_links; counter++) {
9695
ret = pthread_create(&gbl.mb_links[counter].thrd, &thrd_attr, link_loop_and_logic, (void *) &gbl.mb_links[counter].mb_link_num);
9796
if (ret != 0) {
@@ -105,6 +104,14 @@ int main(int argc, char **argv)
105104
sleep(1);
106105
}
107106

107+
for (counter = 0; counter < gbl.tot_mb_links; counter++) {
108+
ret = pthread_join(gbl.mb_links[counter].thrd, NULL);
109+
if (ret != 0) {
110+
ERR(gbl.init_dbg, "Unable to join thread for link number %d: %s", counter, strerror(ret));
111+
}
112+
// OK(gbl.init_dbg, "Link thread %d joined OK OK", counter);
113+
}
114+
108115
QUIT_CLEANUP:
109116
quit_cleanup();
110117
OK(gbl.init_dbg, "going to exit!");

tests/mb2hal/mb2hal.1a/checkresult

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
set -e
3+
4+
TESTDIR=$(dirname $1)
5+
cd "${TESTDIR}"
6+
7+
# HAL assigns each component a unique component ID at load-time.
8+
# The RTAI and uspace HAL implementations assign different component IDs,
9+
# so remove all mentions of specific component IDs from the result file,
10+
# so that a single `expected` file works for both.
11+
sed --in-place --regexp-extended --expression='s/^(.*unloading HAL module \[)[0-9]+(.*)$/\1(ignored comp id)\2/' result
12+
13+
diff -u expected result

tests/mb2hal/mb2hal.1a/expected

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,6 @@ mb2hal main OK: Link thread loop and logic 0 created OK
127127
mb2hal main OK: mb2hal is running
128128
mb2hal quit_signal DEBUG: signal [15] received
129129
mb2hal quit_cleanup DEBUG: started
130-
mb2hal quit_cleanup DEBUG: unloading HAL module [4] ret[0]
130+
mb2hal quit_cleanup DEBUG: unloading HAL module [(ignored comp id)] ret[0]
131131
mb2hal quit_cleanup DEBUG: done OK
132132
mb2hal main OK: going to exit!

tests/mb2hal/mb2hal.1b/checkresult

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
set -e
3+
4+
TESTDIR=$(dirname $1)
5+
cd "${TESTDIR}"
6+
7+
# HAL assigns each component a unique component ID at load-time.
8+
# The RTAI and uspace HAL implementations assign different component IDs,
9+
# so remove all mentions of specific component IDs from the result file,
10+
# so that a single `expected` file works for both.
11+
sed --in-place --regexp-extended --expression='s/^( *)[0-9]+(.*mb2hal.Modbus_fnct_.*)$/\1(ignored comp id)\2/' result
12+
13+
diff -u expected result

tests/mb2hal/mb2hal.1b/expected

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,39 @@
11
Component Pins:
22
Owner Type Dir Value Name
3-
4 bit OUT FALSE mb2hal.Modbus_fnct_02.00
4-
4 bit OUT FALSE mb2hal.Modbus_fnct_02.01
5-
4 bit OUT FALSE mb2hal.Modbus_fnct_02.02
6-
4 bit OUT FALSE mb2hal.Modbus_fnct_02.03
3+
(ignored comp id) bit OUT FALSE mb2hal.Modbus_fnct_02.00
4+
(ignored comp id) bit OUT FALSE mb2hal.Modbus_fnct_02.01
5+
(ignored comp id) bit OUT FALSE mb2hal.Modbus_fnct_02.02
6+
(ignored comp id) bit OUT FALSE mb2hal.Modbus_fnct_02.03
77

88
Component Pins:
99
Owner Type Dir Value Name
10-
4 float OUT 0 mb2hal.Modbus_fnct_03.00.float
11-
4 s32 OUT 0 mb2hal.Modbus_fnct_03.00.int
12-
4 float OUT 0 mb2hal.Modbus_fnct_03.01.float
13-
4 s32 OUT 0 mb2hal.Modbus_fnct_03.01.int
14-
4 float OUT 0 mb2hal.Modbus_fnct_03.02.float
15-
4 s32 OUT 0 mb2hal.Modbus_fnct_03.02.int
16-
4 float OUT 0 mb2hal.Modbus_fnct_03.03.float
17-
4 s32 OUT 0 mb2hal.Modbus_fnct_03.03.int
10+
(ignored comp id) float OUT 0 mb2hal.Modbus_fnct_03.00.float
11+
(ignored comp id) s32 OUT 0 mb2hal.Modbus_fnct_03.00.int
12+
(ignored comp id) float OUT 0 mb2hal.Modbus_fnct_03.01.float
13+
(ignored comp id) s32 OUT 0 mb2hal.Modbus_fnct_03.01.int
14+
(ignored comp id) float OUT 0 mb2hal.Modbus_fnct_03.02.float
15+
(ignored comp id) s32 OUT 0 mb2hal.Modbus_fnct_03.02.int
16+
(ignored comp id) float OUT 0 mb2hal.Modbus_fnct_03.03.float
17+
(ignored comp id) s32 OUT 0 mb2hal.Modbus_fnct_03.03.int
1818

1919
Component Pins:
2020
Owner Type Dir Value Name
21-
4 float IN 0 mb2hal.Modbus_fnct_06.00
22-
4 float IN 0 mb2hal.Modbus_fnct_06.01
23-
4 float IN 0 mb2hal.Modbus_fnct_06.02
24-
4 float IN 0 mb2hal.Modbus_fnct_06.03
21+
(ignored comp id) float IN 0 mb2hal.Modbus_fnct_06.00
22+
(ignored comp id) float IN 0 mb2hal.Modbus_fnct_06.01
23+
(ignored comp id) float IN 0 mb2hal.Modbus_fnct_06.02
24+
(ignored comp id) float IN 0 mb2hal.Modbus_fnct_06.03
2525

2626
Component Pins:
2727
Owner Type Dir Value Name
28-
4 bit IN FALSE mb2hal.Modbus_fnct_15.00
29-
4 bit IN FALSE mb2hal.Modbus_fnct_15.01
30-
4 bit IN FALSE mb2hal.Modbus_fnct_15.02
31-
4 bit IN FALSE mb2hal.Modbus_fnct_15.03
28+
(ignored comp id) bit IN FALSE mb2hal.Modbus_fnct_15.00
29+
(ignored comp id) bit IN FALSE mb2hal.Modbus_fnct_15.01
30+
(ignored comp id) bit IN FALSE mb2hal.Modbus_fnct_15.02
31+
(ignored comp id) bit IN FALSE mb2hal.Modbus_fnct_15.03
3232

3333
Component Pins:
3434
Owner Type Dir Value Name
35-
4 float IN 0 mb2hal.Modbus_fnct_16.00
36-
4 float IN 0 mb2hal.Modbus_fnct_16.01
37-
4 float IN 0 mb2hal.Modbus_fnct_16.02
38-
4 float IN 0 mb2hal.Modbus_fnct_16.03
35+
(ignored comp id) float IN 0 mb2hal.Modbus_fnct_16.00
36+
(ignored comp id) float IN 0 mb2hal.Modbus_fnct_16.01
37+
(ignored comp id) float IN 0 mb2hal.Modbus_fnct_16.02
38+
(ignored comp id) float IN 0 mb2hal.Modbus_fnct_16.03
3939

0 commit comments

Comments
 (0)