summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChase Qi <chase.qi@linaro.org>2018-05-09 13:44:12 +0000
committerLinaro Code Review <review@review.linaro.org>2018-05-09 13:44:12 +0000
commit2d1650408af7ef16a5c114a158f422dd08fc030c (patch)
tree717722ae1e5004d37ad693f80772d38959d21c23
parentacbcd28e8e6faab5ad4c9e0682bb80b05b06ee9b (diff)
parent17bd4efe3e6951bb4c0625216652778f1c2e8f76 (diff)
Merge "badblocks: add new test"
-rwxr-xr-xautomated/linux/badblocks/badblocks.sh53
-rw-r--r--automated/linux/badblocks/badblocks.yaml25
2 files changed, 78 insertions, 0 deletions
diff --git a/automated/linux/badblocks/badblocks.sh b/automated/linux/badblocks/badblocks.sh
new file mode 100755
index 0000000..0698df1
--- /dev/null
+++ b/automated/linux/badblocks/badblocks.sh
@@ -0,0 +1,53 @@
+#!/bin/sh
+
+# shellcheck disable=SC1091
+. ../../lib/sh-test-lib
+OUTPUT="$(pwd)/output"
+RESULT_FILE="${OUTPUT}/result.txt"
+export RESULT_FILE
+TEST_SUITE="badblocks"
+BLOCK_DEVICE="default"
+
+usage() {
+ echo "Usage: $0 [-b <block device>] [-p <badblocks params>] [-s <skip install: true|false]" 1>&2
+ exit 1
+}
+
+while getopts "b:h:p:s:" o; do
+ case "$o" in
+ b) BLOCK_DEVICE="${OPTARG}" ;;
+ p) BADBLOCKS_PARAMS="${OPTARG}" ;;
+ s) SKIP_INSTALL="${OPTARG}" ;;
+ h|*) usage ;;
+ esac
+done
+
+install() {
+ dist_name
+ # shellcheck disable=SC2154
+ case "${dist}" in
+ debian|ubuntu) install_deps "e2fsprogs" "${SKIP_INSTALL}";;
+ unknown) warn_msg "Unsupported distro: package install skipped" ;;
+ esac
+}
+
+if [ "${BLOCK_DEVICE}" = "default" ]; then
+ BLOCK_DEVICE=$(mount | grep "on \/ type" | cut -d' ' -f 1)
+fi
+
+create_out_dir "${OUTPUT}"
+install
+
+command -v badblocks
+exit_on_fail "badblocks-existence-check"
+
+if [ ! -z "${BLOCK_DEVICE}" ] && [ -e "${BLOCK_DEVICE}" ]; then
+ info_msg "Running ${TEST_SUITE} test on ${BLOCK_DEVICE}"
+ LOG_FILE="${OUTPUT}/${TEST_SUITE}-output.txt"
+ test_cmd="badblocks -v ${BADBLOCKS_PARAMS} ${BLOCK_DEVICE} 2>&1"
+ pipe0_status "${test_cmd}" "tee ${LOG_FILE}"
+ check_return "${TEST_SUITE}"
+else
+ info_msg "Skipping ${TEST_SUITE} test on ${BLOCK_DEVICE}"
+ echo "${TEST_SUITE} skip" | tee -a "${RESULT_FILE}"
+fi
diff --git a/automated/linux/badblocks/badblocks.yaml b/automated/linux/badblocks/badblocks.yaml
new file mode 100644
index 0000000..99eec2f
--- /dev/null
+++ b/automated/linux/badblocks/badblocks.yaml
@@ -0,0 +1,25 @@
+metadata:
+ name: badblocks
+ format: "Lava-Test-Shell Test Definition 1.0"
+ description: "Run a read-only test for bad blocks"
+ maintainer:
+ - ryan.harkin@linaro.org
+ os:
+ - openembedded
+ - debian
+ scope:
+ - functional
+ devices:
+ - imx7s-warp
+ - sun8i-h2-plus-bananapi-m2-zero
+
+parameters:
+ BLOCK_DEVICE: 'default'
+ BADBLOCKS_PARAMS: ''
+ SKIP_INSTALL: "False"
+
+run:
+ steps:
+ - cd ./automated/linux/badblocks/
+ - ./badblocks.sh -b "${BLOCK_DEVICE}" -p "${BADBLOCKS_PARAMS}" -s "${SKIP_INSTALL}"
+ - ../../utils/send-to-lava.sh ./output/result.txt