20 lines
722 B
Bash
Executable File
20 lines
722 B
Bash
Executable File
#!/bin/bash
|
|
# Plugs a USB stick (32 MB, label TEAMUSB, one file) into the test VM started
|
|
# with --usb: tests/usb.sh plug|unplug
|
|
cd "$(dirname "$0")/.."
|
|
W=tests/work
|
|
case "$1" in
|
|
plug)
|
|
mkdir -p "$W/usb/content"
|
|
echo "prepared code library" > "$W/usb/content/lib.cpp"
|
|
truncate -s 32M "$W/usb/usb.img"
|
|
mkfs.ext4 -q -F -L TEAMUSB -d "$W/usb/content" "$W/usb/usb.img"
|
|
n=$(date +%s)
|
|
python3 -I tests/monitor.py "$W/monitor.sock" "drive_add 0 if=none,id=ud$n,file=$PWD/$W/usb/usb.img,format=raw"
|
|
python3 -I tests/monitor.py "$W/monitor.sock" "device_add usb-storage,bus=xhci.0,drive=ud$n,id=usbstick"
|
|
;;
|
|
unplug)
|
|
python3 -I tests/monitor.py "$W/monitor.sock" "device_del usbstick"
|
|
;;
|
|
esac
|