@@ -9,49 +9,47 @@ make BOARD=native PORT=tap0 all -C ./sender
9
9
# Build receiver
10
10
make BOARD=native PORT=tap1 all -C ./receiver
11
11
12
- SESSION_NAME=" federated_coap_test"
13
-
14
- SENDER_EXIT_CODE_TMP_FILE_PATH=/tmp/${SESSION_NAME} _sender_exit_code
15
- RECEIVER_EXIT_CODE_TMP_FILE_PATH=/tmp/${SESSION_NAME} _receiver_exit_code
16
-
17
- # Init error code variables
18
- echo " 1" > $SENDER_EXIT_CODE_TMP_FILE_PATH
19
- echo " 1" > $RECEIVER_EXIT_CODE_TMP_FILE_PATH
20
-
21
- # Run the sender
22
- tmux new-session -d -s " $SESSION_NAME " " bash -c './sender/bin/native/*.elf tap0; echo \$ ? > $SENDER_EXIT_CODE_TMP_FILE_PATH '"
12
+ # Start the sender with a 13-second timeout
13
+ timeout 13 ./sender/bin/native/* .elf tap0 &
14
+ pid1=$!
23
15
16
+ # Wait for 3 seconds
24
17
sleep 3
25
18
26
- # Run the receiver
27
- tmux split-window -h -t $SESSION_NAME " bash -c './receiver/bin/native/*.elf tap1; echo \$ ? > $RECEIVER_EXIT_CODE_TMP_FILE_PATH '"
19
+ # Start the receiver with a 10-second timeout
20
+ timeout 10 ./receiver/bin/native/* .elf tap1 &
21
+ pid2=$!
28
22
23
+ # Wait for both binaries to complete or timeout
24
+ wait $pid1
25
+ exit_code_sender=$?
29
26
30
- # Attach to the tmux session
31
- # Attach to the session for 5 seconds
32
- {
33
- sleep 10 && tmux detach-client -s $SESSION_NAME
34
- } &
35
- tmux attach-session -t $SESSION_NAME
27
+ wait $pid2
28
+ exit_code_receiver=$?
36
29
37
- # Check if the tmux session is still running
38
- if tmux has-session -t $SESSION_NAME ; then
39
- tmux kill-session -t $SESSION_NAME
40
- echo " Error: coap_channel_federated_test timed out"
41
- exit 1
30
+ echo " Test completed"
31
+
32
+ # Check if timeout occurred
33
+ if [ $exit_code_sender -eq 124 ]; then
34
+ echo " Error sender timed out"
35
+ echo " Test failed"
36
+ exit 1
42
37
else
43
- echo " Test completed: tmux session has terminated."
44
- sender_exit_code=$( < " $SENDER_EXIT_CODE_TMP_FILE_PATH " )
45
- receiver_exit_code=$( < " $RECEIVER_EXIT_CODE_TMP_FILE_PATH " )
38
+ echo " Exit code of sender: $exit_code_sender "
39
+ fi
46
40
47
- echo Sender exit code: $sender_exit_code
48
- echo Receiver exit code: $receiver_exit_code
41
+ if [ $exit_code_receiver -eq 124 ]; then
42
+ echo " Error receiver timed out"
43
+ echo " Test failed"
44
+ exit 1
45
+ else
46
+ echo " Exit code of receiver: $exit_code_receiver "
47
+ fi
49
48
50
- if [[ $receiver_exit_code -ne 0 ]] ; then
51
- echo " Error: Receiver received wrong message text "
52
- exit 1
53
- fi
49
+ # Check exit code
50
+ if [[ $exit_code_receiver -ne 0 ]] ; then
51
+ echo " Error: Receiver received wrong message text "
52
+ exit 1
54
53
fi
55
54
56
55
echo " All tests passed."
57
-
0 commit comments