Source-Changes-HG archive

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

[src/trunk]: src add regression tests for dlinfo()



details:   https://anonhg.NetBSD.org/src/rev/53101a3a117e
branches:  trunk
changeset: 747623:53101a3a117e
user:      pooka <pooka%NetBSD.org@localhost>
date:      Thu Sep 24 21:33:45 2009 +0000

description:
add regression tests for dlinfo()

diffstat:

 distrib/sets/lists/tests/mi        |  10 +++-
 etc/mtree/NetBSD.dist.base         |   6 ++-
 tests/Makefile                     |   4 +-
 tests/libexec/Atffile              |   6 ++
 tests/libexec/Makefile             |  11 ++++
 tests/libexec/ld.elf_so/Atffile    |   6 ++
 tests/libexec/ld.elf_so/Makefile   |  10 ++++
 tests/libexec/ld.elf_so/t_dlinfo.c |  92 ++++++++++++++++++++++++++++++++++++++
 8 files changed, 141 insertions(+), 4 deletions(-)

diffs (217 lines):

diff -r 0819fe1ad731 -r 53101a3a117e distrib/sets/lists/tests/mi
--- a/distrib/sets/lists/tests/mi       Thu Sep 24 21:30:42 2009 +0000
+++ b/distrib/sets/lists/tests/mi       Thu Sep 24 21:33:45 2009 +0000
@@ -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
diff -r 0819fe1ad731 -r 53101a3a117e etc/mtree/NetBSD.dist.base
--- a/etc/mtree/NetBSD.dist.base        Thu Sep 24 21:30:42 2009 +0000
+++ b/etc/mtree/NetBSD.dist.base        Thu Sep 24 21:33:45 2009 +0000
@@ -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
diff -r 0819fe1ad731 -r 53101a3a117e tests/Makefile
--- a/tests/Makefile    Thu Sep 24 21:30:42 2009 +0000
+++ b/tests/Makefile    Thu Sep 24 21:33:45 2009 +0000
@@ -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
diff -r 0819fe1ad731 -r 53101a3a117e tests/libexec/Atffile
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/libexec/Atffile     Thu Sep 24 21:33:45 2009 +0000
@@ -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: *
diff -r 0819fe1ad731 -r 53101a3a117e tests/libexec/Makefile
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/libexec/Makefile    Thu Sep 24 21:33:45 2009 +0000
@@ -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>
diff -r 0819fe1ad731 -r 53101a3a117e tests/libexec/ld.elf_so/Atffile
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/libexec/ld.elf_so/Atffile   Thu Sep 24 21:33:45 2009 +0000
@@ -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: *
diff -r 0819fe1ad731 -r 53101a3a117e tests/libexec/ld.elf_so/Makefile
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/libexec/ld.elf_so/Makefile  Thu Sep 24 21:33:45 2009 +0000
@@ -0,0 +1,10 @@
+# $NetBSD
+#
+
+.include <bsd.own.mk>
+
+TESTSDIR=      ${TESTSBASE}/libexec/ld.elf_so
+
+TESTS_C+=      t_dlinfo
+
+.include <bsd.test.mk>
diff -r 0819fe1ad731 -r 53101a3a117e tests/libexec/ld.elf_so/t_dlinfo.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/libexec/ld.elf_so/t_dlinfo.c        Thu Sep 24 21:33:45 2009 +0000
@@ -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);
+}



Home | Main Index | Thread Index | Old Index