From patchwork Sat Dec 31 10:51:43 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Weimer X-Patchwork-Id: 89419 Delivered-To: patch@linaro.org Received: by 10.140.20.101 with SMTP id 92csp6800030qgi; Sat, 31 Dec 2016 02:52:08 -0800 (PST) X-Received: by 10.84.208.102 with SMTP id f35mr107124838plh.137.1483181528849; Sat, 31 Dec 2016 02:52:08 -0800 (PST) Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id y186si59876953pfy.31.2016.12.31.02.52.08 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 31 Dec 2016 02:52:08 -0800 (PST) Received-SPF: pass (google.com: domain of libc-alpha-return-76457-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-76457-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-76457-patch=linaro.org@sourceware.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:to:from:subject:message-id:date:mime-version :content-type; q=dns; s=default; b=vrD63nwA3lrsgsKs8sOpRZCAzZrdC iVFi6kxsnqp8ylvWMx3w/2uwZ7WqElhNCZNSDwQOjI+onSMm0neH4lBzDjfuw0fp o/3ZFK7bj8s/4kOsOR18gS7LKZqxsm3vb1gaVB9Zoe/O7yI+jKw6oVXny8s8IIxG jnBkGGiIldPhsk= 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:to:from:subject:message-id:date:mime-version :content-type; s=default; bh=3VUE/SddOJM10rXd6UsBJT+LNjU=; b=W7z J+erML6VdkraZoUE+i0BkzPdKqhXc0Y72jrWuyjKxszuRxoO7UkgMQz1/SoR7uCH f0TaGrqGOnN3xxCtmrWrhuEVJPV3gJCH/gdIdllQIMgIWcizm8nLL7Ak9mwVGnqC oGGKGHjQkywYoKL6maGfumg1oJgCtaDpMK90l/MI= Received: (qmail 130236 invoked by alias); 31 Dec 2016 10:51:58 -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 130225 invoked by uid 89); 31 Dec 2016 10:51:57 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-5.1 required=5.0 tests=BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=monitoring, 1449, Increase, Hx-languages-length:4713 X-HELO: mx1.redhat.com To: GNU C Library From: Florian Weimer Subject: [PATCH] support: Implement --verbose option for test programs Message-ID: Date: Sat, 31 Dec 2016 11:51:43 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1 MIME-Version: 1.0 This patch depends on the failure recording change posted here: Thanks, Florian support: Implement --verbose option for test programs Some tests can produce rather verbose tracing information, and the --verbose option provides a standardized way to enable such logging output. 2016-12-31 Florian Weimer * support/test-driver.h (TEST_DEFAULT_OPTIONS): Add --verbose. (test_verbose): Declare. * support/test-driver.c (main): Use TEST_DEFAULT_OPTIONS. * support/support_test_main.c (default_options): Likewise. (usage, support_test_main): Handle 'v'. (test_verbose): Define. * support/tst-support_record_failure.c (do_test): Use test_verbose. * support/tst-support_record_failure-2.sh (different_status): Add --verbose test. diff --git a/support/support_test_main.c b/support/support_test_main.c index 8d31e2f..1c90986 100644 --- a/support/support_test_main.c +++ b/support/support_test_main.c @@ -37,8 +37,7 @@ static const struct option default_options[] = { - { "direct", no_argument, NULL, OPT_DIRECT }, - { "test-dir", required_argument, NULL, OPT_TESTDIR }, + TEST_DEFAULT_OPTIONS { NULL, 0, NULL, 0 } }; @@ -67,6 +66,9 @@ usage (const struct option *options) printf ("%*s", 25 - indent, ""); switch (options[i].val) { + case 'v': + printf ("Increase the output verbosity"); + break; case OPT_DIRECT: printf ("Run the test directly (instead of forking & monitoring)"); break; @@ -164,7 +166,7 @@ run_test_function (int argc, char **argv, const struct test_config *config) static bool test_main_called; const char *test_dir = NULL; - +unsigned int test_verbose = 0; /* If test failure reporting has been linked in, it may contribute additional test failures. */ @@ -215,6 +217,9 @@ support_test_main (int argc, char **argv, const struct test_config *config) case '?': usage (options); exit (1); + case 'v': + ++test_verbose; + break; case OPT_DIRECT: direct = 1; break; diff --git a/support/test-driver.c b/support/test-driver.c index 3a61b7b..a847c96 100644 --- a/support/test-driver.c +++ b/support/test-driver.c @@ -144,9 +144,7 @@ main (int argc, char **argv) struct option options[] = { CMDLINE_OPTIONS - { "direct", no_argument, NULL, OPT_DIRECT }, - { "test-dir", required_argument, NULL, OPT_TESTDIR }, - { NULL, 0, NULL, 0 } + TEST_DEFAULT_OPTIONS }; test_config.options = &options; #endif diff --git a/support/test-driver.h b/support/test-driver.h index 7787e9c..f3f5c17 100644 --- a/support/test-driver.h +++ b/support/test-driver.h @@ -55,12 +55,18 @@ enum /* Options provided by the test driver. */ #define TEST_DEFAULT_OPTIONS \ + { "verbose", no_argument, NULL, 'v' }, \ { "direct", no_argument, NULL, OPT_DIRECT }, \ { "test-dir", required_argument, NULL, OPT_TESTDIR }, \ /* The directory the test should use for temporary files. */ extern const char *test_dir; +/* The number of --verbose arguments specified during program + invocation. This variable can be used to control the verbosity of + tests. */ +extern unsigned int test_verbose; + int support_test_main (int argc, char **argv, const struct test_config *); __END_DECLS diff --git a/support/tst-support_record_failure-2.sh b/support/tst-support_record_failure-2.sh index a96a60d..6fffd8a 100644 --- a/support/tst-support_record_failure-2.sh +++ b/support/tst-support_record_failure-2.sh @@ -54,13 +54,16 @@ different_status () { run_test 1 "error: 1 test failures" $direct --status=77 run_test 2 "error: tst-support_record_failure.c:108: not true: false error: 1 test failures" $direct --test-verify + run_test 2 "error: tst-support_record_failure.c:108: not true: false +info: execution passed failed TEST_VERIFY +error: 1 test failures" $direct --test-verify --verbose } different_status different_status --direct -run_test 1 "error: tst-support_record_failure.c:113: not true: false +run_test 1 "error: tst-support_record_failure.c:115: not true: false error: 1 test failures" --test-verify-exit # --direct does not print the summary error message if exit is called. -run_test 1 "error: tst-support_record_failure.c:113: not true: false" \ +run_test 1 "error: tst-support_record_failure.c:115: not true: false" \ --direct --test-verify-exit diff --git a/support/tst-support_record_failure.c b/support/tst-support_record_failure.c index a999f70..75dd10f 100644 --- a/support/tst-support_record_failure.c +++ b/support/tst-support_record_failure.c @@ -106,6 +106,8 @@ do_test (void) if (test_verify) { TEST_VERIFY (false); + if (test_verbose) + printf ("info: execution passed failed TEST_VERIFY\n"); return 2; /* Expected exit status. */ } if (test_verify_exit)