Skip to content

tests: various improvements for Octoprobe (WIP) #17782

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

Draft
wants to merge 22 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
c6d57ad
tests/extmod/machine_spi_rate.py: Support samd with default SPI.
dpgeorge Jul 29, 2025
bc5c09c
tests/extmod: Support ESP32-C3 targets.
dpgeorge Jul 29, 2025
74a746f
tests/extmod/machine_spi_rate.py: Use default pins on ESP32.
dpgeorge Jul 29, 2025
1e654db
tests/run-tests.py: Run tests-with-regex-output as normal tests.
dpgeorge Jul 26, 2025
e441df6
esp8266/main: Decrease usable stack by 64 bytes.
dpgeorge Jul 29, 2025
afbd0e7
tests/run-perfbench.py: Skip bm_hexiom on small targets.
dpgeorge Jul 31, 2025
e5f5b70
tests/net_inet/tls_num_errors.py: Support running on unix port.
dpgeorge Jul 31, 2025
8990016
tests/net_inet: Skip tests on axTLS when necessary.
dpgeorge Jul 31, 2025
b1af25f
tests/perf_bench: Skip tests when vfs doesn't exist.
dpgeorge Jul 31, 2025
bae02af
tests/float/string_format_modulo2_intbig.py: Get working on esp8266.
dpgeorge Jul 31, 2025
821a315
tests/extmod/vfs_blockdev_invalid.py: Skip if no RAM to mkfs.
dpgeorge Jul 31, 2025
56b5542
tests/net_hosted/ssl_verify_callback.py: Skip if necessary.
dpgeorge Jul 31, 2025
2474d9a
tests/float/string_format_modulo2_intbig.py: Make CPython compatible.
dpgeorge Jul 31, 2025
7f30f8b
py/persistentcode: Only select hard-fp arch if compiler uses hard ABI.
dpgeorge Jul 31, 2025
e746746
tests/run-perfbench.py: Skip tests that have a MemoryError.
dpgeorge Jul 31, 2025
7895be7
tests/run-tests.py: Skip various tests on small SAMD targets.
dpgeorge Jul 31, 2025
ca4b554
tests/run-tests.py: Add extra logic to skip thumb2 fp tests.
dpgeorge Aug 1, 2025
0c544fe
tests/multi_net: Skip tests on axTLS when needed.
dpgeorge Aug 4, 2025
8881572
tests/multi_net/udp_data_multi.py: Reduce number of UDP groups.
dpgeorge Aug 5, 2025
8c963c7
tests/run-perfbench.py: Skip misc_mandel if target doesn't have complex.
dpgeorge Aug 5, 2025
780ca38
esp32/modules: Convert AttributeError to ImportError.
dpgeorge Aug 5, 2025
66db214
tests/ports/stm32/adcall.py: Print values if test ADC fails.
dpgeorge Aug 6, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion ports/esp32/modules/machine.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,4 +189,7 @@ def phases(self):

# Delegate to built-in machine module.
def __getattr__(attr):
return getattr(_machine, attr)
value = getattr(_machine, attr, None)
if value is None:
raise ImportError(attr)
return value
2 changes: 1 addition & 1 deletion ports/esp8266/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ static void print_reset_info(void) {

static void mp_reset(void) {
mp_stack_set_top((void *)0x40000000);
mp_stack_set_limit(8192);
mp_stack_set_limit(8192 - 64);
mp_hal_init();
gc_init(heap, heap + sizeof(heap));
mp_init();
Expand Down
4 changes: 2 additions & 2 deletions py/persistentcode.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@
#define MPY_FEATURE_ARCH (MP_NATIVE_ARCH_X64)
#elif MICROPY_EMIT_THUMB
#if defined(__thumb2__)
#if defined(__ARM_FP) && (__ARM_FP & 8) == 8
#if defined(__ARM_FP) && (__ARM_FP & 8) == 8 && defined(__ARM_PCS_VFP)
#define MPY_FEATURE_ARCH (MP_NATIVE_ARCH_ARMV7EMDP)
#elif defined(__ARM_FP) && (__ARM_FP & 4) == 4
#elif defined(__ARM_FP) && (__ARM_FP & 4) == 4 && defined(__ARM_PCS_VFP)
#define MPY_FEATURE_ARCH (MP_NATIVE_ARCH_ARMV7EMSP)
#else
#define MPY_FEATURE_ARCH (MP_NATIVE_ARCH_ARMV7EM)
Expand Down
5 changes: 4 additions & 1 deletion tests/extmod/machine_i2s_rate.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@
(2, Pin("D4"), Pin("D3"), Pin("D2"), None),
)
elif "esp32" in sys.platform:
i2s_instances = ((0, Pin(18), Pin(19), Pin(21), Pin(14)),)
if "ESP32C3" in sys.implementation._machine or "ESP32-C3" in sys.implementation._machine:
i2s_instances = ((0, Pin(5), Pin(6), Pin(7), Pin(4)),)
else:
i2s_instances = ((0, Pin(18), Pin(19), Pin(21), Pin(14)),)
# Allow for small additional RTOS overhead
MAX_DELTA_MS = 8

Expand Down
13 changes: 9 additions & 4 deletions tests/extmod/machine_spi_rate.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
if "alif" in sys.platform:
MAX_DELTA_MS = 20
spi_instances = ((0, None, None, None),)
elif "samd" in sys.platform:
# Use default SPI instance (tested working on ADAFRUIT_ITSYBITSY_M0_EXPRESS).
spi_instances = ((None, None, None, None),)
elif "pyboard" in sys.platform:
spi_instances = (
(1, None, None, None), # "explicit choice of sck/mosi/miso is not implemented"
Expand All @@ -25,10 +28,10 @@
spi_instances = ((0, Pin(18), Pin(19), Pin(16)),)
elif "esp32" in sys.platform:
impl = str(sys.implementation)
if any(soc in impl for soc in ("ESP32C2", "ESP32C3", "ESP32C6")):
spi_instances = ((1, Pin(4), Pin(5), Pin(6)),)
if any(soc in impl for soc in ("ESP32C2", "ESP32C3", "ESP32-C3", "ESP32C6")):
spi_instances = ((1, None, None, None),)
else:
spi_instances = ((1, Pin(18), Pin(19), Pin(21)), (2, Pin(18), Pin(19), Pin(21)))
spi_instances = ((1, None, None, None), (2, None, None, None))
elif "esp8266" in sys.platform:
MAX_DELTA_MS = 50 # port requires much looser timing requirements
spi_instances = ((1, None, None, None),) # explicit pin choice not allowed
Expand Down Expand Up @@ -111,8 +114,10 @@ def test_spi(spi_id, sck, mosi, miso, baudrate, polarity, phase, print_results):
polarity=polarity,
phase=phase,
)
else:
elif spi_id is not None:
s = SPI(spi_id, baudrate=baudrate, polarity=polarity, phase=phase)
else:
s = SPI(baudrate=baudrate, polarity=polarity, phase=phase)

# to keep the test runtime down, use shorter buffer for lower baud rate
wr_buf = wr_long if baudrate > 500_000 else wr_short
Expand Down
2 changes: 2 additions & 0 deletions tests/extmod/vfs_blockdev_invalid.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ def ioctl(self, op, arg):

try:
bdev = RAMBlockDevice(50)
vfs.VfsLfs2.mkfs(bdev)
vfs.VfsFat.mkfs(bdev)
except MemoryError:
print("SKIP")
raise SystemExit
Expand Down
20 changes: 17 additions & 3 deletions tests/float/string_format_modulo2_intbig.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# test formatting floats with large precision, that it doesn't overflow the buffer

try:
import micropython
except:

class micropython:
def bytecode(f):
return f


def test(num, num_str):
if num == float("inf") or num == 0.0 and num_str != "0.0":
Expand All @@ -18,6 +26,12 @@ def test(num, num_str):


# check most powers of 10, making sure to include exponents with 3 digits
for e in range(-101, 102):
num = pow(10, e)
test(num, "1e%d" % e)
# force bytecode emitter so it can feed the WDT on esp8266
@micropython.bytecode
def main():
for e in range(-101, 102):
num = pow(10, e)
test(num, "1e%d" % e)


main()
3 changes: 3 additions & 0 deletions tests/multi_net/asyncio_tls_server_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,5 +69,8 @@ def instance0():


def instance1():
if not hasattr(ssl, "CERT_REQUIRED"):
print("SKIP")
raise SystemExit
multitest.next()
asyncio.run(tcp_client(b"client data"))
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
print("SKIP")
raise SystemExit

if not hasattr(ssl, "CERT_REQUIRED"):
print("SKIP")
raise SystemExit

PORT = 8000

# These are test certificates. See tests/README.md for details.
Expand Down
3 changes: 3 additions & 0 deletions tests/multi_net/asyncio_tls_server_client_readline.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,5 +73,8 @@ def instance0():


def instance1():
if not hasattr(ssl, "CERT_REQUIRED"):
print("SKIP")
raise SystemExit
multitest.next()
asyncio.run(tcp_client(b"client data\nclient data2\n"))
3 changes: 3 additions & 0 deletions tests/multi_net/asyncio_tls_server_client_verify_error.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,5 +73,8 @@ def instance0():


def instance1():
if not hasattr(ssl, "CERT_REQUIRED"):
print("SKIP")
raise SystemExit
multitest.next()
asyncio.run(tcp_client(b"client data"))
3 changes: 3 additions & 0 deletions tests/multi_net/ssl_cert_ec.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ def instance0():

# Client
def instance1():
if not hasattr(ssl, "CERT_REQUIRED"):
print("SKIP")
raise SystemExit
multitest.next()
s = socket.socket()
s.connect(socket.getaddrinfo(IP, PORT)[0][-1])
Expand Down
3 changes: 3 additions & 0 deletions tests/multi_net/ssl_cert_rsa.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ def instance0():

# Client
def instance1():
if not hasattr(ssl, "CERT_REQUIRED"):
print("SKIP")
raise SystemExit
multitest.next()
s = socket.socket()
s.connect(socket.getaddrinfo(IP, PORT)[0][-1])
Expand Down
3 changes: 3 additions & 0 deletions tests/multi_net/sslcontext_check_hostname_error.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ def instance0():

# Client
def instance1():
if not hasattr(ssl, "CERT_REQUIRED"):
print("SKIP")
raise SystemExit
multitest.next()
s = socket.socket()
s.connect(socket.getaddrinfo(IP, PORT)[0][-1])
Expand Down
3 changes: 3 additions & 0 deletions tests/multi_net/sslcontext_getpeercert.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@

# Server
def instance0():
if not hasattr(ssl, "CERT_REQUIRED"):
print("SKIP")
raise SystemExit
multitest.globals(IP=multitest.get_network_ip())
s = socket.socket()
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
Expand Down
4 changes: 4 additions & 0 deletions tests/multi_net/sslcontext_server_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ def instance0():

# Client
def instance1():
if not hasattr(ssl, "CERT_REQUIRED"):
print("SKIP")
raise SystemExit

multitest.next()
s = socket.socket()
s.connect(socket.getaddrinfo(IP, PORT)[0][-1])
Expand Down
4 changes: 4 additions & 0 deletions tests/multi_net/sslcontext_server_client_ciphers.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ def instance0():

# Client
def instance1():
if not hasattr(tls, "CERT_REQUIRED"):
print("SKIP")
raise SystemExit

multitest.next()
s = socket.socket()
s.connect(socket.getaddrinfo(IP, PORT)[0][-1])
Expand Down
4 changes: 4 additions & 0 deletions tests/multi_net/sslcontext_server_client_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ def instance0():

# Client
def instance1():
if not hasattr(ssl, "CERT_REQUIRED"):
print("SKIP")
raise SystemExit

multitest.next()
s = socket.socket()
s.connect(socket.getaddrinfo(IP, PORT)[0][-1])
Expand Down
4 changes: 4 additions & 0 deletions tests/multi_net/sslcontext_verify_callback.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ def verify_callback(cert, depth):

# Server
def instance0():
if not hasattr(tls, "CERT_REQUIRED"):
print("SKIP")
raise SystemExit

multitest.globals(IP=multitest.get_network_ip())
s = socket.socket()
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
Expand Down
4 changes: 4 additions & 0 deletions tests/multi_net/sslcontext_verify_error.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ def instance0():

# Client
def instance1():
if not hasattr(ssl, "CERT_REQUIRED"):
print("SKIP")
raise SystemExit

multitest.next()
s = socket.socket()
s.connect(socket.getaddrinfo(IP, PORT)[0][-1])
Expand Down
4 changes: 4 additions & 0 deletions tests/multi_net/sslcontext_verify_time_error.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ def instance0():

# Client
def instance1():
if not hasattr(ssl, "CERT_REQUIRED"):
print("SKIP")
raise SystemExit

multitest.next()
s = socket.socket()
s.connect(socket.getaddrinfo(IP, PORT)[0][-1])
Expand Down
4 changes: 4 additions & 0 deletions tests/multi_net/tls_dtls_server_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
print("SKIP")
raise SystemExit

if not hasattr(tls, "PROTOCOL_DTLS_SERVER"):
print("SKIP")
raise SystemExit

PORT = 8000

# These are test certificates. See tests/README.md for details.
Expand Down
2 changes: 1 addition & 1 deletion tests/multi_net/udp_data_multi.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

NUM_NEW_SOCKETS = 4
NUM_PACKET_BURSTS = 6
NUM_PACKET_GROUPS = 5
NUM_PACKET_GROUPS = 4
TOTAL_PACKET_BURSTS = NUM_NEW_SOCKETS * NUM_PACKET_BURSTS
# The tast passes if more than 75% of packets are received in each group.
PACKET_RECV_THRESH = 0.75 * TOTAL_PACKET_BURSTS
Expand Down
1 change: 0 additions & 1 deletion tests/multi_net/udp_data_multi.py.exp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ pass group=0
pass group=1
pass group=2
pass group=3
pass group=4
--- instance1 ---
test socket 0
test socket 1
Expand Down
7 changes: 6 additions & 1 deletion tests/net_hosted/ssl_verify_callback.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@
import socket
import tls

context = tls.SSLContext(tls.PROTOCOL_TLS_CLIENT)

if not hasattr(context, "verify_callback"):
print("SKIP")
raise SystemExit


def verify_callback(cert, depth):
print("verify_callback:", type(cert), len(cert) > 100, depth)
Expand All @@ -16,7 +22,6 @@ def verify_callback_fail(cert, depth):


def test(peer_addr):
context = tls.SSLContext(tls.PROTOCOL_TLS_CLIENT)
context.verify_mode = tls.CERT_OPTIONAL
context.verify_callback = verify_callback
s = socket.socket()
Expand Down
4 changes: 4 additions & 0 deletions tests/net_inet/asyncio_tls_open_connection_readline.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
import os
import asyncio

if not hasattr(ssl, "CERT_REQUIRED"):
print("SKIP")
raise SystemExit

# This certificate was obtained from micropython.org using openssl:
# $ openssl s_client -showcerts -connect micropython.org:443 </dev/null 2>/dev/null
# The certificate is from Let's Encrypt:
Expand Down
3 changes: 3 additions & 0 deletions tests/net_inet/ssl_cert.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import socket
import ssl

if not hasattr(ssl, "CERT_REQUIRED"):
print("SKIP")
raise SystemExit

# This certificate was obtained from micropython.org using openssl:
# $ openssl s_client -showcerts -connect micropython.org:443 </dev/null 2>/dev/null
Expand Down
4 changes: 4 additions & 0 deletions tests/net_inet/ssl_errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@

import sys, errno, select, socket, ssl

if not hasattr(ssl, "CERT_REQUIRED"):
print("SKIP")
raise SystemExit


def test(addr, hostname, block=True):
print("---", hostname)
Expand Down
4 changes: 4 additions & 0 deletions tests/net_inet/test_sslcontext_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
import socket
import ssl

if not hasattr(ssl, "CERT_REQUIRED"):
print("SKIP")
raise SystemExit

# This certificate was obtained from micropython.org using openssl:
# $ openssl s_client -showcerts -connect micropython.org:443 </dev/null 2>/dev/null
# The certificate is from Let's Encrypt:
Expand Down
7 changes: 7 additions & 0 deletions tests/net_inet/test_tls_nonblock.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
import socket, ssl, errno, sys, time, select

# Although this test doesn't need ssl.CERT_REQUIRED, it does require the ssl module
# to support modern ciphers. So exclude the test on axTLS which doesn't have
# CERT_REQUIRED.
if not hasattr(ssl, "CERT_REQUIRED"):
print("SKIP")
raise SystemExit


def test_one(site, opts):
ai = socket.getaddrinfo(site, 443, socket.AF_INET)
Expand Down
10 changes: 8 additions & 2 deletions tests/net_inet/tls_num_errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,21 @@
import socket, ssl, sys

try:
from micropython import alloc_emergency_exception_buf, heap_lock, heap_unlock
from micropython import heap_lock, heap_unlock
except:
print("SKIP")
raise SystemExit

try:
from micropython import alloc_emergency_exception_buf

alloc_emergency_exception_buf(256)
except:
pass


# test with heap locked to see it switch to number-only error message
def test(addr):
alloc_emergency_exception_buf(256)
s = socket.socket()
s.connect(addr)
try:
Expand Down
Loading
Loading