create FS for usb keys

pull/10/head
Raphaël Vinot 2014-02-02 22:27:32 +01:00
parent b9cf67e9e2
commit cecc2d8ce9
2 changed files with 84 additions and 0 deletions

39
tests/TODO.md Normal file
View File

@ -0,0 +1,39 @@
Expectations
============
Having a way to run after each commit a test on a list of samples and check if
the output and the logs are the ones expected by.
Easy way to check it on the rPi itself before releases.
What to think about
===================
* Exhaustive list of files, edge cases
* Check the logfiles
Ideas
=====
Source keys:
- Working documents, one / multiple partitions
- Non working documents: one / multiple partitions
- different FS on different partitions
- Non working FS
- Malicious documents (very slow, might break the conversions)
Destinations keys
- empty, big enough
- empty, too small
- broken
- not empty
- unmountable (wrong/broken fs)
Things to try out
=================
Run the image in qemu, process USB keys from there

45
tests/mkrawfs.sh Normal file
View File

@ -0,0 +1,45 @@
#!/bin/bash
# Doc: http://wiki.osdev.org/Loopback_Device
set -e
set -x
# User
#FS_EXT='ext2 ext3 ext4'
FS_VFAT='vfat'
#FS_NTFS='ntfs'
SIZE_MB='128'
# System
FS="${FS_EXT} ${FS_VFAT} ${FS_NTFS}"
for f in $FS; do
# Create files of 128Mb
OUT_NAME_NORM="testcase."${f}
OUT_NAME_PART="testcase.part."${f}
dd if=/dev/zero of=${OUT_NAME_NORM} bs=516096c count=200
dd if=/dev/zero of=${OUT_NAME_PART} bs=516096c count=200
parted -s ${OUT_NAME_NORM} mklabel msdos
parted -s ${OUT_NAME_PART} mklabel msdos
if [ $f = ${FS_VFAT} ]; then
parted -s ${OUT_NAME_PART} mkpart primary 8192s 122879s
parted -s ${OUT_NAME_PART} mkpart primary 122880s 201599s
parted -s ${OUT_NAME_NORM} mkpart primary 8192s 201599s
losetup -o$((8192 * 512)) /dev/loop0 ${OUT_NAME_PART}
losetup -o$((122880 * 512)) /dev/loop1 ${OUT_NAME_PART}
losetup -o$((8192 * 512)) /dev/loop2 ${OUT_NAME_NORM}
mkfs.${f} /dev/loop0 57344
mkfs.${f} /dev/loop1 39360
mkfs.${f} /dev/loop2
losetup -d /dev/loop0
losetup -d /dev/loop1
losetup -d /dev/loop2
elif [ $f = ${FS_NTFS} ]; then
mk${f} -f -F ${OUT_NAME}
else
mkfs.${f} -F ${OUT_NAME}
fi
done