Skip to content

Commit 3f3cac5

Browse files
xzpeterakpm00
authored andcommitted
mm/selftests: fix pagemap_ioctl memory map test
__FILE__ is not guaranteed to exist in current dir. Replace that with argv[0] for memory map test. Link: https://lkml.kernel.org/r/20231116201547.536857-4-peterx@redhat.com Fixes: 46fd75d ("selftests: mm: add pagemap ioctl tests") Signed-off-by: Peter Xu <peterx@redhat.com> Reviewed-by: David Hildenbrand <david@redhat.com> Cc: Andrei Vagin <avagin@gmail.com> Cc: David Hildenbrand <david@redhat.com> Cc: Muhammad Usama Anjum <usama.anjum@collabora.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
1 parent 4980e83 commit 3f3cac5

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

tools/testing/selftests/mm/pagemap_ioctl.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ int pagemap_fd;
3636
int uffd;
3737
int page_size;
3838
int hpage_size;
39+
const char *progname;
3940

4041
#define LEN(region) ((region.end - region.start)/page_size)
4142

@@ -1149,11 +1150,11 @@ int sanity_tests(void)
11491150
munmap(mem, mem_size);
11501151

11511152
/* 9. Memory mapped file */
1152-
fd = open(__FILE__, O_RDONLY);
1153+
fd = open(progname, O_RDONLY);
11531154
if (fd < 0)
11541155
ksft_exit_fail_msg("%s Memory mapped file\n", __func__);
11551156

1156-
ret = stat(__FILE__, &sbuf);
1157+
ret = stat(progname, &sbuf);
11571158
if (ret < 0)
11581159
ksft_exit_fail_msg("error %d %d %s\n", ret, errno, strerror(errno));
11591160

@@ -1472,12 +1473,14 @@ static void transact_test(int page_size)
14721473
extra_thread_faults);
14731474
}
14741475

1475-
int main(void)
1476+
int main(int argc, char *argv[])
14761477
{
14771478
int mem_size, shmid, buf_size, fd, i, ret;
14781479
char *mem, *map, *fmem;
14791480
struct stat sbuf;
14801481

1482+
progname = argv[0];
1483+
14811484
ksft_print_header();
14821485

14831486
if (init_uffd())

0 commit comments

Comments
 (0)