Fix 31252 gprofng causes testsuite parallel jobs fail

Before running our tests, we made a fake installation into ./tmpdir.
This installation changes libopcodes.la in the build area.
Gas testing may fail if gas and gprofng tests are run in parallel.

I create a script to run gprofng. Inside this script, LD_LIBRARY_PATH,
GPROFNG_SYSCONFDIR are set.
putenv_libcollector_ld_misc() first uses $GPROFNG_PRELOAD_LIBDIRS to create
directories for SP_COLLECTOR_LIBRARY_PATH ($SP_COLLECTOR_LIBRARY_PATH is used
to set up LD_PRELOAD).

gprofng/ChangeLog
2024-01-19  Vladimir Mezentsev  <vladimir.mezentsev@oracle.com>

	PR gprofng/31252
	PR gprofng/30808
	* src/envsets.cc (putenv_libcollector_ld_misc): Use
	$GPROFNG_PRELOAD_LIBDIRS first to build SP_COLLECTOR_LIBRARY_PATH.
	* testsuite/config/default.exp: Create a script to run gprofng.
	* testsuite/lib/display-lib.exp: Fix typo.
This commit is contained in:
Vladimir Mezentsev 2024-01-19 18:40:21 -08:00
parent e97522312b
commit c37ad9ea16
3 changed files with 57 additions and 20 deletions

View File

@ -146,20 +146,42 @@ collect::putenv_libcollector_ld_misc ()
// so that -agentlib:gp-collector works
// and so that collect -F works with 32/64-bit mix of processes
// Set GPROFNG_PRELOAD_LIBDIRS
StringBuilder sb;
sb.append ("SP_COLLECTOR_LIBRARY_PATH=");
int len = sb.length ();
int cnt = 0;
char *fname;
char *ev = getenv (GPROFNG_PRELOAD_LIBDIRS);
char *libpath_list = NULL;
if (ev == NULL && settings->preload_libdirs == NULL)
if (ev)
{ /* GPROFNG_PRELOAD_LIBDIRS is used only in the gprofng testing.
* Use these directories first. */
ev = strdup (ev);
for (char *s = ev; s;)
{
char *s1 = strchr (s, ':');
if (s1)
*(s1++) = 0;
fname = dbe_sprintf ("%s/%s", s, LIBGP_COLLECTOR);
if (access (fname, R_OK | F_OK) == 0)
{
if (++cnt != 1)
sb.append (':');
sb.append (s);
}
free (fname);
s = s1;
}
free (ev);
ev = NULL;
}
if (settings->preload_libdirs == NULL)
{
settings->read_rc (false);
ev = settings->preload_libdirs;
}
ev = dbe_strdup (ev);
StringBuilder sb;
sb.appendf ("%s=", "SP_COLLECTOR_LIBRARY_PATH");
int len = sb.length ();
int cnt = 0;
char *fname = dbe_sprintf ("%s/%s/%s", LIBDIR, PACKAGE, LIBGP_COLLECTOR);
fname = dbe_sprintf ("%s/%s/%s", LIBDIR, PACKAGE, LIBGP_COLLECTOR);
if (access (fname, R_OK | F_OK) == 0)
{
++cnt;

View File

@ -19,6 +19,7 @@
# MA 02110-1301, USA.
#
# The "make check" target in the Makefile passes in
# "CC=$(CC_FOR_TARGET)". But, if the user invokes runtest directly,
# these flags may not be set.
@ -36,18 +37,32 @@ remote_exec host "sh -c \"rm -rf tmpdir; mkdir -p tmpdir\""
if { "$CHECK_TARGET" == "check-install" } {
set ::env(GPROFNG) "$PREFIX/bin/gprofng"
} else {
# Make a temporary install dir to run gprofng from, and point at it
remote_exec host "sh -c \"$MAKE -C .. install-gprofng MAKEFLAGS=program_transform_name= DESTDIR=$BUILDDIR/tmpdir/root\""
set ::env(GPROFNG) [exec find $BUILDDIR/tmpdir -type f -name gprofng -perm -u+x | head -1]
set ld_library_path "${BUILDDIR}/src/.libs:${BUILDDIR}/libcollector/.libs"
set orig_ld_library_path ""
catch { set orig_ld_library_path $::env(LD_LIBRARY_PATH) }
if [file exists "${BUILDDIR}/../bfd/.libs/libbfd.a"] {
append ld_library_path ":${BUILDDIR}/../bfd/.libs"
}
if [file exists "${BUILDDIR}/../opcodes/.libs/libopcodes.a"] {
append ld_library_path ":${BUILDDIR}/../opcodes/.libs"
}
if [file exists "${BUILDDIR}/../libsframe/.libs/libsframe.a"] {
append ld_library_path ":${BUILDDIR}/../libsframe/.libs"
}
if [file exists "${BUILDDIR}/../libiberty/libiberty.a"] {
append ld_library_path ":${BUILDDIR}/../libiberty"
}
set x [exec find $BUILDDIR/tmpdir -type d -name gprofng | head -1]
set ::env(LD_LIBRARY_PATH) "$x:$x/.."
set x [exec find $BUILDDIR/tmpdir -type f -name gprofng.rc | head -1]
set ::env(GPROFNG_SYSCONFDIR) [exec dirname $x]
puts "### LD_LIBRARY_PATH: $env(LD_LIBRARY_PATH)"
puts "### GPROFNG_SYSCONFDIR: $env(GPROFNG_SYSCONFDIR)"
set f [open "gprofng_wraper" w+]
puts $f "#!/usr/bin/bash"
puts $f "LD_LIBRARY_PATH=$ld_library_path:$orig_ld_library_path"
puts $f "GPROFNG_SYSCONFDIR=$env(srcroot)/src"
puts $f "GPROFNG_PRELOAD_LIBDIRS=$BUILDDIR/libcollector/.libs"
puts $f "export LD_LIBRARY_PATH GPROFNG_SYSCONFDIR GPROFNG_PRELOAD_LIBDIRS"
puts $f "${BUILDDIR}/src/gprofng \"\$@\""
close $f
file attributes gprofng_wraper -permissions +rx
set ::env(GPROFNG) "$BUILDDIR/gprofng_wraper"
}
puts "### GPROFNG: $env(GPROFNG)"

View File

@ -26,8 +26,8 @@ proc run_native_host_cmd { command } {
verbose -log "$command"
set run_output ""
try {
send_log "% timeout $TEST_TIMEOUT sh -c '$command' 2>&1\n"
set run_output [exec "timeout" $TEST_TIMEOUT "sh" "-c" "$command" "2>&1"]
send_log "% timeout $TEST_TIMEOUT sh -c '$command' 2>@1\n"
set run_output [exec "timeout" $TEST_TIMEOUT "sh" "-c" "$command" "2>@1"]
set status 0
} trap CHILDSTATUS {results options} {
set status [lindex [dict get $options -errorcode] 2]