Return-Path: DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=pd/H3MkL+3knMiBFqnGj7FWPDD208UhZONxHe3wF2g0=; b=fgp5Y7fTH+RAZVuk4wmcJk+foGDwWv/wDlxJYQd1QZmlriDizAYtlnAulEHhcGVsh+ ptJgGkIxatui/YpfVULvakFqXLZuGIj+aytDqGpXItFL7BZ8SQMfiwAedwtImjgBVTTB rKtbUqX0nM64S8kMvpTIIVFG640wtKMITupLTmpI2deOLHBhWxp4NtHk5lyShHyT/QDG tQ0oat6ewubEUwe6GKKWQi1zE9jfjJ1bK4k2xZ9rfhdudCGlB45A+nrYndAfLc3/v0HF O4EtIk2ltU8uHE8hLkTVIbKIwUKw102nIAYzsS9z1Y2gGzQQeCXJTyj1bEmqPXg5+EJp V8KQ== From: Rafael Gago Date: Tue, 16 May 2017 13:05:34 +0200 Message-Id: <1494932734-26697-1-git-send-email-rgc@hms.se> Subject: [Fuego] [RFC] tests:serial: Add proof of concept serial test List-Id: Mailing list for the Fuego test framework List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: fuego@lists.linuxfoundation.org Cc: Rafael Gago This test is even simpler than the previous one, as it doesn't require new synchronization primitives at all. --- engine/overlays/base/base-board.fuegoclass | 8 +++ .../Functional.serial_rx/Functional.serial_rx.spec | 12 +++++ engine/tests/Functional.serial_rx/serial_rx.sh | 59 ++++++++++++++++++++++ 3 files changed, 79 insertions(+) create mode 100644 engine/tests/Functional.serial_rx/Functional.serial_rx.spec create mode 100644 engine/tests/Functional.serial_rx/serial_rx.sh diff --git a/engine/overlays/base/base-board.fuegoclass b/engine/overlays/base/base-board.fuegoclass index 6546858..df982b0 100644 --- a/engine/overlays/base/base-board.fuegoclass +++ b/engine/overlays/base/base-board.fuegoclass @@ -80,3 +80,11 @@ function ov_transport_cmd() { ;; esac } + +function ov_board_setup() { + return +} + +function ov_board_teardown() { + return +} \ No newline at end of file diff --git a/engine/tests/Functional.serial_rx/Functional.serial_rx.spec b/engine/tests/Functional.serial_rx/Functional.serial_rx.spec new file mode 100644 index 0000000..dd1c83c --- /dev/null +++ b/engine/tests/Functional.serial_rx/Functional.serial_rx.spec @@ -0,0 +1,12 @@ +{ + "testName": "Functional.serial_rx", + "specs": + [ + { + "name" : "default", + "BAUDRATES" : "9600 115200", + "DUT_SERIAL_DEV" : "/dev/ttyPS0", + "HOST_SERIAL_DEV": "/dev/ttyS0" + } + ] +} diff --git a/engine/tests/Functional.serial_rx/serial_rx.sh b/engine/tests/Functional.serial_rx/serial_rx.sh new file mode 100644 index 0000000..e7855d0 --- /dev/null +++ b/engine/tests/Functional.serial_rx/serial_rx.sh @@ -0,0 +1,59 @@ +#FUEGO_DEBUG=1 + +# Make sure that: +# +# -"getty" is not running on the DUTs port under test. +# -You have the HOST's serial device forwarded to docker (using a privileged +# container created through "docker-create-usb-privileged-container.sh" works) +# -The jenkins user is on the dialout group: +# > "sudo usermod -a -G dialout jenkins", +# you may need to restart the container (logout/login) after adding the user +# to the dialout group. + +function noabort() { + set +e + eval "$@" + RET=$? + set -e + return $RET +} + +function test_build { + true +} + +function test_deploy { + true +} + +function test_run { + assert_define FUNCTIONAL_SERIAL_RX_BAUDRATES + assert_define FUNCTIONAL_SERIAL_RX_DUT_SERIAL_DEV + assert_define FUNCTIONAL_SERIAL_RX_HOST_SERIAL_DEV + + local HOST_DEV=$FUNCTIONAL_SERIAL_RX_HOST_SERIAL_DEV + local DUT_DEV=$FUNCTIONAL_SERIAL_RX_DUT_SERIAL_DEV + local SENDATA="This is a test ASCII string" + + echo -n "$SENDATA" > /tmp/expected + put /tmp/expected /tmp + + for RATE in $FUNCTIONAL_SERIAL_RX_BAUDRATES ; do + 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 + # 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" + done +} + +function test_processing { + log_compare "$TESTDIR" "$(echo "$FUNCTIONAL_SERIAL_RX_BAUDRATES" | wc -w)" "^TEST.*OK" "p" +} + +. $FUEGO_CORE/engine/scripts/functional.sh -- 2.7.4