From patchwork Wed Feb 25 23:55:56 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roland McGrath X-Patchwork-Id: 443709 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 E75171400B6 for ; Thu, 26 Feb 2015 10:56:05 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass reason="1024-bit key; unprotected key" header.d=sourceware.org header.i=@sourceware.org header.b=r/MfrIUd; 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=y8Ir8ucO4+sOJRBf1CbNgyPBh5VRMG2co4FX72KITj722J FDnTiH/wFCJGXK1ILPFcTQhC5KML33ph71vB1Xx87kSrO6t8wSm/hs1E4FFeu7h/ QDKWph5fBBJGXYURioztTCyeqwo9ryo9FwlUgqZShAcdIzlNioCb7BHUzrRoY= 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=SvpDekx/oqTcnNp8hQPIWl+mmCc=; b=r/MfrIUdXXtdYa75eT7y 42rzHVU2YnLalIS0f/a/NnLoMhh9gD7EPLSZ68icojv8O0gHViAfHi5ujnQdo5HY YfT7nU/RgRL2H+X/r00cv9xaCzMuiNG3uYe2ygxM6+RM5Wq1DnlPRWql6wzY0bag qMjhzd+itEsINxK3MgnkHlE= Received: (qmail 50077 invoked by alias); 25 Feb 2015 23:55:59 -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 49963 invoked by uid 89); 25 Feb 2015 23:55:59 -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] Convert tst-iconv5 to use test-skeleton. Message-Id: <20150225235556.48FC02C3ADB@topped-with-meat.com> Date: Wed, 25 Feb 2015 15:55:56 -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=Md-2tOm-NdUW5irVveYA:9 a=PUOXsnmSXY_y5d2B:21 a=l1dE4EhAtEpUuOQP:21 a=CjuIK1q_8ugA:10 Tested x86_64-linux-gnu. Thanks, Roland * iconv/tst-iconv5.c (testcode, number): Make variables static const. (convert): Make function static. (test_unalign): Likewise. Add const to argument pointee types. (main): Replace with static function do_test. Print "Succeeded." only if RET is zero. (TEST_FUNCTION): New macro. Include test-skeleton.c. --- a/iconv/tst-iconv5.c +++ b/iconv/tst-iconv5.c @@ -38,7 +38,7 @@ struct convcode }; /* test builtin transformation */ -struct convcode testcode[] = { +static const struct convcode testcode[] = { {"ASCII", "ASCII"}, {"UTF-8", "ASCII"}, {"UCS-2BE", "ASCII"}, @@ -47,9 +47,9 @@ struct convcode testcode[] = { {"UCS-4LE", "ASCII"}, }; -int number = (int) sizeof (testcode) / sizeof (struct convcode); +static const int number = (int) sizeof (testcode) / sizeof (struct convcode); -int +static int convert (const char *tocode, const char *fromcode, char *inbufp, size_t inbytesleft, char *outbufp, size_t outbytesleft) { @@ -88,8 +88,8 @@ convert (const char *tocode, const char *fromcode, char *inbufp, } -int -test_unalign (struct convcode *codes, char *str, int len) +static int +test_unalign (const struct convcode *codes, const char *str, int len) { struct unalign *inbufp, *outbufp; char *inbuf, *outbuf; @@ -137,8 +137,8 @@ test_unalign (struct convcode *codes, char *str, int len) return 0; } -int -main (int argc, char *argv[]) +static int +do_test (void) { int i; int ret = 0; @@ -151,7 +151,11 @@ main (int argc, char *argv[]) printf ("iconv: %s <-> %s: ok\n", testcode[i].fromcode, testcode[i].tocode); } - printf ("Succeeded.\n"); + if (ret == 0) + printf ("Succeeded.\n"); return ret; } + +#define TEST_FUNCTION do_test () +#include "../test-skeleton.c"