From owner-dev-commits-ports-all@freebsd.org Mon May 31 19:40:36 2021 Return-Path: Delivered-To: dev-commits-ports-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id CA52D64E21E; Mon, 31 May 2021 19:40:36 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Fv5HS5KfNz4nPd; Mon, 31 May 2021 19:40:36 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id A022F16305; Mon, 31 May 2021 19:40:36 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 14VJeaIi067552; Mon, 31 May 2021 19:40:36 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14VJeaj4067551; Mon, 31 May 2021 19:40:36 GMT (envelope-from git) Date: Mon, 31 May 2021 19:40:36 GMT Message-Id: <202105311940.14VJeaj4067551@gitrepo.freebsd.org> To: ports-committers@FreeBSD.org, dev-commits-ports-all@FreeBSD.org, dev-commits-ports-main@FreeBSD.org From: Alexey Dokuchaev Subject: git: a9a4a7c88c78 - main - net/arataga: hook the unit tests to our framework. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: danfe X-Git-Repository: ports X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: a9a4a7c88c78be530d58add7bff01a8be0c724bf Auto-Submitted: auto-generated X-BeenThere: dev-commits-ports-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the ports repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 31 May 2021 19:40:36 -0000 The branch main has been updated by danfe: URL: https://cgit.FreeBSD.org/ports/commit/?id=a9a4a7c88c78be530d58add7bff01a8be0c724bf commit a9a4a7c88c78be530d58add7bff01a8be0c724bf Author: Alexey Dokuchaev AuthorDate: 2021-05-31 19:26:56 +0000 Commit: Alexey Dokuchaev CommitDate: 2021-05-31 19:39:35 +0000 net/arataga: hook the unit tests to our framework. --- net/arataga/Makefile | 4 ++ net/arataga/files/makefile | 92 +++++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 91 insertions(+), 5 deletions(-) diff --git a/net/arataga/Makefile b/net/arataga/Makefile index 237ce2aa02c6..a70d00b2ba8b 100644 --- a/net/arataga/Makefile +++ b/net/arataga/Makefile @@ -21,12 +21,16 @@ BUILD_DEPENDS= ${LOCALBASE}/include/spdlog/spdlog.h:devel/spdlog \ LIB_DEPENDS= libso.${_SO5_LIBVER}.so:devel/sobjectizer \ libfmt.so:devel/libfmt \ libhttp_parser.so:www/http-parser +TEST_DEPENDS= ${LOCALBASE}/include/doctest/doctest.h:devel/doctest USES= compiler:c++17-lang gmake MAKEFILE= ${FILESDIR}/makefile MAKE_ENV= SO5_LIBVER=${_SO5_LIBVER} WRKSRC_SUBDIR= ${PORTNAME} +TEST_TARGET= run_unit_tests +TEST_WRKSRC= ${WRKSRC}/../tests + USE_GITHUB= yes GH_ACCOUNT= Stiffstream GH_PROJECT= noexcept-ctcheck:nectc restinio:rinio so5extra:so5e diff --git a/net/arataga/files/makefile b/net/arataga/files/makefile index 5a25314533f4..5ee132825d72 100644 --- a/net/arataga/files/makefile +++ b/net/arataga/files/makefile @@ -1,7 +1,9 @@ CXXFLAGS+= -std=c++17 -Wall -Wextra -CPPFLAGS+= -I. -I.. -I$(LOCALBASE)/include -DSPDLOG_FMT_EXTERNAL -LDFLAGS+= -pthread $(LOCALBASE)/lib/libso.$(SO5_LIBVER).so \ - -L$(LOCALBASE)/lib -lfmt -lhttp_parser +CPPFLAGS+= -I.$(if $(findstring run_unit_tests,$(MAKECMDGOALS)),./arataga) +CPPFLAGS+= -I.. -I$(LOCALBASE)/include -DSPDLOG_FMT_EXTERNAL +LDFLAGS+= -L$(LOCALBASE)/lib +LIBS= -lpthread $(LOCALBASE)/lib/libso.$(SO5_LIBVER).so \ + -lfmt -lhttp_parser oess_OBJS= oess_2/defs/err_code.o \ oess_2/defs/ex.o \ @@ -57,7 +59,8 @@ all_OBJS= $(oess_OBJS) $(stats_OBJS) config.o $(logging_OBJS) \ CCACHE?= $(shell command -v ccache) %.o: %.cpp - $(CCACHE) $(CXX) $(CXXFLAGS) $(CPPFLAGS) -o $@ -c $< +# XXX: $@ does not play well with VPATH :( + $(CCACHE) $(CXX) $(CXXFLAGS) $(CPPFLAGS) -o $(<:.cpp=.o) -c $< arataga: $(all_OBJS) $(CXX) $(LDFLAGS) -o $@ $^ $(LIBS) @@ -67,4 +70,83 @@ all: arataga install: arataga $(BSD_INSTALL_PROGRAM) $^ $(DESTDIR)$(PREFIX)/bin -.PHONY: all install +UNIT_TESTS= config_parser local_user_list_data dns_types \ + socks5_1 socks5_2 socks5_3 \ + http_1 http_2 http_3 http_4 http_5 + +# Tests live in (and built from) their own subdirectory, but use main +# project files as well, so use VPATH to help make(1) find them. +VPATH= ../arataga + +config_parser_test_OBJS=\ + config_parser/main.o \ + config.o +config_parser_test_LIBS= -lfmt + +local_user_list_data_test_OBJS=\ + local_user_list_data/main.o \ + user_list_auth_data.o +local_user_list_data_test_LIBS= -lfmt + +dns_types_test_OBJS=\ + dns_types/main.o \ + oess_2/defs/err_code.o \ + oess_2/defs/ex.o \ + oess_2/defs/quantity.o \ + oess_2/io/binbuffer.o \ + oess_2/io/bstring_buf.o \ + oess_2/io/fixed_mem_buf.o \ + oess_2/io/stream.o +dns_types_test_LIBS= -lfmt + +# These object files are common to (shared by) SOCKS and HTTP tests. +common_test_OBJS=\ + connection_handler_simulator/impl.o \ + $(connection_handlers_OBJS) $(logging_OBJS) + +socks5_1_test_OBJS= socks5/bind_pdu/main.o $(common_test_OBJS) +socks5_1_test_LIBS= $(LIBS) + +socks5_2_test_OBJS= socks5/command_pdu/main.o $(common_test_OBJS) +socks5_2_test_LIBS= $(LIBS) + +socks5_3_test_OBJS= socks5/illegal_first_pdu/main.o $(common_test_OBJS) +socks5_3_test_LIBS= $(LIBS) + +socks5_4_test_OBJS= socks5/username_password_auth/main.o $(common_test_OBJS) +socks5_4_test_LIBS= $(LIBS) + +http_1_test_OBJS= http/auth_params/main.o $(common_test_OBJS) +http_1_test_LIBS= $(LIBS) + +http_2_test_OBJS= http/chunked_encoding/main.o $(common_test_OBJS) +http_2_test_LIBS= $(LIBS) + +http_3_test_OBJS= http/connect_data_transfer/main.o $(common_test_OBJS) +http_3_test_LIBS= $(LIBS) + +http_4_test_OBJS= http/http_fields/main.o $(common_test_OBJS) +http_4_test_LIBS= $(LIBS) + +http_5_test_OBJS= http/illegal_responses/main.o $(common_test_OBJS) +http_5_test_LIBS= $(LIBS) + +define make_test +$(1)_test: $$($(1)_test_OBJS) +# XXX: again, if object file is missing, make(1) will build it, but +# $^ will contain incorrect path if prerequisite was found via VPATH. + $(CXX) $(LDFLAGS) -o $$@ $$(foreach o,$$^,$$(if $$(wildcard \ + $$o),$$o,$(VPATH)/$$o)) $$($(1)_test_LIBS) + +run_$(1)_test: $(1)_test +# At least one test (local_user_list_data) reads configuration files +# and expects to be run from the project's top directory. + cd .. && tests/$$< + +.PHONY: run_$(1)_test +run_unit_tests: run_$(1)_test +endef + +$(foreach t,$(UNIT_TESTS),$(eval $(call make_test,$(t)))) + +.PHONY: all install run_unit_tests