Skip to content

Commit

Permalink
Test for raw device using a virtual disk image
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
johanneswuerbach committed Nov 4, 2016
1 parent 3a1af93 commit 390115b
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion test/test_linux.exp
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,30 @@ 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

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"

0 comments on commit 390115b

Please sign in to comment.