Skip to content

Commit 493ad63

Browse files
committed
Added new flag -L to list all tests available. Also removed trailing spaces
1 parent 3d49a49 commit 493ad63

File tree

1 file changed

+27
-20
lines changed

1 file changed

+27
-20
lines changed

workspace_tools/make.py

Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -75,18 +75,25 @@
7575
default=None, help="The mbed serial port")
7676
parser.add_option("-b", "--baud", type="int", dest="baud",
7777
default=None, help="The mbed serial baud rate")
78-
78+
parser.add_option("-L", "--list-tests", action="store_true", dest="list_tests",
79+
default=False, help="List available tests in order and exit")
80+
7981
# Ideally, all the tests with a single "main" thread can be run with, or
8082
# without the rtos
8183
parser.add_option("--rtos", action="store_true", dest="rtos",
8284
default=False, help="Link to the rtos")
83-
85+
8486
# Specify a different linker script
8587
parser.add_option("-l", "--linker", dest="linker_script",
8688
default=None, help="use the specified linker script")
87-
89+
8890
(options, args) = parser.parse_args()
8991

92+
# Print available tests in order and exit
93+
if options.list_tests is True:
94+
print '\n'.join(map(str, sorted(TEST_MAP.values())))
95+
sys.exit()
96+
9097
# force program to "0" if a source dir is specified
9198
if options.source_dir is not None:
9299
p = 0
@@ -106,22 +113,22 @@
106113
args_error(parser, "[ERROR] Program with name '%s' not found" % n)
107114
else:
108115
n = alias
109-
p = TEST_MAP[n].n
116+
p = TEST_MAP[n].n
110117
if p is None or (p < 0) or (p > (len(TESTS)-1)):
111118
message = "[ERROR] You have to specify one of the following tests:\n"
112119
message += '\n'.join(map(str, sorted(TEST_MAP.values())))
113120
args_error(parser, message)
114-
121+
115122
# Target
116123
if options.mcu is None :
117124
args_error(parser, "[ERROR] You should specify an MCU")
118125
mcu = options.mcu
119-
126+
120127
# Toolchain
121128
if options.tool is None:
122129
args_error(parser, "[ERROR] You should specify a TOOLCHAIN")
123130
toolchain = options.tool
124-
131+
125132
# Test
126133
test = Test(p)
127134
if options.automated is not None:
@@ -140,19 +147,19 @@
140147
if not test.is_supported(mcu, toolchain):
141148
print 'The selected test is not supported on target %s with toolchain %s' % (mcu, toolchain)
142149
sys.exit()
143-
150+
144151
# RTOS
145152
if options.rtos:
146153
test.dependencies.append(RTOS_LIBRARIES)
147-
154+
148155
build_dir = join(BUILD_DIR, "test", mcu, toolchain, test.id)
149-
if options.source_dir is not None:
156+
if options.source_dir is not None:
150157
test.source_dir = options.source_dir
151158
build_dir = options.source_dir
152159

153-
if options.build_dir is not None:
160+
if options.build_dir is not None:
154161
build_dir = options.build_dir
155-
162+
156163
target = TARGET_MAP[mcu]
157164
try:
158165
bin = build_project(test.source_dir, build_dir, target, toolchain,
@@ -161,31 +168,31 @@
161168
clean=options.clean, verbose=options.verbose,
162169
macros=options.macros)
163170
print 'Image: %s' % bin
164-
171+
165172
if options.disk:
166173
# Simple copy to the mbed disk
167174
copy(bin, options.disk)
168-
175+
169176
if options.serial:
170177
# Import pyserial: https://pypi.python.org/pypi/pyserial
171178
from serial import Serial
172-
179+
173180
sleep(target.program_cycle_s())
174-
181+
175182
serial = Serial(options.serial, timeout = 1)
176183
if options.baud:
177184
serial.setBaudrate(options.baud)
178-
185+
179186
serial.flushInput()
180187
serial.flushOutput()
181-
188+
182189
serial.sendBreak()
183-
190+
184191
while True:
185192
c = serial.read(512)
186193
sys.stdout.write(c)
187194
sys.stdout.flush()
188-
195+
189196
except KeyboardInterrupt, e:
190197
print "\n[CTRL+c] exit"
191198
except Exception,e:

0 commit comments

Comments
 (0)