chiark / gitweb /
test: fix some tests when running inside a container
[elogind.git] / src / test / test-util.c
index 1602aa63937c68bdcf3699e011a4db0557ea7d19..fe54586eeedc252b6c735c40ed1b894622196cda 100644 (file)
@@ -35,6 +35,7 @@
 #include "def.h"
 #include "fileio.h"
 #include "conf-parser.h"
+#include "virt.h"
 
 static void test_streq_ptr(void) {
         assert_se(streq_ptr(NULL, NULL));
@@ -492,7 +493,6 @@ static void test_get_process_comm(void) {
         struct stat st;
         _cleanup_free_ char *a = NULL, *c = NULL, *d = NULL, *f = NULL, *i = NULL, *cwd = NULL, *root = NULL;
         _cleanup_free_ char *env = NULL;
-        unsigned long long b;
         pid_t e;
         uid_t u;
         gid_t g;
@@ -507,9 +507,6 @@ static void test_get_process_comm(void) {
                 log_warning("/proc/1/comm does not exist.");
         }
 
-        assert_se(get_starttime_of_pid(1, &b) >= 0);
-        log_info("pid1 starttime: '%llu'", b);
-
         assert_se(get_process_cmdline(1, 0, true, &c) >= 0);
         log_info("pid1 cmdline: '%s'", c);
 
@@ -548,7 +545,8 @@ static void test_get_process_comm(void) {
         assert_se(r >= 0 || r == -EACCES);
         log_info("self strlen(environ): '%zd'", strlen(env));
 
-        assert_se(get_ctty_devnr(1, &h) == -ENOENT);
+        if (!detect_container(NULL))
+                assert_se(get_ctty_devnr(1, &h) == -ENOENT);
 
         getenv_for_pid(1, "PATH", &i);
         log_info("pid1 $PATH: '%s'", strna(i));