LCOV - code coverage report
Current view: top level - test - test-helper.c (source / functions) Hit Total Coverage
Test: systemd_full.info Lines: 10 14 71.4 %
Date: 2019-08-23 13:36:53 Functions: 1 2 50.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 5 12 41.7 %

           Branch data     Line data    Source code
       1                 :            : /* SPDX-License-Identifier: LGPL-2.1+ */
       2                 :            : 
       3                 :            : #include "test-helper.h"
       4                 :            : #include "random-util.h"
       5                 :            : #include "alloc-util.h"
       6                 :            : #include "cgroup-util.h"
       7                 :            : #include "string-util.h"
       8                 :            : 
       9                 :         52 : int enter_cgroup_subroot(void) {
      10                 :         52 :         _cleanup_free_ char *cgroup_root = NULL, *cgroup_subroot = NULL;
      11                 :            :         CGroupMask supported;
      12                 :            :         int r;
      13                 :            : 
      14                 :         52 :         r = cg_pid_get_path(NULL, 0, &cgroup_root);
      15         [ -  + ]:         52 :         if (r == -ENOMEDIUM)
      16         [ #  # ]:          0 :                 return log_warning_errno(r, "cg_pid_get_path(NULL, 0, ...) failed: %m");
      17         [ -  + ]:         52 :         assert(r >= 0);
      18                 :            : 
      19         [ -  + ]:         52 :         assert_se(asprintf(&cgroup_subroot, "%s/%" PRIx64, cgroup_root, random_u64()) >= 0);
      20         [ -  + ]:         52 :         assert_se(cg_mask_supported(&supported) >= 0);
      21                 :            : 
      22                 :            :         /* If this fails, then we don't mind as the later cgroup operations will fail too, and it's fine if we handle
      23                 :            :          * any errors at that point. */
      24                 :            : 
      25                 :         52 :         r = cg_create_everywhere(supported, _CGROUP_MASK_ALL, cgroup_subroot);
      26         [ +  - ]:         52 :         if (r < 0)
      27                 :         52 :                 return r;
      28                 :            : 
      29                 :          0 :         return cg_attach_everywhere(supported, cgroup_subroot, 0, NULL, NULL);
      30                 :            : }
      31                 :            : 
      32                 :            : /* https://docs.travis-ci.com/user/environment-variables#default-environment-variables */
      33                 :          0 : bool is_run_on_travis_ci(void) {
      34                 :          0 :         return streq_ptr(getenv("TRAVIS"), "true");
      35                 :            : }

Generated by: LCOV version 1.14