summaryrefslogtreecommitdiffstats
path: root/meta/recipes-extended/ltp/ltp/0009-open_posix_testsuite-mmap24-2-Relax-condition-a-bit.patch
blob: d32ac1dd7c97b6f8383912f355c2e673ace77a89 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
From a8715a1446305ffd76406f63c7f160c13a5b2e72 Mon Sep 17 00:00:00 2001
From: "Hongzhi.Song" <hongzhi.song@windriver.com>
Date: Wed, 10 Oct 2018 22:07:05 -0400
Subject: [PATCH] open_posix_testsuite/mmap24-2: Relax condition a bit

Mips will return EINVAL instead of ENOMEM as expected
if the range [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;

Relax the condition and accept both ENOMEM and EINVAL
as expected outcome.

Upstream-Status: Submitted [https://lists.linux.it/pipermail/ltp/2018-October/009624.html]

Signed-off-by: Hongzhi.Song <hongzhi.song@windriver.com>
---
 .../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 9cf83d9..55090a6 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.
  */
 
 #include <stdio.h>
@@ -92,8 +92,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);
 	}
 
@@ -102,6 +102,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;
 }
-- 
2.7.4