From patchwork Wed Nov 2 14:45:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Frysinger X-Patchwork-Id: 59795 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 215CE385AE58 for ; Wed, 2 Nov 2022 16:00:31 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 215CE385AE58 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1667404831; bh=pYMvkYnZCt5UCD1xSUrtm+7X5KxMVOiXuyedbzc4m1U=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=Pm66IU7kWEHZgpaL4Wsc82ZOrdS/qVMjmEKyZrX4azu6HuUiLaOf7HBEjHbozORdL DkSXX2T1Qs0k/ZY++fCJILU8ffLZvSJSiuesKWOYUu3QpavePOOWcZi8jVCIO9Z2iq 5smBesX7GvveU2/iyfoT/fI02diF5XvzRS0JHPQs= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org 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 Received: by smtp.gentoo.org (Postfix, from userid 559) id 2D524340F7A; Wed, 2 Nov 2022 16:00:04 +0000 (UTC) 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 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 X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Mike Frysinger via Gdb-patches From: Mike Frysinger Reply-To: Mike Frysinger Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" 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); } -