From 390115b2afb5f1c0b56bfce98f151773729f6d6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20W=C3=BCrbach?= Date: Fri, 4 Nov 2016 15:46:43 +0100 Subject: [PATCH] Test for raw device using a virtual disk image MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Test whether a disk image is mountable & writable inside the VM and whether the result is readable again by macOS. Signed-off-by: Johannes Würbach --- test/test_linux.exp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/test/test_linux.exp b/test/test_linux.exp index 27a5e0f7..28de35b5 100755 --- a/test/test_linux.exp +++ b/test/test_linux.exp @@ -4,7 +4,11 @@ set KERNEL "./vmlinuz" set INITRD "./initrd.gz" set CMDLINE "earlyprintk=serial console=ttyS0" -spawn ../build/com.docker.hyperkit -A -m 512M -s 0:0,hostbridge -s 31,lpc -l com1,stdio -f kexec,$KERNEL,$INITRD,$CMDLINE +exec hdiutil create -megabytes 20 -fs "MS-DOS" disk +set DISK [exec hdiutil attach -nomount -noverify -noautofsck disk.dmg | head -n1 | cut -f1 -d " "] +set RDISK [string map { disk rdisk } $DISK] + +spawn ../build/com.docker.hyperkit -A -m 512M -s 0:0,hostbridge -s 31,lpc -l com1,stdio -s 1:0,ahci-hd,$RDISK -f kexec,$KERNEL,$INITRD,$CMDLINE set pid [exp_pid] set timeout 20 @@ -12,9 +16,18 @@ expect { timeout {puts "FAIL boot"; exec kill -9 $pid; exit 1} "\r\ntc@box:~$ " } +send "sudo mount /dev/sda1 /mnt/sda1\r\n" +send "sudo touch /mnt/sda1/test\r\n" +send "sudo umount /mnt/sda1\r\n" send "sudo halt\r\n"; expect { timeout {puts "FAIL shutdown"; exec kill -9 $pid; exit 1} "reboot: System halted" } + +exec hdiutil mount -mountpoint ./test-vol /dev/disk4s1 +exec cat ./test-vol/test +exec hdiutil detach $DISK +exec rm disk.dmg + puts "\n\nPASS"