[PATCH v4 2/3] tests: Check wmediumd version
Bob Copeland
me at bobcopeland.com
Fri Mar 10 04:47:31 PST 2017
On Fri, Mar 10, 2017 at 08:12:29AM +0900, Masashi Honma wrote:
> Some wmediumd tests requires new wmediumd features. Modified SNR table,
> location-based config and log levels. The wmediumd 0.2 does not have
> these features, so skip such a tests.
>
> Signed-off-by: Masashi Honma <masashi.honma at gmail.com>
> ---
> tests/hwsim/test_wmediumd.py | 24 ++++++++++++++++++++++++
> 1 file changed, 24 insertions(+)
>
> diff --git a/tests/hwsim/test_wmediumd.py b/tests/hwsim/test_wmediumd.py
> index 9da54d3..a3e475b 100644
> --- a/tests/hwsim/test_wmediumd.py
> +++ b/tests/hwsim/test_wmediumd.py
> @@ -11,6 +11,9 @@ from test_wpas_mesh import check_mesh_support, check_mesh_group_added
> from test_wpas_mesh import check_mesh_peer_connected, add_open_mesh_network
> from test_wpas_mesh import check_mesh_group_removed
>
> +class LocalVariables:
> + is_old_wmediumd = None
> +
> CFG = """
> ifaces :
> {
> @@ -34,6 +37,26 @@ ifaces :
> };
> """
>
> +def check_wmediumd_version():
> + if LocalVariables.is_old_wmediumd != None:
> + if LocalVariables.is_old_wmediumd:
> + raise HwsimSkip('wmediumd not available')
> + return
"is_old_wmediumd" -- is guaranteed to be too vague at some point.
It would be better IMHO to specify the actual needed features from
the test case, e.g.:
# completely untested code follows
def wmediumd_has_position_model():
major, minor, patch = wmediumd_get_version()
return major >= 0 and minor >= 3
def wmediumd_get_version():
try:
verstr = subprocess.check_output(['wmediumd', '-V'])
if 'wmediumd v' not in verstr:
raise HwsimSkip('invalid response from wmediumd version')
# e.g. 'wmediumd v0.0[.0]'
vernum = verstr.split(' ')[1][1:]
revs = vernum.split('.')
# force major, minor, patchlevel
while len(revs) < 3:
revs += [0]
return revs[:3]
except OSError, e:
raise HwsimSkip('wmediumd unavailable')
> def output_wmediumd_log(p, params, data):
> log_file = open(os.path.abspath(os.path.join(params['logdir'],
> 'wmediumd.log')), 'a')
> @@ -93,6 +116,7 @@ def test_wmediumd_path_simple(dev, apdev, params):
> # | |
> # +-----X-----+
> # This tests if 1 and 2 can communicate each other via 0.
> + check_wmediumd_version()
if not wmediumd_has_position_model():
raise HwsimSkip('...')
> fd, fn = tempfile.mkstemp()
> try:
> f = os.fdopen(fd, 'w')
> --
> 2.7.4
>
--
Bob Copeland %% http://bobcopeland.com/
More information about the Hostap
mailing list