From patchwork Thu Jun 8 21:13:17 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 103406 Delivered-To: patch@linaro.org Received: by 10.140.91.77 with SMTP id y71csp2632244qgd; Thu, 8 Jun 2017 14:14:12 -0700 (PDT) X-Received: by 10.84.217.213 with SMTP id d21mr37111856plj.45.1496956451948; Thu, 08 Jun 2017 14:14:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1496956451; cv=none; d=google.com; s=arc-20160816; b=qiH5qhpuMF4xg47iP+ze7VniKYZGdPTnX9fNnpDLHaaLSnQ8AUxzF1gEd0jYJpUqaj ywuR8pTfv95cLOu8RBo1SqogniCh48OA8gOQRsrxVx5ND8y78TCk+waNqFCP2JBkgdSK e2TXnwtFas9vBFVDsNjy5FvnPHOsLkVg2wJDe8g711qvRwyu4AIbOtfaqk9VB+GdPtPR m9v19EYKTKPm2VYa76Z+uCllyAF6pUsMMIz7Q526gXae5qndSLeasNw7WhaD//fu5OtU q1rAeODmW3a7uDtetiXCMxLQ5TQVzNzMs2OUiQmWFZTMEBWaK/LcdZdNXUTE6dpi+pXx 1IfQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:to:from:delivered-to :sender:list-help:list-post:list-archive:list-subscribe :list-unsubscribe:list-id:precedence:mailing-list:dkim-signature :domainkey-signature:arc-authentication-results; bh=B6otIg/Oo+uuQPwN4K6oSKQ8XiMRzRafFtWONWlEKTk=; b=vyaVIHqa26+RJ/qiVPVgxxSZ0KI5vHTfTwb1USJYLRZxqiip35RYpr/5+QNMQCpvvu lvhVX8nwl6B/bhg789EIhAThM4lEw9c/hae19A1NsNmW2VfdcxbmgvS3BAYXljhdzV+4 pHKRaDjaWzI+LU4qUteNGJGBI5eAQtTIzqHEAocn1AvhjbCU+M7yJ3YUZy9LvgVeyG/i vm8enbkjwUyJ87aIM2I85KIoQ/NtN9kX/MaIkwFS1K4HHX/fq80XTlyeyCkSyJRYhaJ3 op22M/YCgGHG2iSR4Z2VzaqiCKkd/05gZfS8gd71EDSeus4SKgx28C2B7PFJCyKbB96t fonQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org; spf=pass (google.com: domain of libc-alpha-return-80200-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-80200-patch=linaro.org@sourceware.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id q2si5270533plk.300.2017.06.08.14.14.11 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 08 Jun 2017 14:14:11 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-return-80200-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org; spf=pass (google.com: domain of libc-alpha-return-80200-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-80200-patch=linaro.org@sourceware.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=AFCcB2BX2IG0Plndc75j2In4KlojVH9 W4uBXCnx7rPY9VJm3S0sPw8RZ4uwN+xOw/T7hkuquxTf8Bsk1oAdhrl50KwpQSxW UzVhE1wSS3BBKk7s2bZ3ljYvSb2shq4ibfFJ/Sn63ivvI4QvnJhoi3cVJI3kq10g z/IMS9VejqIA= 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:from:to:subject:date:message-id:in-reply-to :references; s=default; bh=u0GcMTF/TSkiAIxMODk3+RySQbA=; b=oxRMp y33M0GzWeb5UfrPOvA47i3Mf3M4RwJILYcQzKT0q+1eSW3trLVUfX5O6hY5ksqlw Cn/WGJC1Y5jZs6VLAxzx6mh+GmqN7VZ0EkPqiCzcLtTkLVNFsLGsDPvoGQyBPQ/6 LbFYoSWKlQmGKY18i9uBathhKy1zE876oUFMQU= Received: (qmail 37668 invoked by alias); 8 Jun 2017 21:13:49 -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 37595 invoked by uid 89); 8 Jun 2017 21:13:48 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-27.6 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-qt0-f178.google.com X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=B6otIg/Oo+uuQPwN4K6oSKQ8XiMRzRafFtWONWlEKTk=; b=TD5+KGk2au/EVfV+ubWQ/+RHA/SVQiiAGx9Xjd/psjf3HtSV95itmceMuU1R/8YKGh Y3PcD6Suw81otT3ptwwdPojx0N9BHuig2BobfWRC0OcYy0xNKDoPt0pLzaT8jNQdRRqY gxlTt8yhr0zCTReiZR3D2hCm3eXCx6l5L4F93c0BgxHRnQoQFwv20FcnlXsagpVIP7sK MBcidtNtQIUy2F9E/1xp6IeZdCOZMDtbVYEKvI2t3H3s/imp5n+u7duWZqV/EP5bLGvd MyrHD2IxWQtiayB4T/w64nBu2hOSYvcekbdSLxPKLCSqAKdsD4Zs9or4APVinWxs5AsN woMQ== X-Gm-Message-State: AKS2vOwB7QRuBLPR5waj6//q8qPxj2arTj9ehVpNiMYLBeD0BBpJDZK5 XXNQbHJLvyTqjX7tdbCZPw== X-Received: by 10.55.92.68 with SMTP id q65mr30390389qkb.205.1496956429419; Thu, 08 Jun 2017 14:13:49 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH 03/17] support: Add optstring support Date: Thu, 8 Jun 2017 18:13:17 -0300 Message-Id: <1496956411-25594-4-git-send-email-adhemerval.zanella@linaro.org> In-Reply-To: <1496956411-25594-1-git-send-email-adhemerval.zanella@linaro.org> References: <1496956411-25594-1-git-send-email-adhemerval.zanella@linaro.org> This patch adds an option to test to add small command line option through CMDLINE_OPTSTRING define. For instance: #define CMDLINE_OPTSTRING "vd" static void cmdline_process_function (int c) { switch (c): 'v': /* process '-v' option. */ break; 'd': /* process '-d' option. */ break; } #define CMDLINE_PROCESS cmdline_process_function It will add both '-v' and '-d' along with already default long options. * support/support_test_main.c (support_test_main): Use optstring member for option string in getopt_long. * support/test-driver.c: Add comment about CMDLINE_OPTSTRING. (CMDLINE_OPTSTRING): New define. * support/test-driver.h (test_config): Add optstring member. --- support/support_test_main.c | 3 ++- support/test-driver.c | 9 +++++++++ support/test-driver.h | 1 + 3 files changed, 12 insertions(+), 1 deletion(-) -- 2.7.4 diff --git a/support/support_test_main.c b/support/support_test_main.c index 914d64f..3c411a4 100644 --- a/support/support_test_main.c +++ b/support/support_test_main.c @@ -211,7 +211,8 @@ support_test_main (int argc, char **argv, const struct test_config *config) mallopt (M_PERTURB, 42); } - while ((opt = getopt_long (argc, argv, "+", options, NULL)) != -1) + while ((opt = getopt_long (argc, argv, config->optstring, options, NULL)) + != -1) switch (opt) { case '?': diff --git a/support/test-driver.c b/support/test-driver.c index 482066d..f5a2388 100644 --- a/support/test-driver.c +++ b/support/test-driver.c @@ -93,6 +93,10 @@ has this type: void CMDLINE_PROCESS (int); + + If the program also to process custom default short command line + argument (similar to getopt) it must define CMDLINE_OPTSTRING + with the expected options (for instance "vb"). */ #include @@ -151,6 +155,11 @@ main (int argc, char **argv) #ifdef CMDLINE_PROCESS test_config.cmdline_function = CMDLINE_PROCESS; #endif +#ifdef CMDLINE_OPTSTRING + test_config.optstring = CMDLINE_OPTSTRING; +#else + test_config.optstring = "+"; +#endif return support_test_main (argc, argv, &test_config); } diff --git a/support/test-driver.h b/support/test-driver.h index af1971a..a8fe9c3 100644 --- a/support/test-driver.h +++ b/support/test-driver.h @@ -35,6 +35,7 @@ struct test_config int expected_status; /* Expected exit status. */ int expected_signal; /* If non-zero, expect termination by signal. */ char no_mallopt; /* Boolean flag to disable mallopt. */ + const char *optstring; /* Short command line options. */ }; enum