Source-Changes-HG archive

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

[src/trunk]: src/tests/lib Convert the libposix, libprop, librt, libskey and ...



details:   https://anonhg.NetBSD.org/src/rev/a11d50942c48
branches:  trunk
changeset: 756399:a11d50942c48
user:      jmmv <jmmv%NetBSD.org@localhost>
date:      Fri Jul 16 13:56:31 2010 +0000

description:
Convert the libposix, libprop, librt, libskey and libutil tests to ATF.
Initial work from the GSoC 2008 project by Lukasz Strzygowski.

diffstat:

 tests/lib/Makefile                      |    8 +-
 tests/lib/libposix/Makefile             |   13 ++
 tests/lib/libposix/bsd/Makefile         |   14 ++
 tests/lib/libposix/posix1/Makefile      |   15 ++
 tests/lib/libposix/posix2/Makefile      |   14 ++
 tests/lib/libposix/t_rename.c           |   89 +++++++++++++++
 tests/lib/libprop/Makefile              |   13 ++
 tests/lib/libprop/t_basic.c             |  168 +++++++++++++++++++++++++++++
 tests/lib/librt/Makefile                |   13 ++
 tests/lib/librt/t_sem.c                 |  171 +++++++++++++++++++++++++++++
 tests/lib/libskey/Makefile              |   14 ++
 tests/lib/libskey/t_algorithms.c        |  121 ++++++++++++++++++++
 tests/lib/libutil/Makefile              |   19 +++
 tests/lib/libutil/t_snprintb.c          |   75 ++++++++++++
 tests/lib/libutil/t_sockaddr_snprintf.c |  185 ++++++++++++++++++++++++++++++++
 15 files changed, 930 insertions(+), 2 deletions(-)

diffs (truncated from 998 to 300 lines):

diff -r 229f0260959f -r a11d50942c48 tests/lib/Makefile
--- a/tests/lib/Makefile        Fri Jul 16 13:07:23 2010 +0000
+++ b/tests/lib/Makefile        Fri Jul 16 13:56:31 2010 +0000
@@ -1,8 +1,12 @@
-# $NetBSD: Makefile,v 1.4 2010/07/13 21:13:26 jmmv Exp $
+# $NetBSD: Makefile,v 1.5 2010/07/16 13:56:31 jmmv Exp $
 
 .include <bsd.own.mk>
 
-TESTS_SUBDIRS=         libc libevent semaphore
+TESTS_SUBDIRS= libc libevent libposix libprop librt libutil semaphore
+
+.if (${MKSKEY} != "no")
+TESTS_SUBDIRS+= libskey
+.endif
 
 TESTSDIR=      ${TESTSBASE}/lib
 
diff -r 229f0260959f -r a11d50942c48 tests/lib/libposix/Makefile
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/lib/libposix/Makefile       Fri Jul 16 13:56:31 2010 +0000
@@ -0,0 +1,13 @@
+# $NetBSD: Makefile,v 1.1 2010/07/16 13:56:31 jmmv Exp $
+
+NOMAN=         # defined
+
+.include <bsd.own.mk>
+
+TESTSDIR=      ${TESTSBASE}/lib/libposix
+
+SUBDIR=                bsd
+SUBDIR+=       posix1
+SUBDIR+=       posix2
+
+.include <bsd.test.mk>
diff -r 229f0260959f -r a11d50942c48 tests/lib/libposix/bsd/Makefile
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/lib/libposix/bsd/Makefile   Fri Jul 16 13:56:31 2010 +0000
@@ -0,0 +1,14 @@
+# $NetBSD: Makefile,v 1.1 2010/07/16 13:56:31 jmmv Exp $
+
+NOMAN=         # defined
+
+.include <bsd.own.mk>
+
+.PATH: ${.CURDIR}/..
+TESTSDIR=      ${TESTSBASE}/lib/libposix/bsd
+
+CFLAGS+=       -DBSD_RENAME
+
+TESTS_C=       t_rename
+
+.include <bsd.test.mk>
diff -r 229f0260959f -r a11d50942c48 tests/lib/libposix/posix1/Makefile
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/lib/libposix/posix1/Makefile        Fri Jul 16 13:56:31 2010 +0000
@@ -0,0 +1,15 @@
+# $NetBSD: Makefile,v 1.1 2010/07/16 13:56:31 jmmv Exp $
+
+NOMAN=         # defined
+
+.include <bsd.own.mk>
+
+.PATH: ${.CURDIR}/..
+TESTSDIR=      ${TESTSBASE}/lib/libposix/posix1
+
+DPADD+=                ${LIBPOSIX}
+LDADD+=                -lposix
+
+TESTS_C=       t_rename
+
+.include <bsd.test.mk>
diff -r 229f0260959f -r a11d50942c48 tests/lib/libposix/posix2/Makefile
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/lib/libposix/posix2/Makefile        Fri Jul 16 13:56:31 2010 +0000
@@ -0,0 +1,14 @@
+# $NetBSD: Makefile,v 1.1 2010/07/16 13:56:31 jmmv Exp $
+
+NOMAN=         # defined
+
+.include <bsd.own.mk>
+
+.PATH: ${.CURDIR}/..
+TESTSDIR=      ${TESTSBASE}/lib/libposix/posix2
+
+CFLAGS+=       -D_POSIX_SOURCE
+
+TESTS_C=       t_rename
+
+.include <bsd.test.mk>
diff -r 229f0260959f -r a11d50942c48 tests/lib/libposix/t_rename.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/lib/libposix/t_rename.c     Fri Jul 16 13:56:31 2010 +0000
@@ -0,0 +1,89 @@
+/* $NetBSD: t_rename.c,v 1.1 2010/07/16 13:56:31 jmmv Exp $ */
+
+/*
+ * Copyright (c) 2001, 2008, 2010 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * 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>
+__COPYRIGHT("@(#) Copyright (c) 2008, 2010\
+ The NetBSD Foundation, inc. All rights reserved.");
+__RCSID("$NetBSD: t_rename.c,v 1.1 2010/07/16 13:56:31 jmmv Exp $");
+
+#include <sys/types.h>
+#include <sys/stat.h>
+
+#include <errno.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#include <atf-c.h>
+
+#include "../../h_macros.h"
+
+ATF_TC(rename);
+ATF_TC_HEAD(rename, tc)
+{
+       atf_tc_set_md_var(tc, "descr", "Checks rename(2)");
+}
+ATF_TC_BODY(rename, tc)
+{
+       struct stat sb;
+
+       REQUIRE_LIBC(open("t1", O_CREAT | O_TRUNC | O_WRONLY, 0600), -1);
+       REQUIRE_LIBC(link("t1", "t2"), -1);
+
+       /* Check if rename to same name works as expected */
+       REQUIRE_LIBC(rename("t1", "t1"), -1);
+
+       /* Rename removed file? */
+       REQUIRE_LIBC(stat("t1", &sb), -1);
+
+       REQUIRE_LIBC(rename("t1", "t2"), -1);
+
+#if BSD_RENAME
+       /* check if rename of hardlinked file works the BSD way */
+       ATF_REQUIRE_MSG(stat("t1", &sb) != 0, "BSD rename should remove file t1");
+       ATF_REQUIRE_EQ(errno, ENOENT);
+#else
+       /* check if rename of hardlinked file works as the standard says */
+       REQUIRE_LIBC(stat("t1", &sb), -1);
+#endif
+       /* check if we get the expected error */
+       /* this also exercises icky shared libraries goo */
+       ATF_REQUIRE_MSG(rename("no/such/file/or/dir", "no/such/file/or/dir") != 0,
+               "No error renaming nonexistent file");
+       ATF_REQUIRE_EQ(errno, ENOENT);
+}
+
+ATF_TP_ADD_TCS(tp)
+{
+
+       ATF_TP_ADD_TC(tp, rename);
+
+       return atf_no_error();
+}
diff -r 229f0260959f -r a11d50942c48 tests/lib/libprop/Makefile
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/lib/libprop/Makefile        Fri Jul 16 13:56:31 2010 +0000
@@ -0,0 +1,13 @@
+# $NetBSD: Makefile,v 1.1 2010/07/16 13:56:31 jmmv Exp $
+
+NOMAN=         # defined
+
+.include <bsd.own.mk>
+
+TESTSDIR=      ${TESTSBASE}/lib/libprop
+
+LDADD+=                -lprop
+
+TESTS_C=       t_basic
+
+.include <bsd.test.mk>
diff -r 229f0260959f -r a11d50942c48 tests/lib/libprop/t_basic.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/lib/libprop/t_basic.c       Fri Jul 16 13:56:31 2010 +0000
@@ -0,0 +1,168 @@
+/* $NetBSD: t_basic.c,v 1.1 2010/07/16 13:56:31 jmmv Exp $ */
+
+/*
+ * Copyright (c) 2008 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * 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.
+ */
+
+/*
+ * Written by Jason Thorpe 5/26/2006.
+ * Public domain.
+ */
+
+#include <sys/cdefs.h>
+__COPYRIGHT("@(#) Copyright (c) 2008\
+ The NetBSD Foundation, inc. All rights reserved.");
+__RCSID("$NetBSD: t_basic.c,v 1.1 2010/07/16 13:56:31 jmmv Exp $");
+
+#include <prop/proplib.h>
+#include <stdlib.h>
+
+#include <atf-c.h>
+
+static const char compare1[] =
+"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
+"<!DOCTYPE plist PUBLIC \"-//Apple Computer//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\";>\n"
+"<plist version=\"1.0\">\n"
+"<dict>\n"
+"      <key>false-val</key>\n"
+"      <false/>\n"
+"      <key>one</key>\n"
+"      <integer>1</integer>\n"
+"      <key>three</key>\n"
+"      <array>\n"
+"              <dict>\n"
+"                      <key>one</key>\n"
+"                      <integer>1</integer>\n"
+"                      <key>two</key>\n"
+"                      <string>number-two</string>\n"
+"              </dict>\n"
+"              <dict>\n"
+"                      <key>one</key>\n"
+"                      <integer>1</integer>\n"
+"                      <key>two</key>\n"
+"                      <string>number-two</string>\n"
+"              </dict>\n"
+"              <dict>\n"
+"                      <key>one</key>\n"
+"                      <integer>1</integer>\n"
+"                      <key>two</key>\n"
+"                      <string>number-two</string>\n"
+"              </dict>\n"
+"      </array>\n"
+"      <key>true-val</key>\n"
+"      <true/>\n"
+"      <key>two</key>\n"
+"      <string>number-two</string>\n"
+"</dict>\n"
+"</plist>\n";
+
+ATF_TC(simple);
+ATF_TC_HEAD(simple, tc)
+{
+       atf_tc_set_md_var(tc, "descr", "Checks basic functionality of proplib");
+}
+ATF_TC_BODY(simple, tc)
+{
+       prop_dictionary_t dict;
+       char *ext1;
+
+       dict = prop_dictionary_create();
+       ATF_REQUIRE(dict != NULL);
+
+       {
+               prop_number_t num = prop_number_create_integer(1);
+               ATF_REQUIRE(num != NULL);



Home | Main Index | Thread Index | Old Index