1
0
mirror of https://github.com/systemd/systemd.git synced 2025-01-18 10:04:04 +03:00

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.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2023-08-21 20:25:13 +02:00
parent 857127f1e3
commit e0cfdb85f5

View File

@ -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;
}