Skip to content

Commit 91e3da2

Browse files
committed
Add Make target for testing NGINX
1 parent a9edcec commit 91e3da2

File tree

3 files changed

+40
-0
lines changed

3 files changed

+40
-0
lines changed

Makefile

+18
Original file line numberDiff line numberDiff line change
@@ -102,3 +102,21 @@ nginx/.FOLDER: src/objs/nginx
102102
(cd src && $(MAKE) DESTDIR=$(PWD)/$(@D)/ install)
103103
(cd $(@D) && rm -f *.default koi-win koi-utf win-utf)
104104
touch $@
105+
106+
test:
107+
@./nginx/nginx -c "$$PWD/test.conf" -e /dev/fd/1 -p nginx & \
108+
nginx_pid="$$!" && \
109+
(sleep 0.05 >/dev/null 2>&1 || :) && \
110+
if ! kill -1 "$$nginx_pid"; then \
111+
echo "make $@: unable to start nginx" >&2; \
112+
exit 1; \
113+
fi; \
114+
for _ in 1 2 3; do \
115+
nc -zw1 localhost 4475 && break; \
116+
sleep 1; \
117+
done; \
118+
trap 'kill "$$nginx_pid"' EXIT && \
119+
curl -fsS http://localhost:4475/ >/dev/null || exit_status="$$?" && \
120+
rm -rf nginx/*_temp/ && \
121+
exit "$${exit_status:-0}"
122+
@echo "make $@: test passed"

README.md

+3
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ Some of the other targets provided by the Makefile include:
3434
- **clean**: Delete all folders created by this script.
3535
- **cleaner**: Delete all files created by this script which includes the
3636
downloaded tar-balls.
37+
- **test:** Run a simple test of NGINX. The NGINX binary must already be built,
38+
port 4475 must be available for use, and _curl(1)_ must be installed. This
39+
target does not implicitly build NGINX.
3740

3841
Attributions
3942
------------

test.conf

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
worker_processes 1;
2+
daemon off;
3+
4+
events {
5+
worker_connections 1024;
6+
}
7+
8+
http {
9+
server {
10+
listen 4475;
11+
server_name localhost;
12+
access_log /dev/null;
13+
14+
location / {
15+
root html;
16+
index index.html index.htm;
17+
}
18+
}
19+
}

0 commit comments

Comments
 (0)