Skip to content

Commit 4a6c0fd

Browse files
committed
tests: Auto detect floating point capabilites of the target.
The floating-point precision of the target is detected (0, 30, 32 or 64) and only those tests which can run on the target will be run.
1 parent c408ed9 commit 4a6c0fd

3 files changed

Lines changed: 28 additions & 9 deletions

File tree

tests/feature_check/float.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# detect how many bits of precision the floating point implementation has
2+
3+
try:
4+
float
5+
except NameError:
6+
print(0)
7+
else:
8+
if float('1.0000001') == float('1.0'):
9+
print(30)
10+
elif float('1e300') == float('inf'):
11+
print(32)
12+
else:
13+
print(64)

tests/feature_check/float.py.exp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
64

tests/run-tests

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,7 @@ def run_tests(pyb, tests, args, base_path="."):
239239
skip_tests.add('cmdline/repl_emacs_keys.py')
240240

241241
upy_byteorder = run_feature_check(pyb, args, base_path, 'byteorder.py')
242+
upy_float_precision = int(run_feature_check(pyb, args, base_path, 'float.py'))
242243
has_complex = run_feature_check(pyb, args, base_path, 'complex.py') == b'complex\n'
243244
has_coverage = run_feature_check(pyb, args, base_path, 'coverage.py') == b'coverage\n'
244245
cpy_byteorder = subprocess.check_output([CPYTHON3, base_path + '/feature_check/byteorder.py'])
@@ -252,6 +253,19 @@ def run_tests(pyb, tests, args, base_path="."):
252253
skip_tests.add('thread/stress_heap.py') # has reliability issues
253254
skip_tests.add('thread/stress_recurse.py') # has reliability issues
254255

256+
if upy_float_precision == 0:
257+
skip_tests.add('extmod/ujson_dumps_float.py')
258+
skip_tests.add('extmod/ujson_loads_float.py')
259+
skip_tests.add('misc/rge_sm.py')
260+
if upy_float_precision < 32:
261+
skip_tests.add('float/float2int_intbig.py') # requires fp32, there's float2int_fp30_intbig.py instead
262+
skip_tests.add('float/string_format.py') # requires fp32, there's string_format_fp30.py instead
263+
skip_tests.add('float/bytes_construct.py') # requires fp32
264+
skip_tests.add('float/bytearray_construct.py') # requires fp32
265+
if upy_float_precision < 64:
266+
skip_tests.add('float/float_divmod.py') # tested by float/float_divmod_relaxed.py instead
267+
skip_tests.add('float/float2int_doubleprec_intbig.py')
268+
255269
if not has_complex:
256270
skip_tests.add('float/complex1.py')
257271
skip_tests.add('float/complex1_intbig.py')
@@ -272,8 +286,6 @@ def run_tests(pyb, tests, args, base_path="."):
272286
# Some tests shouldn't be run on pyboard
273287
if pyb is not None:
274288
skip_tests.add('basics/exception_chain.py') # warning is not printed
275-
skip_tests.add('float/float_divmod.py') # tested by float/float_divmod_relaxed.py instead
276-
skip_tests.add('float/float2int_doubleprec_intbig.py') # requires double precision floating point to work
277289
skip_tests.add('micropython/meminfo.py') # output is very different to PC output
278290
skip_tests.add('extmod/machine_mem.py') # raw memory access not supported
279291

@@ -282,19 +294,12 @@ def run_tests(pyb, tests, args, base_path="."):
282294
skip_tests.add('misc/recursion.py') # requires stack checking enabled
283295
skip_tests.add('misc/recursive_data.py') # requires stack checking enabled
284296
skip_tests.add('misc/recursive_iternext.py') # requires stack checking enabled
285-
skip_tests.add('misc/rge_sm.py') # requires floating point
286297
skip_tests.update({'extmod/uctypes_%s.py' % t for t in 'bytearray le native_le ptr_le ptr_native_le sizeof sizeof_native array_assign_le array_assign_native_le'.split()}) # requires uctypes
287298
skip_tests.add('extmod/zlibd_decompress.py') # requires zlib
288-
skip_tests.add('extmod/ujson_dumps_float.py') # requires floating point
289-
skip_tests.add('extmod/ujson_loads_float.py') # requires floating point
290299
skip_tests.add('extmod/uheapq1.py') # uheapq not supported by WiPy
291300
skip_tests.add('extmod/urandom_basic.py') # requires urandom
292301
skip_tests.add('extmod/urandom_extra.py') # requires urandom
293302
elif args.target == 'esp8266':
294-
skip_tests.add('float/float2int_intbig.py') # requires at least fp32, there's float2int_fp30_intbig.py instead
295-
skip_tests.add('float/string_format.py') # requires at least fp32, there's string_format_fp30.py instead
296-
skip_tests.add('float/bytes_construct.py') # requires fp32
297-
skip_tests.add('float/bytearray_construct.py') # requires fp32
298303
skip_tests.add('misc/rge_sm.py') # too large
299304
elif args.target == 'minimal':
300305
skip_tests.add('misc/rge_sm.py') # too large

0 commit comments

Comments
 (0)