X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=gdb%2Ftestsuite%2Flib%2Fperftest.exp;h=205bcb5f0e3281b99b8a5d31286b9b5e9f9dfc32;hb=fbfdbdab95001d4a543598a3caa0e0f01e05b83f;hp=e77a139e5519ea71daa900fc0eaae0ceda11c849;hpb=b811d2c2920ddcb1adcd438da38e90912b31f45f;p=binutils-gdb.git diff --git a/gdb/testsuite/lib/perftest.exp b/gdb/testsuite/lib/perftest.exp index e77a139e551..205bcb5f0e3 100644 --- a/gdb/testsuite/lib/perftest.exp +++ b/gdb/testsuite/lib/perftest.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2013-2020 Free Software Foundation, Inc. +# Copyright (C) 2013-2021 Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -25,9 +25,15 @@ namespace eval PerfTest { set remote_python_file [gdb_remote_download host ${srcdir}/${subdir}/${testfile}.py] # Set sys.path for module perftest. - gdb_test_no_output "python import os, sys" - gdb_test_no_output "python sys.path.insert\(0, os.path.abspath\(\"${srcdir}/${subdir}/lib\"\)\)" - gdb_test_no_output "python exec (open ('${remote_python_file}').read ())" + with_test_prefix "setup perftest" { + gdb_test_no_output "python import os, sys" + gdb_test_no_output \ + "python sys.path.insert\(0, os.path.abspath\(\"${srcdir}/${subdir}/lib\"\)\)" \ + "python sys.path.insert\(0, os.path.abspath\(\"\${srcdir}/${subdir}/lib\"\)\)" + gdb_test_no_output \ + "python exec (open ('${remote_python_file}').read ())" \ + "python exec (open ('\${srcdir}/${subdir}/${testfile}.py').read ())" + } } # A private method to do some cleanups when performance test is @@ -155,3 +161,28 @@ proc tcl_string_list_to_python_list { l } { } return "([join $quoted_list {, }])" } + +# Helper routine for PerfTest::assemble "run" step implementations. +# Issues the "python ${OBJ}.run()" command, and consumes GDB output +# line by line. Issues a FAIL if the command fails with a Python +# error. Issues a PASS on success. MESSAGE is an optional message to +# be printed. If this is omitted, then the pass/fail messages use the +# command string as the message. + +proc gdb_test_python_run {obj {message ""}} { + global gdb_prompt + + set saw_error 0 + gdb_test_multiple "python ${obj}.run()" $message { + -re "Error while executing Python code\\." { + set saw_error 1 + exp_continue + } + -re "\[^\r\n\]*\r\n" { + exp_continue + } + -re "$gdb_prompt $" { + gdb_assert {!$saw_error} $gdb_test_name + } + } +}