summaryrefslogtreecommitdiff
path: root/src/test/test-util.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2015-04-10 14:43:06 +0200
committerLennart Poettering <lennart@poettering.net>2015-04-10 16:23:46 +0200
commit2ff7b0a54271c8480024d6d68edff4a92e781052 (patch)
tree4883cb0ad40483553e06d10a209475f757f273c8 /src/test/test-util.c
parent6dd67163b8f173649e7dc73740f35274714caafc (diff)
util: unify how we parse mode_t strings
Diffstat (limited to 'src/test/test-util.c')
-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;
}