test-cgroup-util.c revision 143bfdaf0b890fa7acadf02d1eafacaef1b696bd
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
/***
This file is part of systemd.
Copyright 2013 Zbigniew Jędrzejewski-Szmek
under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
systemd is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
#include <assert.h>
#include "util.h"
#include "cgroup-util.h"
#include "test-helper.h"
}
static void test_path_decode_unit(void) {
}
}
static void test_path_get_unit(void) {
}
}
static void test_path_get_user_unit(void) {
check_p_g_u_u("/user.slice/user-1000.slice/session-2.scope/waldo.slice/foobar.service", 0, "foobar.service");
check_p_g_u_u("/user.slice/user-1002.slice/session-2.scope/foobar.service/waldo", 0, "foobar.service");
check_p_g_u_u("/user.slice/user-1000.slice/session-2.scope/foobar.service/waldo/uuuux", 0, "foobar.service");
check_p_g_u_u("/user.slice/user-1000.slice/session-2.scope/foobar@pie.service/pa/po", 0, "foobar@pie.service");
check_p_g_u_u("/xyz.slice/xyz-waldo.slice/session-77.scope/foobar@pie.service/pa/po", 0, "foobar@pie.service");
}
_cleanup_free_ char *s = NULL;
}
static void test_path_get_session(void) {
}
}
static void test_path_get_owner_uid(void) {
}
_cleanup_free_ char *m = NULL;
}
static void test_path_get_machine_name(void) {
}
static void test_get_paths(void) {
_cleanup_free_ char *a = NULL;
assert_se(cg_get_root_path(&a) >= 0);
log_info("Root = %s", a);
}
static void test_proc(void) {
int r;
d = opendir("/proc");
assert_se(d);
FOREACH_DIRENT(de, d, break) {
_cleanup_free_ char *path = NULL, *path_shifted = NULL, *session = NULL, *unit = NULL, *user_unit = NULL, *machine = NULL, *prefix = NULL, *slice = NULL;
continue;
if (r < 0)
continue;
if (is_kernel_thread(pid))
continue;
printf("%lu\t%s\t%s\t%s\t%lu\t%s\t%s\t%s\t%s\t%s\n",
(unsigned long) pid,
path,
(unsigned long) uid,
unit,
slice);
}
}
static void test_escape_one(const char *s, const char *r) {
_cleanup_free_ char *b;
b = cg_escape(s);
assert_se(b);
}
static void test_escape(void) {
}
static void test_controller_is_valid(void) {
}
}
static void test_slice_to_path(void) {
test_slice_to_path_one("a-b-c-d-e.slice", "a.slice/a-b.slice/a-b-c.slice/a-b-c-d.slice/a-b-c-d-e.slice", 0);
}
int main(void) {
test_proc();
return 0;
}