From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1521) id 4EF803858418; Thu, 3 Nov 2022 18:43:08 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4EF803858418 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1667500988; bh=hpLUtwx7aGJqRAXt17jbX62K8iVXcxqqmF2/JYKBKrE=; h=From:To:Subject:Date:From; b=qC9jUk6zg0Q0LdfGIYQHs6zEgDuDA42LmpmWcWxdZT4fukpKhhKsceP7MhLfka3bB nBijLc61C9cd5GX6qMu49zriEyX6BHEST5wXAKCmhWmDwU8YjHtbrnHOCCetPllhcC 3NeAjk9xZ5oa3NxEMYBT2ZAz1DrSQzMGhi737qlU= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Michael Frysinger To: gdb-cvs@sourceware.org Subject: [binutils-gdb] sim: testsuite: fix cris stat3 in diff setups X-Act-Checkin: binutils-gdb X-Git-Author: Mike Frysinger X-Git-Refname: refs/heads/master X-Git-Oldrev: 4ce3ba0865ee156be63c3d763f1678cbe57d7dd6 X-Git-Newrev: 7b3dd7b9b3b20cbcf624e85a0d1305c5e3d68663 Message-Id: <20221103184308.4EF803858418@sourceware.org> Date: Thu, 3 Nov 2022 18:43:08 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D7b3dd7b9b3b2= 0cbcf624e85a0d1305c5e3d68663 commit 7b3dd7b9b3b20cbcf624e85a0d1305c5e3d68663 Author: Mike Frysinger Date: Wed Nov 2 20:27:54 2022 +0545 sim: testsuite: fix cris stat3 in diff setups =20 This test uses the test itself as an input to stating regular files. This gets funky though: when we run check in parallel, the output object dir is the subdir that matches the .exp file. When we run with -j1, the output object dir is the sim builddir itself. =20 The old test would append argv[0] to find the file, while the new test uses basename on it. Each method works in only one of the aforementioned build scenarios. Rather than complicate this any more, switch to a different file that we know will always exist: the Makefile. Diff: --- sim/testsuite/cris/c/stat3.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/sim/testsuite/cris/c/stat3.c b/sim/testsuite/cris/c/stat3.c index 321da1b2bd6..a6e4897436c 100644 --- a/sim/testsuite/cris/c/stat3.c +++ b/sim/testsuite/cris/c/stat3.c @@ -7,21 +7,25 @@ #include #include #include -#define mybasename(x) ({ const char *x_ =3D (x), *y_ =3D strrchr (x_, '/')= ; y_ !=3D NULL ? y_ + 1 : x_; }) =20 int main (int argc, char *argv[]) { - char path[1024] =3D "/"; + /* Pick a regular file we know will always be in the sim builddir. */ + char path[1024] =3D "/Makefile"; struct stat buf; =20 - strcat (path, mybasename (argv[0])); if (stat (".", &buf) !=3D 0 || !S_ISDIR (buf.st_mode)) - abort (); + { + fprintf (stderr, "cwd is not a directory\n"); + return 1; + } if (stat (path, &buf) !=3D 0 || !S_ISREG (buf.st_mode)) - abort (); + { + fprintf (stderr, "%s: is not a regular file\n", path); + return 1; + } printf ("pass\n"); exit (0); } -