|
1 | 1 | AUTOMAKE_OPTIONS = foreign subdir-objects |
2 | 2 | ACLOCAL_AMFLAGS = -I m4 |
3 | 3 |
|
| 4 | +# Pull in pkg-config detected flags from configure |
| 5 | +AM_CPPFLAGS = $(ssl_CFLAGS) $(crypto_CFLAGS) $(pthread_CFLAGS) |
| 6 | +AM_CFLAGS = $(AM_CPPFLAGS) |
| 7 | +LDADD_COMMON = $(ssl_LIBS) $(crypto_LIBS) $(pthread_LIBS) -lpthread -lz |
| 8 | + |
4 | 9 | COMMON = src/cwebsocket/utf8.h src/cwebsocket/utf8.c src/cwebsocket/common.h src/cwebsocket/common.c |
5 | 10 | ECHO_CLIENT = src/cwebsocket/subprotocol/echo/echo_client.h src/cwebsocket/subprotocol/echo/echo_client.c |
6 | 11 | ECHO_SERVER = src/cwebsocket/subprotocol/echo/echo_server.h src/cwebsocket/subprotocol/echo/echo_server.c |
7 | 12 | WEBSOCKET_CLIENT = src/cwebsocket/client.h src/cwebsocket/client.c |
8 | 13 | WEBSOCKET_SERVER = src/cwebsocket/server.h src/cwebsocket/server.c |
9 | 14 |
|
10 | | -bin_PROGRAMS = websocket-client websocket-server websocket-testsuite |
| 15 | +bin_PROGRAMS = websocket-client websocket-testsuite |
11 | 16 | websocket_client_SOURCES = $(ECHO_CLIENT) $(COMMON) $(WEBSOCKET_CLIENT) src/websocket-client.c |
12 | | -websocket_server_SOURCES = $(ECHO_SERVER) $(COMMON) $(WEBSOCKET_SERVER) src/websocket-server.c |
| 17 | +websocket_client_LDADD = $(LDADD_COMMON) |
13 | 18 | websocket_testsuite_SOURCES = $(COMMON) $(WEBSOCKET_CLIENT) src/websocket-testsuite.c |
| 19 | +websocket_testsuite_LDADD = $(LDADD_COMMON) |
| 20 | + |
| 21 | +noinst_PROGRAMS = tests-unit |
| 22 | +tests_unit_SOURCES = $(COMMON) $(WEBSOCKET_CLIENT) src/tests-unit.c |
| 23 | +tests_unit_CPPFLAGS = -DUNIT_TESTING $(AM_CPPFLAGS) |
| 24 | +tests_unit_LDADD = $(LDADD_COMMON) |
14 | 25 |
|
15 | | -noinst_LIBRARIES = libwsclient.a libwsserver.a |
| 26 | +noinst_LIBRARIES = libwsclient.a |
16 | 27 | libwsclient_a_SOURCES = $(ECHO_CLIENT) $(COMMON) $(WEBSOCKET_CLIENT) |
17 | | -libwsserver_a_SOURCES = $(ECHO_SERVER) $(COMMON) $(WEBSOCKET_SERVER) |
18 | 28 |
|
19 | 29 | so: |
20 | 30 | gcc -shared -fPIC $(ECHO_CLIENT) $(WEBSOCKET_CLIENT) -o libwsclient.so |
21 | 31 | gcc -shared -fPIC $(ECHO_SERVER) $(WEBSOCKET_SERVER) -o libwsserver.so |
22 | 32 |
|
23 | | -clean: |
24 | | - rm -rf compile ltmain.sh libtool config.sub config.guess libwsclient.* libwsserver.* .gitignore vgcore.* autoscan.log config.h.in config.h config.cache configure install-sh aclocal.m4 autom4te.cache/ config.log config.status Debug/ RPI\ Debug Release depcomp .deps/ m4/ Makefile Makefile.in missing stamp-h1 *.o src/*.o *~ src/.deps/ src/.dirstamp src/cwebsocket/.deps/ src/cwebsocket/.dirstamp src/cwebsocket/client.o src/cwebsocket/common.o src/cwebsocket/server.o src/cwebsocket/subprotocol/echo/.deps/ src/cwebsocket/subprotocol/echo/.dirstamp src/cwebsocket/subprotocol/echo/echo_client.o src/cwebsocket/subprotocol/echo/echo_server.o src/cwebsocket/utf8.o websocket-client websocket-server websocket-testsuite |
| 33 | +# Files to remove with 'make clean' (build outputs, object files, etc.) |
| 34 | +CLEANFILES = \ |
| 35 | + libwsclient.so libwsserver.so \ |
| 36 | + *.o src/*.o src/cwebsocket/*.o src/cwebsocket/subprotocol/echo/*.o \ |
| 37 | + *~ src/*~ src/cwebsocket/*~ \ |
| 38 | + vgcore.* \ |
| 39 | + *.log integration*.log test*.log testsuite.log autoscan.log \ |
| 40 | + *.gcda *.gcno src/*.gcda src/*.gcno src/cwebsocket/*.gcda src/cwebsocket/*.gcno \ |
| 41 | + coverage.info coverage_filtered.info |
| 42 | + |
| 43 | +# Files to remove with 'make distclean' (generated by configure) |
| 44 | +DISTCLEANFILES = \ |
| 45 | + config.h config.h.in config.h.in~ \ |
| 46 | + config.cache config.log config.status \ |
| 47 | + libtool stamp-h1 \ |
| 48 | + Makefile Makefile.in |
| 49 | + |
| 50 | +# Files to remove with 'make maintainerclean' (generated by autotools) |
| 51 | +MAINTAINERCLEANFILES = \ |
| 52 | + aclocal.m4 \ |
| 53 | + compile config.guess config.sub \ |
| 54 | + configure configure~ \ |
| 55 | + depcomp install-sh missing ltmain.sh |
| 56 | + |
| 57 | +# Additional cleanup hook to remove directories and test reports |
| 58 | +clean-local: |
| 59 | + @echo "Removing build artifacts and dependency files..." |
| 60 | + rm -rf src/.deps src/.dirstamp |
| 61 | + rm -rf src/cwebsocket/.deps src/cwebsocket/.dirstamp |
| 62 | + rm -rf src/cwebsocket/subprotocol/echo/.deps src/cwebsocket/subprotocol/echo/.dirstamp |
| 63 | + rm -rf .deps/ |
| 64 | + rm -rf Debug/ "RPI Debug" Release/ |
| 65 | + @echo "Removing test reports..." |
| 66 | + rm -rf autobahn-reports/ |
| 67 | + rm -rf test/autobahn/reports/clients/* |
| 68 | + @echo "Removing coverage reports..." |
| 69 | + rm -rf coverage_html/ |
| 70 | + @echo "Clean complete" |
| 71 | + |
| 72 | +# Full clean for git commit - removes ALL generated files including autotools |
| 73 | +maintainer-clean-local: |
| 74 | + @echo "Removing all generated files for clean git repository..." |
| 75 | + rm -rf autom4te.cache/ |
| 76 | + rm -rf m4/ |
| 77 | + rm -f aclocal.m4 |
| 78 | + rm -f compile config.guess config.sub |
| 79 | + rm -f configure configure~ |
| 80 | + rm -f config.h.in config.h.in~ |
| 81 | + rm -f depcomp install-sh missing ltmain.sh |
| 82 | + @echo "Maintainer clean complete - run ./autogen.sh to regenerate" |
| 83 | + |
| 84 | +# Remove generated autotools files with 'make distclean' |
| 85 | +distclean-local: |
| 86 | + rm -rf autom4te.cache/ |
| 87 | + rm -rf m4/ |
| 88 | + |
| 89 | +.PHONY: autobahn-up autobahn-down autobahn-test-client autobahn-clean \ |
| 90 | + docker-build docker-shell test integration-test inside-unit inside-integration docker-network \ |
| 91 | + autobahn autobahn-local coverage coverage-report coverage-clean |
| 92 | + |
| 93 | +autobahn-up: |
| 94 | + @./scripts/autobahn-up.sh |
| 95 | + |
| 96 | +autobahn-down: |
| 97 | + @./scripts/autobahn-down.sh |
| 98 | + |
| 99 | +autobahn-test-client: integration-test |
| 100 | + @true |
| 101 | + |
| 102 | +autobahn-clean: |
| 103 | + @rm -rf test/autobahn/reports/clients/* |
| 104 | + |
| 105 | +# Dockerized workflow (no host installs required) |
| 106 | +IMAGE_NAME = cwebsocket/test:latest |
| 107 | +REPORTS_WAIT_SECS ?= 900 |
| 108 | + |
| 109 | +docker-build: |
| 110 | + @DOCKER_BUILDKIT=0 docker build -t $(IMAGE_NAME) . |
| 111 | + |
| 112 | +docker-shell: docker-build |
| 113 | + @docker run --rm -it -v $(PWD)/test/autobahn:/app/test/autobahn $(IMAGE_NAME) bash |
| 114 | + |
| 115 | +# Host triggers that run tests inside the container |
| 116 | +test: docker-build |
| 117 | + @docker run --rm -v $(PWD)/test/autobahn:/app/test/autobahn $(IMAGE_NAME) make inside-unit |
| 118 | + |
| 119 | +docker-network: |
| 120 | + @docker network create cwsnet >/dev/null 2>&1 || true |
| 121 | + |
| 122 | +integration-test: docker-build docker-network |
| 123 | + @docker rm -f cwebsocket-autobahn >/dev/null 2>&1 || true |
| 124 | + @rm -f test/autobahn/reports/clients/* >/dev/null 2>&1 || true |
| 125 | + @docker run -d --rm --name cwebsocket-autobahn --network cwsnet -v $(PWD)/test/autobahn:/config crossbario/autobahn-testsuite:latest >/dev/null |
| 126 | + @echo "Waiting for fuzzing server ..." && sleep 2 |
| 127 | + @set -e; docker run --rm --network cwsnet -v $(PWD)/test/autobahn:/app/test/autobahn -e WS_FUZZING_SERVER=ws://cwebsocket-autobahn:9001 -e WS_CASECOUNT_RETRIES=120 $(IMAGE_NAME) bash -lc "./websocket-testsuite" || true; \ |
| 128 | + echo -n "Waiting for reports"; \ |
| 129 | + for i in `seq 1 $${REPORTS_WAIT_SECS}`; do \ |
| 130 | + [ -f $(PWD)/test/autobahn/reports/clients/index.json ] && break; \ |
| 131 | + sleep 1; \ |
| 132 | + done; echo; \ |
| 133 | + if [ -n "`ls -A $(PWD)/test/autobahn/reports/clients 2>/dev/null`" ]; then \ |
| 134 | + echo "Integration reports generated at test/autobahn/reports/clients"; \ |
| 135 | + else \ |
| 136 | + echo "Integration failed: no reports generated."; \ |
| 137 | + exit 1; \ |
| 138 | + fi |
| 139 | + @# copy full HTML+JSON reports directory to CWD |
| 140 | + @rm -rf $(PWD)/autobahn-reports && mkdir -p $(PWD)/autobahn-reports |
| 141 | + @cp -r $(PWD)/test/autobahn/reports/* $(PWD)/autobahn-reports/ |
| 142 | + @echo "Full Autobahn reports copied to ./autobahn-reports (HTML and JSON)." |
| 143 | + @docker rm -f cwebsocket-autobahn >/dev/null 2>&1 || true |
| 144 | + |
| 145 | +.PHONY: integration-logs |
| 146 | +integration-logs: |
| 147 | + @docker logs -f cwebsocket-autobahn |
| 148 | + |
| 149 | +# Simple alias to run full Dockerized Autobahn workflow |
| 150 | +autobahn: integration-test |
| 151 | + |
| 152 | +# Host-run testsuite against a running Autobahn server (default localhost) |
| 153 | +autobahn-local: websocket-testsuite |
| 154 | + @echo "Running websocket-testsuite against $${WS_FUZZING_SERVER:-ws://localhost:9001} ..." |
| 155 | + @WS_FUZZING_SERVER=$${WS_FUZZING_SERVER:-ws://localhost:9001} WS_CASECOUNT_RETRIES=$${WS_CASECOUNT_RETRIES:-120} ./websocket-testsuite || true |
| 156 | + @# If reports were volume-mounted or written under test/autobahn/reports, copy them for convenience |
| 157 | + @mkdir -p autobahn-reports |
| 158 | + @if [ -d test/autobahn/reports ]; then \ |
| 159 | + rm -rf autobahn-reports/*; \ |
| 160 | + cp -r test/autobahn/reports/* autobahn-reports/ 2>/dev/null || true; \ |
| 161 | + echo "Copied reports to ./autobahn-reports (if available)."; \ |
| 162 | + else \ |
| 163 | + echo "No local report directory found. Ensure your fuzzing server writes into test/autobahn/reports or use 'make autobahn'."; \ |
| 164 | + fi |
| 165 | + |
| 166 | +# In-container targets |
| 167 | +inside-unit: tests-unit |
| 168 | + @./tests-unit |
| 169 | + |
| 170 | +inside-integration: |
| 171 | + @echo "Use 'make integration-test' to run Autobahn in multi-container setup." |
| 172 | + |
| 173 | +# Code Coverage Targets |
| 174 | +coverage: coverage-clean |
| 175 | + @echo "Running code coverage analysis..." |
| 176 | + @./coverage.sh |
| 177 | + |
| 178 | +coverage-report: |
| 179 | + @if [ -f coverage_html/index.html ]; then \ |
| 180 | + echo "Opening coverage report..."; \ |
| 181 | + xdg-open coverage_html/index.html 2>/dev/null || open coverage_html/index.html 2>/dev/null || echo "Please open coverage_html/index.html in your browser"; \ |
| 182 | + else \ |
| 183 | + echo "Coverage report not found. Run 'make coverage' first."; \ |
| 184 | + exit 1; \ |
| 185 | + fi |
| 186 | + |
| 187 | +coverage-clean: |
| 188 | + @echo "Cleaning coverage data..." |
| 189 | + @find . -name "*.gcda" -delete 2>/dev/null || true |
| 190 | + @find . -name "*.gcno" -delete 2>/dev/null || true |
| 191 | + @rm -f coverage.info coverage_filtered.info 2>/dev/null || true |
| 192 | + @rm -rf coverage_html 2>/dev/null || true |
| 193 | + @echo "Coverage data cleaned." |
0 commit comments