From patchwork Wed Mar 4 23:59:02 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roland McGrath X-Patchwork-Id: 446512 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 261FE1400B6 for ; Thu, 5 Mar 2015 10:59:12 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass reason="1024-bit key; unprotected key" header.d=sourceware.org header.i=@sourceware.org header.b=K81Zs3i4; dkim-adsp=none (unprotected policy); dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:mime-version:content-type :content-transfer-encoding:from:to:subject:message-id:date; q= dns; s=default; b=X7fi6adpH6ecsr04/ZtiqcmRscVMW6VbEhkGxAL8FR+G+M tc/OeP9ZQriNActVshtlq0V9zsNH5kxS76YrNkcL0pXX2N/KIw6fOEN5kNnlnx9s +1aSCoSjIE0eUno6LQraKK7nGRqT82J9IZ5sFkViW5+NZb2sV9v9fUbPGuAVw= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:mime-version:content-type :content-transfer-encoding:from:to:subject:message-id:date; s= default; bh=lfBMIGs5pSYX9IIrVLX4jH7KtMM=; b=K81Zs3i4YFnghgtBRiLK fT77He82FTvYyWyN69y5IKTNLa5nfB6fPGXX41iqpHxyZgdG8Ue+y5Q8/HbZXAY0 /nBcwFGiur2xo4YgLr642+qHoBbE0fnHE0r0P8ARuIf7+KFh7n+F9QuWCnBb4Xri WThFKIxgy3FWXxuPkQXuP1Q= Received: (qmail 82496 invoked by alias); 4 Mar 2015 23:59:07 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 82486 invoked by uid 89); 4 Mar 2015 23:59:06 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.2 required=5.0 tests=AWL, BAYES_00 autolearn=ham version=3.3.2 X-HELO: topped-with-meat.com MIME-Version: 1.0 From: Roland McGrath To: "GNU C. Library" Subject: [COMMITTED PATCH] Split rpcent tests out of tst-netdb. Message-Id: <20150304235903.0E8E72C3B7B@topped-with-meat.com> Date: Wed, 4 Mar 2015 15:59:02 -0800 (PST) X-CMAE-Score: 0 X-CMAE-Analysis: v=2.1 cv=SvUDtp+0 c=1 sm=1 tr=0 a=WkljmVdYkabdwxfqvArNOQ==:117 a=14OXPxybAAAA:8 a=kj9zAlcOel0A:10 a=hOe2yjtxAAAA:8 a=mDV3o1hIAAAA:8 a=iMjnlC7KE437WK-iYMsA:9 a=30_N9ga6O1NXkC2_:21 a=ci81MTS36Eell1sv:21 a=CjuIK1q_8ugA:10 This lets nss/test-netdb compile in a configuration that omits sunrpc/ entirely. The new sunrpc/test-rpcent is fairly useless (it only tests that using the functions doesn't crash, essentially) but it is exactly the same testing those functions were getting in test-netdb before. Tested x86_64-linux-gnu. Thanks, Roland * nss/test-netdb.c: Don't #include . (setdb): Don't call __nss_configure_lookup for "rpc". (do_test): Don't call test_rpc. (output_rpcent, test_rpc): Functions moved ... * sunrpc/test-rpcent.c: ... to this new file. * sunrpc/Makefile (tests): Add it. --- a/nss/test-netdb.c +++ b/nss/test-netdb.c @@ -23,14 +23,12 @@ - /etc/hosts - /etc/networks - /etc/protocols - - /etc/rpc The tests try to be fairly generic and simple so that they work on every possible setup (and might therefore not detect some possible errors). */ #include -#include #include #include #include @@ -300,43 +298,6 @@ test_protocols (void) } -static void -output_rpcent (const char *call, struct rpcent *rptr) -{ - char **pptr; - - if (rptr == NULL) - printf ("Call: %s returned NULL\n", call); - else - { - printf ("Call: %s, returned: r_name: %s, r_number: %d\n", - call, rptr->r_name, rptr->r_number); - for (pptr = rptr->r_aliases; *pptr != NULL; pptr++) - printf (" alias: %s\n", *pptr); - } -} - -static void -test_rpc (void) -{ - struct rpcent *rptr; - - rptr = getrpcbyname ("portmap"); - output_rpcent ("getrpcyname (\"portmap\")", rptr); - - rptr = getrpcbynumber (100000); - output_rpcent ("getrpcbynumber (100000)", rptr); - - setrpcent (0); - do - { - rptr = getrpcent (); - output_rpcent ("getrpcent ()", rptr); - } - while (rptr != NULL); - endrpcent (); -} - /* Override /etc/nsswitch.conf for this program. This is mainly useful for developers. */ static void __attribute__ ((unused)) @@ -351,7 +312,6 @@ setdb (const char *dbname) __nss_configure_lookup ("networks", dbname); } __nss_configure_lookup ("protocols", dbname); - __nss_configure_lookup ("rpc", dbname); __nss_configure_lookup ("services", dbname); } @@ -366,7 +326,6 @@ do_test (void) test_hosts (); test_network (); test_protocols (); - test_rpc (); test_services (); if (error_count) --- a/sunrpc/Makefile +++ b/sunrpc/Makefile @@ -96,7 +96,7 @@ rpcgen-objs = rpc_main.o rpc_hout.o rpc_cout.o rpc_parse.o \ extra-objs = $(rpcgen-objs) $(addprefix cross-,$(rpcgen-objs)) others += rpcgen -tests = tst-xdrmem tst-xdrmem2 +tests = tst-xdrmem tst-xdrmem2 test-rpcent xtests := tst-getmyaddr ifeq ($(have-thread-library),yes) --- /dev/null +++ b/sunrpc/test-rpcent.c @@ -0,0 +1,74 @@ +/* Test getrpcent and friends. + Copyright (C) 2015 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +/* This is taken from nss/test-netdb.c and is intended to follow that + test's model for everything. This test is separate only because + the interfaces do not exist in configurations that + omit sunrpc/ from the build. */ + +#include +#include + + +static void +output_rpcent (const char *call, struct rpcent *rptr) +{ + char **pptr; + + if (rptr == NULL) + printf ("Call: %s returned NULL\n", call); + else + { + printf ("Call: %s, returned: r_name: %s, r_number: %d\n", + call, rptr->r_name, rptr->r_number); + for (pptr = rptr->r_aliases; *pptr != NULL; pptr++) + printf (" alias: %s\n", *pptr); + } +} + +static void +test_rpc (void) +{ + struct rpcent *rptr; + + rptr = getrpcbyname ("portmap"); + output_rpcent ("getrpcyname (\"portmap\")", rptr); + + rptr = getrpcbynumber (100000); + output_rpcent ("getrpcbynumber (100000)", rptr); + + setrpcent (0); + do + { + rptr = getrpcent (); + output_rpcent ("getrpcent ()", rptr); + } + while (rptr != NULL); + endrpcent (); +} + +static int +do_test (void) +{ + test_rpc (); + + return 0; +} + +#define TEST_FUNCTION do_test () +#include "../test-skeleton.c"