diff options
author | Ryan Harkin <ryan.harkin@linaro.org> | 2020-03-02 11:33:05 +0000 |
---|---|---|
committer | Ryan Harkin <ryan.harkin@linaro.org> | 2021-02-02 12:04:21 +0000 |
commit | 99a3b00978b12fa3a78bd682a6a84064a5ca7811 (patch) | |
tree | b8da670cd0e74e1db483630e321bf65624a97d4e | |
parent | c77a30735ba2877d09786e1271b9e1cfd35a5b0b (diff) |
files-exist test added
Often, it is useful to check if files exist on the board, for example,
before running certain tests, to make sure that the driver is
detecting hardware, or to check the kernel is configured
correctly.
No effort is made to ensure that a file is a character, network or block
device.
In the SE case, we want to make sure that certain device nodes exist,
for example. This test contains knowledge of SE specific files and
device nodes across boards and kernel versions.
The caller can augment the list of files by passing in the -e parameter
with a list of additional files.
The list of filenames to be checked is stored in machine and kernel
specific .lst files within the test folder.
Signed-off-by: Ryan Harkin <ryan.harkin@linaro.org>
-rwxr-xr-x | automated/linux/files-exist/files-exist.sh | 88 | ||||
-rw-r--r-- | automated/linux/files-exist/files-exist.yaml | 21 | ||||
-rw-r--r-- | automated/linux/files-exist/lces2-4.19.lst | 1 | ||||
-rw-r--r-- | automated/linux/files-exist/lces2-4.9.lst | 1 | ||||
l--------- | automated/linux/files-exist/lces2-5.4.lst | 1 | ||||
-rw-r--r-- | automated/linux/files-exist/lces2.lst | 21 | ||||
-rw-r--r-- | automated/linux/files-exist/soca9-4.19.lst | 1 | ||||
-rw-r--r-- | automated/linux/files-exist/soca9-4.9.lst | 1 | ||||
l--------- | automated/linux/files-exist/soca9-5.4.lst | 1 | ||||
-rw-r--r-- | automated/linux/files-exist/soca9.lst | 10 |
10 files changed, 146 insertions, 0 deletions
diff --git a/automated/linux/files-exist/files-exist.sh b/automated/linux/files-exist/files-exist.sh new file mode 100755 index 0000000..9b1609e --- /dev/null +++ b/automated/linux/files-exist/files-exist.sh @@ -0,0 +1,88 @@ +#!/bin/sh +# shellcheck disable=SC1091 + +OUTPUT="$(pwd)/output" +RESULT_FILE="${OUTPUT}/result.txt" + +. ../../lib/sh-test-lib + +create_out_dir "${OUTPUT}" + +usage() { + echo "Usage: $0 [-e <extra files>]" 1>&2 + exit 1 +} + +while getopts "e:h:s" o; do + case "$o" in + e) EXTRA_FILES="${OPTARG}" ;; + h|*) usage ;; + esac +done + +############### +# Generic files +############### +filelist=" \ + /dev/urandom \ + /dev/null \ + /dev/zero \ +" + +file_exists() +{ + file=$1 + if [ -e "${file}" ]; then + result="PASS" + else + result="FAIL" + fi + echo "file_exists_$file ${result}" | sed 'sX/X_Xg' | tee -a "${RESULT_FILE}" +} + +check_file_list() +{ + filelist="$*" + for file in ${filelist}; do + file_exists "$file" + done +} + +add_to_list() +{ + file="${1}".lst + + if [ -e "${file}" ]; then + newfilelist=$(cat "${file}") + filelist="${filelist} ${newfilelist}" + fi +} + +files_exist() +{ + kernel_version="$(uname -a | awk '{print $3}' | awk -F. '{print $1"."$2}')" + model="unknown" + model_file=/proc/device-tree/model + + if [ -e "${model_file}" ]; then + model=$(tr -d '\0' </proc/device-tree/model) + fi + case "${model}" in + *"RZ/N1D"*) + machine=lces2 + ;; + *"SOCA9"*) + machine=soca9 + ;; + *) + machine=unknown + ;; + esac + + add_to_list "${machine}" + add_to_list "${machine}-${kernel_version}" + filelist="${filelist} ${EXTRA_FILES}" + check_file_list "${filelist}" +} + +files_exist diff --git a/automated/linux/files-exist/files-exist.yaml b/automated/linux/files-exist/files-exist.yaml new file mode 100644 index 0000000..f5b21d1 --- /dev/null +++ b/automated/linux/files-exist/files-exist.yaml @@ -0,0 +1,21 @@ +metadata: + name: meminfo + format: "Lava-Test-Shell Test Definition 1.0" + description: "Check files exist" + maintainer: + - ryan.harkin@linaro.org + os: + - oe + scope: + - functional + devices: + - rzn1d + +params: + EXTRA_FILES: '/dev/random' + +run: + steps: + - cd ./automated/linux/files-exist + - ./files-exist.sh -e "${EXTRA_FILES}" + - ../../utils/send-to-lava.sh ./output/result.txt diff --git a/automated/linux/files-exist/lces2-4.19.lst b/automated/linux/files-exist/lces2-4.19.lst new file mode 100644 index 0000000..cc91bb4 --- /dev/null +++ b/automated/linux/files-exist/lces2-4.19.lst @@ -0,0 +1 @@ +/sys/bus/spi/devices/spi0.1/eeprom diff --git a/automated/linux/files-exist/lces2-4.9.lst b/automated/linux/files-exist/lces2-4.9.lst new file mode 100644 index 0000000..ad4ba7f --- /dev/null +++ b/automated/linux/files-exist/lces2-4.9.lst @@ -0,0 +1 @@ +/sys/bus/spi/devices/spi32766.1/eeprom diff --git a/automated/linux/files-exist/lces2-5.4.lst b/automated/linux/files-exist/lces2-5.4.lst new file mode 120000 index 0000000..d459da2 --- /dev/null +++ b/automated/linux/files-exist/lces2-5.4.lst @@ -0,0 +1 @@ +lces2-4.19.lst
\ No newline at end of file diff --git a/automated/linux/files-exist/lces2.lst b/automated/linux/files-exist/lces2.lst new file mode 100644 index 0000000..488a4b7 --- /dev/null +++ b/automated/linux/files-exist/lces2.lst @@ -0,0 +1,21 @@ +/dev/ttyS1 +/dev/watchdog +/dev/mmcblk0 +/dev/mmcblk0p2 +/sys/class/hwmon/hwmon0/temp1_input +/sys/devices/system/clocksource/clocksource0/available_clocksource +/dev/i2c-1 +/dev/mtd1 +/dev/mtd9 +/dev/ubi_ctrl +/sys/class/leds/pl_gpio13/trigger +/sys/class/leds/pl_gpio13/brightness +/sys/class/leds/pl_gpio14/trigger +/sys/class/leds/pl_gpio14/brightness +/sys/class/leds/pl_gpio17/trigger +/sys/class/leds/pl_gpio17/brightness +/sys/class/leds/pl_gpio18/trigger +/sys/class/leds/pl_gpio18/brightness +/sys/kernel/debug/clk/clk_summary +/sys/kernel/rzn1/clk_set_rate +/sys/bus/i2c/devices/1-0050/eeprom diff --git a/automated/linux/files-exist/soca9-4.19.lst b/automated/linux/files-exist/soca9-4.19.lst new file mode 100644 index 0000000..fd73978 --- /dev/null +++ b/automated/linux/files-exist/soca9-4.19.lst @@ -0,0 +1 @@ +/sys/bus/spi/devices/spi0.0/eeprom diff --git a/automated/linux/files-exist/soca9-4.9.lst b/automated/linux/files-exist/soca9-4.9.lst new file mode 100644 index 0000000..c6412be --- /dev/null +++ b/automated/linux/files-exist/soca9-4.9.lst @@ -0,0 +1 @@ +/sys/bus/spi/devices/spi32766.0/eeprom diff --git a/automated/linux/files-exist/soca9-5.4.lst b/automated/linux/files-exist/soca9-5.4.lst new file mode 120000 index 0000000..4c9bede --- /dev/null +++ b/automated/linux/files-exist/soca9-5.4.lst @@ -0,0 +1 @@ +soca9-4.19.lst
\ No newline at end of file diff --git a/automated/linux/files-exist/soca9.lst b/automated/linux/files-exist/soca9.lst new file mode 100644 index 0000000..0f46a78 --- /dev/null +++ b/automated/linux/files-exist/soca9.lst @@ -0,0 +1,10 @@ +/dev/ttyS1 +/dev/watchdog +/dev/mmcblk0 +/dev/mmcblk0p2 +/sys/class/hwmon/hwmon0/temp1_input +/sys/devices/system/clocksource/clocksource0/available_clocksource +/dev/i2c-0 +/dev/mtd0 +/dev/mtd2 +/sys/bus/i2c/devices/0-0050/eeprom |