Let's make the /tmp and /hugetlb directories and mount tmpfs and hugetlbfs respectively, they will be used to check the existing of tmpfs and hugetlbfs. We will also use tmpfs to let some test cases run without procfs. Signed-off-by: Zhangjin Wu <falcon@xxxxxxxxxxx> --- tools/testing/selftests/nolibc/nolibc-test.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/selftests/nolibc/nolibc-test.c index 69f59a395746..8b587961e46a 100644 --- a/tools/testing/selftests/nolibc/nolibc-test.c +++ b/tools/testing/selftests/nolibc/nolibc-test.c @@ -935,6 +935,18 @@ int prepare(void) } } + /* try to mount /tmp if not mounted. Silently fail otherwise */ + if (stat("/tmp/.", &stat_buf) == 0 || mkdir("/tmp", 0755) == 0) { + if (mount("none", "/tmp", "tmpfs", 0, 0) != 0) + rmdir("/tmp"); + } + + /* try to mount /hugetlb if not mounted. Silently fail otherwise */ + if (stat("/hugetlb/.", &stat_buf) == 0 || mkdir("/hugetlb", 0755) == 0) { + if (mount("none", "/hugetlb", "hugetlbfs", 0, 0) != 0) + rmdir("/hugetlb"); + } + return 0; } -- 2.25.1