-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathtest_commands_cgroup.py
More file actions
45 lines (35 loc) · 1.32 KB
/
test_commands_cgroup.py
File metadata and controls
45 lines (35 loc) · 1.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# -*- coding: utf-8 -*-
# vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79:
import unittest
import gdb
import io
import sys
from crash.commands.cgroup import CgroupCommand
from crash.commands import CommandLineError
class TestCommandsCgroup(unittest.TestCase):
def setUp(self):
self.stdout = sys.stdout
self.redirected = io.StringIO()
sys.stdout = self.redirected
self.command = CgroupCommand("cgroup")
# cgrp_dfl_root is available since v3.15-rc1
cgroup_root = gdb.lookup_symbol('cgrp_dfl_root', None)[0].value()
self.cgrp_dfl_root = cgroup_root['cgrp']
def tearDown(self):
sys.stdout = self.stdout
def output(self):
return self.redirected.getvalue()
def output_lines(self):
output = self.output()
return len(output.split("\n")) - 1
def test_proc_cgroup(self):
"""`cgroup` lists controllers"""
self.command.invoke_uncaught(f"")
# header + listing (at least one controller)
self.assertTrue(self.output_lines() > 1)
def test_cgroup_tasks(self):
"""`cgroup -g` lists cgroup tasks"""
addr = int(self.cgrp_dfl_root.address)
self.command.invoke_uncaught(f"-g {addr:x}")
# header + listing (at least one task)
self.assertTrue(self.output_lines() > 1)