mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2025-01-06 12:09:26 +08:00
9344937b04
In this commit:
commit 1845e25464
Date: Wed May 5 16:50:17 2021 +0100
gdb/guile: perform tilde expansion when sourcing guile scripts
A test was added that tries to source a guile script from the users
HOME directory. In order to achieve this the test (temporarily)
modifies $HOME to point into the binutils-gdb source tree.
The problem with this is that sourcing a guile script can cause the
guile script to be byte compiled and written into a .cache/ directory,
which is stored .... in the $HOME directory.
The result was that the test added in the above commit would cause a
.cache/ directory to be added into the binutils-gdb source tree.
In this commit the test is updated to create a new directory in the
build tree, the file we want to source is copied over, and $HOME is
set to point at the location in the build tree. Now when the test is
run the .cache/ directory is created in the build tree, leaving the
source tree untouched.
gdb/testsuite/ChangeLog:
* gdb.guile/guile.exp: Don't use the source directory as a
temporary HOME directory.
103 lines
3.2 KiB
Plaintext
103 lines
3.2 KiB
Plaintext
# Copyright (C) 2008-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
|
|
# the Free Software Foundation; either version 3 of the License, or
|
|
# (at your option) any later version.
|
|
#
|
|
# This program is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU General Public License
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
# This file is part of the GDB testsuite.
|
|
# It tests basic Guile features.
|
|
|
|
load_lib gdb-guile.exp
|
|
|
|
# Start with a fresh gdb.
|
|
gdb_exit
|
|
gdb_start
|
|
gdb_reinitialize_dir $srcdir/$subdir
|
|
|
|
# Do this instead of the skip_guile_check.
|
|
# We want to do some tests when Guile is not present.
|
|
gdb_test_multiple "guile (display 23) (newline)" "verify guile support" {
|
|
-re "Undefined command.*$gdb_prompt $" {
|
|
unsupported "guile not supported."
|
|
return
|
|
}
|
|
-re "not supported.*$gdb_prompt $" {
|
|
unsupported "guile support is disabled"
|
|
|
|
# If Guile is not supported, verify that sourcing a guile script
|
|
# causes an error.
|
|
gdb_test "source $srcdir/$subdir/source2.scm" \
|
|
"Error in sourced command file:.*" \
|
|
"source source2.scm when guile disabled"
|
|
|
|
# Verify multi-line guile commands cause an error.
|
|
gdb_test_multiline "multi-line guile command" \
|
|
"guile" "" \
|
|
"(print 23)" "" \
|
|
"end" "not supported.*"
|
|
|
|
return
|
|
}
|
|
-re "$gdb_prompt $" {}
|
|
}
|
|
|
|
gdb_install_guile_utils
|
|
gdb_install_guile_module
|
|
|
|
gdb_test_multiline "multi-line guile command" \
|
|
"guile" "" \
|
|
"(print 23)" "" \
|
|
"end" "= 23"
|
|
|
|
gdb_test_multiline "show guile command" \
|
|
"define zzq" "Type commands for definition of .* just \"end\"\\.*" \
|
|
"guile" "" \
|
|
"(print 23)" "" \
|
|
"end" "" \
|
|
"end" "" \
|
|
"show user zzq" "User command \"zzq\":.* guile.*\\(print 23\\).* end"
|
|
|
|
gdb_test "source $srcdir/$subdir/source2.scm" "yes" "source source2.scm"
|
|
|
|
gdb_test "source -s source2.scm" "yes"
|
|
|
|
gdb_test "guile (print (current-objfile))" "= #f"
|
|
gdb_test "guile (print (objfiles))" "= \\(\\)"
|
|
|
|
gdb_test_no_output \
|
|
{guile (define x (execute "printf \"%d\", 23" #:to-string #t))}
|
|
gdb_test "guile (print x)" "= 23"
|
|
|
|
gdb_test_no_output "guile (define a (execute \"help\" #:to-string #t))" \
|
|
"collect help from uiout"
|
|
|
|
gdb_test "guile (print a)" "= .*aliases -- User-defined aliases of other commands.*" \
|
|
"verify help to uiout"
|
|
|
|
# Verify that we can source a guile script using ~ for the HOME directory.
|
|
save_vars { env(HOME) } {
|
|
# Create a new directory to act as a temporary HOME directory.
|
|
set tmp_home [standard_output_file tmp_home]
|
|
file mkdir $tmp_home
|
|
|
|
# Copy the file we want to source into the new HOME directory.
|
|
gdb_remote_download host ${srcdir}/${subdir}/source2.scm \
|
|
${tmp_home}/source2.scm
|
|
|
|
# Arrange to use the new HOME directory.
|
|
set env(HOME) $tmp_home
|
|
clean_restart
|
|
|
|
# Finally, source the file out of our new HOME directory.
|
|
gdb_test "source ~/source2.scm" "yes"
|
|
}
|