public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Vladimir Mezentsev <vladimir.mezentsev@oracle.com>
To: "binutils@sourceware.org" <binutils@sourceware.org>
Subject: Fwd: [PATCH] Fix 31252 gprofng causes testsuite parallel jobs fail
Date: Mon, 22 Jan 2024 09:19:07 -0800	[thread overview]
Message-ID: <bd9bba79-7aca-622d-c6f2-92940aa2974a@oracle.com> (raw)
In-Reply-To: <20240120024227.1566464-1-vladimir.mezentsev@oracle.com>

[-- Attachment #1: Type: text/plain, Size: 5965 bytes --]


   OK for 2.42 branch ?




-------- Forwarded Message --------
Subject: 	[PATCH] Fix 31252 gprofng causes testsuite parallel jobs fail
Date: 	Fri, 19 Jan 2024 18:42:27 -0800
From: 	vladimir.mezentsev@oracle.com
To: 	binutils@sourceware.org
CC: 	Vladimir Mezentsev <vladimir.mezentsev@oracle.com>



From: Vladimir Mezentsev <vladimir.mezentsev@oracle.com>

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.
---
gprofng/src/envsets.cc | 36 +++++++++++++++++++++-----
gprofng/testsuite/config/default.exp | 37 +++++++++++++++++++--------
gprofng/testsuite/lib/display-lib.exp | 4 +--
3 files changed, 57 insertions(+), 20 deletions(-)

diff --git a/gprofng/src/envsets.cc b/gprofng/src/envsets.cc
index 1ca39ed9ac1..9cef7452df7 100644
--- a/gprofng/src/envsets.cc
+++ b/gprofng/src/envsets.cc
@@ -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;
diff --git a/gprofng/testsuite/config/default.exp 
b/gprofng/testsuite/config/default.exp
index e22d99bc422..6b51d578d9f 100644
--- a/gprofng/testsuite/config/default.exp
+++ b/gprofng/testsuite/config/default.exp
@@ -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 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]
+ 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"
+ }
- 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)"
diff --git a/gprofng/testsuite/lib/display-lib.exp 
b/gprofng/testsuite/lib/display-lib.exp
index 4843c3678bf..32e8ce5dd73 100644
--- a/gprofng/testsuite/lib/display-lib.exp
+++ b/gprofng/testsuite/lib/display-lib.exp
@@ -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]

-- 
2.31.1

  reply	other threads:[~2024-01-22 17:19 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-20  2:42 vladimir.mezentsev
2024-01-22 17:19 ` Vladimir Mezentsev [this message]
2024-01-22 17:44   ` Fwd: " Nick Clifton

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=bd9bba79-7aca-622d-c6f2-92940aa2974a@oracle.com \
    --to=vladimir.mezentsev@oracle.com \
    --cc=binutils@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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).