@@ -21,6 +21,7 @@ cleanup() {
2121trap cleanup EXIT
2222
2323cp -rv $1 $TEMPDIR
24+ cp test_config.yaml $TEMPDIR /storage/config.yaml
2425
2526cat > $TEMPDIR /storage/registered.json << EOF
2627[
@@ -33,14 +34,30 @@ cat >$TEMPDIR/storage/registered.json <<EOF
3334 "curr_progress": null,
3435 "next_action": "shutdown",
3536 "image": "contestant"
37+ },
38+ {
39+ "mac": [82, 84, 0, 18, 52, 87],
40+ "group": 10,
41+ "row": 9,
42+ "col": 1,
43+ "curr_action": null,
44+ "curr_progress": null,
45+ "next_action": "shutdown",
46+ "image": "contestant"
3647 }
3748]
3849EOF
3950
4051if ! ip link show br-pixie; then
4152 ip link add br-pixie type bridge
4253 ip link set dev br-pixie up
43- ip addr add 10.0.0.1/8 brd 10.255.255.255 dev br-pixie
54+ ip addr add 10.0.0.1/16 dev br-pixie
55+ fi
56+
57+ if ! ip link show br-pixie1; then
58+ ip link add br-pixie1 type bridge
59+ ip link set dev br-pixie1 up
60+ ip addr add 10.10.0.1/16 dev br-pixie1
4461fi
4562
4663RUST_BACKTRACE=short RUST_LOG=debug RUST_LOG_STYLE=always LLVM_PROFILE_FILE=prof-out/pixie-server-%m-%p.profraw ./pixie-server/target/debug/pixie-server -s $TEMPDIR /storage &
@@ -67,7 +84,30 @@ run_qemu() {
6784 -nic bridge,mac=52:54:00:12:34:56,br=br-pixie,model=e1000
6885}
6986
87+ run_qemu1 () {
88+ OVMF=/usr/share/OVMF/OVMF_CODE_4M.fd
89+ if ! [ -e $OVMF ]; then
90+ OVMF=/usr/share/edk2/x64/OVMF_CODE.4m.fd
91+ fi
92+ FILE=prof-out/pixie-uefi-$RANDOM .profraw
93+ truncate -s 500M $FILE
94+ qemu-system-x86_64 \
95+ -nographic \
96+ -chardev stdio,id=char0,logfile=$1 ,signal=off \
97+ -serial chardev:char0 \
98+ -monitor none \
99+ -enable-kvm \
100+ -cpu host -smp cores=2 \
101+ -m 1G \
102+ -drive if=pflash,format=raw,file=$OVMF \
103+ -drive file=$TEMPDIR /disk1.img,if=none,id=nvm,format=raw \
104+ -drive file=$FILE ,format=raw \
105+ -device nvme,serial=deadbeef,drive=nvm \
106+ -nic bridge,mac=52:54:00:12:34:57,br=br-pixie1,model=e1000
107+ }
108+
70109truncate -s 8G $TEMPDIR /disk.img
110+ truncate -s 8G $TEMPDIR /disk1.img
71111echo -e " label: gpt\n- 1GiB - -\n- 1GiB - -\n- - L -" | sfdisk $TEMPDIR /disk.img
72112DEV=$( losetup --partscan --show --find $TEMPDIR /disk.img)
73113mkswap ${DEV} p1
@@ -80,7 +120,7 @@ for PART in ${DEV}p{2..3}; do
80120done
81121losetup -d $DEV
82122
83- curl ' http://localhost:8080/admin/curr_action/all /store'
123+ curl ' http://localhost:8080/admin/curr_action/52:54:00:12:34:56 /store'
84124run_qemu $TEMPDIR /store.log
85125
86126# Check that we restore the original disk image.
@@ -90,6 +130,7 @@ truncate -s 8G $TEMPDIR/disk.img
90130
91131curl ' http://localhost:8080/admin/curr_action/all/flash'
92132run_qemu $TEMPDIR /flash-1.log
133+ run_qemu1 $TEMPDIR /flash1-1.log
93134
94135DEV=$( losetup --partscan --show --find --read-only $TEMPDIR /disk.img)
95136fsck -n ${DEV} p*
@@ -103,10 +144,23 @@ for PART in ${DEV}p{2..3}; do
103144done
104145losetup -d $DEV
105146
147+ DEV=$( losetup --partscan --show --find --read-only $TEMPDIR /disk1.img)
148+ fsck -n ${DEV} p*
149+ for PART in ${DEV} p{2..3}; do
150+ mount -o ro $PART $TEMPDIR /mnt
151+ if [ " $( md5sum $TEMPDIR /mnt/pixie-server | cut -f 1 -d ' ' ) " != " $( md5sum ./pixie-server/target/debug/pixie-server | cut -f 1 -d ' ' ) " ]; then
152+ echo " pixie-server does not contain the expected content"
153+ exit 1
154+ fi
155+ umount $TEMPDIR /mnt
156+ done
157+ losetup -d $DEV
158+
106159# Check that we don't fetch any data if the disk contents have not changed.
107160
108161curl ' http://localhost:8080/admin/curr_action/all/flash'
109162run_qemu $TEMPDIR /flash-2.log
163+ run_qemu1 $TEMPDIR /flash1-2.log
110164
111165DEV=$( losetup --partscan --show --find --read-only $TEMPDIR /disk.img)
112166fsck -n ${DEV} p*
@@ -120,7 +174,24 @@ for PART in ${DEV}p{2..3}; do
120174done
121175losetup -d $DEV
122176
177+ DEV=$( losetup --partscan --show --find --read-only $TEMPDIR /disk1.img)
178+ fsck -n ${DEV} p*
179+ for PART in ${DEV} p{2..3}; do
180+ mount -o ro $PART $TEMPDIR /mnt
181+ if [ " $( md5sum $TEMPDIR /mnt/pixie-server | cut -f 1 -d ' ' ) " != " $( md5sum ./pixie-server/target/debug/pixie-server | cut -f 1 -d ' ' ) " ]; then
182+ echo " pixie-server does not contain the expected content"
183+ exit 1
184+ fi
185+ umount $TEMPDIR /mnt
186+ done
187+ losetup -d $DEV
188+
123189if ! grep " Disk scanned; 0 chunks to fetch" $TEMPDIR /flash-2.log & > /dev/null; then
124190 echo " Data was re-fetched"
125191 exit 1
126192fi
193+
194+ if ! grep " Disk scanned; 0 chunks to fetch" $TEMPDIR /flash1-2.log & > /dev/null; then
195+ echo " Data was re-fetched"
196+ exit 1
197+ fi
0 commit comments