blob: 68ba5aa14b6e0de56d9d79fcf13c41aad83adef0 [file]
#!/usr/bin/env bash
# Copyright 2018 The Fuchsia Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
set -eo pipefail
usage() {
echo "usage: ${0} {arm64, x64}"
exit 1
}
case "${1}" in
arm64)
ARCH="arm64"
TARGET="aarch64-unknown-linux-musl";;
x64)
ARCH="x64"
TARGET="x86_64-unknown-linux-musl";;
*)
usage;;
esac
declare -r OUT_DIR="out/${ARCH}"
declare -r IMAGE_FILE="out/linux-tests-${ARCH}.img"
if [ ! -d "rust-crates" ]; then
git clone "https://fuchsia.googlesource.com/third_party/rust-crates"
else
pushd "rust-crates"
git pull
popd
fi
cargo build --target=${TARGET}
mkdir -p ${OUT_DIR}
cp target/${TARGET}/debug/virtio_block_test_util ${OUT_DIR}
cp target/${TARGET}/debug/virtio_net_test_util ${OUT_DIR}
cp target/${TARGET}/debug/virtio_rng_test_util ${OUT_DIR}
declare -r BLOCK_SIZE=4096
declare -r ADDITIONAL_BLOCKS=1024
declare -r SIZE=$(du -sb ${OUT_DIR} | grep -o '^[0-9]*')
declare -r BLOCKS=$(($((${SIZE}/${BLOCK_SIZE}))+${ADDITIONAL_BLOCKS}))
rm -f "${IMAGE_FILE}"
mke2fs -q -d "${OUT_DIR}" -t ext2 -b ${BLOCK_SIZE} "${IMAGE_FILE}" ${BLOCKS}