-
Notifications
You must be signed in to change notification settings - Fork 0
/
run-tests.sh
executable file
·57 lines (52 loc) · 1.36 KB
/
run-tests.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/bin/bash
TMPDIR=$(mktemp -d)
DISKIMAGE_ROOT="$TMPDIR/image_root.cow"
DISKIMAGE_USER="$TMPDIR/image_user.cow"
INSTALL_MEDIA=arch.iso
TAB=" "
rm -f "$DISKIMAGE_ROOT" "$DISKIMAGE_USER"
qemu-img create -f qcow2 "$DISKIMAGE_ROOT" 8G
echo "Running emulator..."
#qemu-system-x86_64 -m 1024 -cdrom "$INSTALL_MEDIA" -virtfs local,id=ntml,path=.,security_model=none,mount_tag=ntml -boot order=c -drive file=$DISKIMAGE_ROOT,format=qcow2 -nographic -serial mon:stdio <<EOT > log.txt
#$TAB console=ttyS0,38400
#root
#EOT
expect -c "
set timeout 600
spawn qemu-system-x86_64 -m 1024 -cdrom $INSTALL_MEDIA -virtfs local,id=ntml,path=.,security_model=none,mount_tag=ntml -boot order=c -drive file=$DISKIMAGE_ROOT,format=qcow2 -nographic -serial mon:stdio
expect \"Boot Arch Linux (x86_64)\"
send \"$TAB\"
expect \"boot/x86_64/archiso.img\"
send \" console=ttyS0,38400\\n\"
expect \"archiso login:\"
send \"root\\n\"
sleep 1
expect \"#\"
send \"mkdir /root/ntml\\n\"
sleep 1
expect \"#\"
send \"mount -t 9p -o trans=virtio ntml /root/ntml -oversion=9p2000.L\\n\"
sleep 1
expect \"#\"
send \"cd /root/ntml\\n\"
sleep 1
expect \"#\"
send \"./stage01.sh test_config.conf || echo ERROR DETECTED\\n\"
sleep 1
expect {
\"#\" {
exp_continue
}
\"ERROR DETECTED\" {
exit 1
}
}
send \"poweroff\\n\"
sleep 1
expect \"Power down\"
sleep 2
wait
exit 0
" | tr -d '\000\033'
echo "return: $?"
#> log.txt