forked from cloud-hypervisor/rust-hypervisor-firmware
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_coreboot_integration_tests.sh
executable file
·38 lines (28 loc) · 1.07 KB
/
run_coreboot_integration_tests.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/bin/bash
set -xeuf
TARGET="${1:-linux}"
source "${CARGO_HOME:-$HOME/.cargo}/env"
rustup component add rust-src
cargo build --release --target target.json -Zbuild-std=core,alloc -Zbuild-std-features=compiler-builtins-mem --features "coreboot"
FW_BIN="$(pwd)/target/target/release/hypervisor-fw"
CB_DIR="./resources/coreboot"
CB_VERSION="4.13"
CB_URL="https://github.com/coreboot/coreboot.git"
CB_PATH="$CB_DIR/coreboot"
CB_CONFIG="$CB_DIR/qemu-q35-config.in"
if [ ! -d "$CB_PATH" ]; then
git clone --quiet --branch $CB_VERSION --depth 1 $CB_URL $CB_PATH
fi
cat $CB_CONFIG | sed -e "s#@CONFIG_PAYLOAD_FILE@#$FW_BIN#g" > "$CB_PATH/.config"
make -C $CB_PATH crossgcc-i386 CPUS="$(nproc)"
make -C $CB_PATH olddefconfig
make -C $CB_PATH -j"$(nproc)"
if [ "$TARGET" == "linux" ]; then
bash ./fetch_disk_images.sh
fi
# Add the user to the kvm group (if not already in it), so they can run VMs
id -nGz "$USER" | grep -qzxF kvm || sudo adduser "$USER" kvm
newgrp kvm << EOF
export RUST_BACKTRACE=1
cargo test --features "coreboot integration_tests" "integration::tests::${TARGET}"
EOF