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:
parent
f205e231ef
commit
43cb43ed18
6 changed files with 80 additions and 1 deletions
|
|
@ -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
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
|
|
|
||||||
|
|
@ -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"
|
||||||
|
|
|
||||||
18
test/db/archos/not-windows-any/http
Normal file
18
test/db/archos/not-windows-any/http
Normal 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
31
test/scripts/http_server.py
Executable 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
22
test/www/simple.html
Normal 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>
|
||||||
Loading…
Reference in a new issue