#!/bin/bash

tcmd-subcase.sh mmc-detect >/dev/null 2>&1 

mount | grep -q /mnt/sdcard  || die "sdcard is not mounted"

x=0
while true; do 
    ((x++))
    echo $x
    if test $x = 500; then
	break
    fi
done > /mnt/sdcard/test-mmc-rw

sync

last=$(cat /mnt/sdcard/test-mmc-rw | tail -n 1)
test $last = 500 || die "last line of mmc-write is not the same as read back"
echo "Wrote 500 lines into mmc file; read back is OK."
