Make cttest work better with the portable test harness
authortb <tb@openbsd.org>
Fri, 14 Apr 2023 12:37:20 +0000 (12:37 +0000)
committertb <tb@openbsd.org>
Fri, 14 Apr 2023 12:37:20 +0000 (12:37 +0000)
regress/lib/libcrypto/ct/Makefile
regress/lib/libcrypto/ct/cttest.c

index 5cfdf74..a30fd1c 100644 (file)
@@ -1,4 +1,4 @@
-# $OpenBSD: Makefile,v 1.5 2023/04/14 11:18:40 tb Exp $
+# $OpenBSD: Makefile,v 1.6 2023/04/14 12:37:20 tb Exp $
 
 PROG=          cttest
 LDADD=         -lcrypto
@@ -7,8 +7,6 @@ DPADD=          ${LIBCRYPTO}
 WARNINGS=      Yes
 CFLAGS+=       -Wundef -Werror
 CFLAGS+=       -DLIBRESSL_CRYPTO_INTERNAL -DLIBRESSL_INTERNAL
-
-run-regress-cttest: cttest
-       ./cttest ${.CURDIR}/../../libcrypto/ct/
+CFLAGS+=       -DCTPATH=\"${.CURDIR}\"
 
 .include <bsd.regress.mk>
index 8986c93..a0c7556 100644 (file)
@@ -1,4 +1,4 @@
-/* $OpenBSD: cttest.c,v 1.5 2023/04/14 11:18:40 tb Exp $ */
+/* $OpenBSD: cttest.c,v 1.6 2023/04/14 12:37:20 tb Exp $ */
 /*
  * Copyright (c) 2021 Joel Sing <jsing@openbsd.org>
  *
 #include <openssl/pem.h>
 #include <openssl/x509v3.h>
 
+#ifndef CTPATH
+#define CTPATH "."
+#endif
+
 char *test_ctlog_conf_file;
 char *test_cert_file;
 char *test_issuer_file;
@@ -452,14 +456,15 @@ ct_sct_verify_test(void)
 int
 main(int argc, char **argv)
 {
-       const char *ctpath;
+       const char *ctpath = CTPATH;
        int failed = 0;
 
-        if (argc != 2) {
-               fprintf(stderr, "usage: %s ctpath\n", argv[0]);
+       if (argc > 2) {
+               fprintf(stderr, "usage %s [ctpath]\n", argv[0]);
                exit(1);
        }
-       ctpath = argv[1];
+       if (argc == 2)
+               ctpath = argv[1];
 
        if (asprintf(&test_cert_file, "%s/%s", ctpath,
            "libressl.org.crt") == -1)