1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101
|
#!/bin/sh
exit_success ()
{
echo "UBI Utils Test Scripts - SUCCESS!"
exit 0
}
exit_failure ()
{
echo $1
echo "UBI Utils Test Scripts - FAILED!"
exit 1
}
echo UBI Utils Test Scripts
devno=$1
logfile=temp-test-log.txt
if test -z "$devno";
then
echo "Usage is $0 <mtd device number>"
exit 1
fi
cwd=`pwd` || exit_failure "pwd failed"
log="${cwd}/${logfile}"
PATH=$PATH:$cwd:..
cat /dev/null > $log || exit_failure "Failed to create $log"
echo "Setting up for jffs2_test.sh" | tee -a $log
avail=`cat /sys/class/ubi/ubi${devno}/avail_eraseblocks`
size=`cat /sys/class/ubi/ubi${devno}/eraseblock_size`
bytes=`expr $avail \* $size`
ubimkvol -d$devno -s$bytes -n0 -Njtstvol || exit_failure "ubimkvol failed"
mkdir -p /mnt/test_file_system || exit_failure "mkdir failed"
mtd=`cat /proc/mtd | grep jtstvol | cut -d: -f1`
if test -z "$mtd";
then
exit_failure "mtd device not found"
fi
mount -t jffs2 $mtd /mnt/test_file_system || exit_failure "mount failed"
cd /mnt/test_file_system || exit_failure "cd failed"
echo Running jffs2_test.sh | tee -a $log
jffs2_test.sh >> $log 2>&1 || exit_failure "jffs2_test.sh failed"
rm -f *
cd $cwd || exit_failure "cd failed"
umount /mnt/test_file_system || exit_failure "umount failed"
ubirmvol -d$devno -n0 || exit_failure "ubirmvol failed"
major=`cat /sys/class/ubi/ubi${devno}/dev | cut -d: -f1`
for minor in `seq 0 32`; do
if test ! -e /dev/ubi${devno}_$minor ;
then
mknod /dev/ubi${devno}_$minor c $major $(($minor + 1))
fi
done
rm -f testdata.bin readdata.bin
echo Running ubi_jffs2_test.sh | tee -a $log
ubi_jffs2_test.sh >> $log 2>&1 || exit_failure "ubi_jffs2_test.sh failed"
echo Running ubi_test.sh | tee -a $log
ubi_test.sh >> $log 2>&1 || exit_failure "ubi_test.sh failed"
for minor in `seq 0 32`; do
if test -e /sys/class/ubi/ubi${devno}/$minor;
then
ubirmvol -d$devno -n$minor || exit_failure "ubirmvol failed"
fi
done
echo Running ubi_tools_test.sh | tee -a $log
ubi_tools_test.sh >> $log 2>&1 || exit_failure "ubi_tools_test failed"
rm -f $log
exit_success
|