diff options
-rw-r--r-- | etc/mtree/BSD.tests.dist | 2 | ||||
-rw-r--r-- | lib/libutil/Makefile | 4 | ||||
-rw-r--r-- | lib/libutil/tests/Makefile | 15 | ||||
-rw-r--r-- | lib/libutil/tests/flopen_test.c (renamed from tools/regression/lib/libutil/test-flopen.c) | 0 | ||||
-rw-r--r-- | lib/libutil/tests/grp_test.c (renamed from tools/regression/lib/libutil/test-grp.c) | 0 | ||||
-rw-r--r-- | lib/libutil/tests/humanize_number_test.c (renamed from tools/regression/lib/libutil/test-humanize_number.c) | 62 | ||||
-rw-r--r-- | lib/libutil/tests/pidfile_test.c (renamed from tools/regression/lib/libutil/test-pidfile.c) | 0 | ||||
-rw-r--r-- | lib/libutil/tests/trimdomain-nodomain_test.c (renamed from tools/regression/lib/libutil/test-trimdomain-nodomain.c) | 0 | ||||
-rw-r--r-- | lib/libutil/tests/trimdomain_test.c (renamed from tools/regression/lib/libutil/test-trimdomain.c) | 0 | ||||
-rw-r--r-- | tools/regression/lib/libutil/Makefile | 13 | ||||
-rw-r--r-- | tools/regression/lib/libutil/test-flopen.t | 12 | ||||
-rw-r--r-- | tools/regression/lib/libutil/test-grp.t | 12 | ||||
-rwxr-xr-x | tools/regression/lib/libutil/test-humanize_number.t | 10 | ||||
-rw-r--r-- | tools/regression/lib/libutil/test-trimdomain-nodomain.t | 10 | ||||
-rw-r--r-- | tools/regression/lib/libutil/test-trimdomain.t | 10 |
15 files changed, 55 insertions, 95 deletions
diff --git a/etc/mtree/BSD.tests.dist b/etc/mtree/BSD.tests.dist index 6ac8a5e..934304a 100644 --- a/etc/mtree/BSD.tests.dist +++ b/etc/mtree/BSD.tests.dist @@ -87,6 +87,8 @@ .. libmp .. + libutil + .. .. libexec atf diff --git a/lib/libutil/Makefile b/lib/libutil/Makefile index 582ccef..144fb5c 100644 --- a/lib/libutil/Makefile +++ b/lib/libutil/Makefile @@ -81,4 +81,8 @@ MLINKS+=pw_util.3 pw_copy.3 \ pw_util.3 pw_tempname.3 \ pw_util.3 pw_tmp.3 +.if ${MK_TESTS} != "no" +SUBDIR+= tests +.endif + .include <bsd.lib.mk> diff --git a/lib/libutil/tests/Makefile b/lib/libutil/tests/Makefile new file mode 100644 index 0000000..31b6c54 --- /dev/null +++ b/lib/libutil/tests/Makefile @@ -0,0 +1,15 @@ +# $FreeBSD$ + +TESTSDIR= ${TESTSBASE}/lib/libutil + +TAP_TESTS_C+= flopen_test +TAP_TESTS_C+= grp_test +TAP_TESTS_C+= humanize_number_test +TAP_TESTS_C+= pidfile_test +TAP_TESTS_C+= trimdomain_test +TAP_TESTS_C+= trimdomain-nodomain_test + +DPADD+= ${LIBUTIL} +LDADD+= -lutil + +.include <bsd.test.mk> diff --git a/tools/regression/lib/libutil/test-flopen.c b/lib/libutil/tests/flopen_test.c index 0471584..0471584 100644 --- a/tools/regression/lib/libutil/test-flopen.c +++ b/lib/libutil/tests/flopen_test.c diff --git a/tools/regression/lib/libutil/test-grp.c b/lib/libutil/tests/grp_test.c index ae7ce73..ae7ce73 100644 --- a/tools/regression/lib/libutil/test-grp.c +++ b/lib/libutil/tests/grp_test.c diff --git a/tools/regression/lib/libutil/test-humanize_number.c b/lib/libutil/tests/humanize_number_test.c index 24f197d..2d66204 100644 --- a/tools/regression/lib/libutil/test-humanize_number.c +++ b/lib/libutil/tests/humanize_number_test.c @@ -28,17 +28,15 @@ * */ -#include <sys/types.h> -#include <stdlib.h> +#include <sys/param.h> +#include <inttypes.h> #include <libutil.h> +#include <limits.h> +#include <math.h> #include <stdio.h> +#include <stdlib.h> #include <string.h> -#include <inttypes.h> -#include <math.h> #include <unistd.h> -#include <limits.h> - -extern char * optarg; #define MAX_STR_FLAGS_RESULT 80 #define MAX_INT_STR_DIGITS 12 @@ -490,7 +488,7 @@ static void testskipped(size_t i) { - printf("ok %lu # skip - not turned on\n", i); + printf("ok %zu # skip - not turned on\n", i); } int @@ -498,10 +496,8 @@ main(int argc, char * const argv[]) { char *buf; char *flag_str, *scale_str; - size_t i; - size_t errcnt, tested, skipped; + size_t buflen, errcnt, i, skipped, tested; int r; - size_t buflen; int includeNegScale; int includeExabyteTests; int verbose; @@ -522,8 +518,8 @@ main(int argc, char * const argv[]) if (buflen != 4) printf("Warning: buffer size %zu != 4, expect some results to differ.\n", buflen); - printf("1..%lu\n", sizeof test_args / sizeof *test_args); - for (i = 0; i < sizeof test_args / sizeof *test_args; i++) { + printf("1..%zu\n", nitems(test_args)); + for (i = 0; i < nitems(test_args); i++) { /* KLUDGE */ if (test_args[i].num == INT64_MAX && buflen == 4) { /* Start final tests which require buffer of 6 */ @@ -537,12 +533,12 @@ main(int argc, char * const argv[]) if (test_args[i].scale < 0 && ! includeNegScale) { skipped++; - testskipped(i); + testskipped(i + 1); continue; } if (test_args[i].num >= halfExabyte && ! includeExabyteTests) { skipped++; - testskipped(i); + testskipped(i + 1); continue; } @@ -553,36 +549,46 @@ main(int argc, char * const argv[]) if (r != test_args[i].retval) { if (verbose) - printf("wrong return value on index %lu, buflen: %zu, got: %d + \"%s\", expected %d + \"%s\"; num = %" PRId64 ", scale = %s, flags= %s.\n", + printf("wrong return value on index %zu, " + "buflen: %zu, got: %d + \"%s\", " + "expected %d + \"%s\"; num = %jd, " + "scale = %s, flags= %s.\n", i, buflen, r, buf, test_args[i].retval, - test_args[i].res, test_args[i].num, + test_args[i].res, + (intmax_t)test_args[i].num, scale_str, flag_str); else - printf("not ok %lu # return %d != %d\n", i, r, - test_args[i].retval); + printf("not ok %zu # return %d != %d\n", + i + 1, r, test_args[i].retval); errcnt++; } else if (strcmp(buf, test_args[i].res) != 0) { if (verbose) - printf("result mismatch on index %lu, got: \"%s\", expected \"%s\"; num = %" PRId64 ", scale = %s, flags= %s.\n", - i, buf, test_args[i].res, test_args[i].num, + printf("result mismatch on index %zu, got: " + "\"%s\", expected \"%s\"; num = %jd, " + "scale = %s, flags= %s.\n", + i, buf, test_args[i].res, + (intmax_t)test_args[i].num, scale_str, flag_str); else - printf("not ok %lu # buf \"%s\" != \"%s\"\n", i, - buf, test_args[i].res); + printf("not ok %zu # buf \"%s\" != \"%s\"\n", + i + 1, buf, test_args[i].res); errcnt++; } else { if (verbose) - printf("successful result on index %lu, returned %d, got: \"%s\"; num = %" PRId64 ", scale = %s, flags= %s.\n", - i, r, buf, test_args[i].num, scale_str, - flag_str); + printf("successful result on index %zu, " + "returned %d, got: \"%s\"; num = %jd, " + "scale = %s, flags= %s.\n", + i, r, buf, + (intmax_t)test_args[i].num, + scale_str, flag_str); else - printf("ok %lu\n", i); + printf("ok %zu\n", i + 1); } tested++; } if (verbose) - printf("total errors: %lu/%lu tests, %lu skipped\n", errcnt, + printf("total errors: %zu/%zu tests, %zu skipped\n", errcnt, tested, skipped); if (errcnt) diff --git a/tools/regression/lib/libutil/test-pidfile.c b/lib/libutil/tests/pidfile_test.c index 0b70bc8..0b70bc8 100644 --- a/tools/regression/lib/libutil/test-pidfile.c +++ b/lib/libutil/tests/pidfile_test.c diff --git a/tools/regression/lib/libutil/test-trimdomain-nodomain.c b/lib/libutil/tests/trimdomain-nodomain_test.c index c02ccdb..c02ccdb 100644 --- a/tools/regression/lib/libutil/test-trimdomain-nodomain.c +++ b/lib/libutil/tests/trimdomain-nodomain_test.c diff --git a/tools/regression/lib/libutil/test-trimdomain.c b/lib/libutil/tests/trimdomain_test.c index 08fcfc0..08fcfc0 100644 --- a/tools/regression/lib/libutil/test-trimdomain.c +++ b/lib/libutil/tests/trimdomain_test.c diff --git a/tools/regression/lib/libutil/Makefile b/tools/regression/lib/libutil/Makefile deleted file mode 100644 index 229b4d2..0000000 --- a/tools/regression/lib/libutil/Makefile +++ /dev/null @@ -1,13 +0,0 @@ -# $FreeBSD$ - -TESTS= test-trimdomain test-trimdomain-nodomain test-flopen test-grp \ - test-pidfile test-humanize_number -CFLAGS+= -g -Wall -Wextra -Werror -lutil - -.PHONY: tests -tests: ${TESTS} - for p in ${TESTS}; do ${.OBJDIR}/$$p; done - -.PHONY: clean -clean: - -rm -f ${TESTS} diff --git a/tools/regression/lib/libutil/test-flopen.t b/tools/regression/lib/libutil/test-flopen.t deleted file mode 100644 index cbb7c8c..0000000 --- a/tools/regression/lib/libutil/test-flopen.t +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/sh -# -# $FreeBSD$ -# - -base=$(realpath $(dirname $0)) -name=$(basename $0 .t) - -set -e -cd $base -make -s $name >/dev/null -exec $base/$name diff --git a/tools/regression/lib/libutil/test-grp.t b/tools/regression/lib/libutil/test-grp.t deleted file mode 100644 index cbb7c8c..0000000 --- a/tools/regression/lib/libutil/test-grp.t +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/sh -# -# $FreeBSD$ -# - -base=$(realpath $(dirname $0)) -name=$(basename $0 .t) - -set -e -cd $base -make -s $name >/dev/null -exec $base/$name diff --git a/tools/regression/lib/libutil/test-humanize_number.t b/tools/regression/lib/libutil/test-humanize_number.t deleted file mode 100755 index 516bc4c..0000000 --- a/tools/regression/lib/libutil/test-humanize_number.t +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/sh -# $FreeBSD$ - -cd `dirname $0` - -executable=`basename $0 .t` - -make $executable 2>&1 > /dev/null - -exec ./$executable && echo humanize_numbers ok diff --git a/tools/regression/lib/libutil/test-trimdomain-nodomain.t b/tools/regression/lib/libutil/test-trimdomain-nodomain.t deleted file mode 100644 index 8bdfd03..0000000 --- a/tools/regression/lib/libutil/test-trimdomain-nodomain.t +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/sh -# $FreeBSD$ - -cd `dirname $0` - -executable=`basename $0 .t` - -make $executable 2>&1 > /dev/null - -exec ./$executable diff --git a/tools/regression/lib/libutil/test-trimdomain.t b/tools/regression/lib/libutil/test-trimdomain.t deleted file mode 100644 index 8bdfd03..0000000 --- a/tools/regression/lib/libutil/test-trimdomain.t +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/sh -# $FreeBSD$ - -cd `dirname $0` - -executable=`basename $0 .t` - -make $executable 2>&1 > /dev/null - -exec ./$executable |