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
This commit is contained in:
Khairul Azhar Kasmiran 2026-06-18 07:01:00 +08:00 committed by GitHub
parent f205e231ef
commit 43cb43ed18
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 80 additions and 1 deletions

View file

@ -53,5 +53,6 @@ tasks:
cd test cd test
# Workaround to avoid running HTTP POST test # Workaround to avoid running HTTP POST test
rm -f db/cmd/cmd_http_post 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 MALLOC_OPTIONS=S rz-test -L -o results.json

View file

@ -28,4 +28,5 @@ steps:
commands: commands:
- export PATH="`pwd`/prefix/bin:$PATH" - export PATH="`pwd`/prefix/bin:$PATH"
- cd test - cd test
- rm -f db/archos/not-windows-any/http
- rz-test -V -L - rz-test -V -L

View file

@ -171,6 +171,12 @@ precedence = "aggregate"
SPDX-FileCopyrightText = "2020 RizinOrg <info@rizin.re>" SPDX-FileCopyrightText = "2020 RizinOrg <info@rizin.re>"
SPDX-License-Identifier = "LGPL-3.0-only" SPDX-License-Identifier = "LGPL-3.0-only"
[[annotations]]
path = "test/www/**"
precedence = "aggregate"
SPDX-FileCopyrightText = "2026 RizinOrg <info@rizin.re>"
SPDX-License-Identifier = "LGPL-3.0-only OR CC-BY-SA-4.0"
[[annotations]] [[annotations]]
path = "subprojects/rizin-shell-parser/**" path = "subprojects/rizin-shell-parser/**"
precedence = "aggregate" precedence = "aggregate"

View file

@ -0,0 +1,18 @@
NAME=read from http
FILE=--
CMDS=<<EOF
!python3 scripts/http_server.py
o http://127.0.0.1:9000/simple.html
r
b 64
ps
EOF
EXPECT=<<EOF
342
<!DOCTYPE html>
<html>
<head>
<title>My Simple Web Page</title>
EOF
RUN

31
test/scripts/http_server.py Executable file
View file

@ -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()

22
test/www/simple.html Normal file
View file

@ -0,0 +1,22 @@
<!DOCTYPE html>
<html>
<head>
<title>My Simple Web Page</title>
<style>
body {
background-color: lightgrey;
}
h1 {
color: blue;
}
p {
font-family: Arial, sans-serif;
}
</style>
</head>
<body>
<h1>Welcome to My Page!</h1>
<p>This is a simple web page created using HTML.</p>
<a href="https://www.example.com">Visit Example</a>
</body>
</html>