Skip to contentSkip to conversation

Proposal - lightweight auto test binaries

DISCUSSION Ian Jackson 5 participants 6 messages Jan 12, 2021 – Jan 15, 2021

lore
Share & tools
lore
#0 lore raw

Andy and I were discussing some new tests he's written which (will) live in xen.git and which we would like to wire into osstest.

We came up with the following proposal (I have refined some of the details beyond what we discussed on IRC):

* Tests will live in tools/tests/ ideally, but they might live in other places in the xen.git source tree.

* When appropriately configured, the xen.git build system will ship them into dist/install/usr/local/....

* There will be a specific directory containing tests which are suitable for running automatically:
dist/install/usr/local/lib/xen/autotests

* The pass/success reporting API will be encoded into the filename. For now we define only one API:
dist/install/usr/local/lib/xen/autotests/simple/*

The "simple" test API is as follows:

* Every executable file (or symlink to one) in dist/install/usr/local/lib/xen/autotests/simple/ will be run with no arguments.

* Only files whose names contain only [-0-9a-z] will be run. Others will be ignored. NB _ is not allowed.

* A test may exit with one of the XTF exit statuses:
0 # XTF SUCCESS
3 # XTF SKIP
4 # XTF ERROR
5 # XTF FAILURE
6 # XTF CRASH
(osstest will treat anything other than 0 and 3 as "fail") Any other termination should be treated as CRASH.

* If a test exits nonzero it should print some information about the situation to stderr.

* Tests may print other information to stderr, which will be captured and logged.

* Tests *must not* print anything to stdout. Test runners *must* ignore stdout (though they may log it, possibly mixed in with stderr). stdout is reserved for future extension.

* Tests should exit with XTF ERROR if they are passed any arguments.

* Tests will be run sequentially on a Xen dom0. If the environment (eg Xen configuration) or hardware is not suitable they should report SKIP.

* If a test program reports SUCCESS or SKIP, it *must* leave the host in a good state suitable for running more tests. It *must not* leak resources (domains, xenstore entries, files). (It may of course advance the domid counter.)

* If a test reports any other status, the host may not been in a good state any more.

* Tests should support being run from their installed location /usr/local/lib/xen/autotests/
If they need any additional files or data or anything, that *must* be provided somewhere in dist/install/ for installation on the host.

* Tests may also support being run from the build tree, or from dist/install/ without copying into /usr/local. They may require an environment variable to be set to find ancillary files, or perhaps look at their argv[0], or something.

* The protocol document (basically, derived from this email) will live in xen.git (and might be shipped as dist/install/usr/local/lib/xen/autotests/README.md or something)

Future directions:

We think we may invent a new multiple-test API where the test program can report the outcome of multiple tests. That will have its own directory in dist/install/usr/local/lib/xen/autotests/.

We may invent extensions which involve passing environent variables, or command line arguments, to "simple" test programs. The former will be ignored by older test programs and the latter rejected. The precise details are beyond the scope of this mail.

Extension may also involve defining a meaning for the test's stdout.

Ian.

#1 lore raw
Quoted 8 lines · Ian Jackson

Andy and I were discussing some new tests he's written which (will) live in xen.git and which we would like to wire into osstest.

We came up with the following proposal (I have refined some of the details beyond what we discussed on IRC):

* Tests will live in tools/tests/ ideally, but they might live in other places in the xen.git source tree.

I've submitted
https://lore.kernel.org/xen-devel/[email protected]/T/#u
to clean up the not-really-tests from the tests dir.

This leaves us with cpu-policy, depriv, mce-test, vhpet, vpci, x86_emulator and xenstore.

Of those, cpu-policy, vpci and x86_emulator are real unit tests, involving varying quantities of gymnastics to compile.  They can in principle be run on the build machine, but x86_emulator is sensitive to the CPU instructions available, and would definitely benefit from running on as wider set of hardware as possible.

vhpet is also a real unit test, but isn't even compiled by default and seems to need some manual code hacking to compile, and takes a complicated array command line arguments.

xenstore needs a running xenstored to talk to, so needs to run on the test system, but is otherwise self contained and easy to use.

depriv, I'm struggling to follow.  Its presumably doing things with the various ioctl restriction, therefore wants to be on the test system, but does take a complicated array of command line options.

mce-test is a complicated mess of test case scripts, which look like they might have been pulled out of a preexisting test framework elsewhere.  The binary xen-mceinj uses the MCE interposer functionality to try and inject real-looking errors into the system.  I haven't had much luck with this in the past, and it has been bitrotting for most of a decade.  I don't know if there is anything salvageable here or not.

I've had a quick look through the rest of the tree and I can't spot anything else which is obviously test code.

I reckon for a first stab, trying to convert xenstore and cpu-policy to the "simple" API would be a good start.  They both have trivial build requirements, and would be trivial to convert to an exit code based protocol, which would get us content to run for both x86 and ARM in OSSTest.

CC Juergen, who is the owner of the xenstore test.  Are you happy with this being tweaked in the hope that it gets run automatically by OSSTest?

The rest of the tests are going to be varying quantities of complicated to convert.

Quoted 10 lines

* When appropriately configured, the xen.git build system will ship them into dist/install/usr/local/....

* There will be a specific directory containing tests which are suitable for running automatically:
dist/install/usr/local/lib/xen/autotests

* The pass/success reporting API will be encoded into the filename. For now we define only one API:
dist/install/usr/local/lib/xen/autotests/simple/*

Whatever we go for, it ought to be an easy path, and honestly - that's a mouthful to get to.  These tests need to be just as easy for developers to use.

How about opt/xen-autotest/* ?  Much easier in a deb/rpm build to filter the things which clearly shouldn't be in a production system.  It's also invariant of libdir which is an advantage for downstreams who test on more than one distro.

I certainly have plans to reuse this infrastructure in XenRT.  I expect other downstreams would as well.

Quoted 8 lines

The "simple" test API is as follows:

* Every executable file (or symlink to one) in dist/install/usr/local/lib/xen/autotests/simple/ will be run with no arguments.

* Only files whose names contain only [-0-9a-z] will be run. Others will be ignored. NB _ is not allowed.

I'm happy not using _, but why the restriction?

Quoted 12 lines

* A test may exit with one of the XTF exit statuses:
0 # XTF SUCCESS
3 # XTF SKIP
4 # XTF ERROR
5 # XTF FAILURE
6 # XTF CRASH
(osstest will treat anything other than 0 and 3 as "fail") Any other termination should be treated as CRASH.

* If a test exits nonzero it should print some information about the situation to stderr.

Quoted 6 lines

* Tests may print other information to stderr, which will be captured and logged.

* Tests *must not* print anything to stdout. Test runners *must* ignore stdout (though they may log it, possibly mixed in with stderr). stdout is reserved for future extension.

I disagree.  It is far more important that the tests are pleasant for humans to use, both in terms of developing them to begin with, and maintaining them if they go wrong.

In practice, this means human-useful stuff on stdout.  The test automation does not need to care - all it should do is log stdout/stderr, and act upon the exit code.  (Perhaps this is what you meant, but its not clear IMO.)

Quoted 1 line

* Tests should exit with XTF ERROR if they are passed any arguments.

./test-foo --debug-this-harder would be a perfectly reasonable thing for a human to use to investigate problems, and it is what we use in the fuzzing harnesses for investigating crashes.

The automation support shouldn't get in the way of humans, and in this case it really doesn't need to.  Nothing on the automation side of things ought to try passing parameters, and we absolutely aren't going to put in an addition test to fuzz the command line and check that ERROR is reported in all cases.

Quoted 8 lines

* Tests will be run sequentially on a Xen dom0. If the environment (eg Xen configuration) or hardware is not suitable they should report SKIP.

* If a test program reports SUCCESS or SKIP, it *must* leave the host in a good state suitable for running more tests. It *must not* leak resources (domains, xenstore entries, files). (It may of course advance the domid counter.)

I'd relax this slightly (s/program reports/is/ ?), because one possibility is a false SUCCESS/SKIP exit because of a bug in the test binary itself.  This would in practice be a FAIL/ERROR and the host might be in a bad state as a consequence.

Quoted 9 lines

* If a test reports any other status, the host may not been in a good state any more.

* Tests should support being run from their installed location /usr/local/lib/xen/autotests/
If they need any additional files or data or anything, that *must* be provided somewhere in dist/install/ for installation on the host.

Quoted 4 lines

* Tests may also support being run from the build tree, or from dist/install/ without copying into /usr/local. They may require an environment variable to be set to find ancillary files, or perhaps look at their argv[0], or something.

I'd perhaps strengthen this to "Wherever possible, tests SHOULD support", because we want to actively encourage this.

Quoted 11 lines

* The protocol document (basically, derived from this email) will live in xen.git (and might be shipped as dist/install/usr/local/lib/xen/autotests/README.md or something)

Future directions:

We think we may invent a new multiple-test API where the test program can report the outcome of multiple tests. That will have its own directory in dist/install/usr/local/lib/xen/autotests/.

Quoted 6 lines

We may invent extensions which involve passing environent variables, or command line arguments, to "simple" test programs. The former will be ignored by older test programs and the latter rejected. The precise details are beyond the scope of this mail.

Extension may also involve defining a meaning for the test's stdout.

So I think the "simple" prototol will be fine for a lot of cases, including one of the two concrete cases I had (the fault_tll test for exercising error paths in the hypervisor).

The resource mapping test is more complicated, and this complexity overlaps an area which is already a problem for XTF test selection (and was encountered when OpenXT got XTF tests into a runnable state).

For resource mapping, I want to have a test which says "for these configurations, create a domain, and poke the mapping API to check for expected success/failure cases".

The problem is "for these configurations".  Even at the totally basic level,

* PV and Shadow are conditional on Xen's Kconfig.
* PV32 is further conditional on command line settings, and/or whether the hardware supports CET-SS.
* HVM is dependent on Kconfig, hardware, firmware and command line settings.  HAP similarly.

xl create doesn't handle missing CONFIG_SHADOW, or PV32 being disabled cleanly, despite having suitable information available in xl info. While this can (and should) be fixed, its not helpful for the more general testing case.

At the moment, some of this information can be obtained from Xen, but the details are scattered through various stable and unstable hypercalls, and in at least one case, in a stringly typed datastructure.  None are pleasant to obtain at the shell level.

Instead, I was wondering if we should come up with some stable hypfs layout to report Xen platform capabilities.  e.g.

platform/pv/ (dir)
platform/pv/abis = "xen-3.0-x86_64 xen-3.0-x86_32p" (string, but maybe we drop this now as obsolete)
platform/pv/32 (bool or dir)
platform/hvm/ (dir)
platform/hvm/shadow (bool)
platform/hvm/hap (bool)

Fundamentally, we care about *what* xen can/cannot do in this configuration on this hardware, far more than we care about specifically *why* Xen can't do something[0].

These can be retrieved in a reasonably convenient manner on the shell with $(xenhypfs cat /path) and we could definitely do something more useful for scripting with exit codes, etc.

When it comes back to testing, we will have a binary which has a range of configurations built in, and need some mechanism to reliably calculate the subset of configurations applicable in the current situation.

However, again in the interest of making the tests useable for humans, I might go as far as to suggest that we have two separate binaries, a $FOO-select which prints out a list of suitable list of $FOO --config-$X to run and treat as independent "simple" tests.

Thoughts?  I really am making some of this up as I go along, but it is also an area which I've been trying to come up with a good solution for ages.

~Andrew

[0] There is a further goal here in the longrun.  A test lab has an inventory of hardware with a known/expected configuration.  One part of testing should be "does the orchestration framework's idea of what Xen ought to be capable of, match what Xen thinks it is capable of?".

Mismatches here could be a regression in Xen in boot/feature detection, or an unexpected Kconfig for the test, or it could be a change in firmware and/or settings.  Failures of this kind have a habit of causing weird indirect failures, rather than clear cut failures.

These details are important when it comes to (usefully) testing a feature, e.g. TSC handling across migrate.  There are hundreds of moving parts, all of which overlap in complicated ways.  The sane to test this is to first confirm that Xen thinks the TSCs are synchronised, then that dom0 agrees, then that we can exercise the various vTSC= options for domains (using an XTF test rather than a full kernel), as well as the paravirt enlightenments, and then to test a full kernel, first on boot, then on localhost live migrate (i.e. the underlying TSC frequency definitely doesn't change), and then with a remote live migration.

At the moment, debugging "the kernel decided that time went wonky after migrate" is utterly miserable.  The most recent time I played this game, it really was a regression in a firmware update.

Frankly - I would love it if all areas of functionality had tests broken down in a manor similar to ^, because life is far too short to reverse engineer "what went wrong first" manually when a robot can answer that question for me.

#2 lore raw
Quoted 7 lines · Andrew Cooper

I reckon for a first stab, trying to convert xenstore and cpu-policy to the "simple" API would be a good start.  They both have trivial build requirements, and would be trivial to convert to an exit code based protocol, which would get us content to run for both x86 and ARM in OSSTest.

CC Juergen, who is the owner of the xenstore test.  Are you happy with this being tweaked in the hope that it gets run automatically by OSSTest?

Sure!

I've written those tests for validating my rework of the C-xenstored transaction handling, but including them in OSSTest is much appreciated.

Juergen

#3 lore raw
In reply to Andrew Cooper

Andrew Cooper writes ("Re: Proposal - lightweight auto test binaries"):

Quoted 3 lines

I've submitted
https://lore.kernel.org/xen-devel/[email protected]/T/#u
to clean up the not-really-tests from the tests dir.

Yay.

Quoted 13 lines

This leaves us with cpu-policy, depriv, mce-test, vhpet, vpci, x86_emulator and xenstore.

Of those, cpu-policy, vpci and x86_emulator are real unit tests, involving varying quantities of gymnastics to compile.  They can in principle be run on the build machine, but x86_emulator is sensitive to the CPU instructions available, and would definitely benefit from running on as wider set of hardware as possible.

vhpet is also a real unit test, but isn't even compiled by default and seems to need some manual code hacking to compile, and takes a complicated array command line arguments.

Quoted 6 lines

xenstore needs a running xenstored to talk to, so needs to run on the test system, but is otherwise self contained and easy to use.

depriv, I'm struggling to follow.  Its presumably doing things with the various ioctl restriction, therefore wants to be on the test system, but does take a complicated array of command line options.

This is already used by osstest in its qemu depriv tests. It has a complicated bespoke calling convention. It think it should not be disturbed as part of this current work.

Quoted 4 lines

I reckon for a first stab, trying to convert xenstore and cpu-policy to the "simple" API would be a good start.  They both have trivial build requirements, and would be trivial to convert to an exit code based protocol, which would get us content to run for both x86 and ARM in OSSTest.

SGTM

Right, on to your review of my draft. Thanks for the detailed attention.

Quoted 11 lines
Quoted 10 lines

* When appropriately configured, the xen.git build system will ship them into dist/install/usr/local/....

* There will be a specific directory containing tests which are suitable for running automatically:
dist/install/usr/local/lib/xen/autotests

* The pass/success reporting API will be encoded into the filename. For now we define only one API:
dist/install/usr/local/lib/xen/autotests/simple/*

Quoted 8 lines

Whatever we go for, it ought to be an easy path, and honestly - that's a mouthful to get to.  These tests need to be just as easy for developers to use.

How about opt/xen-autotest/* ?  Much easier in a deb/rpm build to filter the things which clearly shouldn't be in a production system.  It's also invariant of libdir which is an advantage for downstreams who test on more than one distro.

I don't have a strong opinion about the path in dist/. I was imagining that we would not build these by default, so there wasn't a problem with clutter in distro packages.

I think that for future extensibility we will want to think about how tests will find any pieces of data, helper executables, or thatever. I would prefer to re-use the existing mechanisms for finding pieces of the installation, even though that makes the result depend on libdir.

Also, that means these tests could be easily plumbed into things like Debian's autopkgtest system. That is a mechanism for testing as-installed packages and a test support .deb is an easy thing to instroduce there.

In summary, I would prefer to use our existing mechanisms for controlling the location and installation of binaries, rather than invent a new ad-hoc arrangement which will turn out to be insufficient, get extended ad-hoc, and maybe eventually replaced by the standard approach.

For human developers, I think it's fine to encourage them to run the programs directly out of the build tree (copied to a target test host if necessary) rather than an installed copy somewhere in /usr. I do that with xl stuff and similar all the time - rsyncing the tree to my test box from the build box if they're not the same environent.

Quoted 5 lines

I certainly have plans to reuse this infrastructure in XenRT.  I expect other downstreams would as well.

Quoted 2 lines

The "simple" test API is as follows:

Quoted 8 lines
Quoted 6 lines

* Every executable file (or symlink to one) in dist/install/usr/local/lib/xen/autotests/simple/ will be run with no arguments.

* Only files whose names contain only [-0-9a-z] will be run. Others will be ignored. NB _ is not allowed.

I'm happy not using _, but why the restriction?

That leaves it possible to use _ for delimiters when test case names are embedded in other strings within in a calling test case framework, etc. Cf the same restriction on Debian package names, which means that a conventional .deb filename can be reliably broken into its component parts.

Also making a rule for _ vs - makes the result more aesthetically pleasing and also easier for humans who do not have to guess (or remember) whether a particular test has _ or - (or even both!). So we should forbid exactly one of the two.

Quoted 4 lines
Quoted 3 lines

* Tests *must not* print anything to stdout. Test runners *must* ignore stdout (though they may log it, possibly mixed in with stderr). stdout is reserved for future extension.

Quoted 8 lines

I disagree.  It is far more important that the tests are pleasant for humans to use, both in terms of developing them to begin with, and maintaining them if they go wrong.

In practice, this means human-useful stuff on stdout.  The test automation does not need to care - all it should do is log stdout/stderr, and act upon the exit code.  (Perhaps this is what you meant, but its not clear IMO.)

I don't know why this human-useful stuff cannot be printed to stderr ?

The reason I want to reserve stdout is that it provides a test behaviour that allows a test runner to distinguish tests conforming to this test protocol, from ones which conform to a more recent version.

So I'm imagining stdout containing machine-readable but human-tolerable output.

Quoted 5 lines
Quoted 1 line

* Tests should exit with XTF ERROR if they are passed any arguments.

./test-foo --debug-this-harder would be a perfectly reasonable thing for a human to use to investigate problems, and it is what we use in the fuzzing harnesses for investigating crashes.

You make a good point.

How about this:

Tests must have a command line parser which rejects unknown options (arguments starting with `--') at the start of the command line. (In the case of a very simple test, it is acceptable to reject all command line arguments.) "Reject" means exit with XTF_ERROR.

However having thought about this I think we need a different error code meaning "I don't support the protocol you are trying to use". None of the existing XTF ones seem suitable. Can we assign 7 to mean XTF_BADUSAGE ?

The only practical burden on test authors is that they have to make their option parser exit 7 on bad options rather than whatever it would normally do. And that they have to actually do *something* with argv even if it's only to insist there's nothing there and bail if there is.

Quoted 5 lines

The automation support shouldn't get in the way of humans, and in this case it really doesn't need to.  Nothing on the automation side of things ought to try passing parameters, and we absolutely aren't going to put in an addition test to fuzz the command line and check that ERROR is reported in all cases.

Passing parameters might be part of a future extension of the API.

Quoted 9 lines
Quoted 8 lines

* Tests will be run sequentially on a Xen dom0. If the environment (eg Xen configuration) or hardware is not suitable they should report SKIP.

* If a test program reports SUCCESS or SKIP, it *must* leave the host in a good state suitable for running more tests. It *must not* leak resources (domains, xenstore entries, files). (It may of course advance the domid counter.)

Quoted 4 lines

I'd relax this slightly (s/program reports/is/ ?), because one possibility is a false SUCCESS/SKIP exit because of a bug in the test binary itself.  This would in practice be a FAIL/ERROR and the host might be in a bad state as a consequence.

I don't understand what you mean. I think a test which falsely reports SUCCESS/SKIP and leaves the host in a bad state is impossible for a test runner to cope with in any reasonable way. So that has to be regarded as a violation of the spec, and the spec must forbid it.

Quoted 7 lines
Quoted 4 lines

* Tests may also support being run from the build tree, or from dist/install/ without copying into /usr/local. They may require an environment variable to be set to find ancillary files, or perhaps look at their argv[0], or something.

I'd perhaps strengthen this to "Wherever possible, tests SHOULD support", because we want to actively encourage this.

Good point. +1.

Quoted 1 line

[ discussion of "for these configurations". ]

...

Quoted 2 lines

Instead, I was wondering if we should come up with some stable hypfs layout to report Xen platform capabilities.  e.g.

IMO that would be a good way to address this problem.

Quoted 4 lines

However, again in the interest of making the tests useable for humans, I might go as far as to suggest that we have two separate binaries, a $FOO-select which prints out a list of suitable list of $FOO --config-$X to run and treat as independent "simple" tests.

Surely we can do this by having the test runner pass a command line argument (or set an env var) rather than making two binaries. Making two binaries is quite annoying as it means two command line parsers and complicated Makefiles for sharing the right object files etc.

Quoted 4 lines

[0] There is a further goal here in the longrun.  A test lab has an inventory of hardware with a known/expected configuration.  One part of testing should be "does the orchestration framework's idea of what Xen ought to be capable of, match what Xen thinks it is capable of?".

Yes. I think this shouldn't be too difficult, at least to get to the point of detecting when Xen changes its mind about what is available.

Ian.

#4 lore raw
In reply to Andrew Cooper
Quoted 12 lines · Andrew Cooper
Quoted 10 lines · Ian Jackson

* When appropriately configured, the xen.git build system will ship them into dist/install/usr/local/....

* There will be a specific directory containing tests which are suitable for running automatically:
dist/install/usr/local/lib/xen/autotests

* The pass/success reporting API will be encoded into the filename. For now we define only one API:
dist/install/usr/local/lib/xen/autotests/simple/*

Quoted 8 lines

Whatever we go for, it ought to be an easy path, and honestly - that's a mouthful to get to.  These tests need to be just as easy for developers to use.

How about opt/xen-autotest/* ?  Much easier in a deb/rpm build to filter the things which clearly shouldn't be in a production system.  It's also invariant of libdir which is an advantage for downstreams who test on more than one distro.

I can see them being packaged as a separate sub-package instead of not packaging at all. And many distributions have rules forbidding native packages form putting stuff into /opt. So a location somewhere in /usr would be preferable.
I'm fine with dist/install/usr/local/lib/xen/autotests.
For running manually, there could be a trivial test runner (shell script) that could be installed into dist/install/usr/local/sbin - to make it even more convenient to access.

Quoted 29 lines

I certainly have plans to reuse this infrastructure in XenRT.  I expect other downstreams would as well.

Quoted 8 lines

The "simple" test API is as follows:

* Every executable file (or symlink to one) in dist/install/usr/local/lib/xen/autotests/simple/ will be run with no arguments.

* Only files whose names contain only [-0-9a-z] will be run. Others will be ignored. NB _ is not allowed.

I'm happy not using _, but why the restriction?

Quoted 15 lines

* A test may exit with one of the XTF exit statuses:
0 # XTF SUCCESS
3 # XTF SKIP
4 # XTF ERROR
5 # XTF FAILURE
6 # XTF CRASH
(osstest will treat anything other than 0 and 3 as "fail") Any other termination should be treated as CRASH.

* If a test exits nonzero it should print some information about the situation to stderr.

* Tests may print other information to stderr, which will be captured and logged.

Quoted 7 lines
Quoted 3 lines

* Tests *must not* print anything to stdout. Test runners *must* ignore stdout (though they may log it, possibly mixed in with stderr). stdout is reserved for future extension.

I disagree.  It is far more important that the tests are pleasant for humans to use, both in terms of developing them to begin with, and maintaining them if they go wrong.

I can see why such restriction would be useful for future extensions, but I don't think it's strictly necessary. An extension can for example require stdout lines with a specific prefix and ignore others.

Quoted 11 lines

In practice, this means human-useful stuff on stdout.  The test automation does not need to care - all it should do is log stdout/stderr, and act upon the exit code.  (Perhaps this is what you meant, but its not clear IMO.)

Quoted 1 line

* Tests should exit with XTF ERROR if they are passed any arguments.

./test-foo --debug-this-harder would be a perfectly reasonable thing for a human to use to investigate problems, and it is what we use in the fuzzing harnesses for investigating crashes.

A data point: libvirt test suite have very same requirement - test binaries needs to be run without an argument and error when they get one. In addition to the error, you get a help message with env variables to use instead (VIR_TEST_DEBUG=1 for example). And I do run it with some dummy argument, to get this help message, because I can't remember how those variables are named. Every single time.
But TBH, if parameters wouldn't be very obvious (like --verbose, or --debug), I'd run --help first too.

In any case, unknown command like arguments should result in an error.

Quoted 8 lines

The problem is "for these configurations".  Even at the totally basic level,

* PV and Shadow are conditional on Xen's Kconfig.
* PV32 is further conditional on command line settings, and/or whether the hardware supports CET-SS.
* HVM is dependent on Kconfig, hardware, firmware and command line settings.  HAP similarly.

Quoted 4 lines

xl create doesn't handle missing CONFIG_SHADOW, or PV32 being disabled cleanly, despite having suitable information available in xl info. While this can (and should) be fixed, its not helpful for the more general testing case.

It indeed is an issue, but in practice this can be worked up incrementally - when the test fails, see if the reason is unsupported (by the test) configuration. And if so - add a condition for this specific case (to return SKIP or choose another configuration). Rinse and repeat.

Quoted 16 lines

At the moment, some of this information can be obtained from Xen, but the details are scattered through various stable and unstable hypercalls, and in at least one case, in a stringly typed datastructure.  None are pleasant to obtain at the shell level.

Instead, I was wondering if we should come up with some stable hypfs layout to report Xen platform capabilities.  e.g.

platform/pv/ (dir)
platform/pv/abis = "xen-3.0-x86_64 xen-3.0-x86_32p" (string, but maybe we drop this now as obsolete)
platform/pv/32 (bool or dir)
platform/hvm/ (dir)
platform/hvm/shadow (bool)
platform/hvm/hap (bool)

Quoted 3 lines

Fundamentally, we care about *what* xen can/cannot do in this configuration on this hardware, far more than we care about specifically *why* Xen can't do something[0].

Yes, I very much agree. But I think it's only slightly related (and definitely not a blocker) for this test layout/API.

Quoted 4 lines

These can be retrieved in a reasonably convenient manner on the shell with $(xenhypfs cat /path) and we could definitely do something more useful for scripting with exit codes, etc.

Quoted 8 lines

When it comes back to testing, we will have a binary which has a range of configurations built in, and need some mechanism to reliably calculate the subset of configurations applicable in the current situation.

However, again in the interest of making the tests useable for humans, I might go as far as to suggest that we have two separate binaries, a $FOO-select which prints out a list of suitable list of $FOO --config-$X to run and treat as independent "simple" tests.

I'd simply go with separate tests returning a SKIP if not applicable on particular config. Internally of course it can be the same code that gets called with different parameters.
In Qubes we do that (various tests that are run on every VM, and some applicable only for Debian/Fedora return a SKIP on the other one) and it works pretty well.

Signature · 5 lines
Best Regards,
Marek Marczykowski-Górecki
Invisible Things Lab
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
#5 lore raw
Quoted 20 lines · Marek Marczykowski-Górecki
Quoted 11 lines · Andrew Cooper
Quoted 10 lines · Ian Jackson

* When appropriately configured, the xen.git build system will ship them into dist/install/usr/local/....

* There will be a specific directory containing tests which are suitable for running automatically:
dist/install/usr/local/lib/xen/autotests

* The pass/success reporting API will be encoded into the filename. For now we define only one API:
dist/install/usr/local/lib/xen/autotests/simple/*

Quoted 8 lines

Whatever we go for, it ought to be an easy path, and honestly - that's a mouthful to get to.  These tests need to be just as easy for developers to use.

How about opt/xen-autotest/* ?  Much easier in a deb/rpm build to filter the things which clearly shouldn't be in a production system.  It's also invariant of libdir which is an advantage for downstreams who test on more than one distro.

Quoted 8 lines

I can see them being packaged as a separate sub-package instead of not packaging at all. And many distributions have rules forbidding native packages form putting stuff into /opt. So a location somewhere in /usr would be preferable.
I'm fine with dist/install/usr/local/lib/xen/autotests.
For running manually, there could be a trivial test runner (shell script) that could be installed into dist/install/usr/local/sbin - to make it even more convenient to access.

local, or not, is down to --prefix, but I do like the idea of having a trivial test runner put into sbin for humans to use.

Automation such as OSSTest and XenRT will want to track tests individually for reporting and/or regression purposes.  But humans wanting to test their change want an easy "run everything and confirm ok".

This is precisely why ./xtf-runner -aqq exists.

Quoted 18 lines
Quoted 18 lines
Quoted 18 lines

* A test may exit with one of the XTF exit statuses:
0 # XTF SUCCESS
3 # XTF SKIP
4 # XTF ERROR
5 # XTF FAILURE
6 # XTF CRASH
(osstest will treat anything other than 0 and 3 as "fail") Any other termination should be treated as CRASH.

* If a test exits nonzero it should print some information about the situation to stderr.

* Tests may print other information to stderr, which will be captured and logged.

* Tests *must not* print anything to stdout. Test runners *must* ignore stdout (though they may log it, possibly mixed in with stderr). stdout is reserved for future extension.

Quoted 6 lines
Quoted 3 lines

I disagree.  It is far more important that the tests are pleasant for humans to use, both in terms of developing them to begin with, and maintaining them if they go wrong.

I can see why such restriction would be useful for future extensions, but I don't think it's strictly necessary. An extension can for example require stdout lines with a specific prefix and ignore others.

If it comes down to it, we can define a new ABI if we need to make an change, and can't find a compatible way of doing it.

But I don't see this plausibly happening for "simple".

Quoted 13 lines
Quoted 4 lines
Quoted 1 line

* Tests should exit with XTF ERROR if they are passed any arguments.

./test-foo --debug-this-harder would be a perfectly reasonable thing for a human to use to investigate problems, and it is what we use in the fuzzing harnesses for investigating crashes.

A data point: libvirt test suite have very same requirement - test binaries needs to be run without an argument and error when they get one. In addition to the error, you get a help message with env variables to use instead (VIR_TEST_DEBUG=1 for example). And I do run it with some dummy argument, to get this help message, because I can't remember how those variables are named. Every single time.
But TBH, if parameters wouldn't be very obvious (like --verbose, or --debug), I'd run --help first too.

Quoted 1 line

In any case, unknown command like arguments should result in an error.

It's somewhat rude to lump every test with needing to use getopt, but I suppose we ought to do something.

Quoted 12 lines
Quoted 8 lines

The problem is "for these configurations".  Even at the totally basic level,

* PV and Shadow are conditional on Xen's Kconfig.
* PV32 is further conditional on command line settings, and/or whether the hardware supports CET-SS.
* HVM is dependent on Kconfig, hardware, firmware and command line settings.  HAP similarly.

Quoted 4 lines

xl create doesn't handle missing CONFIG_SHADOW, or PV32 being disabled cleanly, despite having suitable information available in xl info. While this can (and should) be fixed, its not helpful for the more general testing case.

Quoted 5 lines

It indeed is an issue, but in practice this can be worked up incrementally - when the test fails, see if the reason is unsupported (by the test) configuration. And if so - add a condition for this specific case (to return SKIP or choose another configuration). Rinse and repeat.

That isn't robust.  For the examples given, they all yield EOPNOTSUPP, and from that alone, you can't distinguish "Xen really can't do $X" from "Someone regressed Xen's logic", but you can't distinguish "shadow unavailable" from "HVM unavailable" like this.

Really, what you want is:

if ( xen claims feature $X )
    success = ("text $X" == SUCCESS)
else
    success = ("test $X" == EOPNOTSUPP)

Because that will allow you to spot "someone broke the domain construction logic around $X".

Combined with the orchestration framework's idea of "what should Xen be able to do", you also have:

success = ("xen claims $X" == "xen ought to claim $X")

which allows you to spot "someone broke Xen's ability to spot/enable $X on boot".

Other similar testable areas here are:

foreach interesting CPUID bit:
    if ( bit supported in guest )
        success = ("vm configured with $X" == "$X visible in guest") && ("vm configured without $X" == "$X not visible in guest") else
        success = "vm configured with $X" rejected during construction

There is absolutely a time and a place for the simple tests, and there is a lot of value in having them, but a small piece of C isn't capable of doing this higher level reasoning.

Reasoning this fine grained *is* important given the shear complexity of virtualisation, and I fully intend that the "simple", and this "not-quite-so-simple" set of autotests will be sufficiently quick as to be minutes worth of testing, and live in the Gitlab/patchew pre-commit testing.

~Andrew

P.S. if its not already clear by now, I've spent a lot of time trying to figure out how to turn "something, somewhere, went wrong" bug reports into something more useful for a test robot to report, at the point that it has figured out that something went wrong.