chiark / gitweb /
tests: run manager in session mode
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Wed, 6 Feb 2013 22:03:12 +0000 (17:03 -0500)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Wed, 6 Feb 2013 22:06:26 +0000 (17:06 -0500)
False positives pop up otherwise.

FAIL: test-unit-name (exit: 134)
================================

Failed to open /dev/tty0: Permission denied
Failed to create root cgroup hierarchy: Permission denied
Assertion 'manager_new(SYSTEMD_SYSTEM, &m) == 0' failed at src/test/test-unit-name.c:125, function test_unit_printf(). Aborting.

src/test/test-sched-prio.c
src/test/test-unit-name.c

index 29235e8..63f7ebd 100644 (file)
@@ -33,7 +33,7 @@ int main(int argc, char *argv[]) {
 
         /* prepare the test */
         assert_se(set_unit_path(TEST_DIR) >= 0);
 
         /* prepare the test */
         assert_se(set_unit_path(TEST_DIR) >= 0);
-        assert_se(manager_new(SYSTEMD_SYSTEM, &m) >= 0);
+        assert_se(manager_new(SYSTEMD_USER, &m) >= 0);
         assert_se(manager_startup(m, serial, fdset) >= 0);
 
         /* load idle ok */
         assert_se(manager_startup(m, serial, fdset) >= 0);
 
         /* load idle ok */
index b1a4134..3c0a416 100644 (file)
@@ -122,14 +122,18 @@ static void test_unit_printf(void) {
         assert_se((root = getpwnam("root")));
         assert_se(asprintf(&root_uid, "%d", (int) root->pw_uid) > 0);
 
         assert_se((root = getpwnam("root")));
         assert_se(asprintf(&root_uid, "%d", (int) root->pw_uid) > 0);
 
-        assert_se(manager_new(SYSTEMD_SYSTEM, &m) == 0);
+        assert_se(manager_new(SYSTEMD_USER, &m) == 0);
 
 #define expect(unit, pattern, expected)                                 \
         {                                                               \
 
 #define expect(unit, pattern, expected)                                 \
         {                                                               \
+                char *e;                                                \
                 char _cleanup_free_ *t =                                \
                         unit_full_printf(unit, pattern);                \
                 printf("result: %s\n", t);                              \
                 char _cleanup_free_ *t =                                \
                         unit_full_printf(unit, pattern);                \
                 printf("result: %s\n", t);                              \
-                assert(streq(t, expected));                             \
+                if ((e = endswith(expected, "*")))                      \
+                        assert(strncmp(t, e, e-expected));              \
+                else                                                    \
+                        assert(streq(t, expected));                     \
         }
 
         assert_se(setenv("USER", "root", 1) == 0);
         }
 
         assert_se(setenv("USER", "root", 1) == 0);
@@ -158,7 +162,7 @@ static void test_unit_printf(void) {
         expect(u, "%m", mid);
         expect(u, "%b", bid);
         expect(u, "%H", host);
         expect(u, "%m", mid);
         expect(u, "%b", bid);
         expect(u, "%H", host);
-        expect(u, "%t", "/run");
+        expect(u, "%t", "/run/user/*");
 
         /* templated */
         assert_se(u2 = unit_new(m, sizeof(Service)));
 
         /* templated */
         assert_se(u2 = unit_new(m, sizeof(Service)));
@@ -178,7 +182,7 @@ static void test_unit_printf(void) {
         expect(u2, "%m", mid);
         expect(u2, "%b", bid);
         expect(u2, "%H", host);
         expect(u2, "%m", mid);
         expect(u2, "%b", bid);
         expect(u2, "%H", host);
-        expect(u2, "%t", "/run");
+        expect(u2, "%t", "/run/user/*");
 }
 
 int main(int argc, char* argv[]) {
 }
 
 int main(int argc, char* argv[]) {