Age | Commit message (Collapse) | Author |
|
Only a few ports have TCP/IP loopback enabled in their network stack, and
this test will only pass on those ports. There's not really any good way
to do a feature check for loopback mode without actually running the test
and seeing if it passes/fails, so add an explicit check that the test is
running on a port known to support loopback.
(Enabling loopback on lwIP, eg RPI_PICO_W, costs +568 code and +272 bss and
is a rarely used feature, so not worth unconditionally enabling.)
Signed-off-by: Damien George <damien@micropython.org>
|
|
This allows it to run parts of the test on esp8266 (or any target using
axTLS).
Signed-off-by: Damien George <damien@micropython.org>
|
|
CPython changed its non-blocking socket behaviour recently and this test
would not run under CPython anymore. So the following steps were taken to
get the test working again and then simplify it:
- Run the test against CPython 3.10.10 and capture the output into the .exp
file for the test.
- Run this test on unix port of MicroPython and verify that the output
matches the CPython 3.10.10 output in the new .exp file (it did). From
now on take unix MicroPython as the source of truth for this test when
modifying it.
- Remove all code that was there for CPython compatibility.
- Make it print out more useful information during the test run, including
names of the OSError errno values.
- Add polling of the socket before the send/write/recv/read to verify that
the poll gives the correct result in non-blocking mode.
Tested on unix MicroPython, ESP32_GENERIC, PYBD_SF2 and RPI_PICO_W boards.
Signed-off-by: Damien George <damien@micropython.org>
|
|
If the socket timeout is 0 then a failed socket.connect() raises
EINPROGRESS (which is what the lwIP bindings already did), but if the
socket timeout is non-zero then a failed socket.connect() should raise
ETIMEDOUT. The latter is fixed in this commit.
A test is added for these timeout cases.
Signed-off-by: Damien George <damien@micropython.org>
|
|
The `cert` argument passed to the verify callback is actually a memoryview.
And the `depth` argument seems to start at 1 for the tested URL.
Signed-off-by: Damien George <damien@micropython.org>
|
|
This is a useful alternative to .getpeercert() when the certificate is not
stored to reduce RAM usage.
Signed-off-by: Felix Dörre <felix@dogcraft.de>
|
|
Changes are:
- use ssl.SSLContext.wrap_socket instead of ssl.wrap_socket
- disable check_hostname and call load_default_certs() where appropriate,
to get CPython to run the tests correctly
- pass socket.AF_INET to getaddrinfo and socket.socket(), to force IPv4
- change tests to use github.com instead of google.com, because certificate
validation was failing with google.com
Signed-off-by: Damien George <damien@micropython.org>
|
|
And only enable this method when the relevant feature is available in
mbedtls. Otherwise, if mbedtls doesn't support getting the peer
certificate, this method always returns None and it's confusing why it does
that. It's better to remove the method altogether, so the error trying to
use it is more obvious.
Signed-off-by: Damien George <damien@micropython.org>
|
|
Signed-off-by: Peter Züger <zueger.peter@icloud.com>
|
|
The following code:
server = await asyncio.start_server(...)
async with server:
... code that raises ...
would lose the original exception because the server's task would not have
had a chance to be scheduled yet, and so awaiting the task in wait_closed
would raise the cancellation instead of the original exception.
Additionally, ensures that explicitly cancelling the parent task delivers
the cancellation correctly (previously was masked by the server loop), now
this only happens if the server was closed, not when the task was
cancelled.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
|
|
This work was funded through GitHub Sponsors.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
|
|
This work was funded through GitHub Sponsors.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
|
|
Signed-off-by: Damien George <damien@micropython.org>
|
|
Currently when using uasyncio.start_server() the socket configuration is
done inside a uasyncio.create_task() background function. If the address
and port are already in use however this throws an OSError which cannot be
cleanly caught behind the create_task().
This commit moves the getaddrinfo and socket binding to the start_server()
function, and only creates the task if that succeeds. This means that any
OSError from the initial socket configuration is propagated directly up the
call stack, compatible with CPython behaviour.
See #7444.
Signed-off-by: Damien George <damien@micropython.org>
|
|
Signed-off-by: Damien George <damien@micropython.org>
|
|
Signed-off-by: Damien George <damien@micropython.org>
|
|
Also fix related problems with socket on esp32, improve docs for
wrap_socket, and add more tests.
|
|
The underlying OS (the ESP-IDF) uses it's own internal errno codes and so
it's simpler and cleaner to use those rather than trying to convert
everything to the values defined in py/mperrno.h.
|
|
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.
|
|
POSIX poll should always return POLLERR and POLLHUP in revents, regardless
of whether they were requested in the input events flags.
See issues #4290 and #5172.
|
|
|
|
Behaviour is as per CPython but only the binary form is implemented here.
A test is included.
|
|
In the future, a special runner for such tests will import each test and
call test() function with an address of test server to use.
|
|
The idea is that these tests can be run with just a test server running
on a test host, with device under test connecting to it, instead of
requiring Internet connection for testing.
Such setup is however WIP, and some tests in net_hosted/ are so far
written to connect to Internet, as there're not test server written
yet. This is expected to evolve over time.
|