]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
tests: move user-util related tests to test-user-util.c
authorRonny Chevalier <chevalier.ronny@gmail.com>
Wed, 2 Mar 2016 22:58:48 +0000 (23:58 +0100)
committerRonny Chevalier <chevalier.ronny@gmail.com>
Thu, 3 Mar 2016 18:04:06 +0000 (19:04 +0100)
src/test/test-user-util.c
src/test/test-util.c

index 42c6a8d5e235f373d34995e8750d359b87ecb62d..8d1ec19f17f3f6bbcb9776ca4413afc320f5866e 100644 (file)
@@ -37,6 +37,30 @@ static void test_gid_to_name_one(gid_t gid, const char *name) {
         assert_se(streq_ptr(t, name));
 }
 
+static void test_parse_uid(void) {
+        int r;
+        uid_t uid;
+
+        r = parse_uid("100", &uid);
+        assert_se(r == 0);
+        assert_se(uid == 100);
+
+        r = parse_uid("65535", &uid);
+        assert_se(r == -ENXIO);
+
+        r = parse_uid("asdsdas", &uid);
+        assert_se(r == -EINVAL);
+}
+
+static void test_uid_ptr(void) {
+
+        assert_se(UID_TO_PTR(0) != NULL);
+        assert_se(UID_TO_PTR(1000) != NULL);
+
+        assert_se(PTR_TO_UID(UID_TO_PTR(0)) == 0);
+        assert_se(PTR_TO_UID(UID_TO_PTR(1000)) == 1000);
+}
+
 int main(int argc, char*argv[]) {
 
         test_uid_to_name_one(0, "root");
@@ -48,5 +72,8 @@ int main(int argc, char*argv[]) {
         test_gid_to_name_one(0xFFFF, "65535");
         test_gid_to_name_one(0xFFFFFFFF, "4294967295");
 
+        test_parse_uid();
+        test_uid_ptr();
+
         return 0;
 }
index d769c2191ce3d0ea1cd28772c7ad363094a75011..1ed6f48774b1a1832b7c886aa239efa764fae154 100644 (file)
@@ -44,7 +44,6 @@
 #include "special.h"
 #include "string-util.h"
 #include "strv.h"
-#include "user-util.h"
 #include "util.h"
 #include "virt.h"
 #include "xattr-util.h"
@@ -195,21 +194,6 @@ static void test_close_many(void) {
         unlink(name2);
 }
 
-static void test_parse_uid(void) {
-        int r;
-        uid_t uid;
-
-        r = parse_uid("100", &uid);
-        assert_se(r == 0);
-        assert_se(uid == 100);
-
-        r = parse_uid("65535", &uid);
-        assert_se(r == -ENXIO);
-
-        r = parse_uid("asdsdas", &uid);
-        assert_se(r == -EINVAL);
-}
-
 static void test_u64log2(void) {
         assert_se(u64log2(0) == 0);
         assert_se(u64log2(8) == 3);
@@ -488,15 +472,6 @@ static void test_same_fd(void) {
         assert_se(same_fd(b, a) == 0);
 }
 
-static void test_uid_ptr(void) {
-
-        assert_se(UID_TO_PTR(0) != NULL);
-        assert_se(UID_TO_PTR(1000) != NULL);
-
-        assert_se(PTR_TO_UID(UID_TO_PTR(0)) == 0);
-        assert_se(PTR_TO_UID(UID_TO_PTR(1000)) == 1000);
-}
-
 static void test_sparse_write_one(int fd, const char *buffer, size_t n) {
         char check[n];
 
@@ -580,7 +555,6 @@ int main(int argc, char *argv[]) {
         test_container_of();
         test_div_round_up();
         test_close_many();
-        test_parse_uid();
         test_u64log2();
         test_protect_errno();
         test_config_parse_iec_uint64();
@@ -596,7 +570,6 @@ int main(int argc, char *argv[]) {
         test_parse_proc_cmdline();
         test_raw_clone();
         test_same_fd();
-        test_uid_ptr();
         test_sparse_write();
         test_fgetxattrat_fake();
         test_runlevel_to_target();