summaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorFranck Bui <fbui@suse.com>2017-04-26 18:18:03 +0200
committerSven Eden <yamakuzure@gmx.net>2017-07-25 09:46:52 +0200
commitc55f016940fe25c43d779cfd4706c17eacd01a63 (patch)
tree5324d227d53c55c8580efee1b03639289c2bbae3 /src/test
parentc3e41400d106b6c2482d9d42298fac1a6a882071 (diff)
parse-util: introduce parse_dev() helper
Diffstat (limited to 'src/test')
-rw-r--r--src/test/test-parse-util.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/test/test-parse-util.c b/src/test/test-parse-util.c
index 981370ab9..83f16da27 100644
--- a/src/test/test-parse-util.c
+++ b/src/test/test-parse-util.c
@@ -530,6 +530,19 @@ static void test_parse_nice(void) {
}
#endif // 0
+static void test_parse_dev(void) {
+ dev_t dev;
+
+ assert_se(parse_dev("0", &dev) == -EINVAL);
+ assert_se(parse_dev("5", &dev) == -EINVAL);
+ assert_se(parse_dev("5:", &dev) == -EINVAL);
+ assert_se(parse_dev(":5", &dev) == -EINVAL);
+#if SIZEOF_DEV_T < 8
+ assert_se(parse_dev("4294967295:4294967295", &dev) == -EINVAL);
+#endif
+ assert_se(parse_dev("8:11", &dev) >= 0 && major(dev) == 8 && minor(dev) == 11);
+}
+
int main(int argc, char *argv[]) {
log_parse_environment();
log_open();
@@ -550,6 +563,7 @@ int main(int argc, char *argv[]) {
#if 0 /// UNNEEDED by elogind
test_parse_nice();
#endif // 0
+ test_parse_dev();
return 0;
}