selftests/nolibc: add chmod_argv0 test
authorZhangjin Wu <falcon@tinylab.org>
Fri, 7 Jul 2023 18:46:20 +0000 (02:46 +0800)
committerWilly Tarreau <w@1wt.eu>
Wed, 23 Aug 2023 02:40:15 +0000 (04:40 +0200)
argv0 is readable and chmodable, let's use it for chmod test, but a safe
umask should be used, the readable and executable modes should be
reserved.

Reviewed-by: Thomas Weißschuh <linux@weissschuh.net>
Signed-off-by: Zhangjin Wu <falcon@tinylab.org>
Signed-off-by: Willy Tarreau <w@1wt.eu>
tools/testing/selftests/nolibc/nolibc-test.c

index be9f664..6c94e49 100644 (file)
@@ -706,6 +706,7 @@ int run_syscall(int min, int max)
                CASE_TEST(chdir_root);        EXPECT_SYSZR(1, chdir("/")); chdir(getenv("PWD")); break;
                CASE_TEST(chdir_dot);         EXPECT_SYSZR(1, chdir(".")); break;
                CASE_TEST(chdir_blah);        EXPECT_SYSER(1, chdir("/blah"), -1, ENOENT); break;
+               CASE_TEST(chmod_argv0);       EXPECT_SYSZR(1, chmod(argv0, 0555)); break;
                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;