From cecc2d8ce9c291d568b44afed42450297d349843 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Vinot?= Date: Sun, 2 Feb 2014 22:27:32 +0100 Subject: [PATCH] create FS for usb keys --- tests/TODO.md | 39 +++++++++++++++++++++++++++++++++++++++ tests/mkrawfs.sh | 45 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 84 insertions(+) create mode 100644 tests/TODO.md create mode 100644 tests/mkrawfs.sh diff --git a/tests/TODO.md b/tests/TODO.md new file mode 100644 index 0000000..e2ceadd --- /dev/null +++ b/tests/TODO.md @@ -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 + diff --git a/tests/mkrawfs.sh b/tests/mkrawfs.sh new file mode 100644 index 0000000..0b8ce38 --- /dev/null +++ b/tests/mkrawfs.sh @@ -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 +