54d97251fe
While checking whether we can enable -Wimplicit-fallthrough, I encountered a diagnostic in mp_binary_set_val_array_from_int which led to discovering the following bug: ``` >>> struct.pack("xb", 3) b'\x03\x03' ``` That is, the next value (3) was used as the value of a padding byte, while standard Python always fills "x" bytes with zeros. I initially thought this had to do with the unintentional fallthrough, but it doesn't. Instead, this code would relate to an array.array with a typecode of padding ('x'), which is ALSO not desktop Python compliant: ``` >>> array.array('x', (1, 2, 3)) array('x', [1, 0, 0]) ``` Possibly this is dead code that used to be shared between struct-setting and array-setting, but it no longer is. I also discovered that the argument list length for struct.pack and struct.pack_into were not checked, and that the length of binary data passed to array.array was not checked to be a multiple of the element size. I have corrected all of these to conform more closely to standard Python and revised some tests where necessary. Some tests for micropython-specific behavior that does not conform to standard Python and is not present in CircuitPython was deleted outright. |
||
---|---|---|
.. | ||
basics | ||
bench | ||
circuitpython | ||
cmdline | ||
cpydiff | ||
extmod | ||
feature_check | ||
float | ||
import | ||
inlineasm | ||
io | ||
jni | ||
micropython | ||
misc | ||
net_hosted | ||
net_inet | ||
pyb | ||
pybnative | ||
stress | ||
thread | ||
unicode | ||
unix | ||
wipy | ||
README | ||
pyboard.py | ||
run-bench-tests | ||
run-tests | ||
run-tests-exp.py | ||
run-tests-exp.sh | ||
skip_if.py |
README
This directory contains tests for various functionality areas of MicroPython. To run all stable tests, run "run-tests" script in this directory. Tests of capabilities not supported on all platforms should be written to check for the capability being present. If it is not, the test should merely output 'SKIP' followed by the line terminator, and call sys.exit() to raise SystemExit, instead of attempting to test the missing capability. The testing framework (run-tests in this directory, test_main.c in qemu_arm) recognizes this as a skipped test. There are a few features for which this mechanism cannot be used to condition a test. The run-tests script uses small scripts in the feature_check directory to check whether each such feature is present, and skips the relevant tests if not. When creating new tests, anything that relies on float support should go in the float/ subdirectory. Anything that relies on import x, where x is not a built-in module, should go in the import/ subdirectory.