Skip to content

Curl test 30/30#116

Open
moogchi wants to merge 3 commits intomainfrom
curl_test
Open

Curl test 30/30#116
moogchi wants to merge 3 commits intomainfrom
curl_test

Conversation

@moogchi
Copy link

@moogchi moogchi commented Mar 3, 2026

Add curl test suite for lind-wasm

Summary

Adds a self-contained test runner (curl/test.sh) that verifies curl functionality within the Lind sandbox. 30/30 tests pass.

What's included

curl/test.sh — Test runner with 30 test cases covering:

Basic functionality (3):

  • Binary exists at lindfs/bin/curl
  • curl --version returns valid output
  • curl --help returns usage info

HTTP methods & status codes (6):

  • GET request with body verification
  • GET with status code check (200)
  • HEAD request with Content-Length header
  • 404 error handling
  • POST request (-X POST -d)
  • PUT request (-X PUT)

Request options (7):

  • Custom header (-H)
  • User-Agent (-A)
  • Follow redirect flag (-L)
  • Output to /dev/null (-o)
  • Write-out format (-w)
  • Verbose output (-v)
  • Silent mode (-s)

HTTPS / TLS (2):

  • HTTPS with insecure flag (-k)
  • HTTPS with CA certificate (--cacert)

Data transfer (4):

  • JSON content retrieval
  • Multiple URLs in one request
  • Large file download with size verification
  • Range request (-r)

Timeouts & reliability (3):

  • Connection timeout (--connect-timeout)
  • Max time (--max-time)
  • Retry flag (--retry)

External URLs (5):

  • External HTTP GET (DNS resolution)
  • External HTTPS GET (DNS + TLS)
  • External HTTPS content verification
  • External redirect follow (HTTP 301/302)
  • External HEAD request

External tests probe DNS availability before running and auto-skip if DNS is unavailable.

How it works

Similar to the nginx test approach:

  1. Creates test data files in lindfs/tests/curl/www/
  2. Starts a Python HTTP server on port 8111 (configurable via $HTTP_PORT)
  3. Starts a Python HTTPS server on port 8443 with a self-signed certificate
  4. Runs lind_run bin/curl against local and external servers
  5. Verifies output/status codes
  6. Reports PASS/FAIL per test with a summary
  7. Exits 0 on all pass, 1 on any failure

Setup requirements

  • curl compiled with --disable-ipv6 and copied to lindfs/bin/curl
  • /dev/urandom and /dev/random device nodes in lindfs (script creates them if missing — required for TLS/SSL)
  • python3 and openssl on host (for test servers and certificate generation)

Key findings

  • /dev/urandom required for TLS: HTTPS fails with "Insufficient randomness" without it. The script creates these device nodes if missing.
  • PF_UNSPEC DNS lookups broken: getaddrinfo() works with AF_INET but fails with PF_UNSPEC ("Temporary failure in name resolution"). Curl must be compiled with --disable-ipv6 to force AF_INET only. Opened issue on lind-wasm repo.
  • No CA bundle: Curl is built without a CA bundle, so external HTTPS tests use -k (insecure) to skip certificate verification.

Test results

[curl-test] [PASS] Binary exists at lindfs/bin/curl
[curl-test] [PASS] curl --version
[curl-test] [PASS] curl --help
[curl-test] [PASS] HTTP GET text file
[curl-test] [PASS] HTTP GET status code 200
[curl-test] [PASS] HTTP HEAD request
[curl-test] [PASS] HTTP 404 handling
[curl-test] [PASS] HTTP GET JSON
[curl-test] [PASS] Custom header (-H)
[curl-test] [PASS] User-Agent (-A)
[curl-test] [PASS] Follow redirect flag (-L)
[curl-test] [PASS] Output to /dev/null (-o)
[curl-test] [PASS] Write-out format (-w)
[curl-test] [PASS] Verbose output (-v)
[curl-test] [PASS] Silent mode (-s)
[curl-test] [PASS] Multiple URLs
[curl-test] [PASS] POST request (-X POST -d)
[curl-test] [PASS] PUT request (-X PUT)
127.0.0.1 - - [12/Mar/2026 15:38:22] "GET / HTTP/1.1" 200 -
127.0.0.1 - - [12/Mar/2026 15:38:23] "GET /test.txt HTTP/1.1" 200 -
[curl-test] [PASS] HTTPS insecure (-k)
127.0.0.1 - - [12/Mar/2026 15:38:23] "GET / HTTP/1.1" 200 -
127.0.0.1 - - [12/Mar/2026 15:38:23] "GET /test.txt HTTP/1.1" 200 -
[curl-test] [PASS] HTTPS with CA cert (--cacert)
[curl-test] [PASS] Connection timeout (--connect-timeout)
[curl-test] [PASS] Max time (--max-time)
[curl-test] [PASS] Large file download
[curl-test] [PASS] Range request (-r)
[curl-test] [PASS] Retry flag (--retry)

[curl-test] --- External URL tests (DNS + network) ---
[curl-test] [PASS] External HTTP GET (DNS resolution)
[curl-test] [PASS] External HTTPS GET (DNS + TLS)
[curl-test] [PASS] External HTTPS content verification
[curl-test] [PASS] External redirect follow (HTTP 301/302)
[curl-test] [PASS] External HEAD request

[curl-test] 30/30 tests passed, 0 failed

Usage

cd ~/lind-wasm/lind-wasm-apps
./curl/test.sh

@moogchi moogchi requested a review from vidyalakshmir March 3, 2026 01:30
@vidyalakshmir
Copy link
Contributor

@moogchi This is great. I see that in the test script, a local http server hosts webpages, which curl requests.

Could you please add tests to request for webpages which are not local. This will involve dns resolution and other mechanisms and we would like to test that too.

@moogchi
Copy link
Author

moogchi commented Mar 5, 2026

@vidyalakshmir Added 5 external URL tests (HTTP GET, HTTPS GET, content verification, redirect follow, HEAD request) that test DNS resolution and real network connectivity.

Right now they auto-skip because getaddrinfo() fails for external hosts from inside the sandbox. Curl returns error 6 (Could not resolve host). Local networking works fine though. The tests will automatically run once DNS support is working.

Also found that /etc/resolv.conf was missing from lindfs, but even after copying it in, DNS still doesn't resolve. Looks like it's a syscall-level limitation.

@moogchi moogchi changed the title Curl test 25/25 Curl test 25/30 Mar 6, 2026
@vidyalakshmir
Copy link
Contributor

@moogchi Could you test this again, now that Nick's DNS fix is merged into main?

m-hemmings pushed a commit that referenced this pull request Mar 11, 2026
* feat: added shm changes

* feat: added basic tests

* fix: revert test removal

* feat: added comments for clarity

* fix: revert test cases

* feat: added add_entry_with_overwrite error handeling

* fix: added else block for error propogation

* fix: removed nacl comment

* feat: added shmat tests

* fix: fixed length error

* fix: length order fix

* fix: reverted length error

* fix: update syscall return

* fix: update syscall return
@moogchi moogchi changed the title Curl test 25/30 Curl test 30/30 Mar 12, 2026
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