sigwaittest: Test sigwait() latency

Add sigwaittest from the rt-tests suite (>= v1.4).

The x86_64 and armeabi architecture binaries are build using a Debian
stretch root filesystem.

arm64 binaries were build using a Debian buster root filesystem.

The command to build the binaries is: "CLFAGS=-static make"

Signed-off-by: Daniel Wagner <wagi@monom.org>
diff --git a/automated/linux/sigwaittest/bin/README b/automated/linux/sigwaittest/bin/README
new file mode 100644
index 0000000..faa30d3
--- /dev/null
+++ b/automated/linux/sigwaittest/bin/README
@@ -0,0 +1,6 @@
+The binaries are provided under the terms of the GNU General Public License,
+Version 2. The source can be viewed here:
+
+https://git.kernel.org/cgit/utils/rt-tests/rt-tests.git/
+
+The binaries were built from the v1.4 tag
diff --git a/automated/linux/sigwaittest/bin/arm64/sigwaittest b/automated/linux/sigwaittest/bin/arm64/sigwaittest
new file mode 100755
index 0000000..ead0ee0
--- /dev/null
+++ b/automated/linux/sigwaittest/bin/arm64/sigwaittest
Binary files differ
diff --git a/automated/linux/sigwaittest/bin/armeabi/sigwaittest b/automated/linux/sigwaittest/bin/armeabi/sigwaittest
new file mode 100755
index 0000000..fa936ab
--- /dev/null
+++ b/automated/linux/sigwaittest/bin/armeabi/sigwaittest
Binary files differ
diff --git a/automated/linux/sigwaittest/bin/x86_64/sigwaittest b/automated/linux/sigwaittest/bin/x86_64/sigwaittest
new file mode 100755
index 0000000..65023ed
--- /dev/null
+++ b/automated/linux/sigwaittest/bin/x86_64/sigwaittest
Binary files differ
diff --git a/automated/linux/sigwaittest/sigwaittest.sh b/automated/linux/sigwaittest/sigwaittest.sh
new file mode 100755
index 0000000..ac6c2ae
--- /dev/null
+++ b/automated/linux/sigwaittest/sigwaittest.sh
@@ -0,0 +1,44 @@
+#!/bin/sh -e
+# shellcheck disable=SC1090
+# shellcheck disable=SC2154
+# sigwaittest starts two threads or, optionally, forks two processes that
+# are synchronized via signals and measures the latency between sending
+# a signal and returning from sigwait()
+
+TEST_DIR=$(dirname "$(realpath "$0")")
+OUTPUT="${TEST_DIR}/output"
+LOGFILE="${OUTPUT}/sigwaittest.log"
+RESULT_FILE="${OUTPUT}/result.txt"
+DURATION="5m"
+MAX_LATENCY="100"
+
+usage() {
+    echo "Usage: $0 [-D duration] [-m latency]" 1>&2
+    exit 1
+}
+
+while getopts ":D:m:" opt; do
+    case "${opt}" in
+        D) DURATION="${OPTARG}" ;;
+	m) MAX_LATENCY="${OPTARG}" ;;
+        *) usage ;;
+    esac
+done
+
+. "${TEST_DIR}/../../lib/sh-test-lib"
+
+! check_root && error_msg "Please run this script as root."
+create_out_dir "${OUTPUT}"
+
+# Run sigwaittest.
+if ! binary=$(command -v sigwaittest); then
+    detect_abi
+    # shellcheck disable=SC2154
+    binary="./bin/${abi}/sigwaittest"
+fi
+
+"${binary}" -t -a -p 98 -D "${DURATION}" | tee "${LOGFILE}"
+
+# Parse test log.
+../../lib/parse_rt_tests_results.py sigwaittest "${LOGFILE}" "${MAX_LATENCY}" \
+    | tee -a "${RESULT_FILE}"
diff --git a/automated/linux/sigwaittest/sigwaittest.yaml b/automated/linux/sigwaittest/sigwaittest.yaml
new file mode 100644
index 0000000..62edc3d
--- /dev/null
+++ b/automated/linux/sigwaittest/sigwaittest.yaml
@@ -0,0 +1,41 @@
+metadata:
+    name: sigwaittest
+    format: "Lava-Test-Shell Test Definition 1.0"
+    description: "sigwaittest starts two threads or, optionally, forks
+                  two processes that are synchronized via signals and
+                  measures the latency between sending a signal and
+                  returning from sigwait()."
+    maintainer:
+        - Daniel Wagner <wagi@monom.org>
+    os:
+        - debian
+        - ubuntu
+        - centos
+        - fedora
+        - openembedded
+    scope:
+        - performance
+        - preempt-rt
+    environment:
+        - lava-test-shell
+    devices:
+        - hi6220-hikey
+        - apq8016-sbc
+        - mustang
+        - moonshot
+        - thunderX
+        - d03
+        - d05
+
+params:
+    # Execute sigwaittest for given time
+    DURATION: "5m"
+    # Maximal accepted latency in us
+    # This value is device/kernel specific and needs to be set in the job!
+    MAX_LATENCY: "100"
+
+run:
+    steps:
+        - cd ./automated/linux/sigwaittest/
+        - ./sigwaittest.sh -D "${DURATION}" -m "${MAX_LATENCY}"
+        - ../../utils/send-to-lava.sh ./output/result.txt