From 6dcb01b532cc16d07d2698effeda809a57b2e249 Mon Sep 17 00:00:00 2001 From: Artem Bityutskiy Date: Thu, 2 Aug 2012 21:51:43 +0300 Subject: tests: ubi: add stress-test.sh It is not finished yet, but it will run all tests on nandsim and mtdram of different geometry. Signed-off-by: Artem Bityutskiy --- tests/ubi-tests/stress-test.sh | 95 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100755 tests/ubi-tests/stress-test.sh (limited to 'tests') diff --git a/tests/ubi-tests/stress-test.sh b/tests/ubi-tests/stress-test.sh new file mode 100755 index 0000000..ad9a2af --- /dev/null +++ b/tests/ubi-tests/stress-test.sh @@ -0,0 +1,95 @@ +#!/bin/sh -euf + +srcdir="$(readlink -ev -- ${0%/*})" +PATH="$srcdir:$PATH" + +fatal() +{ + echo "Error: $1" 1>&2 + exit 1 +} + +usage() +{ + cat 1>&2 </dev/null 2>&1 ||: + rmmod nandsim >/dev/null 2>&1 ||: + rmmod mtdram >/dev/null 2>&1 ||: + + # Below is magic to exit with correct exit code + if [ "$ret" != "0" ]; then + trap false EXIT + else + trap true EXIT + fi +} +trap 'cleanup_handler $?' EXIT +trap 'cleanup_handler 1' HUP PIPE INT QUIT TERM + +# Find MTD device number by pattern in /proc/mtd +# Usage: find_mtd_device +find_mtd_device() +{ + printf "%s" "$(grep "$1" /proc/mtd | sed -e "s/^mtd\([0-9]\+\):.*$/\1/")" +} + +exit_handler() +{ + echo exit + cleanup +} + +runtests="runtests.sh" + +if [ "$#" -lt 1 ] || [ "$1" != "run" ]; then + usage + exit 1 +fi + +# Make sure neither mtdram nor nandsim are used +nandsim_patt="NAND simulator" +mtdram_patt="mtdram test device" +! cat /proc/mtd | grep -q "$nandsim_patt" || + fatal "the nandsim driver is already used" +! cat /proc/mtd | grep -q "$mtdram_patt" || + fatal "the mtdram driver is already used" + +rmmod ubi >/dev/null 2>&1 ||: + +if modinfo ubi | grep -q fm_auto; then + fastmap_supported="yes" +else + fastmap_supported="no" +fi + +echo "==================================================" +echo "512MiB nandsim, 2KiB NAND pages, no fastmap" +echo "==================================================" + +modprobe nandsim first_id_byte=0x20 second_id_byte=0xac \ + third_id_byte=0x00 fourth_id_byte=0x15 +mtdnum="$(find_mtd_device "$nandsim_patt")" +modprobe ubi mtd="$mtdnum" +$runtests /dev/ubi0 && echo "SUCCESS" || echo "FAILURE" + +echo "==================================================" +echo "256MiB nandsim, 512-byte NAND pages, no fastmap" +echo "==================================================" + +modprobe nandsim first_id_byte=0x20 second_id_byte=0x71 +mtdnum="$(find_mtd_device "$nandsim_patt")" +modprobe ubi mtd="$mtdnum" +$runtests /dev/ubi0 && echo "SUCCESS" || echo "FAILURE" -- cgit v1.2.3