mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2024-12-22 13:45:20 +00:00
scripts: Support custom arguments to the test binary with dev_cli.sh
The dev container interface script (e.g. 'dev_cli.sh') now supports the following arguments syntax for running tests: `tests [--unit|--cargo|--all] [--libc musl|gnu] [-- [<test scripts args>] [-- [<test binary args>]]] ` In this way, we can pass custom arguments to the test binary (either "cargo test" or "performance-metrics") with our dev container script. For example: `$ ./dev_cli.sh tests --metrics -- -- --report-file /tmp/metrics.json --test-filter latency` `$ ./dev_cli.sh tests --integration -- --test-filter "test_serial" -- --nocapture --test-threads=1` Fixes: #3739 Signed-off-by: Bo Chen <chen.bo@intel.com>
This commit is contained in:
parent
ec7d4e727a
commit
4552d07a80
@ -183,7 +183,7 @@ cmd_help() {
|
|||||||
echo " --volumes Hash separated volumes to be exported. Example --volumes /mnt:/mnt#/myvol:/myvol"
|
echo " --volumes Hash separated volumes to be exported. Example --volumes /mnt:/mnt#/myvol:/myvol"
|
||||||
echo " --hypervisor Underlying hypervisor. Options kvm, mshv"
|
echo " --hypervisor Underlying hypervisor. Options kvm, mshv"
|
||||||
echo ""
|
echo ""
|
||||||
echo " tests [--unit|--cargo|--all] [--libc musl|gnu] [-- [<cargo test args>]]"
|
echo " tests [--unit|--cargo|--all] [--libc musl|gnu] [-- [<test scripts args>] [-- [<test binary args>]]] "
|
||||||
echo " Run the Cloud Hypervisor tests."
|
echo " Run the Cloud Hypervisor tests."
|
||||||
echo " --unit Run the unit tests."
|
echo " --unit Run the unit tests."
|
||||||
echo " --cargo Run the cargo tests."
|
echo " --cargo Run the cargo tests."
|
||||||
@ -369,7 +369,7 @@ cmd_tests() {
|
|||||||
exported_device="/dev/mshv"
|
exported_device="/dev/mshv"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
set -- "$@" '--hypervisor' "$hypervisor"
|
set -- '--hypervisor' "$hypervisor" "$@"
|
||||||
|
|
||||||
ensure_build_dir
|
ensure_build_dir
|
||||||
ensure_latest_ctr
|
ensure_latest_ctr
|
||||||
|
@ -311,13 +311,13 @@ echo 6144 | sudo tee /proc/sys/vm/nr_hugepages
|
|||||||
sudo chmod a+rwX /dev/hugepages
|
sudo chmod a+rwX /dev/hugepages
|
||||||
|
|
||||||
# Run all direct kernel boot (Device Tree) test cases in mod `parallel`
|
# Run all direct kernel boot (Device Tree) test cases in mod `parallel`
|
||||||
time cargo test $features "parallel::$test_filter"
|
time cargo test $features "parallel::$test_filter" -- ${test_binary_args[*]}
|
||||||
RES=$?
|
RES=$?
|
||||||
|
|
||||||
# Run some tests in sequence since the result could be affected by other tests
|
# Run some tests in sequence since the result could be affected by other tests
|
||||||
# running in parallel.
|
# running in parallel.
|
||||||
if [ $RES -eq 0 ]; then
|
if [ $RES -eq 0 ]; then
|
||||||
time cargo test $features "sequential::$test_filter" -- --test-threads=1
|
time cargo test $features "sequential::$test_filter" -- --test-threads=1 ${test_binary_args[*]}
|
||||||
RES=$?
|
RES=$?
|
||||||
else
|
else
|
||||||
exit $RES
|
exit $RES
|
||||||
@ -325,7 +325,7 @@ fi
|
|||||||
|
|
||||||
# Run all ACPI test cases
|
# Run all ACPI test cases
|
||||||
if [ $RES -eq 0 ]; then
|
if [ $RES -eq 0 ]; then
|
||||||
time cargo test $features "aarch64_acpi::$test_filter"
|
time cargo test $features "aarch64_acpi::$test_filter" -- ${test_binary_args[*]}
|
||||||
RES=$?
|
RES=$?
|
||||||
else
|
else
|
||||||
exit $RES
|
exit $RES
|
||||||
@ -333,7 +333,7 @@ fi
|
|||||||
|
|
||||||
# Run all test cases related to live migration
|
# Run all test cases related to live migration
|
||||||
if [ $RES -eq 0 ]; then
|
if [ $RES -eq 0 ]; then
|
||||||
time cargo test $features "live_migration::$test_filter" -- --test-threads=1
|
time cargo test $features "live_migration::$test_filter" -- --test-threads=1 ${test_binary_args[*]}
|
||||||
RES=$?
|
RES=$?
|
||||||
else
|
else
|
||||||
exit $RES
|
exit $RES
|
||||||
|
@ -87,7 +87,7 @@ echo 6144 | sudo tee /proc/sys/vm/nr_hugepages
|
|||||||
sudo chmod a+rwX /dev/hugepages
|
sudo chmod a+rwX /dev/hugepages
|
||||||
|
|
||||||
export RUST_BACKTRACE=1
|
export RUST_BACKTRACE=1
|
||||||
time cargo test $features "live_migration::$test_filter" -- --test-threads=1
|
time cargo test $features "live_migration::$test_filter" -- --test-threads=1 ${test_binary_args[*]}
|
||||||
RES=$?
|
RES=$?
|
||||||
|
|
||||||
exit $RES
|
exit $RES
|
||||||
|
@ -27,7 +27,7 @@ strip target/$BUILD_TARGET/release/cloud-hypervisor
|
|||||||
|
|
||||||
export RUST_BACKTRACE=1
|
export RUST_BACKTRACE=1
|
||||||
|
|
||||||
time cargo test $features "sgx::$test_filter"
|
time cargo test $features "sgx::$test_filter" -- ${test_binary_args[*]}
|
||||||
RES=$?
|
RES=$?
|
||||||
|
|
||||||
exit $RES
|
exit $RES
|
||||||
|
@ -21,7 +21,7 @@ strip target/$BUILD_TARGET/release/cloud-hypervisor
|
|||||||
|
|
||||||
export RUST_BACKTRACE=1
|
export RUST_BACKTRACE=1
|
||||||
|
|
||||||
time cargo test $features "vfio::$test_filter" -- --test-threads=1
|
time cargo test $features "vfio::$test_filter" -- --test-threads=1 ${test_binary_args[*]}
|
||||||
RES=$?
|
RES=$?
|
||||||
|
|
||||||
exit $RES
|
exit $RES
|
||||||
|
@ -51,7 +51,7 @@ export RUST_BACKTRACE=1
|
|||||||
|
|
||||||
# Only run with 1 thread to avoid tests interfering with one another because
|
# Only run with 1 thread to avoid tests interfering with one another because
|
||||||
# Windows has a static IP configured
|
# Windows has a static IP configured
|
||||||
time cargo test $features "windows::$test_filter"
|
time cargo test $features "windows::$test_filter" -- ${test_binary_args[*]}
|
||||||
RES=$?
|
RES=$?
|
||||||
|
|
||||||
dmsetup remove_all -f
|
dmsetup remove_all -f
|
||||||
|
@ -201,14 +201,14 @@ echo 6144 | sudo tee /proc/sys/vm/nr_hugepages
|
|||||||
sudo chmod a+rwX /dev/hugepages
|
sudo chmod a+rwX /dev/hugepages
|
||||||
|
|
||||||
export RUST_BACKTRACE=1
|
export RUST_BACKTRACE=1
|
||||||
time cargo test $features "parallel::$test_filter"
|
time cargo test $features "parallel::$test_filter" -- ${test_binary_args[*]}
|
||||||
RES=$?
|
RES=$?
|
||||||
|
|
||||||
# Run some tests in sequence since the result could be affected by other tests
|
# Run some tests in sequence since the result could be affected by other tests
|
||||||
# running in parallel.
|
# running in parallel.
|
||||||
if [ $RES -eq 0 ]; then
|
if [ $RES -eq 0 ]; then
|
||||||
export RUST_BACKTRACE=1
|
export RUST_BACKTRACE=1
|
||||||
time cargo test $features "sequential::$test_filter" -- --test-threads=1
|
time cargo test $features "sequential::$test_filter" -- --test-threads=1 ${test_binary_args[*]}
|
||||||
RES=$?
|
RES=$?
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -88,7 +88,7 @@ echo 6144 | sudo tee /proc/sys/vm/nr_hugepages
|
|||||||
sudo chmod a+rwX /dev/hugepages
|
sudo chmod a+rwX /dev/hugepages
|
||||||
|
|
||||||
export RUST_BACKTRACE=1
|
export RUST_BACKTRACE=1
|
||||||
time target/$BUILD_TARGET/release/performance-metrics
|
time target/$BUILD_TARGET/release/performance-metrics ${test_binary_args[*]}
|
||||||
RES=$?
|
RES=$?
|
||||||
|
|
||||||
exit $RES
|
exit $RES
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
hypervisor="kvm"
|
hypervisor="kvm"
|
||||||
test_filter=""
|
test_filter=""
|
||||||
|
test_binary_args=()
|
||||||
|
|
||||||
cmd_help() {
|
cmd_help() {
|
||||||
echo ""
|
echo ""
|
||||||
@ -28,12 +29,20 @@ process_common_args() {
|
|||||||
shift
|
shift
|
||||||
test_filter="$1"
|
test_filter="$1"
|
||||||
;;
|
;;
|
||||||
|
"--") {
|
||||||
|
shift
|
||||||
|
break
|
||||||
|
} ;;
|
||||||
*)
|
*)
|
||||||
;;
|
echo "Unknown test scripts argument: $1. Please use '-- --help' for help."
|
||||||
|
exit
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
shift
|
shift
|
||||||
done
|
done
|
||||||
if [[ ! ("$hypervisor" = "kvm" || "$hypervisor" = "mshv") ]]; then
|
if [[ ! ("$hypervisor" = "kvm" || "$hypervisor" = "mshv") ]]; then
|
||||||
die "Hypervisor value must be kvm or mshv"
|
die "Hypervisor value must be kvm or mshv"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
test_binary_args="$@"
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user