From: Henning Schild <henning.schild@siemens.com>
To: Uladzimir Bely <ubely@ilbers.de>
Cc: isar-users@googlegroups.com
Subject: Re: [PATCH 3/3] testsuite: Document custom testcase for downstreams
Date: Tue, 28 Feb 2023 11:16:34 +0100 [thread overview]
Message-ID: <20230228111634.6395b0ff@md1za8fc.ad001.siemens.net> (raw)
In-Reply-To: <20230228074738.16304-4-ubely@ilbers.de>
Would it maybe make sense to put some tests into meta-isar and
actually demo that layering, where some layer-local tests live in the
layer. Eventually we can maybe split up the whole testsuite into "isar"
and "meta-isar" so "core" and "layer".
Henning
Am Tue, 28 Feb 2023 08:47:38 +0100
schrieb Uladzimir Bely <ubely@ilbers.de>:
> Provide a complete example of testsuite implementation on the
> downstream side in their own testcase directory.
>
> Mention `PYTHONPATH` that needs to be adjusted.
>
> Signed-off-by: Uladzimir Bely <ubely@ilbers.de>
> ---
> testsuite/README.md | 101
> ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 101
> insertions(+)
>
> diff --git a/testsuite/README.md b/testsuite/README.md
> index 476b8607..28036bcb 100644
> --- a/testsuite/README.md
> +++ b/testsuite/README.md
> @@ -122,3 +122,104 @@ And to execute this example:
> $ avocado run sample.py:SampleTest.test_sample
> ```
>
> +## Using a different directory for custom testcases
> +
> +Downstreams may want to keep their testcases in a different directory
> +(e.g. `./test/sample.py` as top-level with test description) but
> reuse +classes implemented in Isar testsuite (e.g.
> `./isar/testsuite/*.py`). This is +a common case for downstream that
> use `kas` to handle layers they use. +
> +In this case it's important to adjust `PYTHONPATH` variable before
> running +avocado so that isar testsuite files could be found:
> +
> +```
> +# TESTSUITEDIR="/work/isar/testsuite"
> +export PYTHONPATH=${PYTHONPATH}:${TESTSUITEDIR}
> +```
> +
> +# Example of the downstream testcase
> +
> +Let's assume the downstream builds `custom_image_name` image for
> `qemuarm64` +target in order to running custom tests using qemu.
> +
> +Let's assume the [kas](https://github.com/siemens/kas) is used by
> +the downstream with the following directory structure:
> +
> +```
> +...
> +├── build/
> +├── isar/
> +├── kas
> +│ ├── qemuarm64.yml
> +│ └── kas-container
> +├── meta-custom-layer
> +└── test
> + ├── run_test.sh
> + ├── scripts
> + │ └── sample_script.sh
> + └── sample.py
> +```
> +
> +### test/sample.py:
> +
> +```
> +#!/usr/bin/env python3
> +
> +from cibase import CIBaseTest
> +
> +class SampleTest(CIBaseTest):
> + def test_sample_script(self):
> + self.init("/build")
> + self.vm_start('arm64','bullseye', image='custom_image_name',
> \
> + script='sample_script.sh')
> +```
> +
> +### test/run_test.sh:
> +
> +```
> +#!/usr/bin/env bash
> +
> +# Make Isar testsuite accessable
> +export PYTHONPATH=${PYTHONPATH}:${TESTSUITEDIR}
> +
> +# install avocado in virtualenv in case it is not there already
> +if ! command -v avocado > /dev/null; then
> + sudo apt-get -y update
> + sudo apt-get -y install virtualenv
> + rm -rf /tmp/avocado_venv
> + virtualenv --python python3 /tmp/avocado_venv
> + source /tmp/avocado_venv/bin/activate
> + pip install avocado-framework==100.1
> +fi
> +
> +# Install qemu
> +if ! command -v qemu-system-aarch64 > /dev/null; then
> + sudo apt-get -y update
> + sudo apt-get -y install --no-install-recommends
> qemu-system-aarch64 ipxe-qemu +fi
> +
> +# Start tests in this dir
> +BASE_DIR="/build/avocado"
> +
> +# Provide working path
> +mkdir -p .config/avocado
> +cat <<EOF > .config/avocado/avocado.conf
> +[datadir.paths]
> +base_dir = ${BASE_DIR}/
> +data_dir = ${BASE_DIR}/data
> +logs_dir = ${BASE_DIR}/logs
> +test_dir = ${BASE_DIR}/test
> +EOF
> +export VIRTUAL_ENV="./"
> +
> +tsd=$(dirname $(realpath $0))/scripts
> +
> +# Run SSH tests
> +avocado run --max-parallel-tasks=1 /work/test/test.py -p
> test_script_dir=${tsd} +```
> +
> +Running testcase using `kas shell` may be done as:
> +
> +```
> +./kas/kas-container shell kas/qemuarm64.yml -c
> '/work/test/run_test.sh' +```
prev parent reply other threads:[~2023-02-28 10:16 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-28 7:47 [PATCH 0/3] Creating custom testcases based on Isar one Uladzimir Bely
2023-02-28 7:47 ` [PATCH 1/3] testsuite: Check availability of script to run over ssh Uladzimir Bely
2023-02-28 7:47 ` [PATCH 2/3] testsuite: Move test scripts to their own subdirectory Uladzimir Bely
2023-02-28 7:47 ` [PATCH 3/3] testsuite: Document custom testcase for downstreams Uladzimir Bely
2023-02-28 10:16 ` Henning Schild [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230228111634.6395b0ff@md1za8fc.ad001.siemens.net \
--to=henning.schild@siemens.com \
--cc=isar-users@googlegroups.com \
--cc=ubely@ilbers.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox