From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183]) by sourceware.org (Postfix) with ESMTP id DC7063856952 for ; Wed, 2 Nov 2022 16:00:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org DC7063856952 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gentoo.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gentoo.org Received: by smtp.gentoo.org (Postfix, from userid 559) id 2D524340F7A; Wed, 2 Nov 2022 16:00:04 +0000 (UTC) From: Mike Frysinger To: gdb-patches@sourceware.org Subject: [PATCH] sim: testsuite: fix cris stat3 in diff setups Date: Wed, 2 Nov 2022 20:30:42 +0545 Message-Id: <20221102144542.19653-1-vapier@gentoo.org> X-Mailer: git-send-email 2.37.3 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-11.1 required=5.0 tests=BAYES_00,GIT_PATCH_0,JMQ_SPF_NEUTRAL,KAM_DMARC_STATUS,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: 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. 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. --- 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 321da1b2bd61..a6e4897436c1 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_ = (x), *y_ = strrchr (x_, '/'); y_ != NULL ? y_ + 1 : x_; }) int main (int argc, char *argv[]) { - char path[1024] = "/"; + /* Pick a regular file we know will always be in the sim builddir. */ + char path[1024] = "/Makefile"; struct stat buf; - strcat (path, mybasename (argv[0])); if (stat (".", &buf) != 0 || !S_ISDIR (buf.st_mode)) - abort (); + { + fprintf (stderr, "cwd is not a directory\n"); + return 1; + } if (stat (path, &buf) != 0 || !S_ISREG (buf.st_mode)) - abort (); + { + fprintf (stderr, "%s: is not a regular file\n", path); + return 1; + } printf ("pass\n"); exit (0); } - -- 2.37.3