Message ID | 9dc032064dde254a03e2111da1e58344deca6522.1688078605.git.falcon@tinylab.org (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | allow run with minimal kernel config | expand |
On 2023-06-30 07:52:03+0800, Zhangjin Wu wrote: > Let's create a /tmp directory and mount tmpfs there, if tmpfs is not > mountable, use ramfs as tmpfs. > > tmpfs will be used instead of procfs for some tests. > > Signed-off-by: Zhangjin Wu <falcon@tinylab.org> > --- > tools/testing/selftests/nolibc/nolibc-test.c | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/selftests/nolibc/nolibc-test.c > index c0f5302ada5d..8e3e2792f5e3 100644 > --- a/tools/testing/selftests/nolibc/nolibc-test.c > +++ b/tools/testing/selftests/nolibc/nolibc-test.c > @@ -1054,6 +1054,10 @@ int prepare(void) > } > } > > + /* try to mount /tmp if not mounted, if not mountable, use ramfs as tmpfs */ > + if (stat("/tmp/.", &stat_buf) == 0 || mkdir("/tmp", 0755) == 0) > + mount("none", "/tmp", "tmpfs", 0, 0); > + mkdir() mount() without any error checking should do the same and be easier to read. > return 0; > } > > -- > 2.25.1 >
Hi, Thomas > On 2023-06-30 07:52:03+0800, Zhangjin Wu wrote: > > Let's create a /tmp directory and mount tmpfs there, if tmpfs is not > > mountable, use ramfs as tmpfs. > > > > tmpfs will be used instead of procfs for some tests. > > > > Signed-off-by: Zhangjin Wu <falcon@tinylab.org> > > --- > > tools/testing/selftests/nolibc/nolibc-test.c | 4 ++++ > > 1 file changed, 4 insertions(+) > > > > diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/selftests/nolibc/nolibc-test.c > > index c0f5302ada5d..8e3e2792f5e3 100644 > > --- a/tools/testing/selftests/nolibc/nolibc-test.c > > +++ b/tools/testing/selftests/nolibc/nolibc-test.c > > @@ -1054,6 +1054,10 @@ int prepare(void) > > } > > } > > > > + /* try to mount /tmp if not mounted, if not mountable, use ramfs as tmpfs */ > > + if (stat("/tmp/.", &stat_buf) == 0 || mkdir("/tmp", 0755) == 0) > > + mount("none", "/tmp", "tmpfs", 0, 0); > > + > > mkdir() > mount() > > without any error checking should do the same and be easier to read. > Yeah, will apply it, it saves a call for us. Perhaps the other codes in prepare() can be cleaned up with the same method in the future too. Thanks, Zhangjin > > return 0; > > } > > > > -- > > 2.25.1 > >
diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/selftests/nolibc/nolibc-test.c index c0f5302ada5d..8e3e2792f5e3 100644 --- a/tools/testing/selftests/nolibc/nolibc-test.c +++ b/tools/testing/selftests/nolibc/nolibc-test.c @@ -1054,6 +1054,10 @@ int prepare(void) } } + /* try to mount /tmp if not mounted, if not mountable, use ramfs as tmpfs */ + if (stat("/tmp/.", &stat_buf) == 0 || mkdir("/tmp", 0755) == 0) + mount("none", "/tmp", "tmpfs", 0, 0); + return 0; }
Let's create a /tmp directory and mount tmpfs there, if tmpfs is not mountable, use ramfs as tmpfs. tmpfs will be used instead of procfs for some tests. Signed-off-by: Zhangjin Wu <falcon@tinylab.org> --- tools/testing/selftests/nolibc/nolibc-test.c | 4 ++++ 1 file changed, 4 insertions(+)