#include <config.h>
#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
#include "gpg.h"
int expected_result; \
\
tests ++; \
- \
- printf ("%d. Checking %s...", \
- tests, (description) ?: ""); \
- fflush (stdout); \
- \
+ if (verbose) \
+ { \
+ printf ("%d. Checking %s...", \
+ tests, (description) ?: ""); \
+ fflush (stdout); \
+ } \
test_result = (test); \
expected_result = (expected); \
\
if (test_result == expected_result) \
{ \
- printf (" ok.\n"); \
+ if (verbose) printf (" ok.\n"); \
} \
else \
{ \
+ if (!verbose) \
+ printf ("%d. Checking %s...", \
+ tests, (description) ?: ""); \
printf (" failed.\n"); \
printf (" %s == %s failed.\n", \
STRINGIFY(test), \
{
if (tests_failed == 0)
{
- printf ("All %d tests passed.\n", tests);
+ if (verbose)
+ printf ("All %d tests passed.\n", tests);
exit (!!force);
}
else
}
}
+
+/* Prepend FNAME with the srcdir environment variable's value and
+ return a malloced filename. Caller must release the returned
+ string using test_free. */
+char *
+prepend_srcdir (const char *fname)
+{
+ static const char *srcdir;
+ char *result;
+
+ if (!srcdir && !(srcdir = getenv ("srcdir")))
+ srcdir = ".";
+
+ result = malloc (strlen (srcdir) + 1 + strlen (fname) + 1);
+ strcpy (result, srcdir);
+ strcat (result, "/");
+ strcat (result, fname);
+ return result;
+}
+
+
+void
+test_free (void *a)
+{
+ if (a)
+ free (a);
+}
+
+
int
main (int argc, char *argv[])
{