summaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'src/test')
-rw-r--r--src/test/test-util.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/test/test-util.c b/src/test/test-util.c
index 77e7400bfc..4d36eb26e5 100644
--- a/src/test/test-util.c
+++ b/src/test/test-util.c
@@ -1576,6 +1576,20 @@ static void test_shell_maybe_quote(void) {
test_shell_maybe_quote_one("foo$bar", "\"foo\\$bar\"");
}
+static void test_parse_mode(void) {
+ mode_t m;
+
+ assert_se(parse_mode("-1", &m) < 0);
+ assert_se(parse_mode("", &m) < 0);
+ assert_se(parse_mode("888", &m) < 0);
+ assert_se(parse_mode("77777", &m) < 0);
+
+ assert_se(parse_mode("544", &m) >= 0 && m == 0544);
+ assert_se(parse_mode("777", &m) >= 0 && m == 0777);
+ assert_se(parse_mode("7777", &m) >= 0 && m == 07777);
+ assert_se(parse_mode("0", &m) >= 0 && m == 0);
+}
+
int main(int argc, char *argv[]) {
log_parse_environment();
log_open();
@@ -1654,6 +1668,7 @@ int main(int argc, char *argv[]) {
test_uid_ptr();
test_sparse_write();
test_shell_maybe_quote();
+ test_parse_mode();
return 0;
}