#!/bin/sh # # This script is used to test flash driver function. if part_num=`cat /proc/mtd | grep -c 'mtd'`; then echo "PASS: show $part_num partitions" else echo "FAIL: show $part_num partitions" fi for((part=0; part<$part_num-1; 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" fi done let "test_part=part_num-2" if [ $(flash_erase -j /dev/mtd${test_part} 0 0 | grep -c '100 % complete') ]; then echo "PASS: erase and format partition ${test_part}" else echo "FAIL: erase and format partition ${test_part}" fi mkdir -p /mnt/flash mount -t jffs2 /dev/mtdblock${test_part} /mnt/flash if [ $? -eq 0 ]; then echo "PASS: mount partition ${test_part} as /mnt/flash" else echo "FAIL: mount partition ${test_part} as /mnt/flash" fi cd /mnt/flash touch test if [ $(ls | grep -c 'test') ]; then echo "PASS: touch a file on partition ${test_part}" else echo "FAIL: touch a file on partition ${test_part}" fi cd ~ umount /mnt/flash