Skip to content

Commit fd26492

Browse files
committed
Test whether flashing X on X fetches any data.
1 parent 6de2645 commit fd26492

3 files changed

Lines changed: 30 additions & 4 deletions

File tree

.github/workflows/rust.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,4 +63,4 @@ jobs:
6363
uses: jetli/trunk-action@v0.5.0
6464

6565
- name: Run test
66-
run: ./test.sh
66+
run: setsid ./test.sh

run_test.sh

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ run_qemu() {
5151
fi
5252
qemu-system-x86_64 \
5353
-nographic \
54+
-chardev stdio,id=char0,logfile=$1,signal=off \
55+
-serial chardev:char0 \
56+
-monitor none \
5457
-enable-kvm \
5558
-cpu host -smp cores=2 \
5659
-m 1G \
@@ -69,13 +72,29 @@ umount $TEMPDIR/mnt
6972
losetup -d $DEV
7073

7174
curl 'http://localhost:8080/admin/curr_action/all/store'
72-
run_qemu
75+
run_qemu $TEMPDIR/store.log
76+
77+
# Check that we restore the original disk image.
7378

7479
rm -f $TEMPDIR/disk.img
7580
truncate -s 8G $TEMPDIR/disk.img
7681

7782
curl 'http://localhost:8080/admin/curr_action/all/flash'
78-
run_qemu
83+
run_qemu $TEMPDIR/flash-1.log
84+
85+
DEV=$(losetup --show --find $TEMPDIR/disk.img)
86+
mount -o ro $DEV $TEMPDIR/mnt
87+
if [ "$(md5sum $TEMPDIR/mnt/pixie-server | cut -f 1 -d ' ')" != "$(md5sum ./pixie-server/target/debug/pixie-server | cut -f 1 -d ' ')" ]; then
88+
echo "pixie-server does not contain the expected content"
89+
exit 1
90+
fi
91+
umount $TEMPDIR/mnt
92+
losetup -d $DEV
93+
94+
# Check that we don't fetch any data if the disk contents have not changed.
95+
96+
curl 'http://localhost:8080/admin/curr_action/all/flash'
97+
run_qemu $TEMPDIR/flash-2.log
7998

8099
DEV=$(losetup --show --find $TEMPDIR/disk.img)
81100
mount $DEV $TEMPDIR/mnt
@@ -85,3 +104,9 @@ if [ "$(md5sum $TEMPDIR/mnt/pixie-server | cut -f 1 -d ' ')" != "$(md5sum ./pixi
85104
fi
86105
umount $TEMPDIR/mnt
87106
losetup -d $DEV
107+
108+
if ! grep "Disk scanned; 0 chunks to fetch" $TEMPDIR/flash-2.log &>/dev/null
109+
then
110+
echo "Data was re-fetched"
111+
exit 1
112+
fi

test.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@ cd "$SELFDIR"
88

99
./setup.sh
1010

11-
setsid sudo ./run_test.sh ${SELFDIR}/storage
11+
trap '' SIGTERM
12+
sudo ./run_test.sh ${SELFDIR}/storage

0 commit comments

Comments
 (0)