Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
F
FMC ADC 100M 14b 4cha - Testing
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
FMC ADC 100M 14b 4cha - Testing
Commits
727c24e1
Commit
727c24e1
authored
May 23, 2011
by
Juan David González Cobas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tps: add test name validation code
parent
53da0da3
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
7 deletions
+23
-7
tps.py
tps.py
+23
-7
No files found.
tps.py
View file @
727c24e1
...
...
@@ -18,7 +18,7 @@ default_config_file = 'tpsdefault.cfg'
default_log_pattern
=
'tps_
%(board)
s_
%(serial)
s_
%(number)
s_
%(timestamp)
s.txt'
default_log_name
=
'tps_run_{0}_{1}_{2}_{3}.txt'
default_test_pattern
=
r'test[0-9][0-9]'
default_test_syntax
=
r'(test)?(\d
?
\d)'
default_test_syntax
=
r'(test)?(\d\d)'
def
run_test
(
testname
,
logname
):
"""run test testname with output redirected to logname
...
...
@@ -247,8 +247,23 @@ class Cli(cmd.Cmd, Suite):
do_q
=
do_quit
do_h
=
cmd
.
Cmd
.
do_help
def
normalize_testname
(
name
):
if
name
[:
4
]
==
'test'
:
return
name
[
4
:]
return
name
def
validate_args
(
args
):
valid_args
=
[
normalize_testname
(
arg
)
for
arg
in
args
if
re
.
match
(
default_test_syntax
,
arg
)
]
invalid_args
=
[
arg
for
arg
in
args
if
not
re
.
match
(
default_test_syntax
,
arg
)
]
return
valid_args
,
invalid_args
def
main1
():
usage
=
'
%
prog: [options] test ...'
usage
=
'
%
prog: [options] test ...
\n
run
%
prog --help for more help'
parser
=
OptionParser
(
usage
)
parser
.
add_option
(
"-c"
,
"--config"
,
dest
=
"config"
,
default
=
"tpsdefault.cfg"
,
...
...
@@ -267,24 +282,25 @@ def main1():
help
=
"number of times to repeat the batch of tests"
,
metavar
=
"NUMBER"
)
parser
.
add_option
(
"-r"
,
"--randomize"
,
action
=
"store_true"
,
default
=
False
,
help
=
"run the batch in random order"
,
)
(
options
,
args
)
=
parser
.
parse_args
()
if
not
args
:
parser
.
print_usage
()
return
invalid_args
=
[
arg
for
arg
in
args
if
not
re
.
match
(
default_test_syntax
,
arg
)
]
if
invalid_args
:
valid
,
invalid
=
validate_args
(
args
)
if
invalid
:
print
'invalid test names, aborting:'
,
for
i
in
invalid
_args
:
print
i
,
for
i
in
invalid
:
print
i
,
print
return
s
=
Cli
(
options
.
config
)
s
.
__dict__
.
update
(
options
.
__dict__
)
s
.
sequence
=
args
if
options
.
cli
:
s
.
cmdloop
()
else
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment