diff mbox

[6/8] gen-pert-test: assemble functions return results

Message ID 047d7bacb37e83b5d5051b63006f@google.com
State New
Headers show

Commit Message

Doug Evans July 21, 2015, 1:55 p.m. UTC
Hi.

This patch changes PerfTest::assemble so that each function
provided to it returns a success/fail result.
At the moment PerfTest::assemble sometimes returns a result
and sometimes doesn't.

[btw, the entire patch set has been regression tested on amd64-linux]

2015-07-20  Doug Evans  <dje@google.com>

	* lib/perftest.exp (PerfTest::compile): Unconditionally call body.
	(PerfTest::startup): New function.
	(PerfTest::run): Return result of calling body.
	(PerfTest::assemble): Rewrite.
	* gdb.perf/backtrace.exp (PerfTest::assemble): Update function result.
	* gdb.perf/disassemble.exp (PerfTest::assemble): Ditto.
	* gdb.perf/single-step.exp (PerfTest::assemble): Ditto.
	* gdb.perf/skip-prologue.exp (PerfTest::assemble): Ditto.
	* gdb.perf/solib.exp (PerfTest::assemble): Ditto.
diff mbox

Patch

diff --git a/gdb/testsuite/gdb.perf/backtrace.exp  
b/gdb/testsuite/gdb.perf/backtrace.exp
index a88064b..0ae4b5b 100644
--- a/gdb/testsuite/gdb.perf/backtrace.exp
+++ b/gdb/testsuite/gdb.perf/backtrace.exp
@@ -58,9 +58,12 @@  PerfTest::assemble {

      gdb_breakpoint "fun2"
      gdb_continue_to_breakpoint "fun2"
+
+    return 0
  } {
      global BACKTRACE_DEPTH

      gdb_test "python BackTrace\($BACKTRACE_DEPTH\).run()"

+    return 0
  }
diff --git a/gdb/testsuite/gdb.perf/disassemble.exp  
b/gdb/testsuite/gdb.perf/disassemble.exp
index fe943d8..67e9815 100644
--- a/gdb/testsuite/gdb.perf/disassemble.exp
+++ b/gdb/testsuite/gdb.perf/disassemble.exp
@@ -52,6 +52,9 @@  PerfTest::assemble {
      if ![runto_main] {
  	return -1
      }
+
+    return 0
  } {
      gdb_test "python Disassemble\(\).run()"
+    return 0
  }
diff --git a/gdb/testsuite/gdb.perf/single-step.exp  
b/gdb/testsuite/gdb.perf/single-step.exp
index 74c6de0..d5aa7e2 100644
--- a/gdb/testsuite/gdb.perf/single-step.exp
+++ b/gdb/testsuite/gdb.perf/single-step.exp
@@ -47,10 +47,12 @@  PerfTest::assemble {
  	fail "Can't run to main"
  	return -1
      }
+    return 0
  } {
      global SINGLE_STEP_COUNT

      gdb_test_no_output "python SingleStep\(${SINGLE_STEP_COUNT}\).run()"
      # Terminate the loop.
      gdb_test "set variable flag = 0"
+    return 0
  }
diff --git a/gdb/testsuite/gdb.perf/skip-prologue.exp  
b/gdb/testsuite/gdb.perf/skip-prologue.exp
index 35db047..03d666b 100644
--- a/gdb/testsuite/gdb.perf/skip-prologue.exp
+++ b/gdb/testsuite/gdb.perf/skip-prologue.exp
@@ -52,6 +52,7 @@  PerfTest::assemble {
  	fail "Can't run to main"
  	return -1
      }
+    return 0
  } {
      global SKIP_PROLOGUE_COUNT

@@ -66,4 +67,5 @@  PerfTest::assemble {
  	    pass $test
  	}
      }
+    return 0
  }
diff --git a/gdb/testsuite/gdb.perf/solib.exp  
b/gdb/testsuite/gdb.perf/solib.exp
index 4edc2ea..078a372 100644
--- a/gdb/testsuite/gdb.perf/solib.exp
+++ b/gdb/testsuite/gdb.perf/solib.exp
@@ -80,8 +80,10 @@  PerfTest::assemble {
  	fail "Can't run to main"
  	return -1
      }
+    return 0
  } {
      global SOLIB_COUNT

      gdb_test_no_output "python SolibLoadUnload\($SOLIB_COUNT\).run()"
+    return 0
  }
diff --git a/gdb/testsuite/lib/perftest.exp b/gdb/testsuite/lib/perftest.exp
index 7c334ac..e5398e3 100644
--- a/gdb/testsuite/lib/perftest.exp
+++ b/gdb/testsuite/lib/perftest.exp
@@ -42,14 +42,13 @@  namespace eval PerfTest {
      # actual compilation.  Return zero if compilation is successful,
      # otherwise return non-zero.
      proc compile {body} {
-	global GDB_PERFTEST_MODE
-
-	if { [info exists GDB_PERFTEST_MODE]
-	     && [string compare $GDB_PERFTEST_MODE "run"] } {
-	    return [uplevel 2 $body]
-	}
+	return [uplevel 2 $body]
+    }

-	return 0
+    # Run the startup code.  Return zero if startup is successful,
+    # otherwise return non-zero.
+    proc startup {body} {
+	return [uplevel 2 $body]
      }

      # Start up GDB.
@@ -57,7 +56,8 @@  namespace eval PerfTest {
  	uplevel 2 $body
      }

-    # Run the performance test.
+    # Run the performance test.  Return zero if the run is successful,
+    # otherwise return non-zero.
      proc run {body} {
  	global timeout
  	global GDB_PERFTEST_TIMEOUT
@@ -68,36 +68,56 @@  namespace eval PerfTest {
  	} else {
  	    set timeout 3000
  	}
-	uplevel 2 $body
+	set result [uplevel 2 $body]

  	set timeout $oldtimeout
+	return $result
      }

      # The top-level interface to PerfTest.
      # COMPILE is the tcl code to generate and compile source files.
-    # Return zero if compilation is successful,  otherwise return
-    # non-zero.
      # STARTUP is the tcl code to start up GDB.
      # RUN is the tcl code to drive GDB to do some operations.
+    # Each of COMPILE, STARTUP, and RUN return zero if successful, and
+    # non-zero if there's a failure.
+
      proc assemble {compile startup run} {
  	global GDB_PERFTEST_MODE

-	if { [eval compile {$compile}] } {
-	    untested "Could not compile source files."
+	if ![info exists GDB_PERFTEST_MODE] {
  	    return
  	}

+	if { [string compare $GDB_PERFTEST_MODE "run"] != 0 } {
+	    if { [eval compile {$compile}] } {
+		untested "Could not compile source files."
+		return
+	    }
+	}
+
  	# Don't execute the run if GDB_PERFTEST_MODE=compile.
-	if { [info exists GDB_PERFTEST_MODE]
-	     && [string compare $GDB_PERFTEST_MODE "compile"] == 0} {
+	if { [string compare $GDB_PERFTEST_MODE "compile"] == 0} {
+	    return
+	}
+
+	verbose -log "PerfTest::assemble, startup ..."
+
+	if [eval startup {$startup}] {
+	    fail "startup"
  	    return
  	}

-	eval $startup
+	verbose -log "PerfTest::assemble, done startup"

  	_setup_perftest

-	eval run {$run}
+	verbose -log "PerfTest::assemble, run ..."
+
+	if [eval run {$run}] {
+	    fail "run"
+	}
+
+	verbose -log "PerfTest::assemble, run complete."

  	_teardown_perftest
      }
@@ -109,11 +129,9 @@  proc skip_perf_tests { } {
      global GDB_PERFTEST_MODE

      if [info exists GDB_PERFTEST_MODE] {
-
  	if { "$GDB_PERFTEST_MODE" != "compile"
  	     && "$GDB_PERFTEST_MODE" != "run"
  	     && "$GDB_PERFTEST_MODE" != "both" } {
-	    # GDB_PERFTEST_MODE=compile|run|both is allowed.
  	    error "Unknown value of GDB_PERFTEST_MODE."
  	    return 1
  	}