Convert a couple of old regress tests to ATF.

Remove the regress/usr.bin/rtld/dlopen/dlopen.c test as well as it's
covered by existing ATF test(s).
This commit is contained in:
skrll 2010-12-14 05:57:31 +00:00
parent 16963047ea
commit be2356ad6f
11 changed files with 159 additions and 153 deletions

View File

@ -1,4 +1,4 @@
# $NetBSD: mi,v 1.172 2010/12/13 13:39:42 pooka Exp $
# $NetBSD: mi,v 1.173 2010/12/14 05:57:31 skrll Exp $
#
# Note: don't delete entries from here - mark them as "obsolete" instead.
#
@ -380,6 +380,10 @@
./usr/libdata/debug/usr/tests/lib/libutil/t_sockaddr_snprintf.debug tests-lib-debug debug,atf
./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/h_df_1_noopen1.debug tests-libexec-debug debug,atf
./usr/libdata/debug/usr/tests/libexec/ld.elf_so/h_df_1_noopen2.debug tests-libexec-debug debug,atf
./usr/libdata/debug/usr/tests/libexec/ld.elf_so/t_dlerror-cleared.debug tests-libexec-debug debug,atf
./usr/libdata/debug/usr/tests/libexec/ld.elf_so/t_dlerror-false.debug tests-libexec-debug debug,atf
./usr/libdata/debug/usr/tests/libexec/ld.elf_so/t_dlinfo.debug tests-libexec-debug debug,atf
./usr/libdata/debug/usr/tests/modules tests-sys-debug
./usr/libdata/debug/usr/tests/modules/t_builtin.debug tests-sys-debug debug,atf
@ -1609,6 +1613,11 @@
./usr/tests/libexec/Atffile tests-lib-tests atf
./usr/tests/libexec/ld.elf_so tests-libexec-tests
./usr/tests/libexec/ld.elf_so/Atffile tests-libexec-tests atf
./usr/tests/libexec/ld.elf_so/h_df_1_noopen1 tests-libexec-tests atf
./usr/tests/libexec/ld.elf_so/h_df_1_noopen2 tests-libexec-tests atf
./usr/tests/libexec/ld.elf_so/t_df_1_noopen tests-libexec-tests atf
./usr/tests/libexec/ld.elf_so/t_dlerror-cleared tests-libexec-tests atf
./usr/tests/libexec/ld.elf_so/t_dlerror-false tests-libexec-tests atf
./usr/tests/libexec/ld.elf_so/t_dlinfo tests-libexec-tests atf
./usr/tests/modules tests-sys-tests
./usr/tests/net tests-net-tests

View File

@ -1,10 +0,0 @@
# $NetBSD: Makefile,v 1.1 2002/11/14 21:10:46 nathanw Exp $
NOMAN= # defined
PROG= dlerror-cleared
regress:
./${PROG}
.include <bsd.prog.mk>

View File

@ -1,22 +0,0 @@
#include <stdio.h>
#include <dlfcn.h>
#include <err.h>
int main(void)
{
void *handle;
char *error;
/*
* Test that an error set by dlopen() persists past a successful
* dlopen() call.
*/
handle = dlopen("libnonexistent.so", RTLD_LAZY);
handle = dlopen("libm.so", RTLD_NOW);
error = dlerror();
if (error == NULL)
errx(1, "Failed: dlerror() was cleared by successful dlopen()\n");
printf("OK: %s\n", error);
return 0;
}

View File

@ -1,12 +0,0 @@
# $NetBSD: Makefile,v 1.1 2002/11/14 21:10:47 nathanw Exp $
NOMAN= # defined
PROG= dlerror-false
LDADD= -Wl,-rpath,/var/nonexistent/lib
regress:
./${PROG}
.include <bsd.prog.mk>

View File

@ -1,38 +0,0 @@
#include <stdio.h>
#include <dlfcn.h>
#include <err.h>
int main(void)
{
void *handle, *sym;
char *error;
/*
* Test for dlerror() being set by a successful library open.
* Requires that the rpath be set to something that does not
* include libm.so.
*/
handle = dlopen("libm.so", RTLD_LAZY);
error = dlerror();
if (error != NULL)
errx(1, "Error opening libm.so: %s", error);
if (handle == NULL)
errx(1, "Library handle is NULL but dlerror not set.");
sym = dlsym(handle, "sin");
error = dlerror();
if (error != NULL)
errx(1, "Error looking up sin(): %s", error);
if (sym == NULL)
errx(1, "Looked-up symbol is NULL but dlerror not set.");
dlclose(handle);
error = dlerror();
if (error != NULL)
errx(1, "Error calling dlclose(): %s", error);
printf("OK\n");
return 0;
}

View File

@ -1,19 +0,0 @@
# $NetBSD: Makefile,v 1.8 2003/06/26 18:43:35 drochner Exp $
NOMAN= # defined
PROG= dlopen
CLEANFILES+= dlopen.out
# we don't access program symbols from the shared object yet
#LDADD+= -export-dynamic
regress:
if [ -f ${TESTLIBDIR}/libtest.so ]; then \
./${PROG} ${TESTLIBDIR}/libtest.so >dlopen.out; \
tail +4 ${.CURDIR}/dlopen.exp | diff - dlopen.out; \
fi
.include <bsd.prog.mk>
TESTLIBDIR!= cd ${.CURDIR}/../testlib && ${PRINTOBJDIR}

View File

@ -1,44 +0,0 @@
/* $NetBSD: dlopen.c,v 1.4 2008/04/28 20:23:07 martin Exp $ */
/*-
* Copyright (c) 2000 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 <stdio.h>
#include <dlfcn.h>
int
main(int argc, char **argv)
{
void *p;
p = dlopen(argv[1], RTLD_LAZY);
if (p)
printf("OK\n");
else
printf("%s\n", dlerror());
return (0);
}

View File

@ -1,6 +0,0 @@
# $NetBSD: dlopen.exp,v 1.1 2000/12/08 19:22:51 drochner Exp $
# real output must start in line 4
constructor
OK
destructor

View File

@ -5,6 +5,8 @@
TESTSDIR= ${TESTSBASE}/libexec/ld.elf_so
TESTS_C+= t_dlinfo
TESTS_C+= t_dlerror-cleared t_dlerror-false t_dlinfo
LDADD.t_dlerror-false= -Wl,-rpath,/var/nonexistent/lib
.include <bsd.test.mk>

View File

@ -0,0 +1,67 @@
/* $NetBSD: t_dlerror-cleared.c,v 1.1 2010/12/14 05:57:32 skrll 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_dlerror_cleared);
ATF_TC_HEAD(rtld_dlerror_cleared, tc)
{
atf_tc_set_md_var(tc, "descr",
"error set by dlopen persists past a successful dlopen call");
}
ATF_TC_BODY(rtld_dlerror_cleared, tc)
{
void *handle;
char *error;
/*
* Test that an error set by dlopen() persists past a successful
* dlopen() call.
*/
handle = dlopen("libnonexistent.so", RTLD_LAZY);
ATF_CHECK(handle == NULL);
handle = dlopen("libm.so", RTLD_NOW);
ATF_CHECK(handle);
error = dlerror();
ATF_CHECK(error);
}
ATF_TP_ADD_TCS(tp)
{
ATF_TP_ADD_TC(tp, rtld_dlerror_cleared);
return 0;
}

View File

@ -0,0 +1,79 @@
/* $NetBSD: t_dlerror-false.c,v 1.1 2010/12/14 05:57:32 skrll 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_dlerror_false);
ATF_TC_HEAD(rtld_dlerror_false, tc)
{
atf_tc_set_md_var(tc, "descr",
"error set by dlopen persists past a successful dlopen call");
}
ATF_TC_BODY(rtld_dlerror_false, tc)
{
void *handle, *sym;
char *error;
/*
*
* Test for dlerror() being set by a successful library open.
* Requires that the rpath be set to something that does not
* include libm.so.
*/
handle = dlopen("libm.so", RTLD_LAZY);
error = dlerror();
ATF_CHECK(error == NULL);
ATF_CHECK(handle != NULL);
sym = dlsym(handle, "sin");
error = dlerror();
ATF_CHECK(sym != NULL);
ATF_CHECK(error == NULL);
dlclose(handle);
error = dlerror();
ATF_CHECK(error == NULL);
}
ATF_TP_ADD_TCS(tp)
{
ATF_TP_ADD_TC(tp, rtld_dlerror_false);
return atf_no_error();
}