Skip to content

Commit

Permalink
Merge pull request #174 from harish-24/args_patch
Browse files Browse the repository at this point in the history
Add option to provide test-specific args through host config
  • Loading branch information
Satheesh Rajendran authored Apr 8, 2020
2 parents bbfc569 + 2418c7b commit d14a603
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 17 deletions.
5 changes: 3 additions & 2 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -295,8 +295,9 @@
- The user runs the host_sanity suite using the avocado-setup.py script explained in Section 4 above.
- If the user wishes to run a test with yaml file inputs, the yaml file can be specified in the same line in the cfg file,
separated by a space. Refer config/tests/host/example.cfg for example.
- If the user wishes to run a test with yaml by specifying execution order, the order {tests-per-variant,variants-per-test}
can be specified in the same line, after yaml, separated by a space.
- If the user wishes to run a test with test-specific additional arguements such as --execution-order, --mux-filer-only etc.,
those can be specified in the same line. Note that test-specific arguements can be provided with or without the yaml,
followed by a space within quotes. Refer config/tests/host/example.cfg for example


6. NO RUN TEST
Expand Down
40 changes: 26 additions & 14 deletions avocado-setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import shutil
import time
import sys
import shlex
import argparse
import configparser
import binascii
Expand Down Expand Up @@ -456,6 +457,7 @@ def parse_test_config(test_config_file, avocado_bin, enable_kvm):
test_config_contents = fp.read()
test_list = []
mux_flag = 0
arg_flag = 0
for line in test_config_contents.splitlines():
norun_flag = False
test_dic = {}
Expand All @@ -473,7 +475,8 @@ def parse_test_config(test_config_file, avocado_bin, enable_kvm):
break
if norun_flag:
continue
line = line.split()
# split line ignoring quotes used for additional args
line = shlex.split(line)
test_dic['test'] = line[0].strip('$')
test_dic['name'] = test_dic['test'].split("/")[-1]
if ":" in test_dic['test'].split("/")[-1]:
Expand All @@ -486,28 +489,37 @@ def parse_test_config(test_config_file, avocado_bin, enable_kvm):
if helper.runcmd(cmd, ignore_status=True)[0] != 0:
logger.debug("%s does not exist", test_dic['test'])
continue
# Handling parameters after test from cfg
if len(line) > 1:
test_dic['mux'] = line[1]
mux_flag = 1
test_dic['name'] = "%s_%s" % (test_dic['name'], test_dic['mux'].split("/")[-1].split(".")[0])
if args.inputfile:
mux_file = os.path.join(TEST_DIR, test_dic['mux'])
if not os.path.isfile(mux_file):
logger.debug("%s does not exist", mux_file)
continue
tmp_mux_path = os.path.join('/tmp/mux/', "%s_%s.yaml" % (test_config_name, test_dic['name']))
edit_mux_file(test_config_name, mux_file, tmp_mux_path)
test_dic['mux'] = tmp_mux_path
# Handling yaml file from second param
if '.yaml' in line[1]:
test_dic['mux'] = line[1]
mux_flag = 1
test_dic['name'] = "%s_%s" % (test_dic['name'], test_dic['mux'].split("/")[-1].split(".")[0])
if args.inputfile:
mux_file = os.path.join(TEST_DIR, test_dic['mux'])
if not os.path.isfile(mux_file):
logger.debug("%s does not exist", mux_file)
continue
tmp_mux_path = os.path.join('/tmp/mux/', "%s_%s.yaml" % (test_config_name, test_dic['name']))
edit_mux_file(test_config_name, mux_file, tmp_mux_path)
test_dic['mux'] = tmp_mux_path
# Handling additional args from second param
else:
arg_flag = 1
test_dic['args'] = " %s" % line[1]
count = 0
for list_dic in test_list:
if test_dic['name'] == list_dic['name'].split('.')[0]:
count += 1
if count:
test_dic['name'] += ".%d" % (count + 1)
# Handle additional args after yaml(second arg) from third param
if len(line) > 2:
test_dic['args'] = " --execution-order %s " % line[2]
arg_flag = 1
test_dic['args'] = " %s" % line[2]
test_list.append(test_dic)
if mux_flag == 0:
if mux_flag == 0 and arg_flag == 0:
single_test_dic = {}
single_test_dic['name'] = test_config_name
single_test_dic['test'] = ''
Expand Down
3 changes: 2 additions & 1 deletion config/tests/host/example.cfg
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
avocado-misc-tests/io/disk/ioping.py avocado-misc-tests/io/disk/ioping.py.data/ioping.yaml tests-per-variant
avocado-misc-tests/io/disk/ioping.py avocado-misc-tests/io/disk/ioping.py.data/ioping.yaml "--execution-order tests-per-variant"
avocado-misc-tests/io/disk/fs_mark.py avocado-misc-tests/io/disk/fs_mark.py.data/fs_mark.yaml
avocado-misc-tests/memory/ndctl.py "--mux-filter-out /run/config/mode_types"

0 comments on commit d14a603

Please sign in to comment.