From: Alberto Leiva Popper Date: Thu, 14 Mar 2019 16:44:08 +0000 (-0600) Subject: Leave unit tests out of the build by default X-Git-Tag: v0.0.2~69 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a55a93b556fd024c79c3606b0847695cd4f3d17f;p=thirdparty%2FFORT-validator.git Leave unit tests out of the build by default 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. --- diff --git a/.gitignore b/.gitignore index 6b2a00f6..cf21d8aa 100644 --- a/.gitignore +++ b/.gitignore @@ -92,7 +92,7 @@ test-driver # Temporal files *~ -tmp/ +tmp # Unwanted manure shat by imbecile OSs .DS_Store* diff --git a/Makefile.am b/Makefile.am index ef5e8ee5..7652996c 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,3 +1,4 @@ AUTOMAKE_OPTIONS = foreign -SUBDIRS = src test +SUBDIRS = src $(MAYBE_TESTS) +DIST_SUBDIRS = src diff --git a/README.md b/README.md index ac42ff30..d0a50812 100644 --- 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) diff --git a/configure.ac b/configure.ac index 1a2ee487..c959e6ae 100644 --- a/configure.ac +++ b/configure.ac @@ -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) diff --git a/src/main.c b/src/main.c index 5d28fe4b..ea6ba4d9 100644 --- a/src/main.c +++ b/src/main.c @@ -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 index 00000000..95f1c4b5 --- /dev/null +++ b/test/README.md @@ -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 diff --git a/test/impersonator.c b/test/impersonator.c index c4c81d62..d7c7c1d6 100644 --- a/test/impersonator.c +++ b/test/impersonator.c @@ -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)