Skip to content

env: TestEnv: Add a from_cli() alternative constructor

Darryl Green requested to merge github/fork/valschneider/next-testenv-cli into next

Created by: valschneider

This uses Python's argparse library.

I couldn't find a way to make subparsers work the way I want them to work (I want to be able to specify --kind=android or --kind=linux, not just android/linux), so I had to make do.

With this baby it's easy to write a script dummy.py:

#!/usr/bin/python3

from lisa.env import TestEnv

te = TestEnv.from_cli()
print(te.target.echo("42"))
./dummy.py 
usage: dummy.py [-h] --kind {android,linux,host}
dummy.py: error: the following arguments are required: --kind/-k
./dummy.py -k android
usage: dummy.py [-h] --kind {android,linux,host} --device DEVICE
dummy.py: error: the following arguments are required: --device/-d
./dummy.py -k linux
usage: dummy.py [-h] --kind {android,linux,host} --hostname HOST
                    --username USERNAME --password PASSWORD
dummy.py: error: the following arguments are required: --hostname/-n, --username/-u, --password/-p
./dummy.py -k host
Module bl is not supported by the target
Module devfreq is not supported by the target
Module fastboot is not supported by the target
Module gem5stats is not supported by the target
Module gpufreq is not supported by the target
Module hotplug is not supported by the target
Module odroidxu3-fan is not supported by the target
Module cgroups is not supported by the target
Failed to initialized "bl" devlib Module
Failed to initialized "cgroups" devlib Module
Failed to initialized "devfreq" devlib Module
Failed to initialized "fastboot" devlib Module
Failed to initialized "gem5stats" devlib Module
Failed to initialized "gpufreq" devlib Module
Failed to initialized "hotplug" devlib Module
Failed to initialized "mbed-fan" devlib Module
Failed to initialized "odroidxu3-fan" devlib Module
Couldn't read target energy model: Unable to probe for energy model on target.
42

Merge request reports