File: test_taskstats.py

package info (click to toggle)
pyroute2 0.8.1-3
  • links: PTS, VCS
  • area: main
  • in suites: forky
  • size: 3,700 kB
  • sloc: python: 50,245; makefile: 280; javascript: 183; ansic: 81; sh: 44; awk: 17
file content (23 lines) | stat: -rw-r--r-- 572 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import os

from pr2test.marks import require_root

from pyroute2 import TaskStats

pytestmark = [require_root()]


def test_basic():
    with TaskStats() as ts:
        ts.bind()
        ret = ts.get_pid_stat(os.getpid())[0]

        pid = ret.get_nested('TASKSTATS_TYPE_AGGR_PID', 'TASKSTATS_TYPE_PID')
        stats = ret.get_nested(
            'TASKSTATS_TYPE_AGGR_PID', 'TASKSTATS_TYPE_STATS'
        )

        assert stats['cpu_count'] > 0
        assert stats['ac_pid'] == pid == os.getpid()
        assert stats['coremem'] > 0
        assert stats['virtmem'] > 0