From patchwork Fri Jul 7 15:04:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhangjin Wu X-Patchwork-Id: 13305013 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0457FEB64D9 for ; Fri, 7 Jul 2023 15:05:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233293AbjGGPFC (ORCPT ); Fri, 7 Jul 2023 11:05:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46106 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232882AbjGGPFB (ORCPT ); Fri, 7 Jul 2023 11:05:01 -0400 Received: from bg4.exmail.qq.com (bg4.exmail.qq.com [43.155.65.254]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 151FBAF; Fri, 7 Jul 2023 08:04:59 -0700 (PDT) X-QQ-mid: bizesmtp86t1688742286tdi4pyen Received: from linux-lab-host.localdomain ( [116.30.131.119]) by bizesmtp.qq.com (ESMTP) with id ; Fri, 07 Jul 2023 23:04:44 +0800 (CST) X-QQ-SSF: 01200000000000D0W000000A0000000 X-QQ-FEAT: LE7C6P2vL8SOb2ot9Z4ClJPBG54oOkVEmnFkdgI7ol3U2CHkMdwXkXemITIbi djp+D/7qqCayMft9D4BLvUx1HdAK5PtsH0bKSsHvQQ+CQkH1NcscF1hU+hEdiActny/W++4 6yGiFU5Cz2UjoqfospzFK3ZAlb9V9Z8HNBWYr7kfNzFTOIq05OxVwEbh6Hb0+GXFC6NojBw 7Qtx8mUIxs/JUHjqS8OQABWAVMsbcFSCfrY0zgRT/BHTNmJuJF4kAf7bGtIxHkt0us2ClEh JFf+lGyIaYHHUbIp1aGNk98tQMfnK2RpSFzpwgXnA7ngEk22+dCmS++VBzsBk+5rHAQIBV4 M7h6K18S8y+59KAI10TvychS9ca23hf+ByN50OBU8CyYuCwK1OflvnlqOuJKA== X-QQ-GoodBg: 0 X-BIZMAIL-ID: 4349370555613870298 From: Zhangjin Wu To: w@1wt.eu Cc: falcon@tinylab.org, arnd@arndb.de, david.laight@aculab.com, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-riscv@lists.infradead.org, thomas@t-8ch.de Subject: [PATCH v6 12/15] selftests/nolibc: add sbrk_0 to test current brk getting Date: Fri, 7 Jul 2023 23:04:38 +0800 Message-Id: <1d45f48df9735f7c7cd52e2529712a7436c94355.1688739492.git.falcon@tinylab.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:tinylab.org:qybglogicsvrgz:qybglogicsvrgz5a-1 Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org From musl 0.9.14 (to the latest version 1.2.3), both sbrk() and brk() have almost been disabled for they conflict with malloc, only sbrk(0) is still permitted as a way to get the current location of the program break, let's support such case. EXPECT_PTRNE() is used to expect sbrk() always successfully getting the current break. Signed-off-by: Zhangjin Wu --- tools/testing/selftests/nolibc/nolibc-test.c | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/selftests/nolibc/nolibc-test.c index 8be675debf28..fde1b3c51a4a 100644 --- a/tools/testing/selftests/nolibc/nolibc-test.c +++ b/tools/testing/selftests/nolibc/nolibc-test.c @@ -633,6 +633,7 @@ int run_syscall(int min, int max) CASE_TEST(kill_0); EXPECT_SYSZR(1, kill(getpid(), 0)); break; CASE_TEST(kill_CONT); EXPECT_SYSZR(1, kill(getpid(), 0)); break; CASE_TEST(kill_BADPID); EXPECT_SYSER(1, kill(INT_MAX, 0), -1, ESRCH); break; + CASE_TEST(sbrk_0); EXPECT_PTRNE(1, sbrk(0), (void *)-1); break; CASE_TEST(sbrk); if ((p1 = p2 = sbrk(4096)) != (void *)-1) p2 = sbrk(-4096); EXPECT_SYSZR(1, (p2 == (void *)-1) || p2 == p1); break; CASE_TEST(brk); EXPECT_SYSZR(1, brk(sbrk(0))); break; CASE_TEST(chdir_root); EXPECT_SYSZR(1, chdir("/")); break;