mirror of
https://github.com/vanhoefm/fragattacks.git
synced 2025-02-26 13:49:35 -05:00
tests: Add support for reading modules list from a file
The new run-tests.py argument "-l <file>" can now be used to specify the test modules using a text file. Signed-off-by: Ilan Peer <ilan.peer@intel.com>
This commit is contained in:
parent
6492a9cada
commit
3bfa5f10a9
@ -195,14 +195,16 @@ def main():
|
|||||||
parser.add_argument('-f', dest='testmodules', metavar='<test module>',
|
parser.add_argument('-f', dest='testmodules', metavar='<test module>',
|
||||||
help='execute only tests from these test modules',
|
help='execute only tests from these test modules',
|
||||||
type=str, choices=[[]] + test_modules, nargs='+')
|
type=str, choices=[[]] + test_modules, nargs='+')
|
||||||
|
parser.add_argument('-l', metavar='<modules file>', dest='mfile',
|
||||||
|
help='test modules file name')
|
||||||
parser.add_argument('tests', metavar='<test>', nargs='*', type=str,
|
parser.add_argument('tests', metavar='<test>', nargs='*', type=str,
|
||||||
help='tests to run (only valid without -f)',
|
help='tests to run (only valid without -f)',
|
||||||
choices=[[]] + test_names)
|
choices=[[]] + test_names)
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
if args.tests and args.testmodules:
|
if (args.tests and args.testmodules) or (args.tests and args.mfile) or (args.testmodules and args.mfile):
|
||||||
print 'Invalid arguments - both test module and tests given'
|
print 'Invalid arguments - only one of (test, test modules, modules file) can be given.'
|
||||||
sys.exit(2)
|
sys.exit(2)
|
||||||
|
|
||||||
if not args.logdir:
|
if not args.logdir:
|
||||||
@ -290,6 +292,16 @@ def main():
|
|||||||
if args.dmesg:
|
if args.dmesg:
|
||||||
subprocess.call(['sudo', 'dmesg', '-c'], stdout=open('/dev/null', 'w'))
|
subprocess.call(['sudo', 'dmesg', '-c'], stdout=open('/dev/null', 'w'))
|
||||||
|
|
||||||
|
# read the modules from the modules file
|
||||||
|
if args.mfile:
|
||||||
|
args.testmodules = []
|
||||||
|
with open(args.mfile) as f:
|
||||||
|
for line in f.readlines():
|
||||||
|
line = line.strip()
|
||||||
|
if not line or line.startswith('#'):
|
||||||
|
continue
|
||||||
|
args.testmodules.append(line)
|
||||||
|
|
||||||
tests_to_run = []
|
tests_to_run = []
|
||||||
for t in tests:
|
for t in tests:
|
||||||
name = t.__name__.replace('test_', '', 1)
|
name = t.__name__.replace('test_', '', 1)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user