Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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: 5 additions & 0 deletions extmod/modplatform.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@
#elif defined(__ANDROID__)
#define MICROPY_PLATFORM_LIBC_LIB "bionic"
#define MICROPY_PLATFORM_LIBC_VER MP_STRINGIFY(__ANDROID_API__)
#elif defined(__FreeBSD__)
#define MICROPY_PLATFORM_LIBC_LIB "libc"
#define MICROPY_PLATFORM_LIBC_VER ""
#else
#define MICROPY_PLATFORM_LIBC_LIB ""
#define MICROPY_PLATFORM_LIBC_VER ""
Expand All @@ -112,6 +115,8 @@
#define MICROPY_PLATFORM_SYSTEM "Android"
#elif defined(__linux)
#define MICROPY_PLATFORM_SYSTEM "Linux"
#elif defined(__FreeBSD__)
#define MICROPY_PLATFORM_SYSTEM "FreeBSD"
#elif defined(__unix__)
#define MICROPY_PLATFORM_SYSTEM "Unix"
#elif defined(__CYGWIN__)
Expand Down
9 changes: 8 additions & 1 deletion ports/unix/mpconfigport.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,20 @@
#ifndef MICROPY_PY_SYS_PLATFORM
#if defined(__APPLE__) && defined(__MACH__)
#define MICROPY_PY_SYS_PLATFORM "darwin"
#elif defined(__FreeBSD__)
#define MICROPY_PY_SYS_PLATFORM "freebsd"
#else
#define MICROPY_PY_SYS_PLATFORM "linux"
#endif
#endif

#ifndef MICROPY_PY_SYS_PATH_DEFAULT
#define MICROPY_PY_SYS_PATH_DEFAULT ".frozen:~/.micropython/lib:/usr/lib/micropython"
#if defined(__FreeBSD__)
#define SYSTEM_LIB_PATH "/usr/local/lib/micropython"
#else
#define SYSTEM_LIB_PATH "/usr/lib/micropython"
#endif
#define MICROPY_PY_SYS_PATH_DEFAULT ".frozen:~/.micropython/lib:" SYSTEM_LIB_PATH
#endif

#define MP_STATE_PORT MP_STATE_VM
Expand Down
10 changes: 9 additions & 1 deletion tests/extmod/select_poll_fd.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
# Test select.poll in combination with file descriptors.

try:
import select, errno
import sys, select, errno

select.poll # Raises AttributeError for CPython implementations without poll()
except (ImportError, AttributeError):
print("SKIP")
raise SystemExit

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having the sys module is a requirement for a port to be able to run the tests, but sys.platform can be missing.

If a port has the select and errno modules then it's highly likely it has sys.platform. So I suggest putting the check after the import of select/errno, and just access sys.platform without any try/except, like this:

if sys.platform == "freebsd":
    print("SKIP")
    raise SystemExit

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Turns out sys may not be there, after all. This test is also checked against CPython, which fails with an import error (eg. https://github.com/micropython/micropython/actions/runs/27251624169/job/80477170312?pr=18979).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, sorry, I meant that a port is required to implement the sys module (I didn't mean that sys will already be imported).

Anyway, what you have here is good!


# FreeBSD allows to have up to ~120k file descriptor by default, so this test
# will fail on such a system. Since there's no provision to query sysctl
# values or an easy way to parse the output of `ulimit -n` the test is just
# skipped on FreeBSD.
if sys.platform == "freebsd":
print("SKIP")
raise SystemExit

# Check that poll supports registering file descriptors (integers).
try:
select.poll().register(0)
Expand Down
2 changes: 1 addition & 1 deletion tests/ports/unix/ffi_callback.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def ffi_open(names):
raise err


libc = ffi_open(("libc.so", "libc.so.0", "libc.so.6", "libc.dylib"))
libc = ffi_open(("libc.so", "libc.so.0", "libc.so.6", "libc.so.7", "libc.dylib"))

qsort = libc.func("v", "qsort", "piip")

Expand Down
6 changes: 4 additions & 2 deletions tests/ports/unix/ffi_float.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def ffi_open(names):
raise err


libc = ffi_open(("libc.so", "libc.so.0", "libc.so.6", "libc.dylib"))
libc = ffi_open(("libc.so", "libc.so.0", "libc.so.6", "libc.so.7", "libc.dylib"))

try:
strtof = libc.func("f", "strtof", "sp")
Expand All @@ -33,7 +33,9 @@ def ffi_open(names):
print("%.6f" % strtod("1.23", None))

# test passing double and float args
libm = ffi_open(("libm.so", "libm.so.6", "libc.so.0", "libc.so.6", "libc.dylib"))
libm = ffi_open(
("libm.so", "libm.so.5", "libm.so.6", "libc.so.0", "libc.so.6", "libc.so.7", "libc.dylib")
)
tgamma = libm.func("d", "tgamma", "d")
for fun_name in ("tgamma",):
fun = globals()[fun_name]
Expand Down
Loading