summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNaresh Kamboju <naresh.kamboju@linaro.org>2017-04-19 14:18:32 +0530
committerNaresh Kamboju <naresh.kamboju@linaro.org>2017-04-20 14:21:16 +0530
commitf6cfea9d1545ae8a4d97996577e5f431bb8745d9 (patch)
tree1eb2e4c390a92388e2bea81c9235fb2c982c09ba
parent6c0718c2a8b06603429b44df2380aca30aa82133 (diff)
automated: linux: Adding I2C testi2c
Signed-off-by: Naresh Kamboju <naresh.kamboju@linaro.org>
-rw-r--r--automated/linux/i2c-test/i2c-test.sh57
-rw-r--r--automated/linux/i2c-test/i2c-test.yaml22
2 files changed, 79 insertions, 0 deletions
diff --git a/automated/linux/i2c-test/i2c-test.sh b/automated/linux/i2c-test/i2c-test.sh
new file mode 100644
index 0000000..6d1c4f2
--- /dev/null
+++ b/automated/linux/i2c-test/i2c-test.sh
@@ -0,0 +1,57 @@
+#!/bin/sh
+
+# shellcheck disable=SC1091
+. ../../lib/sh-test-lib
+OUTPUT="$(pwd)/output"
+RESULT_FILE="${OUTPUT}/result.txt"
+export RESULT_FILE
+
+usage() {
+ echo "Usage: $0 [-s <true|false>]" 1>&2
+ exit 1
+}
+
+while getopts "s:h" o; do
+ case "$o" in
+ s) SKIP_INSTALL="${OPTARG}" ;;
+ h|*) usage ;;
+ esac
+done
+
+install() {
+ dist_name
+ # shellcheck disable=SC2154
+ case "${dist}" in
+ debian|ubuntu)
+ pkgs="arduino-mk arduino i2c-tools git build-essential autoconf automake libtool libsoc-dev"
+ install_deps "${pkgs}" "${SKIP_INSTALL}"
+ ;;
+ fedora|centos)
+ warn_msg "fedora/centos distro: test may fail due to unmet dependency packages"
+ ;;
+ unknown)
+ warn_msg "Unsupported distro: package install skipped and test may fail due to unmet dependency packages"
+ ;;
+ esac
+}
+
+run() {
+ # shellcheck disable=SC2039
+ local test="$1"
+ test_case_id="$(echo "${test}" | awk '{print $1}')"
+ echo
+ info_msg "Running ${test_case_id} test..."
+ eval "${test}"
+ check_return "${test_case_id}"
+}
+
+# Test run.
+create_out_dir "${OUTPUT}"
+
+install
+run "i2cset -y 0 0x62 0 0"
+run "i2cset -y 0 0x62 1 0"
+run "i2cset -y 0 0x62 8 0xaa"
+run "i2cset -y 0 0x62 2 0xff"
+run "i2cset -y 0 0x62 3 0xff"
+run "i2cset -y 0 0x62 4 0xff"
diff --git a/automated/linux/i2c-test/i2c-test.yaml b/automated/linux/i2c-test/i2c-test.yaml
new file mode 100644
index 0000000..542597d
--- /dev/null
+++ b/automated/linux/i2c-test/i2c-test.yaml
@@ -0,0 +1,22 @@
+metadata:
+ name: i2c-test
+ format: "Lava-Test-Shell Test Definition 1.0"
+ description: "Run I2C test suite on Debian/Ubuntu"
+ maintainer:
+ - naresh.kamboju@linaro.org
+ os:
+ - debian
+ - ubuntu
+ scope:
+ - functional
+ devices:
+ - hi6220-hikey
+ - apq8016-sbc
+params:
+ SKIP_INSTALL: false
+
+run:
+ steps:
+ - cd ./automated/linux/i2c-test/
+ - ./i2c-test.sh -s "${SKIP_INSTALL}"
+ - ../../utils/send-to-lava.sh ./output/result.txt