curl_config.h.in
libcurl.vers
libcurl_unity.c
+unitprotos.h
# There is plenty of parallelism when building the testdeps target.
# Override the curlu batch size with the maximum to optimize performance.
set_target_properties(curlu PROPERTIES UNITY_BUILD_BATCH_SIZE 0 C_CLANG_TIDY "")
+
+ add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/unitprotos.h"
+ WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
+ COMMAND ${PERL_EXECUTABLE} "${PROJECT_SOURCE_DIR}/scripts/extract-unit-protos"
+ ${CSOURCES} > "${CMAKE_CURRENT_BINARY_DIR}/unitprotos.h"
+ DEPENDS "${PROJECT_SOURCE_DIR}/scripts/extract-unit-protos" ${CSOURCES}
+ VERBATIM)
+ add_custom_target(curlu-unitprotos ALL DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/unitprotos.h")
endif()
## Library definition
if BUILD_UNITTESTS
noinst_LTLIBRARIES = libcurlu.la
+
+# generate a file with "private" prototypes for unit testing
+UNITPROTOS = unitprotos.h
+
else
noinst_LTLIBRARIES =
endif
else
libcurl_la_SOURCES = $(CSOURCES) $(HHEADERS)
libcurlu_la_SOURCES = $(CSOURCES) $(HHEADERS)
+CLEANFILES =
endif
+CLEANFILES += $(UNITPROTOS)
+
libcurl_la_CPPFLAGS_EXTRA =
libcurl_la_LDFLAGS_EXTRA =
libcurl_la_CFLAGS_EXTRA =
if NOT_CURL_CI
if DEBUGBUILD
# for debug builds, we scan the sources on all regular make invokes
-all-local: checksrc
+CHECKSOURCES = checksrc
endif
endif
+all-local: $(CHECKSOURCES) $(UNITPROTOS)
+
+UNIT_V = $(UNITV_$(V))
+UNITV_0 = @echo " UNITPR " $@;
+UNITV_1 =
+UNITV_ = $(UNITV_0)
+
+# UNITPROTOS depends on every C file in the lib/ dir
+$(UNITPROTOS): $(CSOURCES)
+ $(UNIT_V)(cd $(srcdir) && @PERL@ ../scripts/extract-unit-protos $(CSOURCES) > $(top_builddir)/lib/$(UNITPROTOS))
+
# disable the tests that are mostly causing false positives
TIDYFLAGS := -checks=-clang-analyzer-security.insecureAPI.bzero,-clang-analyzer-security.insecureAPI.strcpy,-clang-analyzer-optin.performance.Padding,-clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling -quiet
if CURL_WERROR
EXTRA_DIST = coverage.sh completion.pl firefox-db2pem.sh checksrc.pl checksrc-all.sh \
mk-ca-bundle.pl mk-unity.pl schemetable.c cd2nroff nroff2cd cdall cd2cd managen \
dmaketgz maketgz release-tools.sh verify-release cmakelint.sh mdlinkcheck \
- CMakeLists.txt pythonlint.sh randdisable wcurl top-complexity
+ CMakeLists.txt pythonlint.sh randdisable wcurl top-complexity extract-unit-protos
dist_bin_SCRIPTS = wcurl
--- /dev/null
+#!/usr/bin/env perl
+#***************************************************************************
+# _ _ ____ _
+# Project ___| | | | _ \| |
+# / __| | | | |_) | |
+# | (__| |_| | _ <| |___
+# \___|\___/|_| \_\_____|
+#
+# Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
+#
+# This software is licensed as described in the file COPYING, which
+# you should have received as part of this distribution. The terms
+# are also available at https://curl.se/docs/copyright.html.
+#
+# You may opt to use, copy, modify, merge, publish, distribute and/or sell
+# copies of the Software, and permit persons to whom the Software is
+# furnished to do so, under the terms of the COPYING file.
+#
+# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+# KIND, either express or implied.
+#
+# SPDX-License-Identifier: curl
+#
+###########################################################################
+
+sub scanfile {
+ my ($file) = @_;
+ open(F, "<$file") || die "$file failed";
+ while(<F>) {
+ if($_ =~ /^UNITTEST .*\);/) {
+ push @proto, $_;
+ $inc{$file} = 1;
+ }
+ }
+ close(F);
+}
+
+foreach my $f (@ARGV) {
+ scanfile($f);
+}
+
+print <<HEAD
+#ifndef UNITTESTPROTOS_H
+#define UNITTESTPROTOS_H
+/***************************************************************************
+ * _ _ ____ _
+ * Project ___| | | | _ \\| |
+ * / __| | | | |_) | |
+ * | (__| |_| | _ <| |___
+ * \\___|\\___/|_| \\_\\_____|
+ *
+ * Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
+ *
+ * This software is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution. The terms
+ * are also available at https://curl.se/docs/copyright.html.
+ *
+ * You may opt to use, copy, modify, merge, publish, distribute and/or sell
+ * copies of the Software, and permit persons to whom the Software is
+ * furnished to do so, under the terms of the COPYING file.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ * SPDX-License-Identifier: curl
+ *
+ * Generated-by: extract-unit-protos
+ *
+ ***************************************************************************/
+HEAD
+ ;
+
+for my $f (sort keys %inc) {
+ # convert to suitable header file
+ $f =~ s/\.c/.h/; # .h extension
+
+ if(-f $f) {
+ $f =~ s/.*\///; # cut the path off
+ print "#include \"$f\"\n";
+ }
+}
+
+for my $p (@proto) {
+ print $p;
+}
+
+print <<FOOT
+#endif /* UNITTESTPROTOS_H */
+FOOT
+ ;
VERBATIM)
add_executable(${BUNDLE} EXCLUDE_FROM_ALL "${BUNDLE}.c")
+add_dependencies(${BUNDLE} curlu-unitprotos)
add_dependencies(testdeps ${BUNDLE})
target_link_libraries(${BUNDLE} curlu)
target_include_directories(${BUNDLE} PRIVATE
- "${PROJECT_BINARY_DIR}/lib" # for "curl_config.h"
+ "${PROJECT_BINARY_DIR}/lib" # for "curl_config.h", "unitprotos.h"
"${PROJECT_SOURCE_DIR}/lib" # for "curl_setup.h", curlx
"${PROJECT_SOURCE_DIR}/tests/libtest" # for "first.h"
"${CMAKE_CURRENT_SOURCE_DIR}" # for the generated bundle source to find included test sources
#include "curlcheck.h"
#include "llist.h"
-
-UNITTEST void Curl_node_uremove(struct Curl_llist_node *, void *);
+#include "unitprotos.h"
static void test_Curl_llist_dtor(void *key, void *value)
{
*
***************************************************************************/
#include "curlcheck.h"
-
-/* copied from urlapi.c */
-extern int dedotdotify(const char *input, size_t clen, char **out);
-
#include "memdebug.h"
+#include "unitprotos.h"
static CURLcode test_unit1395(char *arg)
{
#include "urldata.h"
#include "uint-table.h"
#include "curl_trc.h"
-
-UNITTEST void Curl_uint_tbl_clear(struct uint_tbl *tbl);
+#include "unitprotos.h"
#define TBL_SIZE 100
#include "urldata.h"
#include "uint-spbset.h"
#include "curl_trc.h"
-
-UNITTEST void Curl_uint_spbset_clear(struct uint_spbset *bset);
+#include "unitprotos.h"
static void check_spbset(const char *name, const unsigned int *s, size_t slen)
{