tests: Use newgrp to run unit tests

Rather than set filesystem permissions on the /dev/kvm device instead
use the kvm group added by installing qemu for running the unit tests.

Signed-off-by: Rob Bradford <robert.bradford@intel.com>
This commit is contained in:
Rob Bradford 2019-08-16 15:11:47 +01:00 committed by Sebastien Boeuf
parent f5a6e3c1ca
commit 8b78e1221e
2 changed files with 6 additions and 4 deletions

3
Jenkinsfile vendored
View File

@ -11,11 +11,10 @@ stage ("Builds") {
sh "nohup curl https://sh.rustup.rs -sSf | sh -s -- -y" sh "nohup curl https://sh.rustup.rs -sSf | sh -s -- -y"
} }
stage ('Run unit tests') { stage ('Run unit tests') {
sh "sudo chmod a+rw /dev/kvm"
sh "scripts/run_unit_tests.sh" sh "scripts/run_unit_tests.sh"
} }
stage ('Run integration tests') { stage ('Run integration tests') {
sh "sudo mount -t tmpfs tmpfs /tmp" sh "sudo mount -t tmpfs tmpfs /tmp"
sh "scripts/run_integration_tests.sh" sh "scripts/run_integration_tests.sh"
} }
} }

View File

@ -13,8 +13,11 @@ pushd target/debug
ls | grep net_util | grep -v "\.d" | xargs -n 1 sudo setcap cap_net_admin,cap_net_raw+ep ls | grep net_util | grep -v "\.d" | xargs -n 1 sudo setcap cap_net_admin,cap_net_raw+ep
popd popd
for f in $(find . -name Cargo.toml -printf '%h\n' | sort -u); do sudo adduser $USER kvm
pushd $f > /dev/null; newgrp kvm << EOF || exit 1
for f in \$(find . -name Cargo.toml -printf '%h\n' | sort -u); do
pushd \$f > /dev/null;
cargo test || exit 1; cargo test || exit 1;
popd > /dev/null; popd > /dev/null;
done done
EOF