aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.linespec
diff options
context:
space:
mode:
authorSimon Marchi <simon.marchi@polymtl.ca>2022-04-22 09:16:59 -0400
committerSimon Marchi <simon.marchi@polymtl.ca>2022-04-26 20:16:03 -0400
commit019a5c62974523a3331911130c66350ef0a6f3c4 (patch)
treecf2f44ec018c1957bff0c335820a0b87c0479715 /gdb/testsuite/gdb.linespec
parent2538fcd3f4b6807f48de20982a2d9c584d98912b (diff)
downloadbinutils-019a5c62974523a3331911130c66350ef0a6f3c4.zip
binutils-019a5c62974523a3331911130c66350ef0a6f3c4.tar.gz
binutils-019a5c62974523a3331911130c66350ef0a6f3c4.tar.bz2
gdb/testsuite: use with_cwd where possible
I learned about with_cwd today. I spotted a few spots that could use it, to make the code more robust. Change-Id: Ia23664cb827f25e79d31948e0c006a8dc61c33e1
Diffstat (limited to 'gdb/testsuite/gdb.linespec')
-rw-r--r--gdb/testsuite/gdb.linespec/break-ask.exp23
-rw-r--r--gdb/testsuite/gdb.linespec/macro-relative.exp13
2 files changed, 19 insertions, 17 deletions
diff --git a/gdb/testsuite/gdb.linespec/break-ask.exp b/gdb/testsuite/gdb.linespec/break-ask.exp
index d73172d..120c399 100644
--- a/gdb/testsuite/gdb.linespec/break-ask.exp
+++ b/gdb/testsuite/gdb.linespec/break-ask.exp
@@ -28,16 +28,19 @@ if { [file pathtype $objdir] == "relative" } {
untested "objdir $objdir should be absolute"
return
}
-set saved_pwd [pwd]
-cd $srcdir/${subdir}/base/one
-set err1 [gdb_compile "thefile.cc" $objfile1 object $opts]
-cd $saved_pwd
-cd $srcdir/${subdir}/base/two
-set err2 [gdb_compile "thefile.cc" $objfile2 object $opts]
-cd $saved_pwd
-if { $err1 != "" || $err2 != "" } {
- untested "compilation failed"
- return -1
+
+with_cwd $srcdir/${subdir}/base/one {
+ if { [gdb_compile "thefile.cc" $objfile1 object $opts] != "" } {
+ untested "compilation failed"
+ return
+ }
+}
+
+with_cwd $srcdir/${subdir}/base/two {
+ if { [gdb_compile "thefile.cc" $objfile2 object $opts] != "" } {
+ untested "compilation failed"
+ return
+ }
}
if { [gdb_compile "$srcdir/${subdir}/$srcfile $objfile1 $objfile2" \
diff --git a/gdb/testsuite/gdb.linespec/macro-relative.exp b/gdb/testsuite/gdb.linespec/macro-relative.exp
index 609f290..67b779f 100644
--- a/gdb/testsuite/gdb.linespec/macro-relative.exp
+++ b/gdb/testsuite/gdb.linespec/macro-relative.exp
@@ -32,13 +32,12 @@ if { [file pathtype $objdir] == "relative" } {
untested "objdir $objdir should be absolute"
return
}
-set saved_pwd [pwd]
-cd $srcdir/${subdir}/base/two
-set err [gdb_compile "../../${srcfile}" "${binfile}" executable $opts]
-cd $saved_pwd
-if { $err != "" } {
- untested "compilation failed"
- return -1
+
+with_cwd $srcdir/${subdir}/base/two {
+ if { [gdb_compile "../../${srcfile}" "${binfile}" executable $opts] != "" } {
+ untested "compilation failed"
+ return
+ }
}
clean_restart ${testfile}