Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 39 additions & 41 deletions run_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ trap cleanup EXIT

cp -rv $1 $TEMPDIR

cat > $TEMPDIR/storage/registered.json << EOF
cat >$TEMPDIR/storage/registered.json <<EOF
[
{
"mac": [82, 84, 0, 18, 52, 86],
Expand All @@ -38,34 +38,33 @@ cat > $TEMPDIR/storage/registered.json << EOF
EOF

if ! ip link show br-pixie; then
ip link add br-pixie type bridge
ip link set dev br-pixie up
ip addr add 10.0.0.1/8 brd 10.255.255.255 dev br-pixie
ip link add br-pixie type bridge
ip link set dev br-pixie up
ip addr add 10.0.0.1/8 brd 10.255.255.255 dev br-pixie
fi

RUST_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 &

run_qemu() {
OVMF=/usr/share/OVMF/OVMF_CODE_4M.fd
if ! [ -e $OVMF ]
then
OVMF=/usr/share/edk2/x64/OVMF_CODE.4m.fd
fi
FILE=prof-out/pixie-uefi-$RANDOM.profraw
truncate -s 500M $FILE
qemu-system-x86_64 \
-nographic \
-chardev stdio,id=char0,logfile=$1,signal=off \
-serial chardev:char0 \
-monitor none \
-enable-kvm \
-cpu host -smp cores=2 \
-m 1G \
-drive if=pflash,format=raw,file=$OVMF \
-drive file=$TEMPDIR/disk.img,if=none,id=nvm,format=raw \
-drive file=$FILE,format=raw \
-device nvme,serial=deadbeef,drive=nvm \
-nic bridge,mac=52:54:00:12:34:56,br=br-pixie,model=virtio-net-pci
OVMF=/usr/share/OVMF/OVMF_CODE_4M.fd
if ! [ -e $OVMF ]; then
OVMF=/usr/share/edk2/x64/OVMF_CODE.4m.fd
fi
FILE=prof-out/pixie-uefi-$RANDOM.profraw
truncate -s 500M $FILE
qemu-system-x86_64 \
-nographic \
-chardev stdio,id=char0,logfile=$1,signal=off \
-serial chardev:char0 \
-monitor none \
-enable-kvm \
-cpu host -smp cores=2 \
-m 1G \
-drive if=pflash,format=raw,file=$OVMF \
-drive file=$TEMPDIR/disk.img,if=none,id=nvm,format=raw \
-drive file=$FILE,format=raw \
-device nvme,serial=deadbeef,drive=nvm \
-nic bridge,mac=52:54:00:12:34:56,br=br-pixie,model=e1000
}

truncate -s 8G $TEMPDIR/disk.img
Expand All @@ -75,9 +74,9 @@ mkswap ${DEV}p1
mkfs.ntfs -f ${DEV}p2
mkfs.ext4 ${DEV}p3
for PART in ${DEV}p{2..3}; do
mount $PART $TEMPDIR/mnt
cp ./pixie-server/target/debug/pixie-server $TEMPDIR/mnt
umount $TEMPDIR/mnt
mount $PART $TEMPDIR/mnt
cp ./pixie-server/target/debug/pixie-server $TEMPDIR/mnt
umount $TEMPDIR/mnt
done
losetup -d $DEV

Expand All @@ -95,12 +94,12 @@ run_qemu $TEMPDIR/flash-1.log
DEV=$(losetup --partscan --show --find --read-only $TEMPDIR/disk.img)
fsck -n ${DEV}p*
for PART in ${DEV}p{2..3}; do
mount -o ro $PART $TEMPDIR/mnt
if [ "$(md5sum $TEMPDIR/mnt/pixie-server | cut -f 1 -d ' ')" != "$(md5sum ./pixie-server/target/debug/pixie-server | cut -f 1 -d ' ')" ]; then
echo "pixie-server does not contain the expected content"
exit 1
fi
umount $TEMPDIR/mnt
mount -o ro $PART $TEMPDIR/mnt
if [ "$(md5sum $TEMPDIR/mnt/pixie-server | cut -f 1 -d ' ')" != "$(md5sum ./pixie-server/target/debug/pixie-server | cut -f 1 -d ' ')" ]; then
echo "pixie-server does not contain the expected content"
exit 1
fi
umount $TEMPDIR/mnt
done
losetup -d $DEV

Expand All @@ -112,17 +111,16 @@ run_qemu $TEMPDIR/flash-2.log
DEV=$(losetup --partscan --show --find --read-only $TEMPDIR/disk.img)
fsck -n ${DEV}p*
for PART in ${DEV}p{2..3}; do
mount -o ro $PART $TEMPDIR/mnt
if [ "$(md5sum $TEMPDIR/mnt/pixie-server | cut -f 1 -d ' ')" != "$(md5sum ./pixie-server/target/debug/pixie-server | cut -f 1 -d ' ')" ]; then
echo "pixie-server does not contain the expected content"
exit 1
fi
umount $TEMPDIR/mnt
mount -o ro $PART $TEMPDIR/mnt
if [ "$(md5sum $TEMPDIR/mnt/pixie-server | cut -f 1 -d ' ')" != "$(md5sum ./pixie-server/target/debug/pixie-server | cut -f 1 -d ' ')" ]; then
echo "pixie-server does not contain the expected content"
exit 1
fi
umount $TEMPDIR/mnt
done
losetup -d $DEV

if ! grep "Disk scanned; 0 chunks to fetch" $TEMPDIR/flash-2.log &>/dev/null
then
if ! grep "Disk scanned; 0 chunks to fetch" $TEMPDIR/flash-2.log &>/dev/null; then
echo "Data was re-fetched"
exit 1
fi
41 changes: 20 additions & 21 deletions test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,27 +39,26 @@ cp -r pixie-web/dist/* "${STORAGE_DIR}/admin/"
trap '' SIGTERM
sudo ./run_test.sh ${SELFDIR}/storage

TEST_OBJECTS=$( \
for file in \
$( \
RUSTFLAGS="-C instrument-coverage" \
cargo +nightly test --manifest-path pixie-shared/Cargo.toml --no-fail-fast --all-features --no-run --message-format=json \
| jq -r "select(.profile.test == true) | .filenames[]" \
| grep -v dSYM - \
); \
do \
printf "%s %s " -object $file; \
done \
)
TEST_OBJECTS=$(
for file in \
$(
RUSTFLAGS="-C instrument-coverage" \
cargo +nightly test --manifest-path pixie-shared/Cargo.toml --no-fail-fast --all-features --no-run --message-format=json |
jq -r "select(.profile.test == true) | .filenames[]" |
grep -v dSYM -
); do
printf "%s %s " -object $file
done
)

"$LLVM_PROFDATA" merge -sparse prof-out/*.profraw -o prof-out/pixie.profdata
"$LLVM_COV" show \
-instr-profile=prof-out/pixie.profdata \
-object pixie-server/target/debug/pixie-server \
-object pixie-uefi/target/x86_64-unknown-uefi/debug/pixie-uefi.efi \
$TEST_OBJECTS \
-Xdemangler=rustfilt \
--ignore-filename-regex='/.cargo' \
--ignore-filename-regex='/.rustup' \
--format html \
-o prof-out/html
-instr-profile=prof-out/pixie.profdata \
-object pixie-server/target/debug/pixie-server \
-object pixie-uefi/target/x86_64-unknown-uefi/debug/pixie-uefi.efi \
$TEST_OBJECTS \
-Xdemangler=rustfilt \
--ignore-filename-regex='/.cargo' \
--ignore-filename-regex='/.rustup' \
--format html \
-o prof-out/html