Skip to content

Test REPR_B & fix test failures #17688

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open

Conversation

jepler
Copy link
Contributor

@jepler jepler commented Jul 15, 2025

Summary

For m68k-micropython I'm interested in REPR_B. However, CI doesn't check any REPR_B builds, so of course there were test failures.

This patch series adds a 32-bit REPR_B build (i686 Linux) and fixes the test failures that arose.

Testing

I ran the tests locally with a REPR_B build. I'll check the CI for other failures.

Trade-offs and Alternatives

Just for the benefit of one test in the testsuite, I added micropython.small_int_max. Instead, a few tests could be changed so that they just use numbers sized to work on "any repr that gets tested".

Copy link

codecov bot commented Jul 15, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.44%. Comparing base (17fbc5a) to head (66a33e4).

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #17688   +/-   ##
=======================================
  Coverage   98.44%   98.44%           
=======================================
  Files         171      171           
  Lines       22208    22215    +7     
=======================================
+ Hits        21863    21870    +7     
  Misses        345      345           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link

github-actions bot commented Jul 15, 2025

Code size report:

   bare-arm:    +0 +0.000% 
minimal x86:    +0 +0.000% 
   unix x64:    +0 +0.000% standard
      stm32:    +0 +0.000% PYBV10
     mimxrt:    +0 +0.000% TEENSY40
        rp2:    +0 +0.000% RPI_PICO_W
       samd:    +0 +0.000% ADAFRUIT_ITSYBITSY_M4_EXPRESS
  qemu rv32:    +0 +0.000% VIRT_RV32

@jepler
Copy link
Contributor Author

jepler commented Jul 15, 2025

Native & viper tests fail if --via-mpy even after accounting for small int size. I did some digging and I'm guessing it's because mpy-cross uses a fixed representation for integers in the code emitter, e.g.,

        } else if (si->vtype == VTYPE_INT || si->vtype == VTYPE_UINT) {
            ASM_MOV_REG_IMM(emit->as, reg_dest, (uintptr_t)MP_OBJ_NEW_SMALL_INT(si->data.u_imm));

I chose to simply skip running any of the "native" tests, even though locally they succeed when not going via mpy. Because this was the easiest of the choices available.

@jepler jepler force-pushed the test-repr-b branch 2 times, most recently from 5a8c677 to 5dcf5fa Compare July 16, 2025 22:47
@dpgeorge
Copy link
Member

Just for the benefit of one test in the testsuite, I added micropython.small_int_max. Instead, a few tests could be changed so that they just use numbers sized to work on "any repr that gets tested".

I'd prefer not to add this constant, if we can help it. Could the tests automatically detect the max int? Note there is already sys.maxsize which may be useful. Could also add a feature check in tests/feature_check/ to detect the representation.

If we do need to add a constant, it might be better as sys.implementation._small_int.

The field encodings for OBJ_REPR_B need to be slightly
different than for other representations, as there are
only 30 bits (rather than 31) available for small integers.

This accounts for about half of all the test failures
with an OBJ_REPR_B build, using a commandline like (wrapped):
```
make -j$(nproc) -C ports/unix/ VARIANT=coverage \
    MICROPY_FORCE_32BIT=1 \
    CFLAGS_EXTRA="-DMICROPY_OBJ_REPR=MICROPY_OBJ_REPR_B \
        -Dmp_int_t=int32_t -Dmp_uint_t=uint32_t" test
```

I also added some compile time assertions that the values
"should work". For instance, the assertions about about
`!VALUE_MASK` are intended to check that bits from the field type
do not leak into the offset part.

Signed-off-by: Jeff Epler <jepler@gmail.com>
@jepler
Copy link
Contributor Author

jepler commented Jul 18, 2025

I reworked it to not require the added property.

@jepler
Copy link
Contributor Author

jepler commented Jul 18, 2025

is this a known-to-be-flaky test? My changes shouldn't have touched it. 1 tests failed: extmod/select_poll_eintr.py

@dpgeorge
Copy link
Member

is this a known-to-be-flaky test? My changes shouldn't have touched it. 1 tests failed: extmod/select_poll_eintr.py

Yes, it's known flaky. PR #17655 works around the issue.

jepler added 4 commits July 18, 2025 05:51
Different results are needed for different integer sizes.

Signed-off-by: Jeff Epler <jepler@gmail.com>
Signed-off-by: Jeff Epler <jepler@gmail.com>
Signed-off-by: Jeff Epler <jepler@gmail.com>
The check for 'fits in a small int' is specific to the 31-bit
int of other OBJ_REPRs.

Signed-off-by: Jeff Epler <jepler@gmail.com>
This showed up some interesting errors (hopefully all fixed now).

Signed-off-by: Jeff Epler <jepler@gmail.com>
@jepler
Copy link
Contributor Author

jepler commented Jul 18, 2025

The one remaining failure appears to be 1 tests failed: extmod/select_poll_eintr.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy