diff options
author | Ryan Harkin <ryan.harkin@linaro.org> | 2018-04-30 18:04:15 +0100 |
---|---|---|
committer | Ryan Harkin <ryan.harkin@linaro.org> | 2018-05-09 14:15:43 +0100 |
commit | 17bd4efe3e6951bb4c0625216652778f1c2e8f76 (patch) | |
tree | 494473e3b541e4d72b1ceb689bfc45e39c76f8e7 | |
parent | 07876d1db08163150d57815fce82f92499c2a7de (diff) |
badblocks: add new test
Add a new test to run badblocks in read-only mode.
By default, the test will run on the block device where the
rootfs is mounted.
Callers can either set BADBLOCKS_DEVICE variable to test a different
device, or pass the "-d <device>" parameter into badblocks.sh
Additional parameters can also be passed by either setting the
BADBLOCKS_PARAMS variable or passing "-p <params>" to badblocks.sh.
For example, passing the additional parameter "-n" will ask badblocks to
run a read-write test. Note: this will fail is the block device is
mounted, eg. for the rootfs.
Change-Id: Ifa04d78cddb2070110cb7c6eb465f9364f281f6c
Signed-off-by: Ryan Harkin <ryan.harkin@linaro.org>
-rwxr-xr-x | automated/linux/badblocks/badblocks.sh | 53 | ||||
-rw-r--r-- | automated/linux/badblocks/badblocks.yaml | 25 |
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 |