[Avocado-devel] Wrapping a simple test into an instrumented one
Lukáš Doktor
ldoktor at redhat.com
Thu Jan 2 16:12:26 UTC 2020
Dne 11. 07. 19 v 17:09 Alan Martinovic napsal(a):
> Hi,
> I have a standalone executable written as a form of test which accepts
> cli parameters. In it's core it's executed as `./test -c parameter`
>
> I'd like to wrap that with some python code so that it becomes an instrumented
> test. That way it can benefit from the the standardized way of passing parameters.
>
> I've dedicated a directory for both files:
> ```
> wrapper_tests
> |--test
> `--wrapper-test.py
> ```
>
> The wrapper is executing test with:
> ```
> subprocess.check_output("./test")
> ```
>
> As I try to run it with avocado by passing the wrapper_tests as a parameter two
> errors seem to happen:
> * subprocess.check_output can't find ./test
> * ./test itself is detected as a standalone test to run
>
> Is there a best practice for this situation?
>
> (even though names seem to be the same, this isn't a use case
> for the wrapper plugin)
>
> Be Well,
> Alan
Hello Alan,
it looks like you are executing the test from a different location, therefor "./" means a different directory. You can double-check by running the `avocado run wrapper-test.py` from the `wrapper_test` directory, it should pass. Anyway to address this you need to correctly specify the full address, for examply by using `__file__`:
subprocess.check_output(os.path.join(os.path.dirname(__file__), "test"))
Regards,
Lukáš
PS: I'm sorry the response took so long, I was on a different project for a while and only noticed this email when processing emails after Christmas.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/avocado-devel/attachments/20200102/11fb7244/attachment.sig>
More information about the Avocado-devel
mailing list