Skip to content

Commit 0f1c050

Browse files
committed
Test gpt
1 parent 278d5df commit 0f1c050

2 files changed

Lines changed: 30 additions & 22 deletions

File tree

run_test.sh

Lines changed: 30 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@
22
set -xe
33

44
TEMPDIR=$(mktemp -d)
5+
DEV=""
56

67
mkdir $TEMPDIR/mnt
78

89
cleanup() {
910
# Ignore errors in cleanup.
1011
set +e
1112
umount -l -q $TEMPDIR/mnt
13+
[ -z "$DEV" ] || losetup -d $DEV
1214
rm -rf $TEMPDIR
1315
# Kill descendants, but not itself.
1416
trap '' SIGTERM
@@ -41,7 +43,7 @@ if ! ip link show br-pixie; then
4143
ip addr add 10.0.0.1/8 brd 10.255.255.255 dev br-pixie
4244
fi
4345

44-
RUST_BACKTRACE=short RUST_LOG=debug ./pixie-server/target/debug/pixie-server -s $TEMPDIR/storage &
46+
RUST_BACKTRACE=short RUST_LOG=debug RUST_LOG_STYLE=always ./pixie-server/target/debug/pixie-server -s $TEMPDIR/storage &
4547

4648
run_qemu() {
4749
OVMF=/usr/share/OVMF/OVMF_CODE_4M.fd
@@ -64,11 +66,15 @@ run_qemu() {
6466
}
6567

6668
truncate -s 8G $TEMPDIR/disk.img
67-
mkfs.ext4 $TEMPDIR/disk.img
68-
DEV=$(losetup --show --find $TEMPDIR/disk.img)
69-
mount $DEV $TEMPDIR/mnt
70-
cp ./pixie-server/target/debug/pixie-server $TEMPDIR/mnt
71-
umount $TEMPDIR/mnt
69+
echo -e "label: gpt\n- 1GiB - -\n- - L -" | sfdisk $TEMPDIR/disk.img
70+
DEV=$(losetup --partscan --show --find $TEMPDIR/disk.img)
71+
mkfs.ntfs -f ${DEV}p1
72+
mkfs.ext4 ${DEV}p2
73+
for PART in ${DEV}p*; do
74+
mount $PART $TEMPDIR/mnt
75+
cp ./pixie-server/target/debug/pixie-server $TEMPDIR/mnt
76+
umount $TEMPDIR/mnt
77+
done
7278
losetup -d $DEV
7379

7480
curl 'http://localhost:8080/admin/curr_action/all/store'
@@ -82,27 +88,31 @@ truncate -s 8G $TEMPDIR/disk.img
8288
curl 'http://localhost:8080/admin/curr_action/all/flash'
8389
run_qemu $TEMPDIR/flash-1.log
8490

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
91+
DEV=$(losetup --partscan --show --find --read-only $TEMPDIR/disk.img)
92+
for PART in ${DEV}p*; do
93+
mount -o ro $PART $TEMPDIR/mnt
94+
if [ "$(md5sum $TEMPDIR/mnt/pixie-server | cut -f 1 -d ' ')" != "$(md5sum ./pixie-server/target/debug/pixie-server | cut -f 1 -d ' ')" ]; then
95+
echo "pixie-server does not contain the expected content"
96+
exit 1
97+
fi
98+
umount $TEMPDIR/mnt
99+
done
92100
losetup -d $DEV
93101

94102
# Check that we don't fetch any data if the disk contents have not changed.
95103

96104
curl 'http://localhost:8080/admin/curr_action/all/flash'
97105
run_qemu $TEMPDIR/flash-2.log
98106

99-
DEV=$(losetup --show --find $TEMPDIR/disk.img)
100-
mount $DEV $TEMPDIR/mnt
101-
if [ "$(md5sum $TEMPDIR/mnt/pixie-server | cut -f 1 -d ' ')" != "$(md5sum ./pixie-server/target/debug/pixie-server | cut -f 1 -d ' ')" ]; then
102-
echo "pixie-server does not contain the expected content"
103-
exit 1
104-
fi
105-
umount $TEMPDIR/mnt
107+
DEV=$(losetup --partscan --show --find --read-only $TEMPDIR/disk.img)
108+
for PART in ${DEV}p*; do
109+
mount -o ro $PART $TEMPDIR/mnt
110+
if [ "$(md5sum $TEMPDIR/mnt/pixie-server | cut -f 1 -d ' ')" != "$(md5sum ./pixie-server/target/debug/pixie-server | cut -f 1 -d ' ')" ]; then
111+
echo "pixie-server does not contain the expected content"
112+
exit 1
113+
fi
114+
umount $TEMPDIR/mnt
115+
done
106116
losetup -d $DEV
107117

108118
if ! grep "Disk scanned; 0 chunks to fetch" $TEMPDIR/flash-2.log &>/dev/null

test.sh

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
#!/usr/bin/env bash
22
set -xe
33

4-
# TODO: less invasive on host system
5-
64
SELFDIR="$(realpath "$(dirname "$0")")"
75
cd "$SELFDIR"
86

0 commit comments

Comments
 (0)