]> git.ipfire.org Git - thirdparty/FORT-validator.git/commitdiff
Patch build bugs found while Debian-packaging
authorAlberto Leiva Popper <ydahhrk@gmail.com>
Thu, 6 Jun 2019 15:45:12 +0000 (10:45 -0500)
committerAlberto Leiva Popper <ydahhrk@gmail.com>
Thu, 6 Jun 2019 15:46:34 +0000 (10:46 -0500)
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.

21 files changed:
COPYING
Makefile.am
autogen.sh
configure.ac
docs/doc/installation.md
man/Makefile.am
man/fort.8 [moved from man/rpki-validator.8 with 100% similarity]
src/Makefile.am
src/log.h
test/Makefile.am
test/README.md
test/address_test.c
test/client_test.c
test/impersonator.c
test/line_file_test.c
test/rsync_test.c
test/rtr/db/roa_table_test.c
test/rtr/db/rtr_db_impersonator.c [moved from test/rtr/db/impersonator.c with 99% similarity]
test/rtr/db/vrps_test.c
test/rtr/pdu_handler_test.c
test/vcard_test.c

diff --git a/COPYING b/COPYING
index 972886b1baa0f5c710696ff310569f16c0343d32..f59aa49405cd327d3ba402ae74afc91a1e38d2d5 100644 (file)
--- 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
index aece299a1e6c3ef9ed0e9ec1755bc27dfaeb6adf..f2b73326b656ffd2814c19c2c784bff6bbd885bf 100644 (file)
@@ -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
index c06a92499a896d5cc4c374079f1772579854171f..50e8fba83c7f072e129ce14a9eb4c32c6b669b2e 100755 (executable)
@@ -4,4 +4,4 @@
 # Run this file to generate the configure script.
 # You'll need Autoconf and Automake installed!
 
-autoreconf --install
+autoreconf --install --force
index 1846be3aa7e1f25620ae67a53255fd9944b09046..f3263aa766f94e0b06b6473b2855854c9f5e3f91 100644 (file)
@@ -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)
index b79ad0fcfce7da29b8102573b839de09fec8e63d..176a9ca54286bcee9898c511e9bc5d64f4ca215c 100644 (file)
@@ -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.
index 5a0007c2f9d198d1ac82ddee3f02559dfea5f731..92e1524199e0aba280b3fb5d70ee57c11dbfe9a9 100644 (file)
@@ -1 +1 @@
-man_MANS = rtr_server.8
+dist_man_MANS = fort.8
similarity index 100%
rename from man/rpki-validator.8
rename to man/fort.8
index e10c71dd2c5bbe247fd2647032ba7dcdebf5195d..0dd25f35aa4d585af4d812490cc22cf66207607c 100644 (file)
@@ -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
index 2c981241b5dc8ad36f8ed67a813dc13af9b3cd7a..146179da221073666fd44195167b360a629b9270 100644 (file)
--- 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
 
index 83e45d6e969eb015ae6b3979d74815a7e2e53590..9cff02c8caed05855038f9bc98ab99d8c2ed2271 100644 (file)
@@ -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=<test>`.
 # 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
index 95f1c4b5a1d7d4abcd49ae8e463050ed46b87487..34dcbc6fd786d56f77cfd5bd201e3883ddbf5a13 100644 (file)
@@ -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
index c31e8d7c0983a41823435f5e84730f0db9dc18c2..780ab15b6ea37bd8f51df42bcf167fd9776fe926 100644 (file)
@@ -1,9 +1,11 @@
-#include "address.c"
-
 #include <check.h>
 #include <errno.h>
 #include <stdlib.h>
 
+#include "address.c"
+#include "log.c"
+#include "impersonator.c"
+
 static void
 test_range4(uint32_t min, uint32_t max, bool valid)
 {
index 7acaa4ea52efbdd39cf24cdd606ab5ed5fce6b88..4bcdd56c9342016099e4eddec470b19a3cce3358 100644 (file)
@@ -1,8 +1,11 @@
-#include "clients.h"
-
 #include <check.h>
 #include <stdlib.h>
 
+#include "clients.c"
+#include "common.c"
+#include "log.c"
+#include "impersonator.c"
+
 static int
 handle_foreach(struct client const *client, void *arg)
 {
index bbe6a5e68c8870e44269f48555a9317a9507ccb9..af5ceec2e6fc6bcbb5e480b90341a876e024dd5c 100644 (file)
@@ -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));
 }
index 51290de2962269cb91d9c59f63a4f0f816826ea8..4a37b6148c264c55ea8059f4def99513b401ad11 100644 (file)
@@ -1,9 +1,12 @@
-#include "line_file.h"
-
 #include <check.h>
 #include <errno.h>
 #include <stdlib.h>
 
+#include "file.c"
+#include "impersonator.c"
+#include "line_file.c"
+#include "log.c"
+
 START_TEST(file_line_normal)
 {
        struct line_file *lfile;
index aaa8aa4aab4dcf44861e1d61fd2877a77cd5a345..18ba7c417af148268cea989856ee0c38a94cba77 100644 (file)
@@ -1,10 +1,12 @@
-#include "rsync/rsync.c"
-
 #include <check.h>
 #include <errno.h>
 #include <stdlib.h>
 
-#include "common.h"
+#include "log.c"
+#include "impersonator.c"
+#include "str.c"
+#include "uri.c"
+#include "rsync/rsync.c"
 
 START_TEST(rsync_load_normal)
 {
index 5b3901fa436c3295a793fc14e37af77faadf24ee..f3d4dc9b657d4bc1d9a44baa0507e783891e94c0 100644 (file)
@@ -1,7 +1,11 @@
 #include <check.h>
 #include <stdlib.h>
-#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 */
similarity index 99%
rename from test/rtr/db/impersonator.c
rename to test/rtr/db/rtr_db_impersonator.c
index 4f0a7b26aa917be74a02e6221f7b7c7052514797..61901702d5dde25089318e7068f43978b3791271 100644 (file)
@@ -1,6 +1,5 @@
-#include "object/tal.h"
-
 #include <check.h>
+#include "object/tal.h"
 
 static int iteration = 0;
 
index 6ad42b397c567ceee5f66892c23614a22473a3a6..eb3de6ebebd0009d6ecfe848dba866a427ee363a 100644 (file)
@@ -2,10 +2,21 @@
 #include <stdbool.h>
 #include <stdlib.h>
 
-#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;
index 0652e237af3802cb010311c16eddb7429bb1b629..39a1459c82d9990c720d4c2454d92d95cea922c5 100644 (file)
@@ -2,11 +2,23 @@
 #include <stdlib.h>
 #include <sys/queue.h>
 
-#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;
index 6747d666f00b45ce01e1a8b4b75d27b930f8df66..fe5eb0d3efd43a5ad2c4228e979fc2fa97cbda42 100644 (file)
@@ -1,7 +1,9 @@
-#include "object/vcard.c"
-
 #include <check.h>
 
+#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"