Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
P
Production Test Suite
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
9
Issues
9
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
Production Test Suite
Commits
6dacdddf
Commit
6dacdddf
authored
May 24, 2011
by
Juan David González Cobas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tps: enhance validation of parameters
parent
ec1c8594
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
32 deletions
+41
-32
tps.py
tps.py
+36
-28
tpsexcept.py
tpsexcept.py
+5
-4
No files found.
tps.py
View file @
6dacdddf
...
...
@@ -6,6 +6,7 @@ import cmd
import
glob
import
re
import
os
,
os
.
path
import
stat
import
datetime
import
random
...
...
@@ -95,14 +96,24 @@ class Suite(object):
msg
=
'invalid serial number [{0}]'
.
format
(
self
.
serial
)
raise
TpsInvalid
(
msg
)
mode
=
os
.
stat
(
self
.
test_path
)[
stat
.
S_IMODE
]
if
not
(
stat
.
S_ISDIR
(
mode
)
and
stat
.
S_IWUSR
&
mode
):
try
:
tmp
=
os
.
tempnam
(
self
.
test_path
)
open
(
tmp
,
'w'
)
os
.
unlink
(
tmp
)
except
RuntimeWarning
:
pass
except
IOError
:
msg
=
'invalid test path [{0}]'
.
format
(
self
.
test_path
)
raise
TpsInvalid
(
msg
)
mode
=
os
.
stat
(
self
.
log_path
)[
stat
.
S_IMODE
]
if
not
(
stat
.
S_ISDIR
(
mode
)
and
stat
.
S_IWUSR
&
mode
):
msg
=
'invalid log path [{0}]'
.
format
(
self
.
test_path
)
try
:
tmp
=
os
.
tempnam
(
self
.
log_path
)
open
(
tmp
,
'w'
)
os
.
unlink
(
tmp
)
except
RuntimeWarning
:
pass
except
:
msg
=
'invalid log path [{0}]'
.
format
(
self
.
log_path
)
raise
TpsInvalid
(
msg
)
if
not
self
.
repeat
:
...
...
@@ -128,25 +139,17 @@ class Suite(object):
if
self
.
randomize
:
random
.
shuffle
(
run
)
self
.
run
=
repeat
*
run
self
.
run
_
=
self
.
repeat
*
run
return
self
.
run
return
self
.
run
_
def
run
(
self
):
ts
=
timestamp
()
missing
=
self
.
missing
()
if
missing
:
print
'cannot run with missing parameters,'
,
print
'please supply:'
,
for
f
in
missing
:
print
f
,
print
return
runid
=
sha
(
self
.
board
+
':'
+
self
.
serial
+
':'
+
ts
)
sequence
=
self
.
validate_and_compute_run
()
ts
=
timestamp
()
runid
=
sha
(
self
.
board
+
':'
+
self
.
serial
+
':'
+
ts
)
logfilename
=
self
.
log_name
.
format
(
self
.
board
,
self
.
serial
,
ts
,
runid
)
logfilename
=
os
.
path
.
join
(
self
.
log_path
,
logfilename
)
log
=
file
(
logfilename
,
'wb'
)
sequence
=
self
.
validate_and_compute_run
()
log
=
file
(
logfilename
,
'wb'
)
if
self
.
test_path
not
in
sys
.
path
:
sys
.
path
.
append
(
self
.
test_path
)
...
...
@@ -308,7 +311,8 @@ def validate_args(args):
def
main1
():
usage
=
'
%
prog: [options] test ...
\n
run
%
prog --help for more help'
usage
=
(
'
%
prog: [options] test ...
\n
'
'run
%
prog with option -h or --help for more help'
)
parser
=
OptionParser
(
usage
)
parser
.
add_option
(
"-c"
,
"--config"
,
dest
=
"config"
,
default
=
default_config_file
,
...
...
@@ -329,6 +333,8 @@ def main1():
parser
.
add_option
(
"-r"
,
"--randomize"
,
action
=
"store_true"
,
default
=
False
,
help
=
"run the batch in random order"
,
)
parser
.
add_option
(
"-w"
,
"--write-config"
,
action
=
"store_true"
,
help
=
"write configuration data to config file"
,
)
(
options
,
args
)
=
parser
.
parse_args
()
...
...
@@ -346,14 +352,16 @@ def main1():
s
=
Cli
(
options
.
config
)
s
.
__dict__
.
update
(
options
.
__dict__
)
s
.
sequence
=
valid
if
not
s
.
repeat
:
s
.
repeat
=
1
else
:
try
:
s
.
repeat
=
int
(
options
.
repeat
)
except
ValueError
:
print
'repeat value must be an int: [
%
s]'
%
options
.
repeat
return
try
:
s
.
validate_and_compute_run
()
except
TpsInvalid
,
e
:
print
'bad parameters:'
,
e
.
message
return
# decide what to do
if
options
.
write_config
:
s
.
write_config
()
return
if
options
.
cli
:
s
.
cmdloop
()
...
...
tpsexcept.py
View file @
6dacdddf
...
...
@@ -20,15 +20,16 @@ class TpsWarning(TpsException):
"""warning, a cautionary message should be displayed"""
pass
class
TpsNoBatch
(
TpsException
):
class
TpsInvalid
(
TpsException
):
"""reserved: invalid parameters"""
class
TpsNoBatch
(
TpsInvalid
):
"""reserved: a suite was created without batch of tests to run"""
pass
class
TpsBadTestNo
(
Tps
Exception
):
class
TpsBadTestNo
(
Tps
Invalid
):
"""reserved: a bad test number was given"""
pass
if
__name__
==
'__main__'
:
pass
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