summaryrefslogtreecommitdiffstats
path: root/src/test/test-umask-util.c
blob: bd5bc9cb437029d2571323bf2a9f2979d2ddb020 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/* SPDX-License-Identifier: LGPL-2.1-or-later */

#include "tests.h"
#include "umask-util.h"

int main(int argc, char *argv[]) {
        size_t n;
        mode_t u;

        test_setup_logging(LOG_DEBUG);

        u = umask(0111);

        n = 0;
        WITH_UMASK(0123) {
                assert_se(umask(000) == 0123);
                n++;
        }

        assert_se(n == 1);
        assert_se(umask(u) == 0111);

        WITH_UMASK(0135) {
                assert_se(umask(000) == 0135);
                n++;
        }

        assert_se(n == 2);
        assert_se(umask(0111) == u);

        WITH_UMASK(0315) {
                assert_se(umask(000) == 0315);
                n++;
                break;
        }

        assert_se(n == 3);
        assert_se(umask(u) == 0111);

        return EXIT_SUCCESS;
}