Remove tests converted to ATF.

This commit is contained in:
jmmv 2010-07-16 13:59:07 +00:00
parent 64d9d4534b
commit 065d8f673d
19 changed files with 2 additions and 913 deletions

View File

@ -1,8 +1,8 @@
# $NetBSD: Makefile,v 1.22 2009/11/02 15:44:12 plunky Exp $
# $NetBSD: Makefile,v 1.23 2010/07/16 13:59:07 jmmv Exp $
.include <bsd.own.mk>
SUBDIR+= csu libc libm libposix libpthread librt libutil
SUBDIR+= csu libc libm libpthread
.if (${MACHINE_CPU} != "alpha" && \
${MACHINE_CPU} != "mips" && \
@ -10,10 +10,6 @@ SUBDIR+= csu libc libm libposix libpthread librt libutil
#SUBDIR+= libssp
.endif
.if (${MKSKEY} != "no")
SUBDIR+= libskey
.endif
.if ${MKCRYPTO} != "no"
SUBDIR+= libdes
.endif

View File

@ -1,5 +0,0 @@
# $NetBSD: Makefile,v 1.1 1999/02/21 00:20:11 mjl Exp $
SUBDIR= prn1 prn2 nrn
.include <bsd.subdir.mk>

View File

@ -1,4 +0,0 @@
# $NetBSD: Makefile.inc,v 1.1 1999/02/21 00:20:11 mjl Exp $
#
# do not install regression test programs
proginstall::

View File

@ -1,15 +0,0 @@
# $NetBSD: Makefile,v 1.4 2002/09/18 05:41:49 lukem Exp $
NOMAN= # defined
PROG= prename
CPPFLAGS+= -DBSD_RENAME
CLEANFILES+= t1 t2
.PATH: ${.CURDIR}/..
regress:
@echo Testing BSD rename
./prename
.include <bsd.prog.mk>

View File

@ -1,100 +0,0 @@
/* $NetBSD: prename.c,v 1.3 2008/04/28 20:23:05 martin Exp $ */
/*-
* Copyright (c) 2001 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 <stdlib.h>
#include <errno.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
int main(void)
{
int errors = 0;
struct stat sb;
(void)unlink("t1");
(void)unlink("t2");
if (creat("t1", 0600) < 0) {
perror("create t1");
exit(1);
}
if (link("t1", "t2")) {
perror("link t1 t2");
exit(1);
}
/* Check if rename to same name works as expected */
if (rename("t1", "t1")) {
perror("rename t1 t1");
errors++;
}
if (stat("t1", &sb)) {
perror("rename removed file? stat t1");
exit(1);
}
if (rename("t1", "t2")) {
perror("rename t1 t2");
errors++;
}
#if BSD_RENAME
/* check if rename of hardlinked file works the BSD way */
if (stat("t1", &sb)) {
if (errno != ENOENT) {
perror("BSD rename should remove file! stat t1");
errors++;
}
} else {
fprintf(stderr, "BSD rename should remove file!");
errors++;
}
#else
/* check if rename of hardlinked file works as the standard says */
if (stat("t1", &sb)) {
perror("Posix rename should not remove file! stat t1");
errors++;
}
#endif
/* check if we get the expected error */
/* this also exercises icky shared libraries goo */
if (rename("no/such/file/or/dir", "no/such/file/or/dir")) {
if (errno != ENOENT) {
perror("rename no/such/file/or/dir");
errors++;
}
} else {
fprintf(stderr, "No error renaming no/such/file/or/dir\n");
errors++;
}
exit(errors ? 1 : 0);
}

View File

@ -1,16 +0,0 @@
# $NetBSD: Makefile,v 1.4 2002/09/18 05:41:49 lukem Exp $
NOMAN= # defined
PROG= prename
CLEANFILES+= t1 t2
DPADD+= ${LIBPOSIX}
LDADD+= -lposix
.PATH: ${.CURDIR}/..
regress:
@echo Testing posix rename with -lposix
./prename
.include <bsd.prog.mk>

View File

@ -1,15 +0,0 @@
# $NetBSD: Makefile,v 1.4 2002/09/18 05:41:49 lukem Exp $
NOMAN= # defined
PROG= prename
CPPFLAGS+= -D_POSIX_SOURCE
CLEANFILES+= t1 t2
.PATH: ${.CURDIR}/..
regress:
@echo Testing posix rename with -D_POSIX_SOURCE
./prename
.include <bsd.prog.mk>

View File

@ -1,153 +0,0 @@
/* $NetBSD: proptest.c,v 1.3 2008/05/25 20:47:30 christos Exp $ */
/*
* Test basic proplib functionality.
*
* Written by Jason Thorpe 5/26/2006.
* Public domain.
*/
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <prop/proplib.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";
int
main(int argc, char *argv[])
{
prop_dictionary_t dict;
char *ext1;
size_t idx;
dict = prop_dictionary_create();
assert(dict != NULL);
{
prop_number_t num = prop_number_create_integer(1);
assert(num != NULL);
assert(prop_dictionary_set(dict, "one", num) == true);
prop_object_release(num);
}
{
prop_string_t str = prop_string_create_cstring("number-two");
assert(str != NULL);
assert(prop_dictionary_set(dict, "two", str) == true);
prop_object_release(str);
}
{
prop_array_t arr;
prop_dictionary_t dict_copy;
arr = prop_array_create();
assert(arr != NULL);
dict_copy = prop_dictionary_copy(dict);
assert(dict_copy != NULL);
assert(prop_array_add(arr, dict_copy) == true);
prop_object_release(dict_copy);
dict_copy = prop_dictionary_copy(dict);
assert(dict_copy != NULL);
assert(prop_array_add(arr, dict_copy) == true);
prop_object_release(dict_copy);
dict_copy = prop_dictionary_copy(dict);
assert(dict_copy != NULL);
assert(prop_array_add(arr, dict_copy) == true);
prop_object_release(dict_copy);
assert(prop_dictionary_set(dict, "three", arr) == true);
prop_object_release(arr);
}
{
prop_bool_t val = prop_bool_create(true);
assert(val != NULL);
assert(prop_dictionary_set(dict, "true-val", val) == true);
prop_object_release(val);
val = prop_bool_create(false);
assert(val != NULL);
assert(prop_dictionary_set(dict, "false-val", val) == true);
prop_object_release(val);
}
ext1 = prop_dictionary_externalize(dict);
assert(ext1 != NULL);
printf("REFERENCE:\n%s\n", compare1);
printf("GENERATED:\n%s\n", ext1);
for (idx = 0; idx < strlen(ext1); idx++) {
if (compare1[idx] != ext1[idx]) {
printf("Strings differ at byte %zu\n", idx);
printf("REFERENCE:\n%s\n", &compare1[idx]);
printf("GENERATED:\n%s\n", &ext1[idx]);
break;
}
}
assert(strlen(compare1) == strlen(ext1));
assert(strcmp(ext1, compare1) == 0);
{
prop_dictionary_t dict2;
char *ext2;
dict2 = prop_dictionary_internalize(ext1);
assert(dict2 != NULL);
ext2 = prop_dictionary_externalize(dict2);
assert(ext2 != NULL);
assert(strcmp(ext1, ext2) == 0);
prop_object_release(dict2);
free(ext2);
}
prop_object_release(dict);
free(ext1);
exit(0);
}

View File

@ -1,5 +0,0 @@
# $NetBSD: Makefile,v 1.1 2003/01/24 01:56:47 thorpej Exp $
SUBDIR+= sem
.include <bsd.subdir.mk>

View File

@ -1,13 +0,0 @@
# $NetBSD: Makefile,v 1.1 2003/01/24 01:56:48 thorpej Exp $
WARNS?=1
NOMAN= # defined
PROG= sem
LDADD+= -lrt
regress:
@echo Testing POSIX 1003.1b semaphores
./sem
.include <bsd.prog.mk>

View File

@ -1,179 +0,0 @@
/* $NetBSD: sem.c,v 1.3 2003/10/01 12:18:53 kleink Exp $ */
/*
* Copyright (C) 2000 Jason Evans <jasone@freebsd.org>.
* 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(s), this list of conditions and the following disclaimer as
* the first lines of this file unmodified other than the possible
* addition of one or more copyright notices.
* 2. Redistributions in binary form must reproduce the above copyright
* notice(s), 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 COPYRIGHT HOLDER(S) ``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 COPYRIGHT HOLDER(S) 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/wait.h>
#include <assert.h>
#include <stdio.h>
#include <err.h>
#include <fcntl.h>
#include <errno.h>
#include <semaphore.h>
#include <stdlib.h>
#include <unistd.h>
#define NCHILDREN 10
static void
child(sem_t *sem)
{
#ifdef DEBUG
printf("PID %d waiting for semaphore...\n", getpid());
#endif
if (sem_wait(sem))
err(1, "sem_wait");
#ifdef DEBUG
printf("PID %d got semaphore\n", getpid());
#endif
}
static sem_t *
create_sem(const char *name)
{
sem_t *sem;
(void)sem_unlink(name);
sem = sem_open(name, O_CREAT | O_EXCL, 0644, 0);
assert(sem != SEM_FAILED);
return (sem);
}
static void
delete_sem(sem_t *sem, const char *name)
{
assert(0 == sem_close(sem));
assert(0 == sem_unlink(name));
}
static void
dosem(void)
{
sem_t *sem_a, *sem_b;
pid_t children[NCHILDREN];
unsigned i;
int val, status;
pid_t pid;
assert(-1 != sysconf(_SC_SEMAPHORES));
sem_b = create_sem("/sem_b");
assert(0 == sem_getvalue(sem_b, &val));
assert(0 == val);
assert(0 == sem_post(sem_b));
assert(0 == sem_getvalue(sem_b, &val));
assert(1 == val);
assert(0 == sem_wait(sem_b));
assert(-1 == sem_trywait(sem_b));
assert(EAGAIN == errno);
assert(0 == sem_post(sem_b));
assert(0 == sem_trywait(sem_b));
assert(0 == sem_post(sem_b));
assert(0 == sem_wait(sem_b));
assert(0 == sem_post(sem_b));
delete_sem(sem_b, "/sem_b");
sem_a = create_sem("/sem_a");
for (i = 0; i < NCHILDREN; i++) {
switch ((pid = fork())) {
case -1:
abort();
case 0:
child(sem_a);
_exit(0);
default:
children[i] = pid;
break;
}
}
for (i = 0; i < NCHILDREN; i++) {
sleep(1);
#ifdef DEBUG
printf("main loop 1: posting...\n");
#endif
assert(0 == sem_post(sem_a));
}
for (i = 0; i < NCHILDREN; i++) {
assert(children[i] == waitpid(children[i], &status, 0));
assert(WIFEXITED(status));
assert(0 == WEXITSTATUS(status));
}
for (i = 0; i < NCHILDREN; i++) {
switch ((pid = fork())) {
case -1:
abort();
case 0:
child(sem_a);
_exit(0);
default:
children[i] = pid;
break;
}
}
for (i = 0; i < NCHILDREN; i++) {
sleep(1);
#ifdef DEBUG
printf("main loop 2: posting...\n");
#endif
assert(0 == sem_post(sem_a));
}
for (i = 0; i < NCHILDREN; i++) {
assert(children[i] == waitpid(children[i], &status, 0));
assert(WIFEXITED(status));
assert(0 == WEXITSTATUS(status));
}
delete_sem(sem_a, "/sem_a");
}
int
main(int argc, char *argv[])
{
#ifdef DEBUG
printf("Test begin\n");
#endif
dosem();
#ifdef DEBUG
printf("Test end\n");
#endif
return 0;
}

View File

@ -1,16 +0,0 @@
# $NetBSD: Makefile,v 1.5 2002/09/18 05:41:49 lukem Exp $
NOMAN= # defined
PROG= skeytest
DPADD+= ${LIBSKEY}
LDADD+= -lskey
.PATH: ${.CURDIR}/..
regress: skeytest
@echo Testing S/Key hash algorithms
./skeytest
.include <bsd.prog.mk>

View File

@ -1,112 +0,0 @@
/* $NetBSD: skeytest.c,v 1.4 2008/04/28 20:23:05 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.
*/
/* This is a regression test for the S/Key implementation
against the data set from Appendix C of RFC2289 */
#include <stdio.h>
#include <string.h>
#include "skey.h"
struct regRes {
char *algo, *zero, *one, *nine;
};
struct regPass {
char *passphrase, *seed;
struct regRes res[4];
} regPass[] = {
{ "This is a test.", "TeSt", {
{ "md4", "D1854218EBBB0B51", "63473EF01CD0B444", "C5E612776E6C237A" },
{ "md5", "9E876134D90499DD", "7965E05436F5029F", "50FE1962C4965880" },
{ "sha1","BB9E6AE1979D8FF4", "63D936639734385B", "87FEC7768B73CCF9" },
{ NULL } } },
{ "AbCdEfGhIjK", "alpha1", {
{ "md4", "50076F47EB1ADE4E", "65D20D1949B5F7AB", "D150C82CCE6F62D1" },
{ "md5", "87066DD9644BF206", "7CD34C1040ADD14B", "5AA37A81F212146C" },
{ "sha1","AD85F658EBE383C9", "D07CE229B5CF119B", "27BC71035AAF3DC6" },
{ NULL } } },
{ "OTP's are good", "correct", {
{ "md4", "849C79D4F6F55388", "8C0992FB250847B1", "3F3BF4B4145FD74B" },
{ "md5", "F205753943DE4CF9", "DDCDAC956F234937", "B203E28FA525BE47" },
{ "sha1","D51F3E99BF8E6F0B", "82AEB52D943774E4", "4F296A74FE1567EC" },
{ NULL } } },
{ NULL }
};
int main()
{
char data[16], prn[64];
struct regPass *rp;
int i = 0;
int errors = 0;
int j;
for(rp = regPass; rp->passphrase; rp++)
{
struct regRes *rr;
i++;
for(rr = rp->res; rr->algo; rr++)
{
skey_set_algorithm(rr->algo);
keycrunch(data, rp->seed, rp->passphrase);
btoa8(prn, data);
if(strcasecmp(prn, rr->zero))
{
errors++;
printf("Set %d, round 0, %s: Expected %s and got %s\n", i, rr->algo, rr->zero, prn);
}
f(data);
btoa8(prn, data);
if(strcasecmp(prn, rr->one))
{
errors++;
printf("Set %d, round 1, %s: Expected %s and got %s\n", i, rr->algo, rr->one, prn);
}
for(j=1; j<99; j++)
f(data);
btoa8(prn, data);
if(strcasecmp(prn, rr->nine))
{
errors++;
printf("Set %d, round 99, %s: Expected %s and got %s\n", i, rr->algo, rr->nine, prn);
}
}
}
printf("%d errors\n", errors);
return(errors ? 1 : 0);
}

View File

@ -1,5 +0,0 @@
# $NetBSD: Makefile,v 1.2 2004/11/19 21:38:25 christos Exp $
SUBDIR+= snprintb sockaddr_snprintf
.include <bsd.subdir.mk>

View File

@ -1,4 +0,0 @@
# $NetBSD: Makefile.inc,v 1.1 2002/09/20 21:13:29 christos Exp $
#
# do not install regression test programs
proginstall::

View File

@ -1,12 +0,0 @@
# $NetBSD: Makefile,v 1.1 2002/09/20 21:13:29 christos Exp $
PROG= snprintbtest
NOMAN= # defined
regress: ${PROG}
./${PROG}
DPADD+= ${LIBUTIL}
LDADD+= -lutil
.include <bsd.prog.mk>

View File

@ -1,71 +0,0 @@
/* $NetBSD: snprintbtest.c,v 1.3 2008/04/28 20:23:05 martin Exp $ */
/*-
* Copyright (c) 2002 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code was contributed to The NetBSD Foundation by Christos Zoulas.
*
* 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 <string.h>
#include <util.h>
#include <err.h>
struct {
const char *fmt;
uint64_t val;
const char *res;
} test[] = {
{
"\10\2BITTWO\1BITONE",
3,
"03<BITTWO,BITONE>"
},
{
"\177\20b\05NOTBOOT\0b\06FPP\0b\013SDVMA\0b\015VIDEO\0"
"b\020LORES\0b\021FPA\0b\022DIAG\0b\016CACHE\0"
"b\017IOCACHE\0b\022LOOPBACK\0b\04DBGCACHE\0",
0xe860,
"0xe860<NOTBOOT,FPP,SDVMA,VIDEO,CACHE,IOCACHE>"
}
};
int
main(int argc, char *argv[])
{
char buf[1024];
size_t i;
for (i = 0; i < sizeof(test) / sizeof(test[0]); i++) {
int len = snprintb(buf, sizeof(buf), test[i].fmt, test[i].val);
int slen = (int)strlen(test[i].res);
if (strcmp(test[i].res, buf) != 0)
errx(1, "Unexpected result `%s' != `%s'\n",
buf, test[i].res);
if (len != slen)
errx(1, "Unexpected len in result %d != %d\n",
len, slen);
}
return 0;
}

View File

@ -1,19 +0,0 @@
# $NetBSD: Makefile,v 1.2 2005/01/10 02:58:58 lukem Exp $
NOMAN= # defined
.include <bsd.own.mk>
PROG= sockaddr_snprintf
.if (${USE_INET6} != "no")
CPPFLAGS+= -DINET6
.endif
regress: ${PROG}
./${PROG}
DPADD+= ${LIBUTIL}
LDADD+= -lutil
.include <bsd.prog.mk>

View File

@ -1,163 +0,0 @@
/* $NetBSD: sockaddr_snprintf.c,v 1.4 2008/04/28 20:23:05 martin Exp $ */
/*-
* Copyright (c) 2004 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code was contributed to The NetBSD Foundation by Christos Zoulas.
*
* 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 <string.h>
#include <util.h>
#include <sys/socket.h> /* AF_ */
#include <netinet/in.h> /* sin/sin6 */
#include <sys/un.h> /* sun */
#include <netatalk/at.h> /* sat */
#include <net/if_dl.h> /* sdl */
static void
in(void)
{
char buf[1024];
int i;
struct sockaddr_in sin4;
const char *res;
(void)memset(&sin4, 0, sizeof(sin4));
sin4.sin_len = sizeof(sin4);
sin4.sin_family = AF_INET;
sin4.sin_port = ntohs(80);
sin4.sin_addr.s_addr = ntohl(INADDR_LOOPBACK);
i = sockaddr_snprintf(buf, sizeof(buf), "%f %l %p %a",
(struct sockaddr *)&sin4);
if (i != 17)
errx(1, "bad length for sin4 %d != %d", i, 17);
if (strcmp(res = "2 16 80 127.0.0.1", buf) != 0)
errx(1, "res='%s' != '%s'", buf, res);
}
#ifdef INET6
static void
in6(void)
{
char buf[1024];
int i;
struct sockaddr_in6 sin6;
const char *res;
(void)memset(&sin6, 0, sizeof(sin6));
sin6.sin6_len = sizeof(sin6);
sin6.sin6_family = AF_INET6;
sin6.sin6_port = ntohs(80);
sin6.sin6_addr = in6addr_nodelocal_allnodes;
i = sockaddr_snprintf(buf, sizeof(buf), "%f %l %p %a",
(struct sockaddr *)&sin6);
if (i != 16)
errx(1, "bad length for sin6 %d != %d", i, 16);
if (strcmp(res = "24 28 80 ff01::1", buf) != 0)
errx(1, "res='%s' != '%s'", buf, res);
}
#endif /* INET6 */
static void
un(void)
{
char buf[1024];
int i;
struct sockaddr_un sun;
const char *res;
(void)memset(&sun, 0, sizeof(sun));
sun.sun_len = sizeof(sun);
sun.sun_family = AF_UNIX;
(void)strncpy(sun.sun_path, "/tmp/sock", sizeof(sun.sun_path));
i = sockaddr_snprintf(buf, sizeof(buf), "%f %l %a",
(struct sockaddr *)&sun);
if (i != 15)
errx(1, "bad length for sun %d != %d", i, 15);
if (strcmp(res = "1 106 /tmp/sock", buf) != 0)
errx(1, "res='%s' != '%s'", buf, res);
}
static void
at(void)
{
char buf[1024];
int i;
struct sockaddr_at sat;
const char *res;
(void)memset(&sat, 0, sizeof(sat));
sat.sat_len = sizeof(sat);
sat.sat_family = AF_APPLETALK;
sat.sat_addr.s_net = ntohs(101);
sat.sat_addr.s_node = 3;
i = sockaddr_snprintf(buf, sizeof(buf), "%f %l %a",
(struct sockaddr *)&sat);
if (i != 11)
errx(1, "bad length for sat %d != %d", i, 11);
if (strcmp(res = "16 16 101.3", buf) != 0)
errx(1, "res='%s' != '%s'", buf, res);
}
static void
dl(void)
{
char buf[1024];
int i;
struct sockaddr_dl sdl;
const char *res;
(void)memset(&sdl, 0, sizeof(sdl));
sdl.sdl_len = sizeof(sdl);
sdl.sdl_family = AF_LINK;
sdl.sdl_index = 0;
sdl.sdl_type = 0;
sdl.sdl_nlen = 0;
sdl.sdl_alen = 6;
sdl.sdl_slen = 0;
(void)memcpy(sdl.sdl_data, "\01\02\03\04\05\06", 6);
i = sockaddr_snprintf(buf, sizeof(buf), "%f %l %a",
(struct sockaddr *)&sdl);
if (i != 17)
errx(1, "bad length for sdl %d != %d", i, 17);
if (strcmp(res = "18 20 1.2.3.4.5.6", buf) != 0)
errx(1, "res='%s' != '%s'", buf, res);
}
int
main(int argc, char *argv[])
{
in();
#ifdef INET6
in6();
#endif
un();
at();
dl();
return 0;
}