Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src Add basic checks for a64l(3), l64a(3), and l64a_r(3).



details:   https://anonhg.NetBSD.org/src/rev/b5225808bd91
branches:  trunk
changeset: 935375:b5225808bd91
user:      jruoho <jruoho%NetBSD.org@localhost>
date:      Wed Jul 01 07:16:37 2020 +0000

description:
Add basic checks for a64l(3), l64a(3), and l64a_r(3).

diffstat:

 distrib/sets/lists/debug/mi    |    3 +-
 distrib/sets/lists/tests/mi    |    3 +-
 tests/lib/libc/stdlib/Makefile |    3 +-
 tests/lib/libc/stdlib/t_a64l.c |  111 +++++++++++++++++++++++++++++++++++++++++
 4 files changed, 117 insertions(+), 3 deletions(-)

diffs (164 lines):

diff -r 8ae3183340d7 -r b5225808bd91 distrib/sets/lists/debug/mi
--- a/distrib/sets/lists/debug/mi       Wed Jul 01 06:31:18 2020 +0000
+++ b/distrib/sets/lists/debug/mi       Wed Jul 01 07:16:37 2020 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.322 2020/06/30 20:32:10 riastradh Exp $
+# $NetBSD: mi,v 1.323 2020/07/01 07:16:38 jruoho Exp $
 ./etc/mtree/set.debug                           comp-sys-root
 ./usr/lib                                      comp-sys-usr            compatdir
 ./usr/lib/i18n/libBIG5_g.a                     comp-c-debuglib         debuglib,compatfile
@@ -2081,6 +2081,7 @@
 ./usr/libdata/debug/usr/tests/lib/libc/stdlib/h_atexit.debug           tests-lib-debug         debug,atf,compattestfile
 ./usr/libdata/debug/usr/tests/lib/libc/stdlib/h_getopt.debug           tests-lib-debug         debug,atf,compattestfile
 ./usr/libdata/debug/usr/tests/lib/libc/stdlib/h_getopt_long.debug      tests-lib-debug         debug,atf,compattestfile
+./usr/libdata/debug/usr/tests/lib/libc/stdlib/t_a64l.debug             tests-lib-debug         debug,atf,compattestfile
 ./usr/libdata/debug/usr/tests/lib/libc/stdlib/t_abs.debug              tests-lib-debug         debug,atf,compattestfile
 ./usr/libdata/debug/usr/tests/lib/libc/stdlib/t_atoi.debug             tests-lib-debug         debug,atf,compattestfile
 ./usr/libdata/debug/usr/tests/lib/libc/stdlib/t_div.debug              tests-lib-debug         debug,atf,compattestfile
diff -r 8ae3183340d7 -r b5225808bd91 distrib/sets/lists/tests/mi
--- a/distrib/sets/lists/tests/mi       Wed Jul 01 06:31:18 2020 +0000
+++ b/distrib/sets/lists/tests/mi       Wed Jul 01 07:16:37 2020 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.868 2020/06/30 23:51:47 lukem Exp $
+# $NetBSD: mi,v 1.869 2020/07/01 07:16:38 jruoho Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -3068,6 +3068,7 @@
 ./usr/tests/lib/libc/stdlib/h_atexit           tests-lib-tests         compattestfile,atf
 ./usr/tests/lib/libc/stdlib/h_getopt           tests-lib-tests         compattestfile,atf
 ./usr/tests/lib/libc/stdlib/h_getopt_long      tests-lib-tests         compattestfile,atf
+./usr/tests/lib/libc/stdlib/t_a64l             tests-lib-tests         compattestfile,atf
 ./usr/tests/lib/libc/stdlib/t_abs              tests-lib-tests         compattestfile,atf
 ./usr/tests/lib/libc/stdlib/t_atexit           tests-lib-tests         compattestfile,atf
 ./usr/tests/lib/libc/stdlib/t_atoi             tests-lib-tests         compattestfile,atf
diff -r 8ae3183340d7 -r b5225808bd91 tests/lib/libc/stdlib/Makefile
--- a/tests/lib/libc/stdlib/Makefile    Wed Jul 01 06:31:18 2020 +0000
+++ b/tests/lib/libc/stdlib/Makefile    Wed Jul 01 07:16:37 2020 +0000
@@ -1,9 +1,10 @@
-# $NetBSD: Makefile,v 1.32 2020/06/30 16:09:40 jruoho Exp $
+# $NetBSD: Makefile,v 1.33 2020/07/01 07:16:37 jruoho Exp $
 
 .include <bsd.own.mk>
 
 TESTSDIR=      ${TESTSBASE}/lib/libc/stdlib
 
+TESTS_C+=      t_a64l
 TESTS_C+=      t_abs
 TESTS_C+=      t_atoi
 TESTS_C+=      t_div
diff -r 8ae3183340d7 -r b5225808bd91 tests/lib/libc/stdlib/t_a64l.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/lib/libc/stdlib/t_a64l.c    Wed Jul 01 07:16:37 2020 +0000
@@ -0,0 +1,111 @@
+/* $NetBSD: t_a64l.c,v 1.1 2020/07/01 07:16:37 jruoho Exp $ */
+
+/*-
+ * Copyright (c) 2020 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Jukka Ruohonen.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+#include <sys/cdefs.h>
+__RCSID("$NetBSD: t_a64l.c,v 1.1 2020/07/01 07:16:37 jruoho Exp $");
+
+#include <atf-c.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+struct test {
+       const char      *str;
+       size_t           len;
+       long             val;
+} t[] = {
+       { "",        0, 0L        },
+       { "///",     3, 4161L     }, /* 1*64^0 + 1*64^1 + 1*64^2            */
+       { "123",     3, 20739L    }, /* 3*64^0 + 4*64^1 + 5*64^2            */
+       { "zzz",     3, 262143L   }, /* 63*64^0 + 63*64^1 + 63*64^2         */
+       { "a64l",    4, 12870182L }, /* 38*64^0 + 8*64^1 + 6*64^2 + 49*64^3 */
+       { "a64l...", 4, 12870182L }, /* 38*64^0 + 8*64^1 + 6*64^2 + 49*64^3 */
+};
+
+#define MAXLEN 8
+
+ATF_TC(a64l_basic);
+ATF_TC_HEAD(a64l_basic, tc)
+{
+       atf_tc_set_md_var(tc, "descr", "A basic test of a64l(3)");
+}
+
+ATF_TC_BODY(a64l_basic, tc)
+{
+       for (size_t i = 0; i < __arraycount(t); i++) {
+               long val = a64l(t[i].str);
+               ATF_REQUIRE(val == t[i].val);
+       }
+
+}
+
+ATF_TC(l64a_basic);
+ATF_TC_HEAD(l64a_basic, tc)
+{
+       atf_tc_set_md_var(tc, "descr", "A basic test of l64a(3)");
+}
+
+ATF_TC_BODY(l64a_basic, tc)
+{
+       for (size_t i = 0; i < __arraycount(t); i++) {
+               char *str = l64a(t[i].val);
+               ATF_REQUIRE(strlen(str) == t[i].len);
+               ATF_REQUIRE(strncmp(str, t[i].str, t[i].len) == 0);
+       }
+}
+
+ATF_TC(l64a_r_basic);
+ATF_TC_HEAD(l64a_r_basic, tc)
+{
+       atf_tc_set_md_var(tc, "descr", "A basic test of l64a_r(3)");
+}
+
+ATF_TC_BODY(l64a_r_basic, tc)
+{
+       char buf[MAXLEN];
+
+       for (size_t i = 0; i < __arraycount(t); i++) {
+
+               (void)memset(buf, '\0', sizeof(buf));
+
+               ATF_REQUIRE(l64a_r(t[i].val, buf, t[i].len + 1) == 0);
+               ATF_REQUIRE(strlen(buf) == t[i].len);
+               ATF_REQUIRE(strncmp(buf, t[i].str, t[i].len) == 0);
+       }
+}
+
+ATF_TP_ADD_TCS(tp)
+{
+
+       ATF_TP_ADD_TC(tp, a64l_basic);
+       ATF_TP_ADD_TC(tp, l64a_basic);
+       ATF_TP_ADD_TC(tp, l64a_r_basic);
+
+       return atf_no_error();
+}



Home | Main Index | Thread Index | Old Index