diff options
author | Jim Mussared <jim.mussared@gmail.com> | 2022-09-17 23:57:12 +1000 |
---|---|---|
committer | Damien George <damien@micropython.org> | 2022-09-19 23:19:55 +1000 |
commit | d94141e1473aebae0d3c63aeaa8397651ad6fa01 (patch) | |
tree | 3bd11ca1a9475836a0812d1eac617a11997ebecb /tests/micropython/import_mpy_native.py | |
parent | b41aaaa8a918a6645ebc6bfa4483bd17286f9263 (diff) |
py/persistentcode: Introduce .mpy sub-version.
The intent is to allow us to make breaking changes to the native ABI (e.g.
changes to dynruntime.h) without needing the bytecode version to increment.
With this commit the two bits previously used for the feature flags (but
now unused as of .mpy version 6) encode a sub-version. A bytecode-only
.mpy file can be loaded as long as MPY_VERSION matches, but a native .mpy
(i.e. one with an arch set) must also match MPY_SUB_VERSION. This allows 3
additional updates to the native ABI per bytecode revision.
The sub-version is set to 1 because the previous commits that changed the
layout of mp_obj_type_t have changed the native ABI.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
Signed-off-by: Damien George <damien@micropython.org>
Diffstat (limited to 'tests/micropython/import_mpy_native.py')
-rw-r--r-- | tests/micropython/import_mpy_native.py | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/tests/micropython/import_mpy_native.py b/tests/micropython/import_mpy_native.py index 449371dda..73e20694c 100644 --- a/tests/micropython/import_mpy_native.py +++ b/tests/micropython/import_mpy_native.py @@ -11,7 +11,8 @@ except (ImportError, AttributeError): raise SystemExit mpy_arch = usys.implementation._mpy >> 8 -if mpy_arch == 0: +if mpy_arch >> 2 == 0: + # This system does not support .mpy files containing native code print("SKIP") raise SystemExit @@ -54,8 +55,8 @@ class UserFS: valid_header = bytes([77, 6, mpy_arch, 31]) # fmt: off user_files = { - # bad architecture - '/mod0.mpy': b'M\x06\xfc\x1f', + # bad architecture (mpy_arch needed for sub-version) + '/mod0.mpy': bytes([77, 6, 0xfc | mpy_arch, 31]), # test loading of viper and asm '/mod1.mpy': valid_header + ( |