From patchwork Mon Apr 6 21:54:21 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roland McGrath X-Patchwork-Id: 458444 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 B4E34140272 for ; Tue, 7 Apr 2015 07:54:30 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass reason="1024-bit key; unprotected key" header.d=sourceware.org header.i=@sourceware.org header.b=TKADHken; 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=RP3I46SN8HZbJLnNq4pZBecqZ1cNkf5av6X6BYVt/C0dX+ 09B9Kk5liqyKMks8SUVeMkGUVdPFZvWRk0v/rdbBMfSXTsLgiQHVV69kyEqFmwSq rTLI9jVbDjKxLmYjETzC81T17TxDpK6Hr8T0GPuqNAmbd54Yt4s45aGUF32xg= 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=KAbIDkdjztUpDTwsHmFoASD9qN4=; b=TKADHkenQcg4RzeWs+9H cZyG5BXaBRxBd8WgGrZJqJG+Za0SKQA3edGdoeXCqoAaxgxuqlkbh7veYxTs+RBd KUO/fStzZLaVgMHAGp7nFw++1EJ5rAThLBwlyOOuTlbGk69YCnVw1rPx71/Rwe61 09OZb0s3Pz7HqhSTipiF1/Q= Received: (qmail 71368 invoked by alias); 6 Apr 2015 21:54:25 -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 71331 invoked by uid 89); 6 Apr 2015 21:54:24 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.7 required=5.0 tests=AWL, BAYES_00, KAM_LAZY_DOMAIN_SECURITY autolearn=no version=3.3.2 X-HELO: topped-with-meat.com MIME-Version: 1.0 From: Roland McGrath To: "GNU C. Library" Subject: [PATCH roland/test-direct] Make test-skeleton.c grok TEST_DIRECT magic environment variable. Message-Id: <20150406215421.C86492C3C73@topped-with-meat.com> Date: Mon, 6 Apr 2015 14:54:21 -0700 (PDT) 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=sB_yczmgn7tDhNeejrIA:9 a=CjuIK1q_8ugA:10 This changes test-skeleton to check for a new magic environment variable. If TEST_DIRECT is set, it names a file where some info should be written, and tests operate in --direct mode (no fork). I'm using this in combination with a test-wrapper script that approximates the test-skeleton semantics but works for a configuration where fork and wait* are not available. If there are no objections, I'll commit this soon. Thanks, Roland 2015-04-06 Roland McGrath * test-skeleton.c (TIMEOUT): Move #define to top level. (main): Grok environment variable TEST_DIRECT. If set, print test expectation details into that file and then behave as if given --direct. --- a/test-skeleton.c +++ b/test-skeleton.c @@ -45,6 +45,11 @@ # define TEST_DATA_LIMIT (64 << 20) /* Data limit (bytes) to run with. */ #endif +#ifndef TIMEOUT + /* Default timeout is two seconds. */ +# define TIMEOUT 2 +#endif + #define OPT_DIRECT 1000 #define OPT_TESTDIR 1001 @@ -293,7 +298,7 @@ main (int argc, char *argv[]) /* Make sure we see all message, even those on stdout. */ setvbuf (stdout, NULL, _IONBF, 0); - /* make sure temporary files are deleted. */ + /* Make sure temporary files are deleted. */ atexit (delete_temp_files); /* Correct for the possible parameters. */ @@ -306,6 +311,46 @@ main (int argc, char *argv[]) PREPARE (argc, argv); #endif + const char *envstr_direct = getenv ("TEST_DIRECT"); + if (envstr_direct != NULL) + { + FILE *f = fopen (envstr_direct, "w"); + if (f == NULL) + { + printf ("cannot open TEST_DIRECT output file '%s': %m\n", + envstr_direct); + exit (1); + } + + fprintf (f, "timeout=%u\ntimeoutfactor=%u\n", TIMEOUT, timeoutfactor); +#ifdef EXPECTED_STATUS + fprintf (f, "exit=%u\n", EXPECTED_STATUS); +#endif +#ifdef EXPECTED_SIGNAL + switch (EXPECTED_SIGNAL) + { + default: abort (); +# define init_sig(signo, name, text) \ + case signo: fprintf (f, "signal=%s\n", name); break; +# include +# undef init_sig + } +#endif + + if (temp_name_list != NULL) + { + fprintf (f, "temp_files=(\n"); + for (struct temp_name_list *n = temp_name_list; + n != NULL; + n = (struct temp_name_list *) n->q.q_forw) + fprintf (f, " '%s'\n", n->name); + fprintf (f, ")\n"); + } + + fclose (f); + direct = 1; + } + /* If we are not expected to fork run the function immediately. */ if (direct) return TEST_FUNCTION; @@ -359,10 +404,6 @@ main (int argc, char *argv[]) } /* Set timeout. */ -#ifndef TIMEOUT - /* Default timeout is two seconds. */ -# define TIMEOUT 2 -#endif signal (SIGALRM, signal_handler); alarm (TIMEOUT * timeoutfactor);