]> git.ipfire.org Git - thirdparty/FORT-validator.git/commitdiff
Leave unit tests out of the build by default
authorAlberto Leiva Popper <ydahhrk@gmail.com>
Thu, 14 Mar 2019 16:44:08 +0000 (10:44 -0600)
committerAlberto Leiva Popper <ydahhrk@gmail.com>
Thu, 14 Mar 2019 18:09:14 +0000 (12:09 -0600)
For two reasons:

- They need the Check framework, which should not be a dependency
  for everyone.
- Check itself is the only dependency managed by pkg-config, so we
  don't want to force everyone to install that either.

No idea if any of this is good practice. But it's much easier to
explain in the documentation, so there you go.

.gitignore
Makefile.am
README.md
configure.ac
src/main.c
test/README.md [new file with mode: 0644]
test/impersonator.c

index 6b2a00f6edd7c41552ab949195c698f9f73e7666..cf21d8aa9789def5521a46a3fa030c99c7272299 100644 (file)
@@ -92,7 +92,7 @@ test-driver
 
 # Temporal files
 *~
-tmp/
+tmp
 
 # Unwanted manure shat by imbecile OSs
 .DS_Store*
index ef5e8ee58cfcd48b10edd2d374a365532c81a947..7652996cf73aa5fe396b2061a4e03bb336f6861d 100644 (file)
@@ -1,3 +1,4 @@
 AUTOMAKE_OPTIONS = foreign
 
-SUBDIRS = src test
+SUBDIRS = src $(MAYBE_TESTS)
+DIST_SUBDIRS = src
index ac42ff30b3ffaeeb49a9c42385cdf0ed832a375a..d0a5081217e04879b4e4fcf5f826d7b602e26d70 100644 (file)
--- a/README.md
+++ b/README.md
@@ -24,26 +24,27 @@ make install
 
 Further information can be found in the subsections below.
 
-| RFC                              | Implemented |
-|----------------------------------|-------------|
-| 3779 (IP & AS Extensions)        | 100%        |
-| 6350 (VCARD)                     | 0%          |
-| 6482 (ROA)                       | 100%        |
-| 6486 (Manifests)                 | 75%         |
-| 6488 (Signed Objects)            | 90%         |
-| 6487, 7318 (Certificates & CRLs) | 100%        |
-| 6493 (Ghostbusters)              | 100%        |
-| 7730 (TALs)                      | 100%        |
-| 7935 (RPKI algorithms)           | 100%        |
-| 8182 (RRDP)                      | 0%          |
-| 8209 (BGPSec Certificates)       | 0%          |
-| 8360 (Validation Reconsidered)   | 100%        |
-
-### RFC 6350 (VCARD)
-
-The VCARD format is only used by Ghostbusters records. 6350 defines the basic VCARD format, while 6493 defines additional requirements for Ghostbusters-specific VCARDs.
-
-The specific requirements have been implemented, while the basic ones have not.
+| RFC                                                                        | Implemented |
+|----------------------------------------------------------------------------|-------------|
+| [3779](https://tools.ietf.org/html/rfc3779) (IP & AS Extensions)           | 100%        |
+| [6350](https://tools.ietf.org/html/rfc6350) (vCard)                        | 0%          |
+| [6482](https://tools.ietf.org/html/rfc6482) (ROA)                          | 100%        |
+| [6486](https://tools.ietf.org/html/rfc6486) (Manifests)                    | 75%         |
+| [6487](https://tools.ietf.org/html/rfc6487) (Resource Certificates & CRLs) | 100%        |
+| [6488](https://tools.ietf.org/html/rfc6488) (Signed Objects)               | 90%         |
+| [6493](https://tools.ietf.org/html/rfc6493) (Ghostbusters)                 | 100%        |
+| [7318](https://tools.ietf.org/html/rfc7318) (Policy Qualifiers)            | 100%        |
+| [7730](https://tools.ietf.org/html/rfc7730) (TALs)                         | 100%        |
+| [7935](https://tools.ietf.org/html/rfc7935) (RPKI algorithms)              | 100%        |
+| [8182](https://tools.ietf.org/html/rfc8182) (RRDP)                         | 0%          |
+| [8209](https://tools.ietf.org/html/rfc8209) (BGPSec Certificates)          | 0%          |
+| [8360](https://tools.ietf.org/html/rfc8360) (Validation Reconsidered)      | 100%        |
+
+### RFC 6350 (vCard)
+
+The vCard format is only used by Ghostbusters records. 6350 defines the basic vCard format, while 6493 defines additional requirements for Ghostbusters-specific vCard.
+
+The specific validations have been implemented, while the basic ones have not.
 
 ### RFC 6486 (Manifests)
 
index 1a2ee4874487039ea7538f57de95e0f5860c04fd..c959e6aebd7857400cee41b70b46aad1cbef5b6f 100644 (file)
@@ -32,18 +32,49 @@ AC_SEARCH_LIBS([ber_decode], [cmscodec], [],
 AC_SEARCH_LIBS([d2i_X509_bio], [crypto], [],
        [AC_MSG_ERROR([unable to find the d2i_X509_bio() function])]
 )
-
 AC_SEARCH_LIBS([toml_parse], [toml], [],
        [AC_MSG_ERROR([unable to find the toml_parse() function])]
 )
-
 AC_SEARCH_LIBS([backtrace],[execinfo],[],
        [AC_MSG_ERROR([unable to find backtrace() function])]
 )
 
+# Dependencies managed by pkg-config
+
+# 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 pkg-config and check)]
+       )
+)
 
-# Check dependencies.
-PKG_CHECK_MODULES([CHECK], [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."
+#
+# https://autotools.io/pkgconfig/pkg_check_modules.html#pkgconfig.pkg_check_modules.optional
+# Note: Since Check is the only current user of pkg-config, I don't want to
+# force pkg-config as a dependency; it should only be needed by people who want
+# to unit test. That's why I chose to use an `if` (which skips the
+# `PKG_CHECK_MODULES` on false) instead of an `AS_IF` (which evaluates all paths
+# apparently). In other words, if you ever want to add another pkg-config
+# dependency, you will need the `AS_IF` version.
+if test "x$with_unit_tests" = "xyes"; then
+       PKG_CHECK_MODULES([CHECK], [check])
+       MAYBE_TESTS=test
+else
+       MAYBE_TESTS=
+fi
+AC_SUBST([MAYBE_TESTS])
 
 # Spit out the makefiles.
 AC_OUTPUT(Makefile src/Makefile test/Makefile)
index 5d28fe4be3a684399386e8f88468ce717b3c1c03..ea6ba4d907098ad74bf0ddad610b136665f8dd23 100644 (file)
@@ -40,8 +40,10 @@ handle_tal_uri(struct tal *tal, struct rpki_uri const *uri)
        int error;
 
        error = download_files(uri);
-       if (error)
-               return pr_warn("TAL URI '%s' could not be RSYNC'd.");
+       if (error) {
+               return pr_warn("TAL URI '%s' could not be RSYNC'd.",
+                   uri->global);
+       }
 
        error = validation_prepare(&state, tal);
        if (error)
diff --git a/test/README.md b/test/README.md
new file mode 100644 (file)
index 0000000..95f1c4b
--- /dev/null
@@ -0,0 +1,9 @@
+# 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
+
+       make check
index c4c81d62ef54851d9b7a7d15541308c173b4d617..d7c7c1d65d05ec9fe7f202ff77de14b69c6c8e92 100644 (file)
@@ -51,6 +51,11 @@ config_get_color_output(void)
        return false;
 }
 
+enum filename_format
+config_get_filename_format(void)
+{
+       return FNF_NAME;
+}
 
 char *
 config_get_rsync_program(void)