Brad Bishop | 96ff198 | 2019-08-19 13:50:42 -0400 | [diff] [blame^] | 1 | From a8715a1446305ffd76406f63c7f160c13a5b2e72 Mon Sep 17 00:00:00 2001 |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 2 | From: "Hongzhi.Song" <hongzhi.song@windriver.com> |
| 3 | Date: Wed, 10 Oct 2018 22:07:05 -0400 |
| 4 | Subject: [PATCH] open_posix_testsuite/mmap24-2: Relax condition a bit |
| 5 | |
| 6 | Mips will return EINVAL instead of ENOMEM as expected |
| 7 | if the range [addr + len) exceeds TASK_SIZE. |
| 8 | |
| 9 | Linux kernel code: arch/mips/mm/mmap.c |
| 10 | if (flags & MAP_FIXED) { |
| 11 | /* Even MAP_FIXED mappings must reside within TASK_SIZE */ |
| 12 | if (TASK_SIZE - len < addr) |
| 13 | return -EINVAL; |
| 14 | |
| 15 | Relax the condition and accept both ENOMEM and EINVAL |
| 16 | as expected outcome. |
| 17 | |
| 18 | Upstream-Status: Submitted [https://lists.linux.it/pipermail/ltp/2018-October/009624.html] |
| 19 | |
| 20 | Signed-off-by: Hongzhi.Song <hongzhi.song@windriver.com> |
| 21 | --- |
| 22 | .../open_posix_testsuite/conformance/interfaces/mmap/24-2.c | 10 +++++----- |
| 23 | 1 file changed, 5 insertions(+), 5 deletions(-) |
| 24 | |
| 25 | diff --git a/testcases/open_posix_testsuite/conformance/interfaces/mmap/24-2.c b/testcases/open_posix_testsuite/conformance/interfaces/mmap/24-2.c |
Brad Bishop | 96ff198 | 2019-08-19 13:50:42 -0400 | [diff] [blame^] | 26 | index 9cf83d9..55090a6 100644 |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 27 | --- a/testcases/open_posix_testsuite/conformance/interfaces/mmap/24-2.c |
| 28 | +++ b/testcases/open_posix_testsuite/conformance/interfaces/mmap/24-2.c |
| 29 | @@ -7,7 +7,7 @@ |
| 30 | * source tree. |
| 31 | * |
| 32 | * The mmap() function shall fail if: |
| 33 | - * [ENOMEM] MAP_FIXED was specified, |
| 34 | + * [ENOMEM or EINVAL] MAP_FIXED was specified, |
| 35 | * and the range [addr,addr+len) exceeds that allowed |
| 36 | * for the address space of a process; or, if MAP_FIXED was not specified and |
| 37 | * there is insufficient room in the address space to effect the mapping. |
| 38 | @@ -15,7 +15,7 @@ |
| 39 | * Test Step: |
| 40 | * 1. Map a shared memory object, with size exceeding the value get from |
| 41 | * rlim_cur of resource RLIMIT_AS, setting MAP_FIXED; |
| 42 | - * 3. Should get ENOMEM. |
| 43 | + * 3. Should get ENOMEM or EINVAL. |
| 44 | */ |
| 45 | |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 46 | #include <stdio.h> |
| 47 | @@ -92,8 +92,8 @@ int main(void) |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 48 | (unsigned long)len); |
| 49 | pa = mmap(addr, len, PROT_READ | PROT_WRITE, MAP_FIXED | MAP_SHARED, fd, |
| 50 | 0); |
| 51 | - if (pa == MAP_FAILED && errno == ENOMEM) { |
| 52 | - printf("Got ENOMEM: %s\nTest PASSED\n", strerror(errno)); |
| 53 | + if (pa == MAP_FAILED && (errno == ENOMEM || errno == EINVAL)) { |
| 54 | + printf("Got ENOMEM or EINVAL: %s\nTest PASSED\n", strerror(errno)); |
| 55 | exit(PTS_PASS); |
| 56 | } |
| 57 | |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 58 | @@ -102,6 +102,6 @@ int main(void) |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 59 | else |
| 60 | munmap(pa, len); |
| 61 | close(fd); |
| 62 | - printf("Test Fail: Did not get ENOMEM as expected\n"); |
| 63 | + printf("Test Failed: Did not get ENOMEM or EINVAL as expected\n"); |
| 64 | return PTS_FAIL; |
| 65 | } |
| 66 | -- |
Brad Bishop | 96ff198 | 2019-08-19 13:50:42 -0400 | [diff] [blame^] | 67 | 2.7.4 |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 68 | |