Accept mips-sgi-irix output in a few ld tests
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.python / py-prompt.exp
index ab17ab93bd7c94ec0e976225eff27c156f1929c1..a527076523b52642012dc671d62ff90e5bfaab9e 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright (C) 2011-2012 Free Software Foundation, Inc.
+# Copyright (C) 2011-2019 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
 # This file is part of the GDB testsuite.  It tests the mechanism
 # for defining the prompt in Python.
 
-set testfile "py-prompt"
-set srcfile ${testfile}.c
-set binfile ${objdir}/${subdir}/${testfile}
-
-# We need to use TCL's exec to get the pid.
-if [is_remote target] then {
-    return 0
-}
+standard_testfile
 
 load_lib gdb-python.exp
 load_lib prompt.exp
@@ -38,8 +31,7 @@ gdb_reinitialize_dir $srcdir/$subdir
 if { [skip_python_tests] } { continue }
 gdb_exit
 
-if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
-    untested py-prompt.exp
+if {[build_executable $testfile.exp $testfile $srcfile debug] == -1} {
     return -1
 }
 
@@ -62,70 +54,67 @@ set gdb_prompt "\[(\]Foo\[)\]"
 
 set GDBFLAGS [concat $tmp_gdbflags " -ex \"set editing on\""]
 prompt_gdb_start
-gdb_test "python x = len(p); print gdb.execute(\"show prompt\", to_string = True)" \
+gdb_test "python x = len(p); print (gdb.execute(\"show prompt\", to_string = True))" \
         ".*prompt is \"$gdb_prompt \".*" \
         "show prompt gets the correct result"
-gdb_test "python print x, len(p)" "1 2" \
+gdb_test "python print ('%d %d' % (x, len(p)))" "1 2" \
         "retrieving the prompt causes no extra prompt_hook calls"
-gdb_test "python print \"'\" + str(p\[0\]) + \"'\"" "'$gdb_prompt_fail '" \
+gdb_test "python print (\"'\" + str(p\[0\]) + \"'\")" "'$gdb_prompt_fail '" \
         "prompt_hook argument is default prompt."
 gdb_exit
 
 
 set GDBFLAGS [concat $tmp_gdbflags " -ex \"set editing off\""]
 prompt_gdb_start
-gdb_test "python x = len(p); print gdb.execute(\"show prompt\", to_string = True)" \
+gdb_test "python x = len(p); print (gdb.execute(\"show prompt\", to_string = True))" \
         ".*prompt is \"$gdb_prompt \".*" \
         "show prompt gets the correct result 2"
-gdb_test "python print x, len(p)" "1 2" \
+gdb_test "python print ('%d %d' % (x, len(p)))" "1 2" \
         "retrieving the prompt causes no extra prompt_hook calls 2"
-gdb_test "python print \"'\" + str(p\[0\]) + \"'\"" "'$gdb_prompt_fail '" \
+gdb_test "python print (\"'\" + str(p\[0\]) + \"'\")" "'$gdb_prompt_fail '" \
         "prompt_hook argument is default prompt. 2"
 gdb_exit
 
-# Start the program running and then wait for a bit, to be sure
-# that it can be attached to.
-set testpid [eval exec $binfile &]
-exec sleep 2
-if { [istarget "*-*-cygwin*"] } {
-    # testpid is the Cygwin PID, GDB uses the Windows PID, which might be
-    # different due to the way fork/exec works.
-    set testpid [ exec ps -e | gawk "{ if (\$1 == $testpid) print \$4; }" ]
+if {![can_spawn_for_attach]} {
+    set GDBFLAGS $saved_gdbflags
+    return 0
 }
 
-set GDBFLAGS [concat $tmp_gdbflags " -ex \"set target-async on\""]
-set GDBFLAGS [concat $GDBFLAGS " -ex \"set pagination off\""]
+set test_spawn_id [spawn_wait_for_attach $binfile]
+set testpid [spawn_id_get_pid $test_spawn_id]
+
+set GDBFLAGS [concat $tmp_gdbflags " -ex \"set pagination off\""]
 set GDBFLAGS [concat $GDBFLAGS " -ex \"set editing on\""]
 set GDBFLAGS [concat $GDBFLAGS " -ex \"attach $testpid\""]
 set GDBFLAGS [concat $GDBFLAGS " -ex \"continue&\""]
 
 # sync_execution = 1 is_running = 1
 prompt_gdb_start
-gdb_test "python x = len(p); print gdb.execute(\"show prompt\", to_string = True)" \
+gdb_test "python x = len(p); print (gdb.execute(\"show prompt\", to_string = True))" \
         ".*prompt is \"$gdb_prompt \".*" \
         "show prompt gets the correct result 3"
-gdb_test "python print x, len(p)" "1 2" \
+gdb_test "python print ('%d %d' % (x, len(p)))" "1 2" \
         "retrieving the prompt causes no extra prompt_hook calls 3"
-gdb_test "python print \"'\" + str(p\[0\]) + \"'\"" "'$gdb_prompt_fail '" \
+gdb_test "python print (\"'\" + str(p\[0\]) + \"'\")" "'$gdb_prompt_fail '" \
         "prompt_hook argument is default prompt. 3"
 gdb_exit
 
-set GDBFLAGS [concat $tmp_gdbflags " -ex \"set target-async on\""]
-set GDBFLAGS [concat $GDBFLAGS " -ex \"set pagination off\""]
+set GDBFLAGS [concat $tmp_gdbflags " -ex \"set pagination off\""]
 set GDBFLAGS [concat $GDBFLAGS " -ex \"set editing on\""]
 set GDBFLAGS [concat $GDBFLAGS " -ex \"attach $testpid\""]
 set GDBFLAGS [concat $GDBFLAGS " -ex \"interrupt\""]
 
 # sync_execution = 1 is_running = 0
 prompt_gdb_start
-gdb_test "python x = len(p); print gdb.execute(\"show prompt\", to_string = True)" \
+gdb_test "python x = len(p); print (gdb.execute(\"show prompt\", to_string = True))" \
         ".*prompt is \"$gdb_prompt \".*" \
         "show prompt gets the correct result 4"
-gdb_test "python print x, len(p)" "1 2" \
+gdb_test "python print ('%d %d' % (x, len(p)))" "1 2" \
         "retrieving the prompt causes no extra prompt_hook calls 4"
-gdb_test "python print \"'\" + str(p\[0\]) + \"'\"" "'$gdb_prompt_fail '" \
+gdb_test "python print (\"'\" + str(p\[0\]) + \"'\")" "'$gdb_prompt_fail '" \
         "prompt_hook argument is default prompt. 4"
 gdb_exit
 
 set GDBFLAGS $saved_gdbflags
+kill_wait_spawned_process $test_spawn_id
 return 0
This page took 0.028396 seconds and 4 git commands to generate.