From: Alberto Leiva Popper Date: Thu, 6 Jun 2019 15:45:12 +0000 (-0500) Subject: Patch build bugs found while Debian-packaging X-Git-Tag: v0.0.2~10 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=78ea915c1c39a1a2f4b5500193b5e5854b4789df;p=thirdparty%2FFORT-validator.git Patch build bugs found while Debian-packaging The most important ones were - Patch `make distclean`. test/'s distclean was attempting to clean stuff that src/'s distclean had already removed, so it was aborting. Fixed by moving needed .c's from test/Makefile.am to each test .c file. This prevents the unit tests from polluting src/. - Simplify inclusion of unit tests during configure. Rather than purposedly include them with --with-unit-tests, they are now automatically included if Check is installed. This also removes a lot of clutter from configure.ac. --- diff --git a/COPYING b/COPYING index 972886b1..f59aa494 100644 --- a/COPYING +++ b/COPYING @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2018 NIC Mexico +Copyright (c) 2019 NIC Mexico Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/Makefile.am b/Makefile.am index aece299a..f2b73326 100644 --- a/Makefile.am +++ b/Makefile.am @@ -11,5 +11,4 @@ # Man, GNU conventions need a 21 century overhaul badly. AUTOMAKE_OPTIONS = foreign -SUBDIRS = src man $(MAYBE_TESTS) -DIST_SUBDIRS = src man +SUBDIRS = src man test diff --git a/autogen.sh b/autogen.sh index c06a9249..50e8fba8 100755 --- a/autogen.sh +++ b/autogen.sh @@ -4,4 +4,4 @@ # Run this file to generate the configure script. # You'll need Autoconf and Automake installed! -autoreconf --install +autoreconf --install --force diff --git a/configure.ac b/configure.ac index 1846be3a..f3263aa7 100644 --- a/configure.ac +++ b/configure.ac @@ -35,35 +35,14 @@ AC_SEARCH_LIBS([backtrace],[execinfo],[], ) # Dependencies managed by pkg-config - -PKG_CHECK_MODULES([JANSSON], [jansson]) - # By the way: Apparently PKG_CHECK_MODULES is poor practice now. I can't tell; # it's always the same guy complaining about it in Stack Overflow. # (Main one: https://stackoverflow.com/questions/10220946) # But I couldn't make check work with AC_SEARCH_LIBS, and (probably due to # typical obscure bullshit autotools reasoning) I have no idea why. - -AC_ARG_WITH( - [unit-tests], - AS_HELP_STRING( - [--with-unit-tests], - [Generate unit tests. (Requires check)] - ) -) - -# https://www.gnu.org/software/automake/manual/html_node/Conditional-Subdirectories.html -# "Subdirectories with AM_CONDITIONAL" never worked for me. The problem might -# be that it puts `MAYBE_TESTS` in `.PRECIOUS`, which maybe is a bug in the -# autotools. (I honestly can't tell. They are so incredibly poorly designed.) -# The code below is implemented as "Subdirectories with AC_SUBST." -if test "x$with_unit_tests" = "xyes"; then - PKG_CHECK_MODULES([CHECK], [check]) - MAYBE_TESTS=test -else - MAYBE_TESTS= -fi -AC_SUBST([MAYBE_TESTS]) +PKG_CHECK_MODULES([JANSSON], [jansson]) +PKG_CHECK_MODULES([CHECK], [check], [usetests=yes], [usetests=no]) +AM_CONDITIONAL([USE_TESTS], [test "x$usetests" = "xyes"]) # Spit out the makefiles. AC_OUTPUT(Makefile src/Makefile man/Makefile test/Makefile) diff --git a/docs/doc/installation.md b/docs/doc/installation.md index b79ad0fc..176a9ca5 100644 --- a/docs/doc/installation.md +++ b/docs/doc/installation.md @@ -14,6 +14,18 @@ title: Compilation and Installation 2. [Debian-based distributions](#debian-based-distributions) 3. [OpenBSD](#openbsd) +## Introduction + +Currently, you have three options: + +- The Debian package: Easiest; for Debian-based distributions only. +- The generic autotools-based "upstream" tarball: For most (if not all) other users. +- Compiling on the git repository: Best for developers. + +## Debian package + + + ## Dependencies > Note: I'm only including this section in case you intend to install Fort in an unlisted OS (and therefore need a little research). For Debians and OpenBSD, just follow the steps in the sections below. diff --git a/man/Makefile.am b/man/Makefile.am index 5a0007c2..92e15241 100644 --- a/man/Makefile.am +++ b/man/Makefile.am @@ -1 +1 @@ -man_MANS = rtr_server.8 +dist_man_MANS = fort.8 diff --git a/man/rpki-validator.8 b/man/fort.8 similarity index 100% rename from man/rpki-validator.8 rename to man/fort.8 diff --git a/src/Makefile.am b/src/Makefile.am index e10c71dd..0dd25f35 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -88,6 +88,7 @@ fort_SOURCES += rtr/rtr.c rtr/rtr.h fort_SOURCES += rtr/db/delta.c rtr/db/delta.h fort_SOURCES += rtr/db/roa_table.c rtr/db/roa_table.h fort_SOURCES += rtr/db/roa.c rtr/db/roa.h +fort_SOURCES += rtr/db/vrp.h fort_SOURCES += rtr/db/vrps.c rtr/db/vrps.h fort_SOURCES += slurm/slurm_db.c slurm/slurm_db.h diff --git a/src/log.h b/src/log.h index 2c981241..146179da 100644 --- a/src/log.h +++ b/src/log.h @@ -5,14 +5,14 @@ #include "incidence/incidence.h" /* - * __dead is supposed to be defined in sys/cdefs.h, but is apparently not - * portable. + * According to BSD style, __dead is supposed to be defined in sys/cdefs.h, + * but it doesn't exist in Linux. */ #ifndef __dead #if __GNUC__ #define __dead __attribute__((noreturn)) #else -#define __dead +#define __dead /* Nothing */ #endif #endif diff --git a/test/Makefile.am b/test/Makefile.am index 83e45d6e..9cff02c8 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -1,5 +1,6 @@ +if USE_TESTS + # Reminder: `make check` -# Your `./configure` needs to have included the `--with-unit-tests` flag. # If you want to only run one test, do `make check TESTS=`. # Example: `make check TESTS=address` @@ -17,17 +18,6 @@ AM_CFLAGS = -pedantic -Wall -std=gnu11 -I../src -DUNIT_TESTING ${CHECK_CFLAGS} # "my" own "ldadd". Unlike AM_CFLAGS, it needs to be manually added to every # target. MY_LDADD = ${CHECK_LIBS} -BASIC_MODULES = ../src/log.c ../src/log.h -BASIC_MODULES += impersonator.c - -SLURM_SOURCES = ../src/address.c ../src/address.h -SLURM_SOURCES += ../src/json_parser.c ../src/json_parser.h -SLURM_SOURCES += ../src/crypto/base64.c ../src/crypto/base64.h -SLURM_SOURCES += ../src/slurm/slurm_db.c ../src/slurm/slurm_db.h -SLURM_SOURCES += ../src/slurm/slurm_loader.c -SLURM_SOURCES += ../src/slurm/slurm_loader.h -SLURM_SOURCES += ../src/slurm/slurm_parser.c -SLURM_SOURCES += ../src/slurm/slurm_parser.h check_PROGRAMS = address.test check_PROGRAMS += clients.test @@ -42,74 +32,38 @@ check_PROGRAMS += vrps.test #check_PROGRAMS += rtr/primitive_reader.test TESTS = ${check_PROGRAMS} -address_test_SOURCES = ${BASIC_MODULES} -address_test_SOURCES += ../src/address.h -address_test_SOURCES += address_test.c +address_test_SOURCES = address_test.c address_test_LDADD = ${MY_LDADD} -clients_test_SOURCES = ${BASIC_MODULES} -clients_test_SOURCES += ../src/clients.c -clients_test_SOURCES += ../src/common.c -clients_test_SOURCES += client_test.c +clients_test_SOURCES = client_test.c clients_test_LDADD = ${MY_LDADD} -line_file_test_SOURCES = ${BASIC_MODULES} -line_file_test_SOURCES += ../src/file.c ../src/file.h -line_file_test_SOURCES += ../src/line_file.c ../src/line_file.h -line_file_test_SOURCES += line_file_test.c +line_file_test_SOURCES = line_file_test.c line_file_test_LDADD = ${MY_LDADD} -pdu_handler_test_SOURCES = ${BASIC_MODULES} -pdu_handler_test_SOURCES += ${SLURM_SOURCES} -pdu_handler_test_SOURCES += ../src/common.c -pdu_handler_test_SOURCES += ../src/file.c -pdu_handler_test_SOURCES += ../src/output_printer.c -pdu_handler_test_SOURCES += ../src/rtr/pdu_handler.c -pdu_handler_test_SOURCES += ../src/rtr/err_pdu.c -pdu_handler_test_SOURCES += ../src/rtr/db/delta.c -pdu_handler_test_SOURCES += ../src/rtr/db/roa_table.c -pdu_handler_test_SOURCES += ../src/rtr/db/vrps.c -pdu_handler_test_SOURCES += rtr/db/impersonator.c -pdu_handler_test_SOURCES += rtr/pdu_handler_test.c +pdu_handler_test_SOURCES = rtr/pdu_handler_test.c pdu_handler_test_LDADD = ${MY_LDADD} ${JANSSON_LIBS} -roa_table_test_SOURCES = ${BASIC_MODULES} -roa_table_test_SOURCES += ../src/address.c -roa_table_test_SOURCES += ../src/rtr/db/delta.c -roa_table_test_SOURCES += ../src/rtr/db/roa_table.c -roa_table_test_SOURCES += rtr/db/roa_table_test.c +roa_table_test_SOURCES = rtr/db/roa_table_test.c roa_table_test_LDADD = ${MY_LDADD} -rsync_test_SOURCES = ${BASIC_MODULES} -rsync_test_SOURCES += ../src/str.c ../src/str.h -rsync_test_SOURCES += ../src/uri.c ../src/uri.h -rsync_test_SOURCES += rsync_test.c +rsync_test_SOURCES = rsync_test.c rsync_test_LDADD = ${MY_LDADD} #tal_test_SOURCES = ${BASIC_MODULES} -#tal_test_SOURCES += ../src/file.c ../src/file.h -#tal_test_SOURCES += ../src/crypto/base64.c ../src/crypto/base64.h -#tal_test_SOURCES += ../src/random.c ../src/random.h -#tal_test_SOURCES += ../src/str.c ../src/str.h -#tal_test_SOURCES += ../src/uri.c ../src/uri.h -#tal_test_SOURCES += ../src/line_file.c ../src/line_file.h +#tal_test_SOURCES += ../src/file.c +#tal_test_SOURCES += ../src/crypto/base64.c +#tal_test_SOURCES += ../src/random.c +#tal_test_SOURCES += ../src/str.c +#tal_test_SOURCES += ../src/uri.c +#tal_test_SOURCES += ../src/line_file.c #tal_test_SOURCES += tal_test.c #tal_test_LDADD = ${MY_LDADD} -vcard_test_SOURCES = ${BASIC_MODULES} -vcard_test_SOURCES += vcard_test.c +vcard_test_SOURCES = vcard_test.c vcard_test_LDADD = ${MY_LDADD} -vrps_test_SOURCES = ${BASIC_MODULES} -vrps_test_SOURCES += ${SLURM_SOURCES} -vrps_test_SOURCES += ../src/common.c -vrps_test_SOURCES += ../src/file.c -vrps_test_SOURCES += ../src/output_printer.c -vrps_test_SOURCES += ../src/rtr/db/delta.c -vrps_test_SOURCES += ../src/rtr/db/roa_table.c -vrps_test_SOURCES += ../src/rtr/db/vrps.c -vrps_test_SOURCES += rtr/db/impersonator.c -vrps_test_SOURCES += rtr/db/vrps_test.c +vrps_test_SOURCES = rtr/db/vrps_test.c vrps_test_LDADD = ${MY_LDADD} ${JANSSON_LIBS} #rtr_pdu_test_SOURCES = ${BASIC_MODULES} @@ -123,3 +77,11 @@ vrps_test_LDADD = ${MY_LDADD} ${JANSSON_LIBS} #rtr_primitive_reader_test_SOURCES += rtr/primitive_reader_test.c #rtr_primitive_reader_test_SOURCES += rtr/stream.c #rtr_primitive_reader_test_LDADD = ${MY_LDADD} + +EXTRA_DIST = impersonator.c +EXTRA_DIST += rtr/db/rtr_db_impersonator.c +EXTRA_DIST += line_file/core.txt +EXTRA_DIST += line_file/empty.txt +EXTRA_DIST += line_file/error.txt + +endif diff --git a/test/README.md b/test/README.md index 95f1c4b5..34dcbc6f 100644 --- a/test/README.md +++ b/test/README.md @@ -1,9 +1,5 @@ # Unit Tests -This code is left out of the build by default. If you want to run the tests, configure like this (in the parent directory): - - ./configure --with-unit-tests - -Then, to actually run the tests, use +Run with make check diff --git a/test/address_test.c b/test/address_test.c index c31e8d7c..780ab15b 100644 --- a/test/address_test.c +++ b/test/address_test.c @@ -1,9 +1,11 @@ -#include "address.c" - #include #include #include +#include "address.c" +#include "log.c" +#include "impersonator.c" + static void test_range4(uint32_t min, uint32_t max, bool valid) { diff --git a/test/client_test.c b/test/client_test.c index 7acaa4ea..4bcdd56c 100644 --- a/test/client_test.c +++ b/test/client_test.c @@ -1,8 +1,11 @@ -#include "clients.h" - #include #include +#include "clients.c" +#include "common.c" +#include "log.c" +#include "impersonator.c" + static int handle_foreach(struct client const *client, void *arg) { diff --git a/test/impersonator.c b/test/impersonator.c index bbe6a5e6..af5ceec2 100644 --- a/test/impersonator.c +++ b/test/impersonator.c @@ -11,25 +11,25 @@ static char addr_buffer1[INET6_ADDRSTRLEN]; static char addr_buffer2[INET6_ADDRSTRLEN]; char const * -v4addr2str(struct in_addr *addr) +v4addr2str(struct in_addr const *addr) { return inet_ntop(AF_INET, addr, addr_buffer1, sizeof(addr_buffer1)); } char const * -v4addr2str2(struct in_addr *addr) +v4addr2str2(struct in_addr const *addr) { return inet_ntop(AF_INET, addr, addr_buffer2, sizeof(addr_buffer2)); } char const * -v6addr2str(struct in6_addr *addr) +v6addr2str(struct in6_addr const *addr) { return inet_ntop(AF_INET6, addr, addr_buffer1, sizeof(addr_buffer1)); } char const * -v6addr2str2(struct in6_addr *addr) +v6addr2str2(struct in6_addr const *addr) { return inet_ntop(AF_INET6, addr, addr_buffer2, sizeof(addr_buffer2)); } diff --git a/test/line_file_test.c b/test/line_file_test.c index 51290de2..4a37b614 100644 --- a/test/line_file_test.c +++ b/test/line_file_test.c @@ -1,9 +1,12 @@ -#include "line_file.h" - #include #include #include +#include "file.c" +#include "impersonator.c" +#include "line_file.c" +#include "log.c" + START_TEST(file_line_normal) { struct line_file *lfile; diff --git a/test/rsync_test.c b/test/rsync_test.c index aaa8aa4a..18ba7c41 100644 --- a/test/rsync_test.c +++ b/test/rsync_test.c @@ -1,10 +1,12 @@ -#include "rsync/rsync.c" - #include #include #include -#include "common.h" +#include "log.c" +#include "impersonator.c" +#include "str.c" +#include "uri.c" +#include "rsync/rsync.c" START_TEST(rsync_load_normal) { diff --git a/test/rtr/db/roa_table_test.c b/test/rtr/db/roa_table_test.c index 5b3901fa..f3d4dc9b 100644 --- a/test/rtr/db/roa_table_test.c +++ b/test/rtr/db/roa_table_test.c @@ -1,7 +1,11 @@ #include #include -#include "thread_var.h" -#include "rtr/db/roa_table.h" + +#include "address.c" +#include "log.c" +#include "impersonator.c" +#include "rtr/db/delta.c" +#include "rtr/db/roa_table.c" #define ADDR1 htonl(0xC0000201) /* 192.0.2.1 */ #define ADDR2 htonl(0xC0000202) /* 192.0.2.2 */ diff --git a/test/rtr/db/impersonator.c b/test/rtr/db/rtr_db_impersonator.c similarity index 99% rename from test/rtr/db/impersonator.c rename to test/rtr/db/rtr_db_impersonator.c index 4f0a7b26..61901702 100644 --- a/test/rtr/db/impersonator.c +++ b/test/rtr/db/rtr_db_impersonator.c @@ -1,6 +1,5 @@ -#include "object/tal.h" - #include +#include "object/tal.h" static int iteration = 0; diff --git a/test/rtr/db/vrps_test.c b/test/rtr/db/vrps_test.c index 6ad42b39..eb3de6eb 100644 --- a/test/rtr/db/vrps_test.c +++ b/test/rtr/db/vrps_test.c @@ -2,10 +2,21 @@ #include #include -#include "common.h" -#include "thread_var.h" -#include "validation_handler.h" -#include "rtr/db/vrps.h" +#include "address.c" +#include "crypto/base64.c" +#include "common.c" +#include "file.c" +#include "impersonator.c" +#include "json_parser.c" +#include "log.c" +#include "output_printer.c" +#include "rtr/db/delta.c" +#include "rtr/db/roa_table.c" +#include "rtr/db/rtr_db_impersonator.c" +#include "rtr/db/vrps.c" +#include "slurm/slurm_db.c" +#include "slurm/slurm_loader.c" +#include "slurm/slurm_parser.c" /* -- Expected database descriptors -- */ @@ -54,7 +65,7 @@ static const bool deltas_3to3_clean[] = { 0, 0, 0, 0, 0, 0, 0, 0, }; serial_t current_min_serial = 0; -serial_t +int clients_get_min_serial(serial_t *result) { *result = current_min_serial; diff --git a/test/rtr/pdu_handler_test.c b/test/rtr/pdu_handler_test.c index 0652e237..39a1459c 100644 --- a/test/rtr/pdu_handler_test.c +++ b/test/rtr/pdu_handler_test.c @@ -2,11 +2,23 @@ #include #include -#include "validation_handler.h" -#include "rtr/pdu.h" -#include "rtr/pdu_handler.h" -#include "rtr/pdu_sender.h" -#include "rtr/db/vrps.h" +#include "address.c" +#include "common.c" +#include "file.c" +#include "impersonator.c" +#include "json_parser.c" +#include "log.c" +#include "output_printer.c" +#include "crypto/base64.c" +#include "rtr/pdu_handler.c" +#include "rtr/err_pdu.c" +#include "rtr/db/delta.c" +#include "rtr/db/roa_table.c" +#include "rtr/db/rtr_db_impersonator.c" +#include "rtr/db/vrps.c" +#include "slurm/slurm_db.c" +#include "slurm/slurm_loader.c" +#include "slurm/slurm_parser.c" /* Helper functions */ @@ -89,7 +101,7 @@ init_serial_query(struct rtr_request *request, struct serial_query_pdu *query, /* Impersonator functions */ -serial_t +int clients_get_min_serial(serial_t *result) { *result = 0; diff --git a/test/vcard_test.c b/test/vcard_test.c index 6747d666..fe5eb0d3 100644 --- a/test/vcard_test.c +++ b/test/vcard_test.c @@ -1,7 +1,9 @@ -#include "object/vcard.c" - #include +#include "log.c" +#include "impersonator.c" +#include "object/vcard.c" + #define VC_BEGIN "BEGIN:VCARD\r\n" #define VC_VERSION "VERSION:4.0\r\n" #define VC_FN "FN:name\r\n"