Module Name:    src
Committed By:   pooka
Date:           Thu Sep 24 21:33:45 UTC 2009

Modified Files:
        src/distrib/sets/lists/tests: mi
        src/etc/mtree: NetBSD.dist.base
        src/tests: Makefile
Added Files:
        src/tests/libexec: Atffile Makefile
        src/tests/libexec/ld.elf_so: Atffile Makefile t_dlinfo.c

Log Message:
add regression tests for dlinfo()


To generate a diff of this commit:
cvs rdiff -u -r1.49 -r1.50 src/distrib/sets/lists/tests/mi
cvs rdiff -u -r1.2 -r1.3 src/etc/mtree/NetBSD.dist.base
cvs rdiff -u -r1.16 -r1.17 src/tests/Makefile
cvs rdiff -u -r0 -r1.1 src/tests/libexec/Atffile src/tests/libexec/Makefile
cvs rdiff -u -r0 -r1.1 src/tests/libexec/ld.elf_so/Atffile \
    src/tests/libexec/ld.elf_so/Makefile \
    src/tests/libexec/ld.elf_so/t_dlinfo.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/distrib/sets/lists/tests/mi
diff -u src/distrib/sets/lists/tests/mi:1.49 src/distrib/sets/lists/tests/mi:1.50
--- src/distrib/sets/lists/tests/mi:1.49	Sat Sep 19 21:51:47 2009
+++ src/distrib/sets/lists/tests/mi	Thu Sep 24 21:33:45 2009
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.49 2009/09/19 21:51:47 apb Exp $
+# $NetBSD: mi,v 1.50 2009/09/24 21:33:45 pooka Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -139,6 +139,9 @@
 ./usr/libdata/debug/usr/tests/lib/libc/stdlib/t_mi_vector_hash.debug	tests-lib-debug	debug
 ./usr/libdata/debug/usr/tests/lib/libc/string				tests-lib-debug
 ./usr/libdata/debug/usr/tests/lib/libc/string/t_popcount.debug		tests-lib-debug	debug
+./usr/libdata/debug/usr/tests/libexec					tests-lib-debug
+./usr/libdata/debug/usr/tests/libexec/ld.elf_so				tests-libexec-debug
+./usr/libdata/debug/usr/tests/libexec/ld.elf_so/t_dlinfo		tests-libexec-debug debug
 ./usr/libdata/debug/usr/tests/modules					tests-sys-debug
 ./usr/libdata/debug/usr/tests/modules/t_modctl.debug			tests-sys-debug		debug
 ./usr/libdata/debug/usr/tests/net					tests-net-debug
@@ -854,6 +857,11 @@
 ./usr/tests/lib/libc/string			tests-lib-tests
 ./usr/tests/lib/libc/string/Atffile		tests-lib-tests
 ./usr/tests/lib/libc/string/t_popcount		tests-lib-tests
+./usr/tests/libexec				tests-lib-tests
+./usr/tests/libexec/Atffile			tests-lib-tests
+./usr/tests/libexec/ld.elf_so			tests-libexec-tests
+./usr/tests/libexec/ld.elf_so/Atffile		tests-libexec-tests
+./usr/tests/libexec/ld.elf_so/t_dlinfo		tests-libexec-tests
 ./usr/tests/modules				tests-sys-tests
 ./usr/tests/net					tests-net-tests
 ./usr/tests/net/Atffile				tests-net-tests

Index: src/etc/mtree/NetBSD.dist.base
diff -u src/etc/mtree/NetBSD.dist.base:1.2 src/etc/mtree/NetBSD.dist.base:1.3
--- src/etc/mtree/NetBSD.dist.base:1.2	Mon Sep  7 21:07:03 2009
+++ src/etc/mtree/NetBSD.dist.base	Thu Sep 24 21:33:45 2009
@@ -1,4 +1,4 @@
-#	$NetBSD: NetBSD.dist.base,v 1.2 2009/09/07 21:07:03 mrg Exp $
+#	$NetBSD: NetBSD.dist.base,v 1.3 2009/09/24 21:33:45 pooka Exp $
 #	@(#)4.4BSD.dist	8.1 (Berkeley) 6/13/93
 
 # Do not customize this file as it may be overwritten on upgrades.
@@ -208,6 +208,8 @@
 ./usr/libdata/debug/usr/tests/lib/libc
 ./usr/libdata/debug/usr/tests/lib/libc/stdlib
 ./usr/libdata/debug/usr/tests/lib/libc/string
+./usr/libdata/debug/usr/tests/libexec
+./usr/libdata/debug/usr/tests/libexec/ld.elf_so
 ./usr/libdata/debug/usr/tests/modules
 ./usr/libdata/debug/usr/tests/net
 ./usr/libdata/debug/usr/tests/net/sys
@@ -1093,6 +1095,8 @@
 ./usr/tests/lib/libc
 ./usr/tests/lib/libc/stdlib
 ./usr/tests/lib/libc/string
+./usr/tests/libexec
+./usr/tests/libexec/ld.elf_so
 ./usr/tests/modules
 ./usr/tests/net
 ./usr/tests/net/sys

Index: src/tests/Makefile
diff -u src/tests/Makefile:1.16 src/tests/Makefile:1.17
--- src/tests/Makefile:1.16	Mon Jul 20 17:03:37 2009
+++ src/tests/Makefile	Thu Sep 24 21:33:45 2009
@@ -1,8 +1,8 @@
-# $NetBSD: Makefile,v 1.16 2009/07/20 17:03:37 joerg Exp $
+# $NetBSD: Makefile,v 1.17 2009/09/24 21:33:45 pooka Exp $
 
 .include <bsd.own.mk>
 
-SUBDIR=	crypto fs games ipf kernel lib net rump syscall util
+SUBDIR=	crypto fs games ipf kernel lib libexec net rump syscall util
 
 .if ${MACHINE} != "evbppc"
 SUBDIR+= modules

Added files:

Index: src/tests/libexec/Atffile
diff -u /dev/null src/tests/libexec/Atffile:1.1
--- /dev/null	Thu Sep 24 21:33:46 2009
+++ src/tests/libexec/Atffile	Thu Sep 24 21:33:45 2009
@@ -0,0 +1,6 @@
+Content-Type: application/X-atf-atffile; version="1"
+X-NetBSD-Id: "$NetBSD: Atffile,v 1.1 2009/09/24 21:33:45 pooka Exp $"
+
+prop: test-suite = "NetBSD"
+
+tp-glob: *
Index: src/tests/libexec/Makefile
diff -u /dev/null src/tests/libexec/Makefile:1.1
--- /dev/null	Thu Sep 24 21:33:46 2009
+++ src/tests/libexec/Makefile	Thu Sep 24 21:33:45 2009
@@ -0,0 +1,11 @@
+# $NetBSD: Makefile,v 1.1 2009/09/24 21:33:45 pooka Exp $
+#
+
+.include <bsd.own.mk>
+
+SUBDIR=		ld.elf_so
+
+TESTSDIR=	${TESTSBASE}/libexec
+
+.include <bsd.test.mk>
+.include <bsd.subdir.mk>

Index: src/tests/libexec/ld.elf_so/Atffile
diff -u /dev/null src/tests/libexec/ld.elf_so/Atffile:1.1
--- /dev/null	Thu Sep 24 21:33:46 2009
+++ src/tests/libexec/ld.elf_so/Atffile	Thu Sep 24 21:33:45 2009
@@ -0,0 +1,6 @@
+Content-Type: application/X-atf-atffile; version="1"
+X-NetBSD-Id: "$NetBSD: Atffile,v 1.1 2009/09/24 21:33:45 pooka Exp $"
+
+prop: test-suite = "NetBSD"
+
+tp-glob: *
Index: src/tests/libexec/ld.elf_so/Makefile
diff -u /dev/null src/tests/libexec/ld.elf_so/Makefile:1.1
--- /dev/null	Thu Sep 24 21:33:46 2009
+++ src/tests/libexec/ld.elf_so/Makefile	Thu Sep 24 21:33:45 2009
@@ -0,0 +1,10 @@
+# $NetBSD
+#
+
+.include <bsd.own.mk>
+
+TESTSDIR=	${TESTSBASE}/libexec/ld.elf_so
+
+TESTS_C+=	t_dlinfo
+
+.include <bsd.test.mk>
Index: src/tests/libexec/ld.elf_so/t_dlinfo.c
diff -u /dev/null src/tests/libexec/ld.elf_so/t_dlinfo.c:1.1
--- /dev/null	Thu Sep 24 21:33:46 2009
+++ src/tests/libexec/ld.elf_so/t_dlinfo.c	Thu Sep 24 21:33:45 2009
@@ -0,0 +1,92 @@
+/*	$NetBSD: t_dlinfo.c,v 1.1 2009/09/24 21:33:45 pooka Exp $	*/
+
+/*
+ * Copyright (c) 2009 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/types.h>
+
+#include <atf-c.h>
+#include <dlfcn.h>
+#include <link_elf.h>
+
+#include "../../h_macros.h"
+
+ATF_TC(rtld_dlinfo_linkmap_self);
+ATF_TC_HEAD(rtld_dlinfo_linkmap_self, tc)
+{
+	atf_tc_set_md_var(tc, "descr", "dlinfo with RTLD_SELF handle works");
+}
+ATF_TC_BODY(rtld_dlinfo_linkmap_self, tc)
+{
+	struct link_map *map;
+	int rv;
+
+	rv = dlinfo(RTLD_SELF, RTLD_DI_LINKMAP, &map);
+	ATF_CHECK_EQ(rv, 0);
+	ATF_CHECK((strstr(map->l_name, "t_dlinfo") != NULL));
+}
+
+ATF_TC(rtld_dlinfo_linkmap_inval);
+ATF_TC_HEAD(rtld_dlinfo_linkmap_inval, tc)
+{
+	atf_tc_set_md_var(tc, "descr", "dlinfo with invalid handle fails");
+}
+ATF_TC_BODY(rtld_dlinfo_linkmap_inval, tc)
+{
+	void *v;
+	int rv;
+
+	rv = dlinfo(NULL, RTLD_DI_LINKMAP, &v);
+	ATF_CHECK_EQ(rv, -1);
+}
+
+ATF_TC(rtld_dlinfo_linkmap_dlopen);
+ATF_TC_HEAD(rtld_dlinfo_linkmap_dlopen, tc)
+{
+	atf_tc_set_md_var(tc, "descr", "dlinfo dlopen'd handle works");
+}
+ATF_TC_BODY(rtld_dlinfo_linkmap_dlopen, tc)
+{
+	struct link_map *map;
+	void *handle;
+	int rv;
+
+	handle = dlopen("libutil.so", RTLD_LAZY);
+	ATF_CHECK(handle);
+
+	rv = dlinfo(handle, RTLD_DI_LINKMAP, &map);
+	ATF_CHECK_EQ(rv, 0);
+	ATF_CHECK((strstr(map->l_name, "libutil.so") != NULL));
+	dlclose(handle);
+}
+
+ATF_TP_ADD_TCS(tp)
+{
+	ATF_TP_ADD_TC(tp, rtld_dlinfo_linkmap_self);
+	ATF_TP_ADD_TC(tp, rtld_dlinfo_linkmap_inval);
+	ATF_TP_ADD_TC(tp, rtld_dlinfo_linkmap_dlopen);
+}

Reply via email to