From: Simon Marchi <simon.marchi@ericsson.com>
To: <gdb-patches@sourceware.org>
Cc: Simon Marchi <simon.marchi@ericsson.com>
Subject: [PATCH] Remove symlinks created in argv0-symlink.exp and general cleanup
Date: Thu, 30 Jul 2015 20:13:00 -0000 [thread overview]
Message-ID: <1438287227-11303-1-git-send-email-simon.marchi@ericsson.com> (raw)
When running argv0-symlink.exp, symlinks are left in the test output
directory. One of them is a recursive symlink. This causes the same tests
to be found multiple times and disturbs subsequent test runs.
To witness it simply, just run
$ make check RUNTESTFLAGS="argv0-symlink.exp"
twice in a row. The second run will find and run argv0-symlink.exp
multiple times because of the recursive symlink left by the first run. Note
that this only happens when building in tree. The simple fix is to
remove the links when we are done.
At the same time, I did a general cleanup of the test:
- Add and use a create_link proc.
- Bail out early if target does not support argv[0].
- Of course, remove created symlinks before returning.
gdb/testsuite/ChangeLog:
* gdb.base/argv0-symlink.exp: Remove symlinks when done.
General cleanup.
---
gdb/testsuite/gdb.base/argv0-symlink.exp | 90 ++++++++++++++++++++------------
1 file changed, 56 insertions(+), 34 deletions(-)
diff --git a/gdb/testsuite/gdb.base/argv0-symlink.exp b/gdb/testsuite/gdb.base/argv0-symlink.exp
index f030656..053f8c5 100644
--- a/gdb/testsuite/gdb.base/argv0-symlink.exp
+++ b/gdb/testsuite/gdb.base/argv0-symlink.exp
@@ -13,80 +13,102 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Delete files specified in ARGS. The paths are relative to the standard
+# test output directory.
+
+proc cleanup {args} {
+ foreach file $args {
+ remote_exec host "rm -f [standard_output_file $file]"
+ }
+}
+
+
+# Create a symbolic link from LINK_NAME to TARGET. Return 1 on success,
+# 0 otherwise.
+
+proc create_link {target link_name} {
+ set status [remote_exec host "ln -sf ${target} ${link_name}"]
+ if { [lindex $status 0] != 0 } {
+ return 0
+ }
+
+ return 1
+}
+
standard_testfile
-set has_argv0 [gdb_has_argv0]
+if { ![gdb_has_argv0] } {
+ unsupported "target does not provide argv\[0\]"
+ return 0
+}
+
+set filelink "${testfile}-filelink"
+set dirlink "${testfile}-dirlink"
+
+# For a link named /PATH/TO/DIR/LINK, we want to check the output
+# against "/DIR/LINK", but computed in a way that doesn't make
+# assumptions about the test directory layout.
+set full_filelink [standard_output_file $filelink]
+set lastdir [file tail [file dirname $full_filelink]]
if { [build_executable ${testfile}.exp ${testfile} ${srcfile}] == -1 } {
return -1
}
+# Remove any existing link.
+cleanup "$filelink" "$dirlink"
+
+# Test with symlink to files.
set test "kept file symbolic link name"
-set filelink "${testfile}-filelink"
-remote_file host delete [standard_output_file $filelink]
-set status [remote_exec host "ln -sf ${testfile} [standard_output_file $filelink]"]
-if {[lindex $status 0] != 0} {
+if { ![create_link "${testfile}" "[standard_output_file $filelink]"] } {
unsupported "$test (host does not support symbolic links)"
+ cleanup "$filelink" "$dirlink"
return 0
}
clean_restart "$filelink"
-if ![runto_main] {
+if { ![runto_main] } {
untested "could not run to main"
+ cleanup "$filelink" "$dirlink"
return -1
}
gdb_test_no_output "set print repeats 10000"
gdb_test_no_output "set print elements 10000"
-if { $has_argv0 } {
- gdb_test {print argv[0]} "/$filelink\"" $test
-} else {
- unsupported $test
-}
-
-# For a link named /PATH/TO/DIR/LINK, we want to check the output
-# against "/DIR/LINK", but computed in a way that doesn't make
-# assumptions about the test directory layout.
-set full_filelink [standard_output_file $filelink]
-set lastdir [file tail [file dirname $full_filelink]]
+gdb_test {print argv[0]} "/$filelink\"" $test
gdb_test "info inferiors" "/$lastdir/$filelink *" "$test for info inferiors"
-
+# Test with symlink to dir.
set test "kept directory symbolic link name"
-set dirlink "${testfile}-dirlink"
-# 'ln -sf' does not overwrite symbol link to a directory.
-# 'remote_file host delete' uses stat (not lstat), therefore it refuses to
-# delete a directory.
-remote_exec host "rm -f [standard_output_file $dirlink]"
-set status [remote_exec host "ln -sf . [standard_output_file $dirlink]"]
-if {[lindex $status 0] != 0} {
+if { ![create_link "." "[standard_output_file $dirlink]"] } {
unsupported "$test (host does not support symbolic links)"
+ cleanup "$filelink" "$dirlink"
return 0
}
clean_restart "$dirlink/$filelink"
-if ![runto_main] {
+if { ![runto_main] } {
untested "could not run to main"
+ cleanup "$filelink" "$dirlink"
return -1
}
gdb_test_no_output "set print repeats 10000"
gdb_test_no_output "set print elements 10000"
-if { $has_argv0 } {
- # gdbserver does not have this issue.
- if ![is_remote target] {
- setup_kfail "*-*-*" gdb/15934
- }
- gdb_test {print argv[0]} "/$dirlink/$filelink\"" $test
-} else {
- unsupported $test
+# gdbserver does not have this issue.
+if { ![is_remote target] } {
+ setup_kfail "*-*-*" gdb/15934
}
+gdb_test {print argv[0]} "/$dirlink/$filelink\"" $test
gdb_test "info inferiors" "/$lastdir/$filelink *" "$test for info inferiors"
+
+cleanup "$filelink" "$dirlink"
--
2.1.4
next reply other threads:[~2015-07-30 20:13 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-30 20:13 Simon Marchi [this message]
2015-08-03 14:23 ` Pedro Alves
2015-08-03 15:16 ` Simon Marchi
2015-08-03 16:34 ` Pedro Alves
2015-08-03 16:38 ` Pedro Alves
2015-08-03 18:10 ` Simon Marchi
2015-08-03 18:42 ` Pedro Alves
2015-08-04 16:11 ` Sergio Durigan Junior
2015-08-04 17:21 ` Joel Brobecker
2015-08-11 17:36 ` Doug Evans
2015-08-11 19:58 ` Joel Brobecker
2015-08-11 20:43 ` Doug Evans
2015-08-11 23:02 ` Joel Brobecker
2015-08-12 9:30 ` Pedro Alves
2015-08-12 16:40 ` Sergio Durigan Junior
2015-08-12 17:22 ` Joel Brobecker
2015-08-12 17:38 ` Doug Evans
2015-08-12 18:43 ` Joel Brobecker
2015-08-12 18:50 ` Doug Evans
2015-08-12 19:41 ` Joel Brobecker
2015-08-12 20:23 ` Doug Evans
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=1438287227-11303-1-git-send-email-simon.marchi@ericsson.com \
--to=simon.marchi@ericsson.com \
--cc=gdb-patches@sourceware.org \
/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