Hi, Thomas > Hi Zhangjin, > > On 2023-06-23 03:32:49+0800, Zhangjin Wu wrote: > > > On 2023-06-19 23:55:41+0800, Zhangjin Wu wrote: > > > > Three mmap/munmap related test cases are added: > > > > (snipped) > > > > > > > > +int test_mmap_munmap(int size) > > > > +{ > > > > + char init_files[5][20] = {"/init", "/sbin/init", "/etc/init", "/bin/init", "/bin/sh"}; > > > > > > Why not /proc/1/exe or even /proc/self/exe? > > > > > > I know your other series tries to remove the procfs dependency, but > > > we're not there yet :-). > > > > > > > Yeah, '/proc/self/exe' is a choice, if so, the 'has_proc' should be added ;-) > > Currently procfs is a hard requirement. So I would leave 'has_proc' to > the other series that may change this. > Yeah, but to be consistent with the already existing 'proc' condition check, 'proc' will be used at first ;-) $ grep '(proc,' -ur tools/testing/selftests/nolibc/nolibc-test.c CASE_TEST(chmod_net); EXPECT_SYSZR(proc, chmod("/proc/self/net", 0555)); break; CASE_TEST(chmod_self); EXPECT_SYSER(proc, chmod("/proc/self", 0555), -1, EPERM); break; CASE_TEST(chown_self); EXPECT_SYSER(proc, chown("/proc/self", 0, 0), -1, EPERM); break; CASE_TEST(chroot_exe); EXPECT_SYSER(proc, chroot("/proc/self/exe"), -1, ENOTDIR); break; CASE_TEST(link_cross); EXPECT_SYSER(proc, link("/proc/self/net", "/blah"), -1, EXDEV); break; Btw, for the /proc/self used in test_stat_timestamps, in the revision of the 'minimal' config support series, instead of using '/', a 'proc' should be added like above test cases. > > > Also does it make sense to pass a size parameter? > > > Why not use either PAGE_SIZE or the real size of the binary from > > > fstat(). > > > > > > > Ok, as the manpage of mmap shows: > > > > For mmap(), offset must be a multiple of the underlying huge page > > size. The system automatically aligns length to be a multiple of > > the underlying huge page size. > > > > For munmap(), addr, and length must both be a multiple of the > > underlying huge page size. > > > > perhaps we should do further tests: > > > > * the real size/length > > * even > the real size > > * the PAGE_SIZE > > * not aligned with PAGE_SIZE > > > > If such tests are required, the 'size' and even 'offset' arguments could be > > provided to cover different combination or we do such tests internally, then, > > the arguments are not required. > > I think task of nolibc-test is to test the code in nolibc itself. > The custom mmap implementation is trivial and directly calls the > syscall. These additionally proposed tests would effectively test the > core kernels implementation of mmap() and not the code of nolibc. > > Therefore I don't think they are necessary in nolibc-test and the > functionality is hopefully already be tested in another testsuite. > Ok, it is reasonable. > > Note: > > Testing mmap is indeed useful to test the implementation of > my_syscall6() by providing a bogus value in the 'offset' parameter. > I think we do have such a testcase. > Ok, we can pass a valid offset (n*PAGE_SIZE) to mmap() in test_mmap_munmap() or add a whole new mmap_offset test case with a PAGE_SIZE not aligned offset (such as 1). Thanks, Zhangjin > <snip> > > Thomas