public inbox for jit@gcc.gnu.org
 help / color / mirror / Atom feed
From: David Malcolm <dmalcolm@redhat.com>
To: gcc-patches@gcc.gnu.org, jit@gcc.gnu.org
Cc: Jeff Law <law@redhat.com>, David Malcolm <dmalcolm@redhat.com>
Subject: [PATCH 05/05] Add command-line option-parsing to jit testcases
Date: Wed, 01 Jan 2014 00:00:00 -0000	[thread overview]
Message-ID: <1416965664-15360-6-git-send-email-dmalcolm@redhat.com> (raw)
In-Reply-To: <1416965664-15360-1-git-send-email-dmalcolm@redhat.com>

Add command-line option-parsing to the testcases, so that we can
manipulate them without needing a recompile (e.g. varying
optimization levels etc).

This uses getopt_long, which is a GNU extension to libc.  Is that
acceptable?

Implement a --num-iterations option, to override the default of 5.

When running tests under valgrind, pass in "--num-iterations=1",
speeding up the tests by a factor of 5.

gcc/testsuite/ChangeLog:
	* jit.dg/harness.h (num_iterations): New variable.
        (parse_options): New function.
        (main): Use "num_iterations", rather than hardcoding 5.
	* jit.dg/jit.exp (fixed_host_execute): When running tests under
	valgrind, pass in "--num-iterations=1".
---
 gcc/testsuite/jit.dg/harness.h | 46 +++++++++++++++++++++++++++++++++++++++---
 gcc/testsuite/jit.dg/jit.exp   |  5 +++++
 2 files changed, 48 insertions(+), 3 deletions(-)

diff --git a/gcc/testsuite/jit.dg/harness.h b/gcc/testsuite/jit.dg/harness.h
index bff64de..a30b66e 100644
--- a/gcc/testsuite/jit.dg/harness.h
+++ b/gcc/testsuite/jit.dg/harness.h
@@ -247,17 +247,57 @@ extract_progname (const char *argv0)
 }
 
 #ifndef TEST_PROVIDES_MAIN
+
+/* Option parsing, for varying how we run the built testcases
+   (e.g. when poking at things in the debugger).  */
+
+#include <getopt.h>
+int num_iterations = 5;
+
+static void
+parse_options (int argc, char **argv)
+{
+  while (1)
+    {
+      static struct option long_options[] =
+	{
+	  {"num-iterations", required_argument, 0, 'i'},
+	  {0, 0, 0, 0}
+	};
+
+      int option_index = 0;
+      /* getopt_long is a GNU extension to libc.  */
+      int c = getopt_long (argc, argv, "i:",
+			   long_options, &option_index);
+      if (c == -1)
+	break;
+
+      switch (c)
+	{
+	case 'i':
+	  num_iterations = atoi (optarg);
+	  break;
+	default:
+	  fprintf (stderr, "Usage: %s [--num-iterations NUM]\n",
+		   argv[0]);
+	  exit(EXIT_FAILURE);
+	}
+    }
+}
+
 int
 main (int argc, char **argv)
 {
   int i;
 
-  for (i = 1; i <= 5; i++)
+  parse_options (argc, argv);
+
+  for (i = 1; i <= num_iterations; i++)
     {
       snprintf (test, sizeof (test),
 		"%s iteration %d of %d",
-                extract_progname (argv[0]),
-                i, 5);
+		extract_progname (argv[0]),
+		i, num_iterations);
 
       //printf ("ITERATION %d\n", i);
       test_jit (argv[0], NULL);
diff --git a/gcc/testsuite/jit.dg/jit.exp b/gcc/testsuite/jit.dg/jit.exp
index a37ccc7..438aabd 100644
--- a/gcc/testsuite/jit.dg/jit.exp
+++ b/gcc/testsuite/jit.dg/jit.exp
@@ -157,6 +157,11 @@ proc fixed_host_execute {args} {
 	set valgrind_params {"valgrind"}
 	lappend valgrind_params "--leak-check=full"
 	lappend valgrind_params "--log-file=${valgrind_logfile}"
+	# When running under valgrind, speed things up by only running one
+	# in-process iteration of the testcase, rather than the default of 5.
+	# Only testcases that use the "main" from harness.h
+	# (#ifndef TEST_PROVIDES_MAIN) will respond to this option.
+	lappend params "--num-iterations=1"
     } else {
 	set valgrind_params {}
     }
-- 
1.8.5.3

  parent reply	other threads:[~2014-11-26  1:26 UTC|newest]

Thread overview: 69+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-01  0:00 [PATCH 00/21] PR 63854: Fix various memory leaks David Malcolm
2014-01-01  0:00 ` [PATCH 18/21] PR jit/63854: Add "long-term" allocator to gcc::context David Malcolm
2014-01-01  0:00   ` Joseph Myers
2015-01-01  0:00     ` PING: " David Malcolm
2015-01-01  0:00       ` Joseph Myers
2014-01-01  0:00 ` [PATCH 01/21] PR jit/63854: Fix memory leak within gcc_options David Malcolm
2014-01-01  0:00   ` Richard Biener
2014-01-01  0:00 ` [PATCH 12/21] PR jit/63854: Add a valgrind suppresion file David Malcolm
2014-01-01  0:00   ` Richard Biener
2014-01-01  0:00     ` Jeff Law
2014-01-01  0:00       ` David Malcolm
2015-01-01  0:00         ` Hans-Peter Nilsson
2014-01-01  0:00 ` [PATCH 21/21] PR jit/63854: Fix leaks in test-fuzzer.c David Malcolm
2014-01-01  0:00   ` Jeff Law
2014-01-01  0:00 ` [PATCH 20/21] PR jit/63854: Fix leak in ipa-icf.c David Malcolm
2014-01-01  0:00   ` Richard Biener
2014-01-01  0:00 ` [PATCH 13/21] PR jit/63854: Add support for running "make check-jit" under valgrind David Malcolm
2014-01-01  0:00   ` Jeff Law
2014-01-01  0:00     ` Running cc1 etc under valgrind (was Re: [PATCH 13/21] PR jit/63854: Add support for running "make check-jit" under valgrind) David Malcolm
2014-01-01  0:00       ` David Malcolm
2014-01-01  0:00     ` [PATCH 00/05] Fixes to jit.exp David Malcolm
2014-01-01  0:00       ` [PATCH 03/05] jit.exp: fix timeout bug inherited from dejagnu.exp David Malcolm
2014-01-01  0:00       ` [PATCH 01/05] jit.exp: Avoid embedding full paths into test results David Malcolm
2014-01-01  0:00         ` Mike Stump
2014-01-01  0:00       ` [PATCH 04/05] jit.exp: Verify the exit status of the spawnee David Malcolm
2014-01-01  0:00       ` David Malcolm [this message]
2014-01-01  0:00         ` PING: Re: [PATCH 05/05] Add command-line option-parsing to jit testcases David Malcolm
2014-01-01  0:00           ` Mike Stump
2014-01-01  0:00             ` David Malcolm
2014-01-01  0:00               ` Mike Stump
2014-01-01  0:00       ` [PATCH 02/05] PR jit/63854: Add support for running "make check-jit" under valgrind David Malcolm
2014-01-01  0:00     ` [PATCH 13/21] " David Malcolm
2014-01-01  0:00       ` Jeff Law
2014-01-01  0:00     ` [PATCH 00/05] Fixes to jit.exp David Malcolm
2014-01-01  0:00 ` [PATCH 10/21] PR jit/63854: Fix leak of worklist within jit-recording.c David Malcolm
2014-01-01  0:00   ` Jeff Law
2014-01-01  0:00     ` David Malcolm
2014-01-01  0:00       ` Richard Biener
2014-01-01  0:00         ` Jeff Law
2014-01-01  0:00 ` [PATCH 17/21] PR jit/63854: Fix leaking vec in jit David Malcolm
2014-01-01  0:00   ` Jeff Law
2014-01-01  0:00 ` [PATCH 03/21] PR jit/63854: Fix memory leaks within context/pass_manager/dump_manager David Malcolm
2014-01-01  0:00   ` Jeff Law
2014-01-01  0:00 ` [PATCH 16/21] PR jit/63854: Add all_late_ipa_passes to GCC_PASS_LISTS David Malcolm
2014-01-01  0:00   ` Richard Biener
2014-01-01  0:00 ` [PATCH 06/21] PR jit/63854: Fix leak of opts_obstack David Malcolm
2014-01-01  0:00   ` Richard Biener
2014-01-01  0:00 ` [PATCH 11/21] PR jit/63854: Fix leak of "avail" within tree-ssa-pre.c David Malcolm
2014-01-01  0:00   ` Richard Biener
2014-01-01  0:00 ` [PATCH 15/21] PR jit/63854: lra.c: Fix leak of point_freq_vec's buffer when calling lra_inheritance David Malcolm
2014-01-01  0:00   ` Jeff Law
2014-01-01  0:00 ` [PATCH 05/21] PR jit/63854: Fix memory leak of save_decoded_options David Malcolm
2014-01-01  0:00   ` Richard Biener
2014-01-01  0:00 ` [PATCH 19/21] PR jit/63854: Fix leak of ipa hooks David Malcolm
2014-01-01  0:00   ` Jeff Law
2014-01-01  0:00     ` PING " David Malcolm
2014-01-01  0:00       ` Jan Hubicka
2014-01-01  0:00 ` [PATCH 04/21] PR jit/63854: Fix memory leak within bb-reorder.c David Malcolm
2014-01-01  0:00   ` Richard Biener
2014-01-01  0:00 ` [PATCH 09/21] PR jit/63854: Don't leak producer_string in dwarf2out.c David Malcolm
2014-01-01  0:00   ` Richard Biener
2014-01-01  0:00 ` [PATCH 07/21] PR jit/63854: Fix leak of optimization_summary_obstack David Malcolm
2014-01-01  0:00   ` Richard Biener
2014-01-01  0:00 ` [PATCH 02/21] PR jit/63854: Fix memory leak of reginfo.c: valid_mode_changes_obstack David Malcolm
2014-01-01  0:00   ` Richard Biener
2014-01-01  0:00 ` [PATCH 08/21] PR jit/63854: Add ira_costs_c_finalize David Malcolm
2014-01-01  0:00   ` Richard Biener
2014-01-01  0:00 ` [PATCH 14/21] PR jit/63854: Fix leak of paths within jump threading David Malcolm
2014-01-01  0:00   ` Richard Biener

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1416965664-15360-6-git-send-email-dmalcolm@redhat.com \
    --to=dmalcolm@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jit@gcc.gnu.org \
    --cc=law@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).