Debian Codegraph @

src/cgroups/test.c

raw symbols SCIP
1 /*
2 * SPDX-License-Identifier: GPL-2.0-or-later
3 */
4
5 #include "config.h"
6
7 #include <glib.h>
8
9 #include "gsm-cgroups.c"
10
11
12 static void
13 test_cgroups_v2 (void)
14 {
15 g_assert_cmpstr (extract_name (NULL), ==, "");
16 g_assert_cmpstr (extract_name (""), ==, "");
17 g_assert_cmpstr (extract_name ("0::/"), ==, "");
18 g_assert_cmpstr (extract_name ("0::/\n"), ==, "");
19 g_assert_cmpstr (extract_name ("0::/a\n"), ==, "/a");
20 }
21
22
23 static void
24 test_cgroups_v1_one_entry (void)
25 {
26 g_assert_cmpstr (extract_name ("0:a1:/b1\n"), ==, "/b1 (a1)");
27 g_assert_cmpstr (extract_name ("0:name=a2:/b2\n"), ==, "/b2 (a2)");
28 }
29
30
31 static void
32 test_cgroups_v1_multiple_entry (void)
33 {
34 g_assert_cmpstr (extract_name ("1:a1:/b1\n0:a0:/b0\n"), ==, "/b0 (a0), /b1 (a1)");
35 }
36
37
38 int
39 main (int argc, char *argv[])
40 {
41 g_test_init (&argc, &argv, NULL);
42
43 g_test_add_func ("/gnome-system-monitor/cgroups/v2", test_cgroups_v2);
44 g_test_add_func ("/gnome-system-monitor/cgroups/v1/one-entry",
45 test_cgroups_v1_one_entry);
46 g_test_add_func ("/gnome-system-monitor/cgroups/v1/multiple-entry",
47 test_cgroups_v1_multiple_entry);
48
49 return g_test_run ();
50 }