From 43cb43ed180d3722da8c1c6218b2df64cd64e4e6 Mon Sep 17 00:00:00 2001 From: Khairul Azhar Kasmiran Date: Thu, 18 Jun 2026 07:01:00 +0800 Subject: [PATCH] Add reliable http:// test (#6509) * Add reliable http:// test * REUSE.toml: Add `test/www/**` entry * Use `cwd` instead to work around old http.server in Python 3.6 * Move test to `not-windows-any` * NetBSD: Add `python3` symbolic link * Prevent test from running on woodpecker --- .builds/netbsd.yml | 3 ++- .woodpecker/macos-arm64.yml | 1 + REUSE.toml | 6 ++++++ test/db/archos/not-windows-any/http | 18 +++++++++++++++++ test/scripts/http_server.py | 31 +++++++++++++++++++++++++++++ test/www/simple.html | 22 ++++++++++++++++++++ 6 files changed, 80 insertions(+), 1 deletion(-) create mode 100644 test/db/archos/not-windows-any/http create mode 100755 test/scripts/http_server.py create mode 100644 test/www/simple.html diff --git a/.builds/netbsd.yml b/.builds/netbsd.yml index ba9689b8f3..60f43ab3af 100644 --- a/.builds/netbsd.yml +++ b/.builds/netbsd.yml @@ -53,5 +53,6 @@ tasks: cd test # Workaround to avoid running HTTP POST test rm -f db/cmd/cmd_http_post - # Running the unit tests + # Running rz-test + ln -s `which python3.10` ${HOME}/bin/python3 MALLOC_OPTIONS=S rz-test -L -o results.json diff --git a/.woodpecker/macos-arm64.yml b/.woodpecker/macos-arm64.yml index afad3199de..ef383e5796 100644 --- a/.woodpecker/macos-arm64.yml +++ b/.woodpecker/macos-arm64.yml @@ -28,4 +28,5 @@ steps: commands: - export PATH="`pwd`/prefix/bin:$PATH" - cd test + - rm -f db/archos/not-windows-any/http - rz-test -V -L diff --git a/REUSE.toml b/REUSE.toml index 514584e6f9..fb98fffa10 100644 --- a/REUSE.toml +++ b/REUSE.toml @@ -171,6 +171,12 @@ precedence = "aggregate" SPDX-FileCopyrightText = "2020 RizinOrg " SPDX-License-Identifier = "LGPL-3.0-only" +[[annotations]] +path = "test/www/**" +precedence = "aggregate" +SPDX-FileCopyrightText = "2026 RizinOrg " +SPDX-License-Identifier = "LGPL-3.0-only OR CC-BY-SA-4.0" + [[annotations]] path = "subprojects/rizin-shell-parser/**" precedence = "aggregate" diff --git a/test/db/archos/not-windows-any/http b/test/db/archos/not-windows-any/http new file mode 100644 index 0000000000..8ae93a7d3c --- /dev/null +++ b/test/db/archos/not-windows-any/http @@ -0,0 +1,18 @@ +NAME=read from http +FILE=-- +CMDS=< + + +My Simple Web Page + +EOF +RUN diff --git a/test/scripts/http_server.py b/test/scripts/http_server.py new file mode 100755 index 0000000000..9aa8cbe1f6 --- /dev/null +++ b/test/scripts/http_server.py @@ -0,0 +1,31 @@ +#!/usr/bin/env python3 + +r""" +This script launches python -m http.server in a subprocess and waits until it's ready to receive +a new connection. + +""" + +import http.client +import subprocess + + +def main(): + subprocess.run( + "python3 -m http.server 9000 --bind 127.0.0.1 &", + shell=True, + check=True, + cwd="www", + stdout=subprocess.DEVNULL, + stderr=subprocess.DEVNULL, + ) + while True: + try: + http.client.HTTPConnection("127.0.0.1", 9000, timeout=5).connect() + except ConnectionRefusedError: + continue + break + + +if __name__ == "__main__": + main() diff --git a/test/www/simple.html b/test/www/simple.html new file mode 100644 index 0000000000..5ea239e4f4 --- /dev/null +++ b/test/www/simple.html @@ -0,0 +1,22 @@ + + + +My Simple Web Page + + + +

Welcome to My Page!

+

This is a simple web page created using HTML.

+Visit Example + +