From 6da9d81e77b2f56a91a697ac474473e787a58ccf Mon Sep 17 00:00:00 2001 From: Bogdan Oprescu Date: Wed, 15 Nov 2023 11:09:08 +0200 Subject: T1042RDB: Adding ddt tests Signed-off-by: Bogdan Oprescu --- .../ddt-runner/files/scripts/t1042rdb/ethernet | 83 ++++++++++++++++ .../ddt-runner/files/scripts/t1042rdb/flash | 49 +++++++++ recipes-test/ddt-runner/files/scripts/t1042rdb/i2c | 43 ++++++++ .../ddt-runner/files/scripts/t1042rdb/pci-express | 109 +++++++++++++++++++++ .../ddt-runner/files/scripts/t1042rdb/sata | 86 ++++++++++++++++ .../ddt-runner/files/scripts/t1042rdb/sdhc | 42 ++++++++ recipes-test/ddt-runner/files/scripts/t1042rdb/spi | 35 +++++++ recipes-test/ddt-runner/files/scripts/t1042rdb/usb | 48 +++++++++ .../ddt-runner/files/scripts/t1042rdb/watchdog | 93 ++++++++++++++++++ 9 files changed, 588 insertions(+) create mode 100755 recipes-test/ddt-runner/files/scripts/t1042rdb/ethernet create mode 100755 recipes-test/ddt-runner/files/scripts/t1042rdb/flash create mode 100755 recipes-test/ddt-runner/files/scripts/t1042rdb/i2c create mode 100755 recipes-test/ddt-runner/files/scripts/t1042rdb/pci-express create mode 100755 recipes-test/ddt-runner/files/scripts/t1042rdb/sata create mode 100755 recipes-test/ddt-runner/files/scripts/t1042rdb/sdhc create mode 100755 recipes-test/ddt-runner/files/scripts/t1042rdb/spi create mode 100755 recipes-test/ddt-runner/files/scripts/t1042rdb/usb create mode 100755 recipes-test/ddt-runner/files/scripts/t1042rdb/watchdog diff --git a/recipes-test/ddt-runner/files/scripts/t1042rdb/ethernet b/recipes-test/ddt-runner/files/scripts/t1042rdb/ethernet new file mode 100755 index 0000000..107d102 --- /dev/null +++ b/recipes-test/ddt-runner/files/scripts/t1042rdb/ethernet @@ -0,0 +1,83 @@ +#!/bin/sh + +ethernet_interface="eth3" +ethernet_ping_ipaddr="172.21.3.22" +ethernet_ipaddr=$1 + +IFCONFIG=`which ifconfig` + +$IFCONFIG $ethernet_interface up > /dev/null 2>&1 +$IFCONFIG | grep $ethernet_interface > /dev/null 2>&1 +if [ $? -ne 0 ]; then + echo "FAIL: $ethernet_interface is not up" + exit 1 +else + echo "PASS: $ethernet_interface is up" +fi + +if [ "x$ethernet_ipaddr" != "x" ]; then + $IFCONFIG $ethernet_interface $ethernet_ipaddr +fi + +$IFCONFIG $ethernet_interface |grep 'inet addr:' |sed -e 's@inet addr:@@' |sed q | awk '{print $1}' >/dev/null 2>&1 +if [ $? -ne 0 ]; then + echo "FAIL: setup $ethernet_interface ipaddr failed" + exit 1 +else + echo "PASS: setup $ethernet_interface ipaddr succeeded" +fi + +mindatasize=56 +maxdatasize=650 +stepsize=100 +iteration=1 +datasize=$mindatasize +logfile=`/bin/mktemp` +statistics=`/bin/mktemp` +error=0 + +trap cleanup SIGHUP SIGINT SIGTERM + +clean_tasks() { + rm -f $logfile $statistics +} + +cleanup() { + echo "Aborting script execution" + clean_tasks + exit 0 +} + +while [ $datasize -le $maxdatasize ]; do + for i in `seq 1 $iteration`; do + ping -c 1 -s $datasize $ethernet_ping_ipaddr > $statistics + ping_err=$? + cat $statistics | grep "PING" > /dev/null 2>&1 + cat $statistics | grep "received" > /dev/null 2>&1 + [ `echo $?` -eq 0 ] || packets_received=0 && \ + packets_received=`cat $statistics | \ + grep "received" | awk '{print$4}'` + + # Evaluate possible errors on the ping operation + if [ $ping_err -ne 0 ] || [ $packets_received -eq 0 ]; then + error=1 + echo -e `cat $statistics | grep PING` >> $logfile 2>/dev/null + fi + done + let datasize=$datasize+$stepsize +done + +# Report failures +if [ $error -eq 1 ]; then + echo "=================== error report ===================" + cat $logfile + echo "====================================================" + clean_tasks + echo -e "FAIL: $ethernet_interface test failed\n" + exit 1 +else + clean_tasks + echo -e "PASS: $ethernet_interface test passed" +fi + +exit 0 diff --git a/recipes-test/ddt-runner/files/scripts/t1042rdb/flash b/recipes-test/ddt-runner/files/scripts/t1042rdb/flash new file mode 100755 index 0000000..dffac6b --- /dev/null +++ b/recipes-test/ddt-runner/files/scripts/t1042rdb/flash @@ -0,0 +1,49 @@ +#!/bin/sh +# +# This script is used to test flash driver functionality. I removed the write +# operations since all partition are in use in p2041rdb and there might be +# possibility of corrupting data even if we backup in test script. + +if part_num=`cat /proc/mtd | grep -c 'mtd'`; then + echo "PASS: show $part_num partitions" +else + echo "FAIL: show $part_num partitions" + exit 1 +fi + +for((part=0; part<$part_num; part++)); +do + if [ $(mtd_debug info /dev/mtd$part | grep -c 'mtd.type') ]; then + echo "PASS: show partition $part debug info" + else + echo "FAIL: show partition $part debug info" + exit 1 + fi +done + +READ_TEST=`find / -name mtd_readtest.ko -print` + +if [ ! -e $READ_TEST ]; then + echo "FAIL: $READ_TEST does not exist" + exit 1 +else + echo "PASS: $READ_TEST exists" +fi + +for((part=0; part<$part_num; part++)); +do + dmesg -c + + insmod $READ_TEST dev=$part + + finish=`dmesg | grep -c 'mtd_readtest: finished'` + if [ $finish -eq 1 ]; then + echo "PASS: read test $part" + else + echo "FAIL: read test $part" + rmmod $READ_TEST + exit 1 + fi + + rmmod $READ_TEST +done diff --git a/recipes-test/ddt-runner/files/scripts/t1042rdb/i2c b/recipes-test/ddt-runner/files/scripts/t1042rdb/i2c new file mode 100755 index 0000000..7766e43 --- /dev/null +++ b/recipes-test/ddt-runner/files/scripts/t1042rdb/i2c @@ -0,0 +1,43 @@ +#!/bin/sh +# This script is used to test i2c bus functionality for p2041rdb board. + +if I2C_ADAPTERS=$(i2cdetect -l |wc -l); then + echo "PASS: found $I2C_ADAPTERS i2c adapters" +else + echo "FAIL: no i2c adapters found" + exit 1 +fi + +if [ -z "$adapters" ]; then + adapters=0 +fi + +while [ $adapters -lt $I2C_ADAPTERS ] +do + i2cdetect -y $adapters + if [ $? -ne 0 ]; then + echo "FAIL: detect i2c adapter $adapters failed" + else + echo "PASS: detect i2c adapter $adapters success" + fi + adapters=`expr $adapters + 1` + sleep 1 +done + +i2cdetect -y 0 +if [ $? -ne 0 ]; then + echo "FAIL: detect i2c bus 0 fail" + exit 1 +else + echo "PASS: detect i2c bus 0 success" +fi + +#i2c bus 0, device address 0x52, DDR3 DIMM Socket 1, SPD EEPROM +i2cdump -f -y 0 0x51 | grep "EDPAR22QA01" +if [ $? -ne 0 ]; then + echo "FAIL: read SPD EEPROM on i2c bus 0 fail" + exit 1 +else + echo "PASS: read SPD EEPROM on i2c bus 0 success" +fi + diff --git a/recipes-test/ddt-runner/files/scripts/t1042rdb/pci-express b/recipes-test/ddt-runner/files/scripts/t1042rdb/pci-express new file mode 100755 index 0000000..c3f720d --- /dev/null +++ b/recipes-test/ddt-runner/files/scripts/t1042rdb/pci-express @@ -0,0 +1,109 @@ +#!/bin/sh + +ethernet_interface="eth3" +#sestord02 ip address +ethernet_ping_ipaddr="172.21.3.22" +ethernet_ipaddr=$1 + +#Intel Corporation 82574L Gigabit Network Card (intel e1000e) +vendor_id="8086" +product_id="10d3" + +#find vendor id & product id +lspci -nn | grep $vendor_id:$product_id +if [ $? -ne 0 ]; then + echo "SKIP: no pci-e ethernet card device found" + exit 1 +else + echo "PASS: got pci-e ethernet card device" +fi + +setpci -v -d $vendor_id:$product_id latency_timer=b0 +if [ $? -ne 0 ]; then + echo "FAIL: parameter changes to pci config space failed" + exit 1 +else + echo "PASS: parameter changes to pci config space success" +fi + +IFCONFIG=`which ifconfig` + +$IFCONFIG $ethernet_interface up +$IFCONFIG | grep $ethernet_interface +if [ $? -ne 0 ]; then + echo "FAIL: pci-e ethernet card device $ethernet_interface is not up" + exit 1 +else + echo "PASS: pci-e ethernet card device $ethernet_interface is up" +fi + +if [ "x$ethernet_ipaddr" != "x" ]; then + $IFCONFIG $ethernet_interface $ethernet_ipaddr +fi + +$IFCONFIG $ethernet_interface | grep 'inet addr:' |sed -e 's@inet addr:@@' |sed q | awk '{print $1}' +if [ $? -ne 0 ]; then + echo "FAIL: ipaddr of pci-e ethernet card device $ethernet_interface setup failed" + exit 1 +else + echo "PASS: ipaddr of pci-e ethernet card device $ethernet_interface setup success" +fi + +mindatasize=56 +maxdatasize=650 +stepsize=100 +iteration=1 +datasize=$mindatasize +logfile=`/bin/mktemp` +statistics=`/bin/mktemp` +error=0 + +trap cleanup SIGHUP SIGINT SIGTERM + +clean_tasks() { + echo "Executing clean up tasks" + rm -f $logfile $statistics +} + +cleanup() { + echo "Aborting script execution" + clean_tasks + exit 0 +} + +echo "start ping test for pci-e ethernet card device $ethernet_interface..." + +while [ $datasize -le $maxdatasize ]; do + for i in `seq 1 $iteration`; do + ping -c 1 -s $datasize $ethernet_ping_ipaddr > $statistics + ping_err=`echo $?` + echo "" && cat $statistics | grep "PING" + cat $statistics | grep "received" + [ `echo $?` -eq 0 ] || packets_received=0 && \ + packets_received=`cat $statistics | \ + grep "received" | awk '{print$4}'` + + # Evaluate possible errors on the ping operation + if [ $ping_err -ne 0 ] || [ $packets_received -eq 0 ]; then + error=1 + echo -e `cat $statistics | grep PING` >> $logfile + echo -e "Size: $datasize Iteration: $i\n" >> $logfile + fi + done + let datasize=$datasize+$stepsize +done + +# Report failures +if [ $error -eq 1 ]; then + echo -e "=================== error report ===================\n" + cat $logfile + echo -e "====================================================\n" + clean_tasks + echo -e "FAIL: ping test for pci-e ethernet card device $ethernet_interface failed\n" + exit 1 +else + clean_tasks + echo -e "PASS: ping test for pci-e ethernet card device $ethernet_interface success\n" +fi + +exit 0 diff --git a/recipes-test/ddt-runner/files/scripts/t1042rdb/sata b/recipes-test/ddt-runner/files/scripts/t1042rdb/sata new file mode 100755 index 0000000..62766b0 --- /dev/null +++ b/recipes-test/ddt-runner/files/scripts/t1042rdb/sata @@ -0,0 +1,86 @@ +#!/bin/sh + +# +#This script is to test sata devices on target +# + +result=0 +devpath="" +satainfo="" + +SD=`ls -l /dev/sd[^0-9] 2> /dev/null | awk '{print $5 $6 "," $10}'` +if [ -z "$SD" ]; then + echo "SKIP: no sata device found" + exit 1 +else + echo "PASS: find sata device" +fi + +HDPARM=`which hdparm` +if [ -z $HDPARM ]; then + result=$? + echo "FAIL: find hdparm" + exit 1 +else + echo "PASS: find hdparm" +fi + +for s in $SD + do + devpath=`echo "$s" | awk -F "," '{print "/sys/dev/block/" $1 ":" $2}'` + satainfo=`ls -l $devpath | grep sata` + + if [ -z "$satainfo" ] ; then + continue + fi + s=`echo "$s" | awk -F "," '{print $3}'` + + echo "testing $s" + $HDPARM -I $s + if [ $? -ne 0 ]; then + result=$? + echo "FAIL: $HDPARM -I $s Detailed/current information directly from $s" + else + echo "PASS: $HDPARM -I $s Detailed/current information directly from $s" + fi + $HDPARM -tT $s + if [ $? -ne 0 ]; then + result=$? + echo "FAIL: $HDPARM -tT $s Perform device/cache read timings on $s" + else + echo "PASS: $HDPARM -tT $s Perform device/cache read timings on $s" + fi + + + mkdir -p /mnt/sata_tmp + for partition in `ls "$s"[1-9]` + do + mount "$partition" /mnt/sata_tmp + if [ $? -ne 0 ]; then + result=$? + echo "FAIL: Mount $s" + else + echo "PASS: Mount $s" + dd if=/dev/urandom of=/mnt/sata_tmp/writefile bs=1M count=50 + if [ $? -ne 0 ]; then + result=$? + echo "FAIL: write test on $s" + else + echo "PASS: write test on $s" + rm -f /mnt/sata_tmp/writefile + fi + dd if=$s of=/mnt/sata_tmp/readfile bs=1M count=10 + if [ $? -ne 0 ]; then + result=$? + echo "FAIL: read test on $s" + else + echo "PASS: read test on $s" + rm -f /mnt/sata_tmp/readfile + fi + umount /mnt/sata_tmp + fi + done + + rm -fr /mnt/sata_tmp +done +exit $result diff --git a/recipes-test/ddt-runner/files/scripts/t1042rdb/sdhc b/recipes-test/ddt-runner/files/scripts/t1042rdb/sdhc new file mode 100755 index 0000000..883c572 --- /dev/null +++ b/recipes-test/ddt-runner/files/scripts/t1042rdb/sdhc @@ -0,0 +1,42 @@ +#!/bin/sh + +# the content of SD will be lost by running this test case. + +SDHC_DEVICE="/dev/mmcblk0" + +if [ -b "$SDHC_DEVICE" ]; then + echo "PASS: $SDHC_DEVICE device exists" +else + echo "SKIP: $SDHC_DEVICE does not exist" + exit 1 +fi + +mount | grep mmcblk0p1 > /dev/null 2>&1 + +if [ $? -eq 0 ]; then + umount $SDHC_DEVICE > /dev/null 2>&1 +fi + +/sbin/mkfs.ext2 $SDHC_DEVICE > /dev/null 2>&1 + +if [ $? -ne 0 ]; then + echo "FAIL: format $SDHC_DEVICE fail" + exit 1 +else + mkdir -p /mnt/sdhc > /dev/null 2>&1 + mount $SDHC_DEVICE /mnt/sdhc > /dev/null 2>&1 + if [ $? -ne 0 ]; then + echo "FAIL: mount $SDHC_DEVICE fail" + exit 1 + else + cp /bin/busybox /mnt/sdhc > /dev/null 2>&1 + ls /mnt/sdhc |grep busybox > /dev/null 2>&1 + if [ $? -ne 0 ]; then + echo "FAIL: read or write $SDHC_DEVICE fail" + exit 1 + else + umount $SDHC_DEVICE > /dev/null 2>&1 + echo "PASS: read or write $SDHC_DEVICE success" + fi + fi +fi diff --git a/recipes-test/ddt-runner/files/scripts/t1042rdb/spi b/recipes-test/ddt-runner/files/scripts/t1042rdb/spi new file mode 100755 index 0000000..06475a7 --- /dev/null +++ b/recipes-test/ddt-runner/files/scripts/t1042rdb/spi @@ -0,0 +1,35 @@ +#!/bin/bash + +SPIDEVS=`cat /proc/mtd | grep -e "^mtd" | grep -i spi | gawk -e '{print $1}' | sed 's/://'` +if [ -z "$SPIDEVS" ]; then + echo "SKIP: no spi device found" + exit 1 +fi + + +MTD_DEBUG=`which mtd_debug` +if [ -z "$MTD_DEBUG" ] ; then + echo "FAIL: mtd_debug utility not found on the system" + exit 1 +fi + +ERRCODE=0 + +for DV in $SPIDEVS ; do + FNAME=`cat /proc/mtd | grep $DV | gawk -F\" '{print $2}'` + FDEV=/dev/$DV + MTDSIZE=`$MTD_DEBUG info $FDEV | grep "mtd.size" | gawk -e '{print $3}'` + if [ $MTDSIZE -eq 0 ] ; then + echo "SKIP: $FNAME size is $MTDSIZE (skipped)" + else + $MTD_DEBUG read $FDEV 0 $MTDSIZE /dev/null > /dev/null 2>&1 + if [ $? -eq 0 ] ; then + echo "PASS: \"$FNAME\" read $MTDSIZE bytes" + else + echo "FAIL: \"$FNAME\" trying to read $MTDSIZE bytes" + ERRCODE=2 + fi + fi +done + +exit $ERRCODE diff --git a/recipes-test/ddt-runner/files/scripts/t1042rdb/usb b/recipes-test/ddt-runner/files/scripts/t1042rdb/usb new file mode 100755 index 0000000..017287f --- /dev/null +++ b/recipes-test/ddt-runner/files/scripts/t1042rdb/usb @@ -0,0 +1,48 @@ +#!/bin/sh +# +#This script is to test usb devices on p2041rdb target +# + +USB_DISK=`ls /dev/sd*[1-9] | sort | tail -n 1` + +usbutils_is_installed=`which lsusb` +if [ -z $usbutils_is_installed ]; then + echo "FAIL: Cannot find lsusb" + exit 1 +else + echo "PASS: usbutils found" +fi + +usbdev_num=`lsusb | grep -v root\ hub | wc -l` +if [ $usbdev_num -eq 0 ]; then + echo "FAIL: USB device is not connected" + exit 1 +else + echo "PASS: $usbdev_num USB device(s) connected" +fi + +lsusb | grep -v root\ hub +mkdir -p /mnt/usb_ehci +mount $USB_DISK /mnt/usb_ehci +if [ $? -ne 0 ]; then + echo "FAIL: Mount USB device failed" + exit 1 +else + echo "PASS: Mount USB device succeed" +fi + +echo "Begin test usb device..." +dd if=/dev/urandom of=/mnt/usb_ehci/testfile bs=1M count=50 +if [ $? -ne 0 ]; then + echo "FAIL: test failed" + rm -f /mnt/usb_ehci_testfile + umount /mnt/usb_ehci + rm -fr /mnt/usb_ehci + exit 1 +fi + +echo "PASS: test succeed" +rm -f /mnt/usb_ehci_testfile +umount /mnt/usb_ehci +rm -fr /mnt/usb_ehci +exit 0 diff --git a/recipes-test/ddt-runner/files/scripts/t1042rdb/watchdog b/recipes-test/ddt-runner/files/scripts/t1042rdb/watchdog new file mode 100755 index 0000000..2010e3c --- /dev/null +++ b/recipes-test/ddt-runner/files/scripts/t1042rdb/watchdog @@ -0,0 +1,93 @@ +#!/bin/sh +# +# This script is used to test watchdog functionality. + +WAITTIME=10 +WDPID=0 + +WATCHDOG=`which watchdog` +if [ "x$WATCHDOG" != "x" ]; then + echo "PASS: watchdog found" +else + echo "FAIL: watchdog not found" + exit 1 +fi + +WATCHDOG_CONF=/etc/watchdog.conf +if [ -f $WATCHDOG_CONF ]; then + echo "PASS: watchdog config file found" + sed -i '23,23 s/#//' $WATCHDOG_CONF +else + echo "FAIL: watchdog config file not found" + exit 1 +fi + +# kill any previous instance of watchdog (pkill may be used as well) +for wpid in `ps ax | grep $WATCHDOG | grep -v grep | awk -e '{print $1}'` ; do + kill -KILL $wpid +done + +# wait until all processes are gone +for wt in `seq 1 $WAITTIME ` ; do + sleep 1 + wd_running=`ps ax | grep $WATCHDOG | grep -v grep | awk -e '{print $1}'` + + if [ -z $wd_running ] ; then + break + fi +done + +if [ $wt -ge $WAITTIME ] ; then + echo "FAIL: Failed to stop the watchdog daemon" + exit 1 +fi + +# start a fresh watchdog +$WATCHDOG -v /dev/watchdog + +# wait up to $WAITTIME seconds for the process to start +for wt in `seq 1 $WAITTIME ` ; do + sleep 1 + wd_running=`ps ax | grep $WATCHDOG | grep -v grep | awk -e '{print $1}'` + if [ ! -z $wd_running ] ; then + WDPID=$wd_running + echo "PASS: Watchdog daemon started successfully [$WDPID]" + break + fi + + echo $wt +done + +if [ $wt -ge $WAITTIME ] ; then + echo "FAIL: Failed to start watchdog daemon" + exit 1 +fi + +logmsg_test() +{ + WDCOUNTER1=`cat /var/log/messages | grep watchdog | grep $WDPID | wc -l` + sleep 5 + WDCOUNTER2=`cat /var/log/messages | grep watchdog | grep $WDPID | wc -l` + + if [ $WDCOUNTER2 -gt $WDCOUNTER1 ] ; then + return 0 + fi + + return 1 +} + +exit_code=1 + +# test is performed 2 times because logrotate may step in during those 5sec +if logmsg_test || logmsg_test ; then + echo "PASS: Watchdog is alive" + kill -KILL $WDPID > /dev/null 2>&1 + exit_code=0 +else + echo "FAIL: Watchdog is not working" + kill -KILL $WDPID > /dev/null 2>&1 + exit_code=1 +fi + +kill -KILL $WDPID > /dev/null 2>&1 +exit $exit_code -- cgit v1.2.3-54-g00ecf