diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2023-08-21 20:25:13 +0200 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2023-08-22 12:31:45 +0200 |
commit | e0cfdb85f55ba3f0e863e5825ca7ddccc9a77a18 (patch) | |
tree | 0fff43f9757377a539875d1a5327942f022c36f2 /src | |
parent | mount-tool: reduce scope of iterator variables (diff) | |
download | systemd-e0cfdb85f55ba3f0e863e5825ca7ddccc9a77a18.tar.xz systemd-e0cfdb85f55ba3f0e863e5825ca7ddccc9a77a18.zip |
test-umask-util: add test for get_process_umask()
It didn't have any test, and here we're setting umask, so we can add
the test for free.
Diffstat (limited to 'src')
-rw-r--r-- | src/test/test-umask-util.c | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/test/test-umask-util.c b/src/test/test-umask-util.c index bd5bc9cb43..8316dfb44a 100644 --- a/src/test/test-umask-util.c +++ b/src/test/test-umask-util.c @@ -1,11 +1,12 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ +#include "process-util.h" #include "tests.h" #include "umask-util.h" int main(int argc, char *argv[]) { size_t n; - mode_t u; + mode_t u, t; test_setup_logging(LOG_DEBUG); @@ -15,19 +16,31 @@ int main(int argc, char *argv[]) { WITH_UMASK(0123) { assert_se(umask(000) == 0123); n++; + + assert_se(get_process_umask(0, &t) == 0); + assert_se(t == 000); } assert_se(n == 1); assert_se(umask(u) == 0111); + assert_se(get_process_umask(getpid_cached(), &t) == 0); + assert_se(t == u); + WITH_UMASK(0135) { assert_se(umask(000) == 0135); n++; + + assert_se(get_process_umask(0, &t) == 0); + assert_se(t == 000); } assert_se(n == 2); assert_se(umask(0111) == u); + assert_se(get_process_umask(0, &t) == 0); + assert_se(t == 0111); + WITH_UMASK(0315) { assert_se(umask(000) == 0315); n++; @@ -37,5 +50,8 @@ int main(int argc, char *argv[]) { assert_se(n == 3); assert_se(umask(u) == 0111); + assert_se(get_process_umask(0, &t) == 0); + assert_se(t == u); + return EXIT_SUCCESS; } |