From patchwork Wed Oct 24 02:36:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Hongzhi, Song" X-Patchwork-Id: 988456 X-Patchwork-Delegate: chrubis@suse.cz Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=lists.linux.it (client-ip=213.254.12.146; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=windriver.com Received: from picard.linux.it (picard.linux.it [213.254.12.146]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42fvZt3G46z9s9G for ; Wed, 24 Oct 2018 13:38:46 +1100 (AEDT) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id D818A3E6B2D for ; Wed, 24 Oct 2018 04:38:43 +0200 (CEST) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-6.smtp.seeweb.it (in-6.smtp.seeweb.it [IPv6:2001:4b78:1:20::6]) by picard.linux.it (Postfix) with ESMTP id 78B5A3E6AF1 for ; Wed, 24 Oct 2018 04:38:42 +0200 (CEST) Received: from mail5.wrs.com (mail5.windriver.com [192.103.53.11]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by in-6.smtp.seeweb.it (Postfix) with ESMTPS id 1FA931400BE9 for ; Wed, 24 Oct 2018 04:38:40 +0200 (CEST) Received: from ALA-HCB.corp.ad.wrs.com (ala-hcb.corp.ad.wrs.com [147.11.189.41]) by mail5.wrs.com (8.15.2/8.15.2) with ESMTPS id w9O2c8eg022872 (version=TLSv1 cipher=AES128-SHA bits=128 verify=FAIL); Tue, 23 Oct 2018 19:38:18 -0700 Received: from pek-lpggp1.wrs.com (128.224.153.74) by ALA-HCB.corp.ad.wrs.com (147.11.189.41) with Microsoft SMTP Server id 14.3.408.0; Tue, 23 Oct 2018 19:37:57 -0700 From: "Hongzhi.Song" To: , Date: Tue, 23 Oct 2018 22:36:47 -0400 Message-ID: <1540348607-217391-1-git-send-email-hongzhi.song@windriver.com> X-Mailer: git-send-email 2.8.1 MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.99.2 at in-6.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=-0.0 required=7.0 tests=SPF_PASS autolearn=disabled version=3.4.0 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on in-6.smtp.seeweb.it Subject: [LTP] [PATCH] open_posix_testsuite/mmap24-2: Support mips X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.18 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" Mips will return EINVAL instead of ENOMEM as expected if MAP_FIXED is set and the range of [addr + len) exceeds TASK_SIZE. Linux kernel code: arch/mips/mm/mmap.c if (flags & MAP_FIXED) { /* Even MAP_FIXED mappings must reside within TASK_SIZE */ if (TASK_SIZE - len < addr) return -EINVAL; The POSIX specification says: "If MAP_FIXED is set, mmap() may return MAP_FAILED and set errno to [EINVAL]." [http://pubs.opengroup.org/onlinepubs/9699919799/functions/mmap.html] So I think the mips kernel remains POSIX compliant. Relax the condition and accept both ENOMEM and EINVAL as expected outcome. Signed-off-by: Hongzhi.Song --- .../open_posix_testsuite/conformance/interfaces/mmap/24-2.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/testcases/open_posix_testsuite/conformance/interfaces/mmap/24-2.c b/testcases/open_posix_testsuite/conformance/interfaces/mmap/24-2.c index de51d43..810e5c8 100644 --- a/testcases/open_posix_testsuite/conformance/interfaces/mmap/24-2.c +++ b/testcases/open_posix_testsuite/conformance/interfaces/mmap/24-2.c @@ -7,7 +7,7 @@ * source tree. * * The mmap() function shall fail if: - * [ENOMEM] MAP_FIXED was specified, + * [ENOMEM or EINVAL] MAP_FIXED was specified, * and the range [addr,addr+len) exceeds that allowed * for the address space of a process; or, if MAP_FIXED was not specified and * there is insufficient room in the address space to effect the mapping. @@ -15,7 +15,7 @@ * Test Step: * 1. Map a shared memory object, with size exceeding the value get from * rlim_cur of resource RLIMIT_AS, setting MAP_FIXED; - * 3. Should get ENOMEM. + * 3. Should get ENOMEM or EINVAL. */ #define _XOPEN_SOURCE 600 @@ -93,8 +93,8 @@ int main(void) (unsigned long)len); pa = mmap(addr, len, PROT_READ | PROT_WRITE, MAP_FIXED | MAP_SHARED, fd, 0); - if (pa == MAP_FAILED && errno == ENOMEM) { - printf("Got ENOMEM: %s\nTest PASSED\n", strerror(errno)); + if (pa == MAP_FAILED && (errno == ENOMEM || errno == EINVAL)) { + printf("Got ENOMEM or EINVAL: %s\nTest PASSED\n", strerror(errno)); exit(PTS_PASS); } @@ -103,6 +103,6 @@ int main(void) else munmap(pa, len); close(fd); - printf("Test Fail: Did not get ENOMEM as expected\n"); + printf("Test Failed: Did not get ENOMEM or EINVAL as expected\n"); return PTS_FAIL; }