summaryrefslogtreecommitdiff
path: root/tests/unix
AgeCommit message (Collapse)Author
2020-12-07py/mpprint: Fix length calculation for strings with precision-modifier.Joris Peeraer
Two issues are tackled: 1. The calculation of the correct length to print is fixed to treat the precision as a maximum length instead as the exact length. This is done for both qstr (%q) and for regular str (%s). 2. Fix the incorrect use of mp_printf("%.*s") to mp_print_strn(). Because of the fix of above issue, some testcases that would print an embedded null-byte (^@ in test-output) would now fail. The bug here is that "%s" was used to print null-bytes. Instead, mp_print_strn is used to make sure all bytes are outputted and the exact length is respected. Test-cases are added for both %s and %q with a combination of precision and padding specifiers.
2020-10-29examples: Add example code for user C modules, both C and C++.stijn
Add working example code to provide a starting point for users with files that they can just copy, and include the modules in the coverage test to verify the complete user C module build functionality. The cexample module uses the code originally found in cmodules.rst, which has been updated to reflect this and partially rewritten with more complete information.
2020-10-29esp32,unix: Support building C++ code.stijn
Support building .cpp files and linking them into the micropython executable in a way similar to how it is done for .c files. The main incentive here is to enable user C modules to use C++ files (which are put in SRC_MOD_CXX by py.mk) since the core itself does not utilize C++. However, to verify build functionality a unix overage test is added. The esp32 port already has CXXFLAGS so just add the user modules' flags to it. For the unix port use a copy of the CFLAGS but strip the ones which are not usable for C++.
2020-03-30tests: Format all Python code with black, except tests in basics subdir.David Lechner
This adds the Python files in the tests/ directory to be formatted with ./tools/codeformat.py. The basics/ subdirectory is excluded for now so we aren't changing too much at once. In a few places `# fmt: off`/`# fmt: on` was used where the code had special formatting for readability or where the test was actually testing the specific formatting.
2020-02-07tests/unix: Add coverage tests for kbd-intr and scheduler.Damien George
2020-01-24tests/unix: Add coverage tests for mp_obj_is_type() and variants.Yonatan Goldschmidt
2020-01-23tests/unix: Add coverage test for mp_obj_new_exception_args.Damien George
Because it's no longer called anywhere in the code.
2020-01-22tests/unix: Add coverage tests for pairheap data structure.Damien George
2020-01-14tests/unix: Add coverage test for new mp_obj_int_get_uint_checked func.Damien George
2020-01-06tests/unix: Make unix time test pass on more platforms.stijn
As the mktime documentation for CPython states: "The earliest date for which it can generate a time is platform-dependent". In particular on Windows this depends on the timezone so e.g. for UTC+2 the earliest is 2 hours past midnight January 1970. So change the reference to the earliest possible, for UTC+14.
2019-12-28unix/modtime: Add utime.mktime function, to complement utime.localtime.Andrew Leech
This also adds it to the windows port.
2019-10-01unix/coverage: Add coverage tests for ringbuf.Jim Mussared
2019-09-26py: Rename MP_QSTR_NULL to MP_QSTRnull to avoid intern collisions.Josh Lloyd
Fixes #5140.
2019-08-15tests/unix: Update extra_coverage expected output with new atexit func.Damien George
2019-07-31py/builtinimport: Populate __file__ when importing frozen or mpy files.Paul m. p. P
Note that bytecode already includes the source filename as a qstr so there is no additional memory used by the interning operation here.
2019-05-03unix/coverage: Add test for printing literal % character.Damien George
2019-03-26py/scheduler: Convert micropythyon.schedule() to a circular buffer.Andrew Leech
This means the schedule operates on a first-in, first-executed manner rather than the current last-in, first executed.
2018-10-05tests/unix/ffi_float: Skip if strtof() is not available.Paul Sokolovsky
As the case for e.g. Android's Bionic Libc.
2018-06-18tests/unix/extra_coverage: Don't test stream objs with NULL write fun.Damien George
This behaviour of a NULL write C method on a stream that uses the write adaptor objects is no longer supported. It was only ever used by the coverage build for testing the fail path of mp_get_stream_raise().
2018-03-03tests/unix: Add coverage test for uio.resource_stream from frozen str.Damien George
2018-03-02tests: Move heap-realloc-while-locked test from C to Python.Damien George
This test for calling gc_realloc() while the GC is locked can be done in pure Python, so better to do it that way since it can then be tested on more ports.
2018-03-01tests/unix: Add coverage tests for various GC calls.Damien George
2018-03-01py/formatfloat: Fix rounding of %f format with edge-case FP values.Damien George
Prior to this patch the %f formatting of some FP values could be off by up to 1, eg '%.0f' % 123 would return "122" (unix x64). Depending on the FP precision (single vs double) certain numbers would format correctly, but others wolud not. This patch should fix all cases of rounding for %f.
2018-02-27tests/unix: Add coverage test for VM executing invalid bytecode.Damien George
2018-02-25tests/unix: Add coverage tests for mpz_set_from_float, mpz_mul_inpl.Damien George
These new tests cover cases that can't be reached from Python and get coverage of py/mpz.c to 100%. These "unreachable from Python" pieces of code could be removed but they form an integral part of the mpz C API and may be useful for non-Python usage of mpz.
2018-02-19py/repl: Generalise REPL autocomplete to use qstr probing.Damien George
This patch changes the way REPL autocomplete finds matches. It now probes the target object for all qstrs via mp_load_method_maybe to look for a match with the given input string. Similar to how the builtin dir() function works, this new algorithm now find all methods and instances of user-defined classes including attributes of their parent classes. This helps a lot at the REPL prompt for user-discovery and to autocomplete names even for classes that are derived. The downside is that this new algorithm is slower than the previous one, and in particular will be slower the more qstrs there are in the system. But because REPL autocomplete is primarily used in an interactive way it is not that important to make it fast, as long as it is "fast enough" compared to human reaction. On a slow microcontroller (CPU running at 16MHz) the autocomplete time for a list of 35 names in the outer namespace (pressing tab at a bare prompt) takes about 160ms with this algorithm, compared to about 40ms for the previous implementation (this time includes the actual printing of the names as well). This time of 160ms is very reasonable especially given the new functionality of listing all the names. This patch also decreases code size by: bare-arm: +0 minimal x86: -128 unix x64: -128 unix nanbox: -224 stm32: -88 cc3200: -80 esp8266: -92 esp32: -84
2018-02-08tests/unix: Add coverage test for calling mp_obj_new_bytearray.Damien George
2017-12-19tests/unix: Add test for printf with %lx format.Damien George
2017-10-27py/objtype: Define all special methods if requested.Paul Sokolovsky
If MICROPY_PY_ALL_SPECIAL_METHODS is defined, actually define all special methods (still subject to gating by e.g. MICROPY_PY_REVERSE_SPECIAL_METHODS). This adds quite a number of qstr's, so should be used sparingly.
2017-09-21py/vstr: Raise a RuntimeError if fixed vstr buffer overflows.Damien George
Current users of fixed vstr buffers (building file paths) assume that there is no overflow and do not check for overflow after building the vstr. This has the potential to lead to NULL pointer dereferences (when vstr_null_terminated_str returns NULL because it can't allocate RAM for the terminating byte) and stat'ing and loading invalid path names (due to the path being truncated). The safest and simplest thing to do in these cases is just raise an exception if a write goes beyond the end of a fixed vstr buffer, which is what this patch does. It also simplifies the vstr code.
2017-09-18py/modbuiltins: Implement abs() by dispatching to MP_UNARY_OP_ABS.Paul Sokolovsky
This allows user classes to implement __abs__ special method, and saves code size (104 bytes for x86_64), even though during refactor, an issue was fixed and few optimizations were made: * abs() of minimum (negative) small int value is calculated properly. * objint_longlong and objint_mpz avoid allocating new object is the argument is already non-negative.
2017-08-11py/modsys: Initial implementation of sys.getsizeof().Paul Sokolovsky
Implemented as a new MP_UNARY_OP. This patch adds support lists, dicts and instances.
2017-06-30tests/unix/extra_coverage: Add test for mp_vprintf with bad fmt spec.Damien George
2017-06-10tests: Convert remaining "sys.exit()" to "raise SystemExit".Paul Sokolovsky
2017-03-20unix/coverage: Enable scheduler and add tests for it.Damien George
2017-03-14tests: Improve binary.c test coverage.Rami Ali
2017-01-17tests/io: Improve test coverage of io.BufferedWriter.Rami Ali
2017-01-16tests: Improve frozen import test coverage.Rami Ali
2017-01-16tests: Improve stream.c test coverage.Rami Ali
2017-01-08tests/unix/extra_coverage: Add tests for importing frozen packages.Damien George
2017-01-05tests/unix/extra_coverage: Add basic tests to import frozen str and mpy.Damien George
2017-01-05tests/unix: Improve formatfloat.c test coverage using C.Rami Ali
2017-01-05tests: Improve warning.c test coverage.Rami Ali
2016-12-29tests/unix: Improve runtime_utils.c test coverage.Rami Ali
2016-09-02tests/unix/extra_coverage: Add test for str/bytes with invalid hash.Damien George
2016-09-01py/mpprint: Fail an assertion with unsupported format specifiers.Delio Brignoli
Arguments of an unknown type cannot be skipped and continuing to parse a format string after encountering an unknown format specifier leads to undefined behaviour. This patch helps to find use of unsupported formats.
2016-02-01py/mpprint: Fix sign extension when printf'ing %u, %x and %X.Damien George
2015-12-05tests/extra_coverage: Update for sys.modules addition.Paul Sokolovsky
2015-10-01tests: Add further tests for mpz code.Damien George
2015-09-03tests: Add tests to improve coverage of objstr.c.Damien George