Index: head/etc/mtree/BSD.tests.dist =================================================================== --- head/etc/mtree/BSD.tests.dist (revision 292316) +++ head/etc/mtree/BSD.tests.dist (revision 292317) @@ -1,620 +1,622 @@ # $FreeBSD$ # # Please see the file src/etc/mtree/README before making changes to this file. # /set type=dir uname=root gname=wheel mode=0755 . bin cat .. chown .. date .. dd .. expr .. ls .. mv .. pax .. pkill .. sh builtins .. errors .. execution .. expansion .. parameters .. parser .. set-e .. .. sleep .. test .. .. cddl lib .. sbin .. usr.bin .. usr.sbin dtrace common aggs .. arithmetic .. arrays .. assocs .. begin .. bitfields .. buffering .. builtinvar .. cg .. clauses .. cpc .. decls .. drops .. dtraceUtil .. end .. enum .. error .. exit .. fbtprovider .. funcs .. grammar .. include .. inline .. io .. ip .. java_api .. json .. lexer .. llquantize .. mdb .. mib .. misc .. multiaggs .. offsetof .. operators .. pid .. plockstat .. pointers .. pragma .. predicates .. preprocessor .. print .. printa .. printf .. privs .. probes .. proc .. profile-n .. providers .. raise .. rates .. safety .. scalars .. sched .. scripting .. sdt .. sizeof .. speculation .. stability .. stack .. stackdepth .. stop .. strlen .. strtoll .. struct .. syscall .. sysevent .. tick-n .. trace .. tracemem .. translators .. typedef .. types .. uctf .. union .. usdt .. ustack .. vars .. version .. .. .. .. .. etc rc.d .. .. games .. gnu lib .. usr.bin diff .. .. .. lib atf libatf-c detail .. .. libatf-c++ detail .. .. test-programs .. .. libarchive .. libc c063 .. db .. gen execve .. posix_spawn .. .. hash data .. .. inet .. locale .. net getaddrinfo data .. .. .. regex data .. .. + resolv + .. rpc .. ssp .. stdio .. stdlib .. string .. sys .. time .. tls dso .. .. termios .. ttyio .. .. libcrypt .. libmp .. libnv .. libpam .. libproc .. librt .. libthr dlopen .. .. libutil .. libxo .. msun .. .. libexec atf atf-check .. atf-sh .. .. rtld-elf .. .. sbin dhclient .. devd .. growfs .. ifconfig .. mdconfig .. .. secure lib .. libexec .. usr.bin .. usr.sbin .. .. share examples tests atf .. plain .. .. .. .. sys acl .. aio .. fifo .. file .. kern acct .. execve .. pipe .. .. kqueue .. mqueue .. netinet .. opencrypto .. pjdfstest chflags .. chmod .. chown .. ftruncate .. granular .. link .. mkdir .. mkfifo .. mknod .. open .. rename .. rmdir .. symlink .. truncate .. unlink .. .. posixshm .. vfs .. vm .. .. usr.bin apply .. basename .. bmake archives fmt_44bsd .. fmt_44bsd_mod .. fmt_oldbsd .. .. basic t0 .. t1 .. t2 .. t3 .. .. execution ellipsis .. empty .. joberr .. plus .. .. shell builtin .. meta .. path .. path_select .. replace .. select .. .. suffixes basic .. src_wild1 .. src_wild2 .. .. syntax directive-t0 .. enl .. funny-targets .. semi .. .. sysmk t0 2 1 .. .. mk .. .. t1 2 1 .. .. mk .. .. t2 2 1 .. .. mk .. .. .. variables modifier_M .. modifier_t .. opt_V .. t0 .. .. .. calendar .. cmp .. cpio .. col .. comm .. cut .. dirname .. file2c .. grep .. gzip .. ident .. join .. jot .. lastcomm .. limits .. m4 .. mkimg .. ncal .. opensm .. printf .. sed regress.multitest.out .. .. soelim .. tar .. timeout .. tr .. truncate .. units .. uudecode .. uuencode .. xargs .. xo .. yacc yacc .. .. .. usr.sbin etcupdate .. fstyp .. makefs .. newsyslog .. nmtree .. pw .. sa .. .. .. # vim: set expandtab ts=4 sw=4: Index: head/lib/libc/tests/Makefile =================================================================== --- head/lib/libc/tests/Makefile (revision 292316) +++ head/lib/libc/tests/Makefile (revision 292317) @@ -1,31 +1,32 @@ # $FreeBSD$ .include SUBDIR= tls_dso TESTS_SUBDIRS= c063 TESTS_SUBDIRS+= db TESTS_SUBDIRS+= gen TESTS_SUBDIRS+= hash TESTS_SUBDIRS+= inet TESTS_SUBDIRS+= net TESTS_SUBDIRS+= regex +TESTS_SUBDIRS+= resolv TESTS_SUBDIRS+= rpc TESTS_SUBDIRS+= stdio TESTS_SUBDIRS+= stdlib TESTS_SUBDIRS+= string TESTS_SUBDIRS+= sys TESTS_SUBDIRS+= termios TESTS_SUBDIRS+= tls TESTS_SUBDIRS+= ttyio .if ${MK_LOCALES} != "no" TESTS_SUBDIRS+= locale .endif .if ${MK_SSP} != "no" TESTS_SUBDIRS+= ssp .endif .include Index: head/lib/libc/tests/resolv/mach =================================================================== --- head/lib/libc/tests/resolv/mach (nonexistent) +++ head/lib/libc/tests/resolv/mach (revision 292317) @@ -0,0 +1,46 @@ +# $FreeBSD$ +localhost +anoncvs.cirr.com +anoncvs.netbsd.se +antioche.antioche.eu.org +centaurus.4web.cz +chur.math.ntnu.no +console.netbsd.org +cvs.netbsd.org +cvsup.netbsd.se +ftp.chg.ru +ftp.estpak.ee +ftp.fsn.hu +ftp.funet.fi +ftp.netbsd.org +ftp.nluug.nl +ftp.plig.org +ftp.uni-erlangen.de +ftp.xgate.co.kr +gd.tuwien.ac.at +gort.ludd.luth.se +irc.warped.net +knug.youn.co.kr +mail.jp.netbsd.org +mail.netbsd.org +melanoma.cs.rmit.edu.au +mirror.aarnet.edu.au +moon.vub.ac.be +net.bsd.cz +netbsd.3miasto.net +netbsd.4ka.mipt.ru +netbsd.csie.nctu.edu.tw +netbsd.enderunix.org +netbsd.ftp.fu-berlin.de +netbsd.pair.com +netbsdiso.interoute.net.uk +netbsdwww.cs.rmit.edu.au +netbsdwww.interoute.net.uk +ns.netbsd.org +skeleton.phys.spbu.ru +www.en.netbsd.de +www.netbsd.cl +www.netbsd.nl +www.netbsd.org +www.netbsd.ro +zeppo.rediris.es Property changes on: head/lib/libc/tests/resolv/mach ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: head/lib/libc/tests/resolv/resolv_test.c =================================================================== --- head/lib/libc/tests/resolv/resolv_test.c (nonexistent) +++ head/lib/libc/tests/resolv/resolv_test.c (revision 292317) @@ -0,0 +1,321 @@ +/* $NetBSD: resolv.c,v 1.6 2004/05/23 16:59:11 christos Exp $ */ + +/*- + * Copyright (c) 2004 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software 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. + */ +/* $FreeBSD$ */ +#include +__RCSID("$NetBSD: resolv.c,v 1.6 2004/05/23 16:59:11 christos Exp $"); + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#define NTHREADS 10 +#define NHOSTS 100 +#define WS " \t\n\r" + +enum method { + METHOD_GETADDRINFO, + METHOD_GETHOSTBY, + METHOD_GETIPNODEBY +}; + +static StringList *hosts = NULL; +static enum method method = METHOD_GETADDRINFO; +static int *ask = NULL; +static int *got = NULL; + +static void load(const char *); +static void resolvone(int); +static void *resolvloop(void *); +static void run(int *); + +static pthread_mutex_t stats = PTHREAD_MUTEX_INITIALIZER; + +static void +load(const char *fname) +{ + FILE *fp; + size_t len; + char *line; + + if ((fp = fopen(fname, "r")) == NULL) + ATF_REQUIRE(fp != NULL); + while ((line = fgetln(fp, &len)) != NULL) { + char c = line[len]; + char *ptr; + line[len] = '\0'; + for (ptr = strtok(line, WS); ptr; ptr = strtok(NULL, WS)) { + if (ptr == '\0' || ptr[0] == '#') + continue; + sl_add(hosts, strdup(ptr)); + } + line[len] = c; + } + + (void)fclose(fp); +} + +static int +resolv_getaddrinfo(pthread_t self, char *host, int port) +{ + char portstr[6], buf[1024], hbuf[NI_MAXHOST], pbuf[NI_MAXSERV]; + struct addrinfo hints, *res; + int error, len; + + snprintf(portstr, sizeof(portstr), "%d", port); + memset(&hints, 0, sizeof(hints)); + hints.ai_family = AF_UNSPEC; + hints.ai_flags = AI_PASSIVE; + hints.ai_socktype = SOCK_STREAM; + error = getaddrinfo(host, portstr, &hints, &res); + len = snprintf(buf, sizeof(buf), "%p: host %s %s\n", + self, host, error ? "not found" : "ok"); + (void)write(STDOUT_FILENO, buf, len); + if (error == 0) { + memset(hbuf, 0, sizeof(hbuf)); + memset(pbuf, 0, sizeof(pbuf)); + getnameinfo(res->ai_addr, res->ai_addrlen, hbuf, sizeof(hbuf), + pbuf, sizeof(pbuf), 0); + len = snprintf(buf, sizeof(buf), + "%p: reverse %s %s\n", self, hbuf, pbuf); + (void)write(STDOUT_FILENO, buf, len); + } + if (error == 0) + freeaddrinfo(res); + return error; +} + +static int +resolv_gethostby(pthread_t self, char *host) +{ + char buf[1024]; + struct hostent *hp, *hp2; + int len; + + hp = gethostbyname(host); + len = snprintf(buf, sizeof(buf), "%p: host %s %s\n", + self, host, (hp == NULL) ? "not found" : "ok"); + (void)write(STDOUT_FILENO, buf, len); + if (hp) { + memcpy(buf, hp->h_addr, hp->h_length); + hp2 = gethostbyaddr(buf, hp->h_length, hp->h_addrtype); + if (hp2) { + len = snprintf(buf, sizeof(buf), + "%p: reverse %s\n", self, hp2->h_name); + (void)write(STDOUT_FILENO, buf, len); + } + } + return hp ? 0 : -1; +} + +static int +resolv_getipnodeby(pthread_t self, char *host) +{ + char buf[1024]; + struct hostent *hp, *hp2; + int len, h_error; + + hp = getipnodebyname(host, AF_INET, 0, &h_error); + len = snprintf(buf, sizeof(buf), "%p: host %s %s\n", + self, host, (hp == NULL) ? "not found" : "ok"); + (void)write(STDOUT_FILENO, buf, len); + if (hp) { + memcpy(buf, hp->h_addr, hp->h_length); + hp2 = getipnodebyaddr(buf, hp->h_length, hp->h_addrtype, + &h_error); + if (hp2) { + len = snprintf(buf, sizeof(buf), + "%p: reverse %s\n", self, hp2->h_name); + (void)write(STDOUT_FILENO, buf, len); + } + if (hp2) + freehostent(hp2); + } + if (hp) + freehostent(hp); + return hp ? 0 : -1; +} + +static void +resolvone(int n) +{ + char buf[1024]; + pthread_t self = pthread_self(); + size_t i = (random() & 0x0fffffff) % hosts->sl_cur; + char *host = hosts->sl_str[i]; + struct addrinfo hints, *res; + int error, len; + + len = snprintf(buf, sizeof(buf), "%p: %d resolving %s %d\n", + self, n, host, (int)i); + (void)write(STDOUT_FILENO, buf, len); + switch (method) { + case METHOD_GETADDRINFO: + error = resolv_getaddrinfo(self, host, i); + break; + case METHOD_GETHOSTBY: + error = resolv_gethostby(self, host); + break; + case METHOD_GETIPNODEBY: + error = resolv_getipnodeby(self, host); + break; + default: + break; + } + pthread_mutex_lock(&stats); + ask[i]++; + got[i] += error == 0; + pthread_mutex_unlock(&stats); +} + +static void * +resolvloop(void *p) +{ + int *nhosts = (int *)p; + if (*nhosts == 0) + return NULL; + do + resolvone(*nhosts); + while (--(*nhosts)); + return NULL; +} + +static void +run(int *nhosts) +{ + pthread_t self; + int rc; + + self = pthread_self(); + rc = pthread_create(&self, NULL, resolvloop, nhosts); + ATF_REQUIRE_MSG(rc == 0, "pthread_create failed: %s", strerror(rc)); +} + +static int +run_tests(const char *hostlist_file, enum method method) +{ + int nthreads = NTHREADS; + int nhosts = NHOSTS; + int i, c, done, *nleft; + hosts = sl_init(); + + srandom(1234); + + load(hostlist_file); + + ATF_REQUIRE_MSG(0 < hosts->sl_cur, "0 hosts in %s", hostlist_file); + + nleft = malloc(nthreads * sizeof(int)); + ATF_REQUIRE(nleft != NULL); + + ask = calloc(hosts->sl_cur, sizeof(int)); + ATF_REQUIRE(ask != NULL); + + got = calloc(hosts->sl_cur, sizeof(int)); + ATF_REQUIRE(got != NULL); + + for (i = 0; i < nthreads; i++) { + nleft[i] = nhosts; + run(&nleft[i]); + } + + for (done = 0; !done;) { + done = 1; + for (i = 0; i < nthreads; i++) { + if (nleft[i] != 0) { + done = 0; + break; + } + } + sleep(1); + } + c = 0; + for (i = 0; i < hosts->sl_cur; i++) { + if (ask[i] != got[i] && got[i] != 0) { + printf("Error: host %s ask %d got %d\n", + hosts->sl_str[i], ask[i], got[i]); + c++; + } + } + free(nleft); + free(ask); + free(got); + sl_free(hosts, 1); + return c; +} + +#define HOSTLIST_FILE "mach" + +#define RUN_TESTS(tc, method) \ +do { \ + char *_hostlist_file; \ + ATF_REQUIRE(0 < asprintf(&_hostlist_file, "%s/%s", \ + atf_tc_get_config_var(tc, "srcdir"), HOSTLIST_FILE)); \ + ATF_REQUIRE(run_tests(_hostlist_file, method) == 0); \ +} while(0) + +ATF_TC_WITHOUT_HEAD(getaddrinfo_test); +ATF_TC_BODY(getaddrinfo_test, tc) +{ + + RUN_TESTS(tc, METHOD_GETADDRINFO); +} + +ATF_TC_WITHOUT_HEAD(gethostby_test); +ATF_TC_BODY(gethostby_test, tc) +{ + + RUN_TESTS(tc, METHOD_GETHOSTBY); +} + +ATF_TC_WITHOUT_HEAD(getipnodeby_test); +ATF_TC_BODY(getipnodeby_test, tc) +{ + + RUN_TESTS(tc, METHOD_GETIPNODEBY); +} + +ATF_TP_ADD_TCS(tp) +{ + + ATF_TP_ADD_TC(tp, getaddrinfo_test); + ATF_TP_ADD_TC(tp, gethostby_test); + ATF_TP_ADD_TC(tp, getipnodeby_test); + + return (atf_no_error()); +} Property changes on: head/lib/libc/tests/resolv/resolv_test.c ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: head/tools/regression/lib/libc/resolv/Makefile =================================================================== --- head/tools/regression/lib/libc/resolv/Makefile (revision 292316) +++ head/tools/regression/lib/libc/resolv/Makefile (nonexistent) @@ -1,14 +0,0 @@ -# $NetBSD: Makefile,v 1.1 2004/05/13 19:17:12 christos Exp $ -# $FreeBSD$ - -PROG= resolv -MAN= - -# Note: this test relies on being dynamically linked. You will get a -# spurious PASS for a statically linked test. -LIBADD+= pthread - -regress: ${PROG} - ./${PROG} -r ${.CURDIR}/mach - -.include Property changes on: head/tools/regression/lib/libc/resolv/Makefile ___________________________________________________________________ Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Index: head/tools/regression/lib/libc/resolv/mach =================================================================== --- head/tools/regression/lib/libc/resolv/mach (revision 292316) +++ head/tools/regression/lib/libc/resolv/mach (nonexistent) @@ -1,46 +0,0 @@ -# $FreeBSD$ -localhost -anoncvs.cirr.com -anoncvs.netbsd.se -antioche.antioche.eu.org -centaurus.4web.cz -chur.math.ntnu.no -console.netbsd.org -cvs.netbsd.org -cvsup.netbsd.se -ftp.chg.ru -ftp.estpak.ee -ftp.fsn.hu -ftp.funet.fi -ftp.netbsd.org -ftp.nluug.nl -ftp.plig.org -ftp.uni-erlangen.de -ftp.xgate.co.kr -gd.tuwien.ac.at -gort.ludd.luth.se -irc.warped.net -knug.youn.co.kr -mail.jp.netbsd.org -mail.netbsd.org -melanoma.cs.rmit.edu.au -mirror.aarnet.edu.au -moon.vub.ac.be -net.bsd.cz -netbsd.3miasto.net -netbsd.4ka.mipt.ru -netbsd.csie.nctu.edu.tw -netbsd.enderunix.org -netbsd.ftp.fu-berlin.de -netbsd.pair.com -netbsdiso.interoute.net.uk -netbsdwww.cs.rmit.edu.au -netbsdwww.interoute.net.uk -ns.netbsd.org -skeleton.phys.spbu.ru -www.en.netbsd.de -www.netbsd.cl -www.netbsd.nl -www.netbsd.org -www.netbsd.ro -zeppo.rediris.es Property changes on: head/tools/regression/lib/libc/resolv/mach ___________________________________________________________________ Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Index: head/tools/regression/lib/libc/resolv/resolv.c =================================================================== --- head/tools/regression/lib/libc/resolv/resolv.c (revision 292316) +++ head/tools/regression/lib/libc/resolv/resolv.c (nonexistent) @@ -1,326 +0,0 @@ -/* $NetBSD: resolv.c,v 1.6 2004/05/23 16:59:11 christos Exp $ */ - -/*- - * Copyright (c) 2004 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software 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. - */ -/* $FreeBSD$ */ -#include -__RCSID("$NetBSD: resolv.c,v 1.6 2004/05/23 16:59:11 christos Exp $"); - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define NTHREADS 10 -#define NHOSTS 100 -#define WS " \t\n\r" - -enum method { - METHOD_GETADDRINFO, - METHOD_GETHOSTBY, - METHOD_GETIPNODEBY -}; - -static StringList *hosts = NULL; -static int debug = 0; -static enum method method = METHOD_GETADDRINFO; -static int reverse = 0; -static int *ask = NULL; -static int *got = NULL; - -static void usage(void) __attribute__((__noreturn__)); -static void load(const char *); -static void resolvone(int); -static void *resolvloop(void *); -static void run(int *); - -static pthread_mutex_t stats = PTHREAD_MUTEX_INITIALIZER; - -static void -usage(void) -{ - (void)fprintf(stderr, - "Usage: %s [-AdHIr] [-h ] [-n ] ...\n", - getprogname()); - exit(1); -} - -static void -load(const char *fname) -{ - FILE *fp; - size_t len; - char *line; - - if ((fp = fopen(fname, "r")) == NULL) - err(1, "Cannot open `%s'", fname); - while ((line = fgetln(fp, &len)) != NULL) { - char c = line[len]; - char *ptr; - line[len] = '\0'; - for (ptr = strtok(line, WS); ptr; ptr = strtok(NULL, WS)) { - if (ptr == '\0' || ptr[0] == '#') - continue; - sl_add(hosts, strdup(ptr)); - } - line[len] = c; - } - - (void)fclose(fp); -} - -static int -resolv_getaddrinfo(pthread_t self, char *host, int port) -{ - char portstr[6], buf[1024], hbuf[NI_MAXHOST], pbuf[NI_MAXSERV]; - struct addrinfo hints, *res; - int error, len; - - snprintf(portstr, sizeof(portstr), "%d", port); - memset(&hints, 0, sizeof(hints)); - hints.ai_family = AF_UNSPEC; - hints.ai_flags = AI_PASSIVE; - hints.ai_socktype = SOCK_STREAM; - error = getaddrinfo(host, portstr, &hints, &res); - if (debug) { - len = snprintf(buf, sizeof(buf), "%p: host %s %s\n", - self, host, error ? "not found" : "ok"); - (void)write(STDOUT_FILENO, buf, len); - } - if (error == 0 && reverse) { - memset(hbuf, 0, sizeof(hbuf)); - memset(pbuf, 0, sizeof(pbuf)); - getnameinfo(res->ai_addr, res->ai_addrlen, hbuf, sizeof(hbuf), - pbuf, sizeof(pbuf), 0); - if (debug) { - len = snprintf(buf, sizeof(buf), - "%p: reverse %s %s\n", self, hbuf, pbuf); - (void)write(STDOUT_FILENO, buf, len); - } - } - if (error == 0) - freeaddrinfo(res); - return error; -} - -static int -resolv_gethostby(pthread_t self, char *host) -{ - char buf[1024]; - struct hostent *hp, *hp2; - int len; - - hp = gethostbyname(host); - if (debug) { - len = snprintf(buf, sizeof(buf), "%p: host %s %s\n", - self, host, (hp == NULL) ? "not found" : "ok"); - (void)write(STDOUT_FILENO, buf, len); - } - if (hp && reverse) { - memcpy(buf, hp->h_addr, hp->h_length); - hp2 = gethostbyaddr(buf, hp->h_length, hp->h_addrtype); - if (hp2 && debug) { - len = snprintf(buf, sizeof(buf), - "%p: reverse %s\n", self, hp2->h_name); - (void)write(STDOUT_FILENO, buf, len); - } - } - return hp ? 0 : -1; -} - -static int -resolv_getipnodeby(pthread_t self, char *host) -{ - char buf[1024]; - struct hostent *hp, *hp2; - int len, h_error; - - hp = getipnodebyname(host, AF_INET, 0, &h_error); - if (debug) { - len = snprintf(buf, sizeof(buf), "%p: host %s %s\n", - self, host, (hp == NULL) ? "not found" : "ok"); - (void)write(STDOUT_FILENO, buf, len); - } - if (hp && reverse) { - memcpy(buf, hp->h_addr, hp->h_length); - hp2 = getipnodebyaddr(buf, hp->h_length, hp->h_addrtype, - &h_error); - if (hp2 && debug) { - len = snprintf(buf, sizeof(buf), - "%p: reverse %s\n", self, hp2->h_name); - (void)write(STDOUT_FILENO, buf, len); - } - if (hp2) - freehostent(hp2); - } - if (hp) - freehostent(hp); - return hp ? 0 : -1; -} - -static void -resolvone(int n) -{ - char buf[1024]; - pthread_t self = pthread_self(); - size_t i = (random() & 0x0fffffff) % hosts->sl_cur; - char *host = hosts->sl_str[i]; - struct addrinfo hints, *res; - int error, len; - - if (debug) { - len = snprintf(buf, sizeof(buf), "%p: %d resolving %s %d\n", - self, n, host, (int)i); - (void)write(STDOUT_FILENO, buf, len); - } - switch (method) { - case METHOD_GETADDRINFO: - error = resolv_getaddrinfo(self, host, i); - break; - case METHOD_GETHOSTBY: - error = resolv_gethostby(self, host); - break; - case METHOD_GETIPNODEBY: - error = resolv_getipnodeby(self, host); - break; - default: - break; - } - pthread_mutex_lock(&stats); - ask[i]++; - got[i] += error == 0; - pthread_mutex_unlock(&stats); -} - -static void * -resolvloop(void *p) -{ - int *nhosts = (int *)p; - if (*nhosts == 0) - return NULL; - do - resolvone(*nhosts); - while (--(*nhosts)); - return NULL; -} - -static void -run(int *nhosts) -{ - pthread_t self = pthread_self(); - if (pthread_create(&self, NULL, resolvloop, nhosts) != 0) - err(1, "pthread_create"); -} - -int -main(int argc, char *argv[]) -{ - int nthreads = NTHREADS; - int nhosts = NHOSTS; - int i, c, done, *nleft; - hosts = sl_init(); - - srandom(1234); - - while ((c = getopt(argc, argv, "Adh:HIn:r")) != -1) - switch (c) { - case 'A': - method = METHOD_GETADDRINFO; - break; - case 'd': - debug++; - break; - case 'h': - nhosts = atoi(optarg); - break; - case 'H': - method = METHOD_GETHOSTBY; - break; - case 'I': - method = METHOD_GETIPNODEBY; - break; - case 'n': - nthreads = atoi(optarg); - break; - case 'r': - reverse++; - break; - default: - usage(); - } - - for (i = optind; i < argc; i++) - load(argv[i]); - - if (hosts->sl_cur == 0) - usage(); - - if ((nleft = malloc(nthreads * sizeof(int))) == NULL) - err(1, "malloc"); - if ((ask = calloc(hosts->sl_cur, sizeof(int))) == NULL) - err(1, "calloc"); - if ((got = calloc(hosts->sl_cur, sizeof(int))) == NULL) - err(1, "calloc"); - - - for (i = 0; i < nthreads; i++) { - nleft[i] = nhosts; - run(&nleft[i]); - } - - for (done = 0; !done;) { - done = 1; - for (i = 0; i < nthreads; i++) { - if (nleft[i] != 0) { - done = 0; - break; - } - } - sleep(1); - } - c = 0; - for (i = 0; i < hosts->sl_cur; i++) { - if (ask[i] != got[i] && got[i] != 0) { - warnx("Error: host %s ask %d got %d\n", - hosts->sl_str[i], ask[i], got[i]); - c++; - } - } - free(nleft); - free(ask); - free(got); - sl_free(hosts, 1); - return c; -} Property changes on: head/tools/regression/lib/libc/resolv/resolv.c ___________________________________________________________________ Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Index: head/tools/regression/lib/libc/resolv/resolv.t =================================================================== --- head/tools/regression/lib/libc/resolv/resolv.t (revision 292316) +++ head/tools/regression/lib/libc/resolv/resolv.t (nonexistent) @@ -1,24 +0,0 @@ -#!/bin/sh -# $FreeBSD$ - -do_test() { - number=$1 - comment=$2 - opt=$3 - if ./$executable $opt; then - echo "ok $number - $comment" - else - echo "not ok $number - $comment" - fi -} - -cd `dirname $0` - -executable=`basename $0 .t` - -make $executable 2>&1 > /dev/null - -echo 1..3 -do_test 1 'getaddrinfo()' '-r mach' -do_test 2 'gethostbyname()' '-rH mach' -do_test 3 'getipnodebyname()' '-rI mach' Property changes on: head/tools/regression/lib/libc/resolv/resolv.t ___________________________________________________________________ Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property