Skip to content

Commit 57771ac

Browse files
committed
add pma etc. in bin directory, run pma.py etc. in pymodel
revise test*.py in all samples to use pma etc. not pma.py etc. remove bin/tpath and tpath.bat, now included in pymodel_paths
1 parent 5e4bd8b commit 57771ac

36 files changed

+235
-151
lines changed

bin/pma

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/usr/bin/env python
2+
"""
3+
This is pma command in bin directory, runs pma.py module in pymodel directory
4+
"""
5+
6+
import pma # find pma.py anywhere on Python path
7+
8+
pma.main()

bin/pmg

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/usr/bin/env python
2+
"""
3+
This is pmg command in bin directory, runs pmg.py module in pymodel directory
4+
"""
5+
6+
import pmg # find pmg.py anywhere on Python path
7+
8+
pmg.main()

bin/pmv

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/usr/bin/env python
2+
"""
3+
This is pmv command in bin directory, runs pmv.py module in pymodel directory
4+
"""
5+
6+
import pmv # find pmv.py anywhere on Python path
7+
8+
pmv.main()

bin/tpath

-1
This file was deleted.

bin/tpath.bat

-3
This file was deleted.

bin/trun

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/usr/bin/env python
2+
3+
import sys
4+
import os
5+
6+
# argv[1] is name of module containing test cases
7+
# dir containing this module must be on PYTHONPATH
8+
9+
test = __import__(sys.argv[1])
10+
11+
# Test cases are in 'cases', a list of pairs of strings, descrip. and commmand:
12+
# cases = [
13+
# ('Test PowerOn, PowerOff alternate due to enabling conditions',
14+
# 'pct.py -n 10 PowerSwitch'),
15+
# ... ]
16+
17+
for (description, cmd) in test.cases:
18+
print description
19+
os.system(cmd)
20+
print

bin/wsgirunner

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/usr/bin/env python
2+
"""
3+
This is wsgirunner command in bin directory, runs wsgirunner.py module in pymodel directory
4+
"""
5+
6+
import wsgirunner # find wsgirunner.py anywhere on Python path
7+
8+
wsgirunner.main()

pymodel/pmv.py

+13-9
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,16 @@ def command(cmd):
3232
if status:
3333
print 'Failed: %s' % cmd # status 0 means success
3434

35-
(options, args) = ViewerOptions.parse_args()
36-
basename = options.__dict__['output'] if options.__dict__['output'] else '%sFSM' % args[0]
37-
pma = 'pma.py ' + make_opts(pma_keys, options) + ' ' + ' '.join(args)
38-
command(pma)
39-
pmg = 'pmg.py ' + make_opts(pmg_keys, options) + ' %s' % basename
40-
command(pmg)
41-
dot = 'dot -T%(type)s -o %(name)s.%(type)s %(name)s.dot' % \
42-
{'type': options.__dict__['fileType'], 'name': basename}
43-
command(dot)
35+
def main():
36+
(options, args) = ViewerOptions.parse_args()
37+
basename = options.__dict__['output'] if options.__dict__['output'] else '%sFSM' % args[0]
38+
pma = 'pma ' + make_opts(pma_keys, options) + ' ' + ' '.join(args)
39+
command(pma)
40+
pmg = 'pmg ' + make_opts(pmg_keys, options) + ' %s' % basename
41+
command(pmg)
42+
dot = 'dot -T%(type)s -o %(name)s.%(type)s %(name)s.dot' % \
43+
{'type': options.__dict__['fileType'], 'name': basename}
44+
command(dot)
45+
46+
if __name__ == ' __main__':
47+
main()

samples/PowerSwitch/SpeedControl.py

+27-8
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,33 @@
1-
"""
2-
SpeedControl defined by FSM, no shared actions with PowerSwitch
3-
"""
1+
2+
# pma --maxTransitions 100 --output SpeedControl SpeedControl
3+
# 3 states, 3 transitions, 1 accepting states, 0 unsafe states, 0 finished and 0 deadend states
4+
5+
# actions here are just labels, but must be symbols with __name__ attribute
46

57
def IncrementSpeed(): pass
68

7-
cleanup = (IncrementSpeed,)
9+
# states, key of each state here is its number in graph etc. below
10+
11+
states = {
12+
0 : {'SpeedControl': 0},
13+
1 : {'SpeedControl': 1},
14+
2 : {'SpeedControl': 2},
15+
}
16+
17+
# initial state, accepting states, unsafe states, frontier states, deadend states
818

919
initial = 0
10-
accepting = (0,)
20+
accepting = [0]
21+
unsafe = []
22+
frontier = []
23+
finished = []
24+
deadend = []
25+
runstarts = [0]
26+
27+
# finite state machine, list of tuples: (current, (action, args, result), next)
1128

12-
graph = ((0, (IncrementSpeed, (), None), 1),
13-
(1, (IncrementSpeed, (), None), 2),
14-
(2, (IncrementSpeed, (), None), 0))
29+
graph = (
30+
(0, (IncrementSpeed, (), None), 1),
31+
(1, (IncrementSpeed, (), None), 2),
32+
(2, (IncrementSpeed, (), None), 0),
33+
)

samples/PowerSwitch/test_graphics.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,25 @@
44

55
cases = [
66
('Generate FSM from PowerSwitch model program',
7-
'pma.py PowerSwitch'),
7+
'pma PowerSwitch'),
88

99
('Generate dot graphics commands from generated PowerSwitchFSM',
10-
'pmg.py PowerSwitchFSM'),
10+
'pmg PowerSwitchFSM'),
1111

1212
('Generate SVG file from dot commands',
1313
'dotsvg PowerSwitchFSM'),
1414

1515
('Generate dot commands from SpeedControl FSM',
16-
'pmg.py SpeedControl'),
16+
'pmg SpeedControl'),
1717

1818
('Generate SVG file from dot commands',
1919
'dotsvg SpeedControl'),
2020

2121
('Generate FSM from composition of PowerSwitch and SpeedControl, show interleaving',
22-
'pma.py SpeedControl PowerSwitch -o PowerSpeed'),
22+
'pma SpeedControl PowerSwitch -o PowerSpeed'),
2323

2424
('Generate dot commands from composed FSM',
25-
'pmg.py PowerSpeed'),
25+
'pmg PowerSpeed'),
2626

2727
('Generate SVG from dot',
2828
'dotsvg PowerSpeed')

samples/PowerSwitch/test_scenarios.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
cases = [
22
('Scenarios module with four runs, by itself',
3-
'pmt.py Scenarios'),
3+
'pmt Scenarios'),
44

55
('Scenarios module, compose with PowerSwitch model, last two runs not allowed',
6-
'pmt.py Scenarios PowerSwitch'),
6+
'pmt Scenarios PowerSwitch'),
77

88
('SpeedControl module, by itself',
9-
'pmt.py -n 2 -c 3 SpeedControl'),
9+
'pmt -n 2 -c 3 SpeedControl'),
1010

1111
('PowerSwitch module, compose with SpeedControl, no shared actions',
12-
'pmt.py -s 3 -n 10 -c 3 SpeedControl PowerSwitch')
12+
'pmt -s 3 -n 10 -c 3 SpeedControl PowerSwitch')
1313
]

samples/Stack/test_graphics.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,25 @@
44

55
cases = [
66
('Generate FSM with first 12 transitions',
7-
'pma.py Stack -m 12'),
7+
'pma Stack -m 12'),
88

99
('Generate dot commands',
10-
'pmg.py StackFSM'),
10+
'pmg StackFSM'),
1111

1212
('Generate SVG file',
1313
'dotsvg StackFSM'),
1414

1515
('Generate dot commands for scenario FSM',
16-
'pmg.py StackOneScenario'),
16+
'pmg StackOneScenario'),
1717

1818
('Generate SVG',
1919
'dotsvg StackOneScenario'),
2020

2121
('Explore composition of model with scenario machine, show synchronization',
22-
'pma.py Stack StackOneScenario StackDepthThree -m 6 -o StackSynchronized'),
22+
'pma Stack StackOneScenario StackDepthThree -m 6 -o StackSynchronized'),
2323

2424
('Generate dot',
25-
'pmg.py StackSynchronized'),
25+
'pmg StackSynchronized'),
2626

2727
('Generate SVG',
2828
'dotsvg StackSynchronized')

samples/Stack/test_observables.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
cases = [
22
('Push is observable here so no actions are enabled in the initial state',
3-
'pmt.py -n 10 -s 1 Stack Observables'),
3+
'pmt -n 10 -s 1 Stack Observables'),
44

55
('Accepts Push(3) but not Pop(3) because here Push is observable, Pop controllable',
6-
'pmt.py -n 10 -s 1 Stack Observables Scenarios'),
6+
'pmt -n 10 -s 1 Stack Observables Scenarios'),
77

88
('Accepts both Push(3) and Pop(3) because here both are observable, still doesnt accept out-of-order Pop.',
9-
'pmt.py -n 10 -s 1 Stack AllObservables Scenarios'),
9+
'pmt -n 10 -s 1 Stack AllObservables Scenarios'),
1010
]
+8-8
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
cases = [
22
('Scenarios module with three runs, by itself',
3-
'pma.py Scenarios'),
4-
('Generate Dot', 'pmg.py ScenariosFSM'),
3+
'pma Scenarios'),
4+
('Generate Dot', 'pmg ScenariosFSM'),
55
('Generate SVG', 'dotsvg ScenariosFSM'),
66

77
('Scenarios module, compose with Stack model, last three runs not allowed',
8-
'pma.py -o ValidateScenarios Scenarios Stack'),
9-
('Generate Dot', 'pmg.py ValidateScenarios'),
8+
'pma -o ValidateScenarios Scenarios Stack'),
9+
('Generate Dot', 'pmg ValidateScenarios'),
1010
('Generate SVG', 'dotsvg ValidateScenarios'),
1111

1212
('Scenarios, compose with Stack, Push is observable',
13-
'pma.py -o ValidateObservables Scenarios Stack Observables'),
14-
('Generate Dot', 'pmg.py ValidateObservables'),
13+
'pma -o ValidateObservables Scenarios Stack Observables'),
14+
('Generate Dot', 'pmg ValidateObservables'),
1515
('Generate SVG', 'dotsvg ValidateObservables'),
1616

1717
('Scenarios, compose with Stack, Push and Pop are observable',
18-
'pma.py -o ValidateAllObservables Scenarios Stack AllObservables'),
19-
('Generate Dot', 'pmg.py ValidateAllObservables'),
18+
'pma -o ValidateAllObservables Scenarios Stack AllObservables'),
19+
('Generate Dot', 'pmg ValidateAllObservables'),
2020
('Generate SVG', 'dotsvg ValidateAllObservables')
2121
]

samples/Stack/test_scenarios.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
cases = [
22
('Scenarios module with four runs, by itself',
3-
'pmt.py Scenarios'),
3+
'pmt Scenarios'),
44

55
('Scenarios module, compose with Stack model, last two runs not allowed',
6-
'pmt.py Scenarios Stack'),
6+
'pmt Scenarios Stack'),
77

88
('Scenarios, compose with Stack, Push is observable, get args from scenario',
9-
'pmt.py Scenarios Stack Observables'),
9+
'pmt Scenarios Stack Observables'),
1010

1111
('Scenarios, compose with Stack, Push and Pop are observable, get args from scenario',
12-
'pmt.py Scenarios Stack AllObservables')
12+
'pmt Scenarios Stack AllObservables')
1313
]

samples/StackResult/test.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44

55
cases = [
66
('Default random strategy, actions repeat',
7-
'pmt.py -n 10 -s 1 Stack'),
7+
'pmt -n 10 -s 1 Stack'),
88

99
('ActionNameCoverage, Push and Pop alternate',
10-
'pmt.py -n 10 -s 1 Stack -g ActionNameCoverage'),
10+
'pmt -n 10 -s 1 Stack -g ActionNameCoverage'),
1111

1212
('StateCoverage, repeat Push',
13-
'pmt.py -n 10 -s 1 Stack StackDepthTen -g StateCoverage')
13+
'pmt -n 10 -s 1 Stack StackDepthTen -g StateCoverage')
1414
]

samples/StackResult/test_graphics.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -4,28 +4,28 @@
44

55
cases = [
66
('Generate FSM with first 12 transitions',
7-
'pma.py Stack -m 12'),
7+
'pma Stack -m 12'),
88

99
('Generate dot commands',
10-
'pmg.py StackFSM'),
10+
'pmg StackFSM'),
1111

1212
('Generate SVG file',
1313
'dotsvg StackFSM'),
1414

1515
('Generate dot commands for scenario FSM',
16-
'pmg.py StackOneScenario'),
16+
'pmg StackOneScenario'),
1717

1818
('Generate dot commands for scenario FSM',
19-
'pmg.py StackOneScenario'),
19+
'pmg StackOneScenario'),
2020

2121
('Generate SVG',
2222
'dotsvg StackOneScenario'),
2323

2424
('Explore composition of model with scenario machine, show synchronization',
25-
'pma.py Stack StackOneScenario -m 6 -o StackSynchronized'),
25+
'pma Stack StackOneScenario -m 6 -o StackSynchronized'),
2626

2727
('Generate dot',
28-
'pmg.py StackSynchronized'),
28+
'pmg StackSynchronized'),
2929

3030
('Generate SVG',
3131
'dotsvg StackSynchronized'),
@@ -34,10 +34,10 @@
3434
# in browser
3535

3636
('Generate FSM with state filter',
37-
'pma.py -o Stack3FSM Stack Filter3'),
37+
'pma -o Stack3FSM Stack Filter3'),
3838

3939
('Generate dot commands',
40-
'pmg.py Stack3FSM'),
40+
'pmg Stack3FSM'),
4141

4242
('Generate SVG file',
4343
'dotsvg Stack3FSM'),

samples/WebApplication/test.py

+10-10
Original file line numberDiff line numberDiff line change
@@ -4,32 +4,32 @@
44

55
cases = [
66
('WebModel -a option includes only Initialize Action',
7-
'pmt.py -n 10 -a Initialize WebModel'),
7+
'pmt -n 10 -a Initialize WebModel'),
88

99
('WebModel -e option excludes Login, Logout actions',
10-
'pmt.py -n 10 -e Login -e Logout WebModel'),
10+
'pmt -n 10 -e Login -e Logout WebModel'),
1111

1212
('WebModel TestIntSuccess offline test suite',
13-
'pmt.py TestIntSuccess'),
13+
'pmt TestIntSuccess'),
1414

1515
('WebModel on-the-fly with all actions, default random strategy, shows repeated calls to same action',
16-
'pmt.py -n 10 -s 2 WebModel'),
16+
'pmt -n 10 -s 2 WebModel'),
1717

1818
('WebModel on-the-fly with all actions, ActionNameCoverage strategy, shows the same (enabled) action is not repeated more than 2x',
19-
'pmt.py -n 10 -s 2 WebModel -g ActionNameCoverage'),
19+
'pmt -n 10 -s 2 WebModel -g ActionNameCoverage'),
2020

2121
('WebModel on-the-fly with all actions, StateCoverage strategy, shows Login and UpdateInt actions repeat but with different arguments',
22-
'pmt.py -n 10 -s 2 WebModel -g StateCoverage'),
22+
'pmt -n 10 -s 2 WebModel -g StateCoverage'),
2323

2424
('WebModel, no -c option, ends in non-accepting state with users logged in',
25-
'pmt.py -n 10 -s 2 WebModel'),
25+
'pmt -n 10 -s 2 WebModel'),
2626

2727
('WebModel, with -c option for cleanup, logs off users to reach accepting state',
28-
'pmt.py -n 10 -s 2 -c 3 WebModel'),
28+
'pmt -n 10 -s 2 -c 3 WebModel'),
2929

3030
('WebModel, with -r --runs option, in each run Initialize is enabled again',
31-
'pmt.py -n 5 -s 3 -r 3 WebModel'),
31+
'pmt -n 5 -s 3 -r 3 WebModel'),
3232

3333
('WebModel TestIntTwoRuns offline test suite with two runs',
34-
'pmt.py TestIntTwoRuns'),
34+
'pmt TestIntTwoRuns'),
3535
]

0 commit comments

Comments
 (0)