syscalls/mmap09: Drop hardcoded /tmp path
PATCH 1/1 syscalls/mmap09: Drop hardcoded /tmp path
In some environments (such as Android devices), the /tmp directory might not exist, which causes the test to fail during setup when trying to open /tmp/mmaptest.
Since this test already utilizes the new LTP API with .needs_tmpdir = 1, the framework automatically creates and chdirs into a unique temporary directory. Therefore, we can safely use a relative path for the test file instead of hardcoding /tmp.
--- testcases/kernel/syscalls/mmap/mmap09.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
testcases/kernel/syscalls/mmap/mmap09.c +1 -1
@@ -43,7 +43,7 @@ static void verify_mmap(unsigned int nr)static void setup (void ) { - fd =SAFE_OPEN ("/tmp/mmaptest" ,O_RDWR |O_CREAT ,0666 ); + fd =SAFE_OPEN ("mmaptest" ,O_RDWR |O_CREAT ,0666 );/* set the file to initial size */ SAFE_FTRUNCATE (fd,MAPSIZE );
Signature · 5 lines
2.54.0.rc2.544.gc7ae2d5bb8-goog -- Mailing list info: https://lists.linux.it/listinfo/ltp
Hi Darren,
testcases/kernel/syscalls/mmap/mmap09.c static void verify_mmap(unsigned int nr) · line 46
Quoted 4 lines · Darren Chang
syscalls/mmap09: Drop hardcoded /tmp path
testcases/kernel/syscalls/mmap/mmap09.c +1
-1- fd =SAFE_OPEN ("/tmp/mmaptest" ,O_RDWR |O_CREAT ,0666 ); + fd =SAFE_OPEN ("mmaptest" ,O_RDWR |O_CREAT ,0666 );
Correct fix — .needs_tmpdir = 1 already chdirs into the temp directory, so the relative path is the right approach.
Pre-existing issues noticed in the surrounding code (not introduced by this patch):
- mmap09.c:57 — cleanup() guards SAFE_CLOSE with if (fd), but fd is a static int that defaults to 0 (stdin). Use if (fd >= 0) with fd initialized to -1.
---
Note:
Our agent completed the review of the patch.
The agent can sometimes produce false positives although often its findings are genuine. If you find issues with the review, please comment this email or ignore the suggestions.
Regards,
LTP AI Reviewer
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Patch merged, thanks!
Signature · 5 lines
Regards, Li Wang -- Mailing list info: https://lists.linux.it/listinfo/ltp