-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests reorganization and add main test script (#307)
* tests reorganization and add main test script 1 - reorganization of the tests folder tests having same category live in a subfolder 2 - expose pytest capabilities to users currently, tox is masking all pytest features and only expose what we specify in tox.ini file since tox is only here to manage the test environment it should be transparent to the users for tests execution and management. the users should be able to take full advantage of what pytest offers. we introduced a new script tdtest that hides tox and exopose all pytest features to users * Update tests/README.md Co-authored-by: Will French <will.french@canonical.com> * update tdtest param --------- Co-authored-by: Will French <will.french@canonical.com>
- Loading branch information
1 parent
258f020
commit 2176fdb
Showing
29 changed files
with
96 additions
and
110 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
#!/bin/bash | ||
|
||
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) | ||
|
||
usage() { | ||
cat <<EOM | ||
This script executes tests for TDX | ||
It is a wrapper around pytest, pytest being the framework used to run the tests. | ||
It makes use of tox to manage the test execution environment. | ||
It also provides additional arguments on top of pytest arguments. | ||
So in addition to its specific arguments listed below, the script will | ||
pass through all the arguments to pytest (please check pytest -h to see | ||
available argument). | ||
NB: all pytest arguments must come together AFTER the arguments of tdtest. | ||
Usage: $(basename "$0") [-i|-h] pytest_args | ||
-i|--td-image <image> Ubuntu guest image | ||
-h|--help Show this help | ||
Examples: | ||
To run tests in boot folder: | ||
$ sudo $(basename "$0") tests/boot | ||
To list tests in boot folder: | ||
$ sudo $(basename "$0") --co tests/boot | ||
To run all the tests: | ||
$ sudo $(basename "$0") | ||
--- | ||
EOM | ||
} | ||
|
||
parse_params() { | ||
while :; do | ||
case "${1-}" in | ||
-h | --help) | ||
usage | ||
exit 0 | ||
;; | ||
-i | --td-image) | ||
TDXTEST_GUEST_IMG=$(realpath "${2-}") | ||
shift | ||
;; | ||
"") | ||
break | ||
;; | ||
*) | ||
# other arguments will be passed to pytest | ||
pytest_args="$@" | ||
break | ||
;; | ||
esac | ||
shift | ||
done | ||
} | ||
|
||
parse_params "$@" | ||
|
||
if [ "$EUID" -ne 0 ] | ||
then echo "Please run as root" | ||
exit | ||
fi | ||
|
||
if [[ -z "${UBUNTU_VER}" ]]; then | ||
UBUNTU_VER=$(lsb_release -rs) | ||
fi | ||
|
||
if [[ ! -f "${TDXTEST_GUEST_IMG}" ]]; then | ||
TDXTEST_GUEST_IMG=$PWD/../guest-tools/image/tdx-guest-ubuntu-${UBUNTU_VER}-generic.qcow2 | ||
fi | ||
|
||
apt install -y python3 tox | ||
|
||
export TDXTEST_GUEST_IMG | ||
|
||
echo "Run tests with TD image: ${TDXTEST_GUEST_IMG}" | ||
echo " pytest args: ${pytest_args}" | ||
tox -- --ignore=lib/ "${pytest_args}" |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters