Skip to contentSkip to conversation

Functional.serial_rx: fix errors in test_run

PATCH In review Qiu Tingting 2 participants 2 messages Jul 31, 2018 – Aug 31, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Functional.serial_rx: fix errors in test_run

Details: 1. change non-exist functional.sh to functions.sh
2. calls stty with sudo
3. create new sh file to make sendmessage work
4. delete tmp files on board

---
 engine/tests/Functional.serial_rx/fuego_test.sh | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
engine/tests/Functional.serial_rx/fuego_test.sh +6 -3
index e7855d0..566755b 100644
@@ -39,13 +39,15 @@ function test_run {
 	put /tmp/expected /tmp
 
 	for RATE in $FUNCTIONAL_SERIAL_RX_BAUDRATES ; do
-		stty -F $HOST_DEV $RATE raw -echo -echoe -echok
+		sudo stty -F $HOST_DEV $RATE raw -echo -echoe -echok
 		# Receive for either SENDATA.length or 10 sec.
 		cmd "stty -F $DUT_DEV $RATE raw -echo -echoe -echok min ${#SENDATA} time 100"
 		cmd "nohup cat $DUT_DEV > /tmp/received &"
 		# cmd seems to be returning slightly before the cat starts reading
 		sleep 0.3
-		echo -n "$SENDATA" > $FUNCTIONAL_SERIAL_RX_HOST_SERIAL_DEV
+		echo "echo -n \" $SENDATA\" > $FUNCTIONAL_SERIAL_RX_HOST_SERIAL_DEV" > sendmessage.sh
+		chmod +x sendmessage.sh
+		sudo ./sendmessage.sh
 		# kill "cat" in case that the communication failed.
 		noabort "cmd \"sync ; killall cat\""
 		report_append "diff /tmp/received /tmp/expected && echo TEST-$RATE OK || echo TEST-$RATE FAILED"
@@ -53,7 +55,8 @@ function test_run {
 }
 
 function test_processing {
+	noabort "cmd \"rm /tmp/received ; rm /tmp/expected\""
 	log_compare "$TESTDIR" "$(echo "$FUNCTIONAL_SERIAL_RX_BAUDRATES" | wc -w)" "^TEST.*OK" "p"
 }
 
-. $FUEGO_CORE/engine/scripts/functional.sh
+. $FUEGO_CORE/engine/scripts/functions.sh
Signature · 1 line
2.7.4
#1 lore raw

Please see comments inline below.

One issue with the Subject (patch summary line). Don't use the test type ("Functional" or "Benchmark"), unless the test name by itself is ambiguous. That is, please use "serial_rx: fix errors ..." rather than "Functional.serial_rx: fix errors ..."

I don't have hardware set up in my lab to test this. So please test my changes on your setup, and let me know if there are any problems.

Quoted 19 lines

-----Original Message-----
From: Qiu Tingting

Details: 1. change non-exist functional.sh to functions.sh
2. calls stty with sudo
3. create new sh file to make sendmessage work
4. delete tmp files on board

---
 engine/tests/Functional.serial_rx/fuego_test.sh | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
engine/tests/Functional.serial_rx/fuego_test.sh +0 -0
index e7855d0..566755b 100644

engine/tests/Functional.serial_rx/fuego_test.sh function test_run { · line 42

Quoted 5 lines
engine/tests/Functional.serial_rx/fuego_test.sh +1 -1
@@ -39,13 +39,15 @@ function test_run {
 	put /tmp/expected /tmp
 
 	for RATE in $FUNCTIONAL_SERIAL_RX_BAUDRATES ; do
-		stty -F $HOST_DEV $RATE raw -echo -echoe -echok
+		sudo stty -F $HOST_DEV $RATE raw -echo -echoe -echok

stty should work, if jenkins is in the dialout group inside the container. Did you try this (according to the instructions at the top of the patch)?

I'm going to assume you did. But I'd still like to try the stty and the write to the serial port without sudo. So I modified this to try without 'sudo' first, then if that fails to try the operations using 'sudo'.

Quoted 18 lines
engine/tests/Functional.serial_rx/fuego_test.sh +0 -0
 		# Receive for either SENDATA.length or 10 sec.
 		cmd "stty -F $DUT_DEV $RATE raw -echo -echoe -echok min

${#SENDATA} time 100"

engine/tests/Functional.serial_rx/fuego_test.sh +0 -0
 		cmd "nohup cat $DUT_DEV > /tmp/received &"
 		# cmd seems to be returning slightly before the cat starts

reading

engine/tests/Functional.serial_rx/fuego_test.sh +0 -1
 		sleep 0.3
-		echo -n "$SENDATA" >

$FUNCTIONAL_SERIAL_RX_HOST_SERIAL_DEV

engine/tests/Functional.serial_rx/fuego_test.sh +1 -0
+		echo "echo -n \" $SENDATA\" >

$FUNCTIONAL_SERIAL_RX_HOST_SERIAL_DEV" > sendmessage.sh

engine/tests/Functional.serial_rx/fuego_test.sh +2 -0
+		chmod +x sendmessage.sh
+		sudo ./sendmessage.sh
 		# kill "cat" in case that the communication failed.
 		noabort "cmd \"sync ; killall cat\""
 		report_append "diff /tmp/received /tmp/expected && echo

TEST-$RATE OK || echo TEST-$RATE FAILED"

engine/tests/Functional.serial_rx/fuego_test.sh function test_run { · line 58

Quoted 4 lines
engine/tests/Functional.serial_rx/fuego_test.sh +1 -0
@@ -53,7 +55,8 @@ function test_run {
 }
 
 function test_processing {
+	noabort "cmd \"rm /tmp/received ; rm /tmp/expected\""

This should go into a test_cleanup function, not the test_processing function.

See http://fuegotest.org/wiki/function_test_cleanup

Quoted 6 lines
engine/tests/Functional.serial_rx/fuego_test.sh +0 -0
 	log_compare "$TESTDIR" "$(echo

"$FUNCTIONAL_SERIAL_RX_BAUDRATES" | wc -w)" "^TEST.*OK" "p"
}

-. $FUEGO_CORE/engine/scripts/functional.sh
+. $FUEGO_CORE/engine/scripts/functions.sh

This 'source' is not needed any more, and can be removed completely. (main.sh will source the functions needed from functions.sh and elsewhere)

I applied the patch, but with some changes.
I also removed the test_build and test_deploy functions, as they were just stubs.

Please test my changes, which are now pushed to the master branch, and let me know if there are issues with them.

Thanks,
-- Tim