Skip to contentSkip to conversation

configure: Enable out-of-tree acceptance tests

RFC PATCH In review Philippe Mathieu-Daudé 3 participants 9 messages May 30, 2018 – Jun 6, 2018

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 configure: Enable out-of-tree acceptance tests

In order to allow out-of-tree acceptance tests with Avocado, create a symlink in the build tree.

---
Based-on: [email protected]
http://lists.nongnu.org/archive/html/qemu-devel/2018-05/msg06877.html

Before:

build_dir$ avocado run /full/path/to/sources/qemu/tests/acceptance/boot_linux_console.py

After

build_dir$ avocado run tests/acceptance/boot_linux_console.py

I first wanted to try something like:

echo "[datadir.paths]" > .avocado.conf
echo "test_dir = $source_path/tests/acceptance" >> .avocado.conf

to run:

build_dir$ avocado run -t console

but this doesn't work this way, I'd have to use

  build_dir$ avocado --config .avocado.conf boot_linux_console.py -t console

which isn't a win.

---
 configure | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
configure +5 -3
index a6a4616c3e..0763ebe5ba 100755
@@ -7213,9 +7213,11 @@ for rom in seabios vgabios ; do
 done
 
 # set up tests data directory
-if [ ! -e tests/data ]; then
-    symlink "$source_path/tests/data" tests/data
-fi
+for tests_subdir in acceptance data; do
+    if [ ! -e tests/$tests_subdir ]; then
+        symlink "$source_path/tests/$tests_subdir" tests/$tests_subdir
+    fi
+done
 
 # set up qemu-iotests in this build directory
 iotests_common_env="tests/qemu-iotests/common.env"
Signature · 1 line
2.17.1
#1 lore raw
Quoted 3 lines · Philippe Mathieu-Daudé

In order to allow out-of-tree acceptance tests with Avocado, create a symlink in the build tree.

"In other to allow" seems to imply that running acceptance tests on an out-of-tree build is impossible without this patch, but:

[...]

Quoted 8 lines

Before:

build_dir$ avocado run /full/path/to/sources/qemu/tests/acceptance/boot_linux_console.py

After

build_dir$ avocado run tests/acceptance/boot_linux_console.py

This seems to imply that running them is possible, but this patch makes it more convenient.

Is this just for convenience, or necessary to allow acceptance tests to run properly? Can this be clarified in the commit message?

Quoted 40 lines

I first wanted to try something like:

echo "[datadir.paths]" > .avocado.conf
echo "test_dir = $source_path/tests/acceptance" >> .avocado.conf

to run:

build_dir$ avocado run -t console

but this doesn't work this way, I'd have to use

  build_dir$ avocado --config .avocado.conf boot_linux_console.py -t console

which isn't a win.

---
 configure | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
configure +5 -3
index a6a4616c3e..0763ebe5ba 100755
@@ -7213,9 +7213,11 @@ for rom in seabios vgabios ; do
 done
 
 # set up tests data directory
-if [ ! -e tests/data ]; then
-    symlink "$source_path/tests/data" tests/data
-fi
+for tests_subdir in acceptance data; do
+    if [ ! -e tests/$tests_subdir ]; then
+        symlink "$source_path/tests/$tests_subdir" tests/$tests_subdir
+    fi
+done
 
 # set up qemu-iotests in this build directory
 iotests_common_env="tests/qemu-iotests/common.env"
Signature · 1 line
2.17.1
Signature · 1 line
Eduardo
#2 lore raw
In reply to Philippe Mathieu-Daudé
Quoted 12 lines · Philippe Mathieu-Daudé

In order to allow out-of-tree acceptance tests with Avocado, create a symlink in the build tree.

---
Based-on: [email protected]
http://lists.nongnu.org/archive/html/qemu-devel/2018-05/msg06877.html

Before:

build_dir$ avocado run /full/path/to/sources/qemu/tests/acceptance/boot_linux_console.py

Quoted 9 lines

After

build_dir$ avocado run tests/acceptance/boot_linux_console.py

I first wanted to try something like:

echo "[datadir.paths]" > .avocado.conf
echo "test_dir = $source_path/tests/acceptance" >> .avocado.conf

FIY, "$HOME/.config/avocado/avocado.conf" is parsed by default. Take a look at the "avocado config" output for the details.

Quoted 4 lines

to run:

build_dir$ avocado run -t console

I see your point, you'd like the command above to behave similarly to:

avocado run -t console $avocado_datadir_paths_test_dir

Right? So, the first compromise solution with current Avocado is:

echo "[datadir.paths]" > ~/.config/avocado/avocado.conf echo "test_dir = $source_path/tests/acceptance" >>
~/.config/avocado/avocado.conf

With "$source_path" being something literal, and not a variable. It allows individual tests to be found at that location:

cd /some/random/path
avocado run boot_linux_console.py

But the following still won't work:

avocado run -t console
No test references provided nor any other arguments resolved into
tests. Please double check the executed command.

I do think the current Avocado behavior is somewhat inconsistent, because list and run should ideally be symmetrical. With the configuration above, "list" behaves like this:

avocado list
INSTRUMENTED /home/cleber/src/qemu/tests/acceptance/boot_linux_console.py:BootLinuxConsole.test INSTRUMENTED /home/cleber/src/qemu/tests/acceptance/version.py:Version.test_qmp_human_info_version INSTRUMENTED /home/cleber/src/qemu/tests/acceptance/vnc.py:Vnc.test_no_vnc INSTRUMENTED /home/cleber/src/qemu/tests/acceptance/vnc.py:Vnc.test_no_vnc_change_password INSTRUMENTED /home/cleber/src/qemu/tests/acceptance/vnc.py:Vnc.test_vnc_change_password_requires_a_password INSTRUMENTED /home/cleber/src/qemu/tests/acceptance/vnc.py:Vnc.test_vnc_change_password

But at the same, there are security implications: list won't load/execute any test code (different from, say, standard Python unittests), while "run" obviously will. So "avocado run" may end up running what users don't want if a malicious user controls "$avocado_datadir_paths_test_dir".

What if Avocado introduces an option that would enable the use of Avocado's test dir when no test reference is given? This could be enabled only once (but would be disabled by default):

echo "[loader]" > ~/.config/avocado/avocado.conf echo "use_test_dir_when_no_references_given = True" >> >
~/.config/avocado/avocado.conf

echo "[datadir.paths]" >> ~/.config/avocado/avocado.conf echo "test_dir = $source_path/tests/acceptance" >>
~/.config/avocado/avocado.conf

And after that, the following would run all "console" tests:

avocado run -t console

How does this sound?

- Cleber.

Quoted 29 lines

but this doesn't work this way, I'd have to use

  build_dir$ avocado --config .avocado.conf boot_linux_console.py -t console

which isn't a win.

---
 configure | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
configure +5 -3
index a6a4616c3e..0763ebe5ba 100755
@@ -7213,9 +7213,11 @@ for rom in seabios vgabios ; do
 done
 
 # set up tests data directory
-if [ ! -e tests/data ]; then
-    symlink "$source_path/tests/data" tests/data
-fi
+for tests_subdir in acceptance data; do
+    if [ ! -e tests/$tests_subdir ]; then
+        symlink "$source_path/tests/$tests_subdir" tests/$tests_subdir
+    fi
+done
 
 # set up qemu-iotests in this build directory
 iotests_common_env="tests/qemu-iotests/common.env"
#3 lore raw
Quoted 17 lines · Cleber Rosa
Quoted 16 lines · Philippe Mathieu-Daudé

In order to allow out-of-tree acceptance tests with Avocado, create a symlink in the build tree.

---
Based-on: [email protected]
http://lists.nongnu.org/archive/html/qemu-devel/2018-05/msg06877.html

Before:

build_dir$ avocado run /full/path/to/sources/qemu/tests/acceptance/boot_linux_console.py

After

build_dir$ avocado run tests/acceptance/boot_linux_console.py

Quoted 8 lines
Quoted 5 lines

I first wanted to try something like:

echo "[datadir.paths]" > .avocado.conf
echo "test_dir = $source_path/tests/acceptance" >> .avocado.conf

FIY, "$HOME/.config/avocado/avocado.conf" is parsed by default. Take a look at the "avocado config" output for the details.

I followed the virtualenv installation from the link you added in testing.rst:
http://avocado-framework.readthedocs.io/en/latest/GetStartedGuide.html#installing-avocado

So my config is:

Config files read (in order):

/builds/qemu/venv2/local/lib/python2.7/site-packages/avocado/etc/avocado/avocado.conf

/builds/qemu/venv2/local/lib/python2.7/site-packages/avocado/etc/avocado/conf.d/result_upload.conf

/builds/qemu/venv2/local/lib/python2.7/site-packages/avocado/etc/avocado/conf.d/resultsdb.conf

/builds/qemu/venv2/local/lib/python2.7/site-packages/avocado/etc/avocado/conf.d/jobscripts.conf

/builds/qemu/venv2/local/lib/python2.7/site-packages/avocado/etc/avocado/conf.d/gdb.conf

    Section.Key                              Value
    datadir.paths.base_dir                   /var/lib/avocado
    datadir.paths.test_dir                   /usr/share/avocado/tests
    datadir.paths.data_dir                   /var/lib/avocado/data
    datadir.paths.logs_dir                   ~/avocado/job-results

I find useful to be able to append/overwrite the user 'global' config with a current directory one, like we have with .gdbinit, because I use out-of-tree build dir to test different build options/features with the same codebase.

So personally I'd like this parse order:

- $VENV/lib/python2.7/site-packages/avocado/etc/avocado/avocado.conf
- $HOME/.config/avocado/avocado.conf
- .avocado.conf

Quoted 16 lines
Quoted 5 lines

to run:

build_dir$ avocado run -t console

I see your point, you'd like the command above to behave similarly to:

avocado run -t console $avocado_datadir_paths_test_dir

Right? So, the first compromise solution with current Avocado is:

echo "[datadir.paths]" > ~/.config/avocado/avocado.conf echo "test_dir = $source_path/tests/acceptance" >>
~/.config/avocado/avocado.conf

Quoted 5 lines

With "$source_path" being something literal, and not a variable. It allows individual tests to be found at that location:

cd /some/random/path
avocado run boot_linux_console.py

'echo' is not that friendly :S

$ avocado run boot_linux_console.py
Avocado crashed unexpectedly: Value 'logs_dir' not found in section
'datadir.paths'
You can find details in
/var/tmp/avocado-traceback-2018-06-05_11:32:01-MUn_kE.log
Quoted 42 lines

But the following still won't work:

avocado run -t console
No test references provided nor any other arguments resolved into
tests. Please double check the executed command.

I do think the current Avocado behavior is somewhat inconsistent, because list and run should ideally be symmetrical. With the configuration above, "list" behaves like this:

avocado list
INSTRUMENTED /home/cleber/src/qemu/tests/acceptance/boot_linux_console.py:BootLinuxConsole.test INSTRUMENTED /home/cleber/src/qemu/tests/acceptance/version.py:Version.test_qmp_human_info_version INSTRUMENTED /home/cleber/src/qemu/tests/acceptance/vnc.py:Vnc.test_no_vnc INSTRUMENTED /home/cleber/src/qemu/tests/acceptance/vnc.py:Vnc.test_no_vnc_change_password INSTRUMENTED /home/cleber/src/qemu/tests/acceptance/vnc.py:Vnc.test_vnc_change_password_requires_a_password INSTRUMENTED /home/cleber/src/qemu/tests/acceptance/vnc.py:Vnc.test_vnc_change_password

But at the same, there are security implications: list won't load/execute any test code (different from, say, standard Python unittests), while "run" obviously will. So "avocado run" may end up running what users don't want if a malicious user controls "$avocado_datadir_paths_test_dir".

What if Avocado introduces an option that would enable the use of Avocado's test dir when no test reference is given? This could be enabled only once (but would be disabled by default):

echo "[loader]" > ~/.config/avocado/avocado.conf echo "use_test_dir_when_no_references_given = True" >> >
~/.config/avocado/avocado.conf

echo "[datadir.paths]" >> ~/.config/avocado/avocado.conf echo "test_dir = $source_path/tests/acceptance" >>
~/.config/avocado/avocado.conf

Quoted 5 lines

And after that, the following would run all "console" tests:

avocado run -t console

How does this sound?

For my use cases this doesn't worry me, I'll let Eduardo/Fam opine about use_test_dir_when_no_references_given.

Quoted 32 lines

- Cleber.

Quoted 29 lines

but this doesn't work this way, I'd have to use

  build_dir$ avocado --config .avocado.conf boot_linux_console.py -t console

which isn't a win.

---
 configure | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
configure +5 -3
index a6a4616c3e..0763ebe5ba 100755
@@ -7213,9 +7213,11 @@ for rom in seabios vgabios ; do
 done
 
 # set up tests data directory
-if [ ! -e tests/data ]; then
-    symlink "$source_path/tests/data" tests/data
-fi
+for tests_subdir in acceptance data; do
+    if [ ! -e tests/$tests_subdir ]; then
+        symlink "$source_path/tests/$tests_subdir" tests/$tests_subdir
+    fi
+done
 
 # set up qemu-iotests in this build directory
 iotests_common_env="tests/qemu-iotests/common.env"
#4 lore raw

On Tue, Jun 05, 2018 at 11:45:03AM -0300, Philippe Mathieu-Daudé wrote:
[... something about config files ...]

Quoted 8 lines
Quoted 5 lines

And after that, the following would run all "console" tests:

avocado run -t console

How does this sound?

For my use cases this doesn't worry me, I'll let Eduardo/Fam opine about use_test_dir_when_no_references_given.

Well, I can't give an opinion because I couldn't understand what's the final goal here.

What exactly is missing in the current solution? Why "avocado run -t console ." wouldn't work?

Signature · 1 line
Eduardo
#5 lore raw
Quoted 6 lines · Eduardo Habkost

On Tue, Jun 05, 2018 at 11:45:03AM -0300, Philippe Mathieu-Daudé wrote:
[... something about config files ...]

Quoted 4 lines
Quoted 4 lines

And after that, the following would run all "console" tests:

avocado run -t console

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

How does this sound?

For my use cases this doesn't worry me, I'll let Eduardo/Fam opine about use_test_dir_when_no_references_given.

Well, I can't give an opinion because I couldn't understand what's the final goal here.

You cut too much, the relevant part is:

Quoted 9 lines · Cleber Rosa

But at the same, there are security implications: list won't load/execute any test code (different from, say, standard Python unittests), while "run" obviously will. So "avocado run" may end up running what users don't want if a malicious user controls "$avocado_datadir_paths_test_dir".

What exactly is missing in the current solution? Why "avocado run -t console ." wouldn't work?

It doesn't work in out-of-tree builds, I have to use the full path:

Quoted 1 line
Quoted 1 line

build_dir$ avocado run

/full/path/to/sources/qemu/tests/acceptance/boot_linux_console.py

Don't worry about this RFC patch, I don't have problem to use the full path for now, I suppose the Avocado team will resolve this differently via a configurable option.

Regards,

Phil.

#6 lore raw
Quoted 12 lines · Philippe Mathieu-Daudé
Quoted 11 lines · Eduardo Habkost

On Tue, Jun 05, 2018 at 11:45:03AM -0300, Philippe Mathieu-Daudé wrote:
[... something about config files ...]

Quoted 8 lines
Quoted 5 lines

And after that, the following would run all "console" tests:

avocado run -t console

How does this sound?

For my use cases this doesn't worry me, I'll let Eduardo/Fam opine about use_test_dir_when_no_references_given.

Quoted 11 lines
Quoted 2 lines

Well, I can't give an opinion because I couldn't understand what's the final goal here.

You cut too much, the relevant part is:

Quoted 5 lines · Cleber Rosa

But at the same, there are security implications: list won't load/execute any test code (different from, say, standard Python unittests), while "run" obviously will. So "avocado run" may end up running what users don't want if a malicious user controls "$avocado_datadir_paths_test_dir".

The final goal still isn't clear to me. Why would somebody want to use $avocado_datadir_paths_test_dir instead of just specifying "." in the command-line?

Quoted 9 lines
Quoted 4 lines

What exactly is missing in the current solution? Why "avocado run -t console ." wouldn't work?

It doesn't work in out-of-tree builds, I have to use the full path:

Quoted 1 line
Quoted 1 line

build_dir$ avocado run

/full/path/to/sources/qemu/tests/acceptance/boot_linux_console.py

Isn't the symlink you suggested a better solution than requiring the user to edit a config file?

Signature · 1 line
Eduardo
#7 lore raw
Quoted 35 lines · Eduardo Habkost
Quoted 12 lines · Philippe Mathieu-Daudé
Quoted 11 lines · Eduardo Habkost

On Tue, Jun 05, 2018 at 11:45:03AM -0300, Philippe Mathieu-Daudé wrote:
[... something about config files ...]

Quoted 8 lines
Quoted 5 lines

And after that, the following would run all "console" tests:

avocado run -t console

How does this sound?

For my use cases this doesn't worry me, I'll let Eduardo/Fam opine about use_test_dir_when_no_references_given.

Quoted 11 lines
Quoted 2 lines

Well, I can't give an opinion because I couldn't understand what's the final goal here.

You cut too much, the relevant part is:

Quoted 5 lines · Cleber Rosa

But at the same, there are security implications: list won't load/execute any test code (different from, say, standard Python unittests), while "run" obviously will. So "avocado run" may end up running what users don't want if a malicious user controls "$avocado_datadir_paths_test_dir".

The final goal still isn't clear to me. Why would somebody want to use $avocado_datadir_paths_test_dir instead of just specifying "." in the command-line?

Quoted 5 lines
Quoted 4 lines

What exactly is missing in the current solution? Why "avocado run -t console ." wouldn't work?

Quoted 8 lines
Quoted 4 lines

It doesn't work in out-of-tree builds, I have to use the full path:

Quoted 1 line
Quoted 1 line

build_dir$ avocado run

/full/path/to/sources/qemu/tests/acceptance/boot_linux_console.py

Isn't the symlink you suggested a better solution than requiring the user to edit a config file?

It's definitely the simplest, and would avoid a questionable knob and behavior in Avocado.

- Cleber.

#8 lore raw
Quoted 26 lines · Cleber Rosa
Quoted 25 lines · Eduardo Habkost
Quoted 23 lines · Philippe Mathieu-Daudé
Quoted 6 lines · Eduardo Habkost

On Tue, Jun 05, 2018 at 11:45:03AM -0300, Philippe Mathieu-Daudé wrote:
[... something about config files ...]

Quoted 4 lines
Quoted 4 lines

And after that, the following would run all "console" tests:

avocado run -t console

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

How does this sound?

For my use cases this doesn't worry me, I'll let Eduardo/Fam opine about use_test_dir_when_no_references_given.

Well, I can't give an opinion because I couldn't understand what's the final goal here.

You cut too much, the relevant part is:

Quoted 5 lines · Cleber Rosa

But at the same, there are security implications: list won't load/execute any test code (different from, say, standard Python unittests), while "run" obviously will. So "avocado run" may end up running what users don't want if a malicious user controls "$avocado_datadir_paths_test_dir".

Quoted 3 lines
Quoted 3 lines

The final goal still isn't clear to me. Why would somebody want to use $avocado_datadir_paths_test_dir instead of just specifying "." in the command-line?

Oh I guess I misunderstood your first review, I'll just improve the commit message and repost.

Quoted 12 lines
Quoted 12 lines
Quoted 11 lines
Quoted 6 lines

What exactly is missing in the current solution? Why "avocado run -t console ." wouldn't work?

It doesn't work in out-of-tree builds, I have to use the full path:

Quoted 1 line
Quoted 1 line

build_dir$ avocado run

/full/path/to/sources/qemu/tests/acceptance/boot_linux_console.py

Quoted 6 lines
Quoted 3 lines

Isn't the symlink you suggested a better solution than requiring the user to edit a config file?

It's definitely the simplest, and would avoid a questionable knob and behavior in Avocado.

:)