diff options
author | Ryan Harkin <ryan.harkin@linaro.org> | 2020-07-14 15:47:24 +0100 |
---|---|---|
committer | Ryan Harkin <ryan.harkin@linaro.org> | 2020-09-25 10:02:04 +0100 |
commit | 9e9a71cba1ec2c20f4ca719e962caa9fa8ec74b9 (patch) | |
tree | 265c276f5ac9689893c1428f1b44a3d30e92bc75 | |
parent | b3533677aa6dd75cf984e3fbb41780e1fbe80889 (diff) |
eeprom test added
Add a test to write data to an EEPROM device.
Accesses are a subset of standard file operations.
This test deprecates manual tests TB39 and TC24 which test the SPI
EEPROM on soca9 and lces2.
Signed-off-by: Ryan Harkin <ryan.harkin@linaro.org>
-rwxr-xr-x | automated/linux/eeprom/eeprom.sh | 153 | ||||
-rw-r--r-- | automated/linux/eeprom/eeprom.yaml | 23 | ||||
-rw-r--r-- | manual/se/tb39.yaml | 22 | ||||
-rw-r--r-- | manual/se/tc24.yaml | 44 | ||||
-rw-r--r-- | plans/se-auto.yaml | 22 |
5 files changed, 194 insertions, 70 deletions
diff --git a/automated/linux/eeprom/eeprom.sh b/automated/linux/eeprom/eeprom.sh new file mode 100755 index 0000000..e5a470c --- /dev/null +++ b/automated/linux/eeprom/eeprom.sh @@ -0,0 +1,153 @@ +#!/bin/sh + +OUTPUT="$(pwd)/output" +RESULT_FILE="${OUTPUT}/result.txt" +EEPROM="/sys/bus/spi/devices/spi0.1/eeprom" +BLOCK_COUNT=128 +BLOCK_SIZE=1024 + +. ../../lib/sh-test-lib + +create_out_dir "${OUTPUT}" + +usage() { + echo "Usage: $0 [-e <eeprom_device>] [-s <skip install: true|false]" 1>&2 + exit 1 +} + +while getopts "b:c:e:h:s" o; do + case "$o" in + b) BLOCK_SIZE="${OPTARG}" ;; + c) BLOCK_COUNT="${OPTARG}" ;; + e) EEPROM="${OPTARG}" ;; + s) SKIP_INSTALL="${OPTARG}" ;; + h|*) usage ;; + esac +done + + + +################################################################################ +# Data Test +################################################################################ +data_test () { + local count=$1 + local bs=$2 + local pattern=$3 + local tmpfile=$(mktemp "/tmp/eeprom.XXXXXXXXXXXX") + + case ${pattern} in + "0" | "00" | "zero" | "zeros") + str="all zeros" + # Generate random data + dd if=/dev/zero count=1 bs=${bs} of=${tmpfile} 2> /dev/null + ;; + "ff" | "FF") + str="all ones" + dd if=/dev/zero count=1 bs=${bs} 2> /dev/null | tr '\000' '\377' > ${tmpfile} # 377 octal = 0xFF + ;; + "55") + str="all 5s" + dd if=/dev/zero count=1 bs=${bs} 2> /dev/null | tr '\000' '\125' > ${tmpfile} # 125 octal = 0x55 + ;; + "aa" | "AA") + str="all As" + dd if=/dev/zero count=1 bs=${bs} 2> /dev/null | tr '\000' '\252' > ${tmpfile} # 252 octal = 0xAA + ;; + *) + str="random data" + # Generate random data + dd if=/dev/urandom of=${tmpfile} count=1 bs=${bs} 2> /dev/null + ;; + esac + + if [ "${VERBOSE}" = "1" ]; then + echo "Testing write/read of ${bs} bytes of ${str} to SPI EEPROM..." + cat ${tmpfile} | head -c ${bs} | hexdump -v -C ${tmpfile} + echo VERBOSE=${VERBOSE} + fi + + # Write an exact amount of data + dd if=${tmpfile} of=${EEPROM} count=1 bs=${bs} 2> /dev/null + + # Read an exact amount of data + dd if=${EEPROM} of=${tmpfile}.read count=1 bs=${bs} 2> /dev/null + + cmp ${tmpfile} ${tmpfile}.read && result="pass" || result="fail" + + if [ "${result}" = "fail" ]; then + echo "write-data failed when writing ${count} blocks of ${bs} bytes of ${str} to ${EEPROM}" + fi + rm ${tmpfile}* +} + +################################################################################ +# Check device exists +################################################################################ +echo "Check EEPROM device ${EEPROM} exists before running tests..." +if [ -e ${EEPROM} ]; then + result="pass" +else + result="fail" +fi +echo "eeprom-device-exists ${result}" | tee -a ${RESULT_FILE} + + +################################################################################ +# Test access using standard data access method +################################################################################ +if [ "${result}" = "pass" ]; then + echo "Test EEPROM read/write using standard file access..." + + # Target corner cases + for size in `seq 1 33` `seq 4089 4096`; do + echo -n "With block size: ${size} pattern: " + for pattern in 00 55 AA FF random; do + echo -n "${pattern} " + if [ "${result}" = "pass" ]; then + data_test 1 ${size} ${pattern} + fi + done + echo "" + done + echo "" + echo "eeprom-data-access ${result}" | tee -a ${RESULT_FILE} +fi + + +################################################################################ +# Try filling the device +################################################################################ +if [ "${result}" = "pass" ]; then + echo "Test we can write to the entire device of ${BLOCK_COUNT} blocks of ${BLOCK_SIZE} bytes" + echo -n "With pattern: " + + for pattern in 00 55 AA FF random; do + if [ "${result}" = "pass" ]; then + echo -n "${pattern} " + data_test ${BLOCK_COUNT} ${BLOCK_SIZE} ${pattern} + fi + done + echo "" + echo "eeprom-fill ${result}" | tee -a ${RESULT_FILE} +fi + + +################################################################################ +# Test access using standard file operations like "echo" and "cat" +################################################################################ +if [ "${result}" = "pass" ]; then + echo "Test string access works..." + + out=" SPI EEPROM test" + len=$(expr ${#out} + 16) # pad out the amount of data by an arbitrary amount + + # First blank the start of the device + data_test 1 ${len} 00 + + echo "${out}" > ${EEPROM} + in=$(cat ${EEPROM} | head -c ${len} | tr -d '\000') + + [ "${in}" = "${out}" ] && result=pass || result=fail + echo "eeprom-string-access ${result}" | tee -a ${RESULT_FILE} +fi diff --git a/automated/linux/eeprom/eeprom.yaml b/automated/linux/eeprom/eeprom.yaml new file mode 100644 index 0000000..788340f --- /dev/null +++ b/automated/linux/eeprom/eeprom.yaml @@ -0,0 +1,23 @@ +metadata: + name: meminfo + format: "Lava-Test-Shell Test Definition 1.0" + description: "Schneider Electric EEPROM test" + maintainer: + - ryan.harkin@linaro.org + os: + - oe + scope: + - functional + devices: + - rzn1d + +params: + EEPROM: '/sys/bus/spi/devices/spi0.1/eeprom' + BLOCK_SIZE: 1024 + BLOCK_COUNT: 128 + +run: + steps: + - cd ./automated/linux/eeprom + - ./eeprom.sh -e "${EEPROM}" -b ${BLOCK_SIZE} -c ${BLOCK_COUNT} + - ../../utils/send-to-lava.sh ./output/result.txt diff --git a/manual/se/tb39.yaml b/manual/se/tb39.yaml deleted file mode 100644 index 496415d..0000000 --- a/manual/se/tb39.yaml +++ /dev/null @@ -1,22 +0,0 @@ -metadata: - name: TB39 - format: "Manual Test Definition 1.0" - description: "TB39: SPI EEPROM (FRAM)" - maintainer: - - ryan.harkin@linaro.org - os: - - openembedded - scope: - - functional - devices: - - lces2 - - soca9 - environment: - - manual-test - -run: - steps: - - "Run tc24" - - expected: - - "Same result as tc24" diff --git a/manual/se/tc24.yaml b/manual/se/tc24.yaml deleted file mode 100644 index 819cfa2..0000000 --- a/manual/se/tc24.yaml +++ /dev/null @@ -1,44 +0,0 @@ -metadata: - name: TC24 - format: "Manual Test Definition 1.0" - description: "TC24: SPI EEPROM (FRAM)" - maintainer: - - ryan.harkin@linaro.org - os: - - openembedded - scope: - - functional - devices: - - lces2 - - soca9 - environment: - - manual-test - -run: - steps: - - "#soca9: ok" - - "# 4.9:" - - "FRAM=/sys/bus/spi/devices/spi32766.0/eeprom" - - "# 4.19:" - - "FRAM=/sys/bus/spi/devices/spi0.0/eeprom" - - " " - - "#lces2: ok" - - "# 4.9:" - - "FRAM=/sys/bus/spi/devices/spi32766.1/eeprom" - - "# 4.19:" - - "FRAM=/sys/bus/spi/devices/spi0.1/eeprom" - - " " - - "cd test-scripts" - - ". ./check_devices.sh" - - "device_exists $FRAM" - - " " - - "dd if=/dev/zero of=$FRAM count=16 bs=1" - - "cat $FRAM | hexdump -v -C | head -5" - - "echo \" SPI EEPROM test\" > $FRAM" - - "cat $FRAM | hexdump -v -C | head -5" - - " " - - "# Then run the SPI test case script" - - "FRAM=$FRAM ./spi/test-spi-fram.sh" - - expected: - - "SPI test returns pass" diff --git a/plans/se-auto.yaml b/plans/se-auto.yaml index a6e1e67..4e50ddf 100644 --- a/plans/se-auto.yaml +++ b/plans/se-auto.yaml @@ -141,8 +141,22 @@ tests: branch: linaro path: automated/linux/optee/optee-xtest.yaml + - name: spi-eeprom-lces2 + from: git + history: false + repository: https://github.com/omnium21/test-definitions.git + branch: linaro + path: automated/linux/eeprom/eeprom.yaml + parameters: + SKIP_INSTALL: 'true' + EEPROM: '/sys/bus/spi/devices/spi0.1/eeprom' - - - - + - name: spi-eeprom-soca9 + from: git + history: false + repository: https://github.com/omnium21/test-definitions.git + branch: linaro + path: automated/linux/eeprom/eeprom.yaml + parameters: + SKIP_INSTALL: 'true' + EEPROM: '/sys/bus/spi/devices/spi0.0/eeprom' |