Exemplo n.º 1
0
def test_parse_ps(capture, result):
    cpu_core, lines = ps_section.parse_ps(copy.deepcopy(capture))
    assert cpu_core == result[0]  # cpu_cores

    for (ps_info_item, cmd_line), ref in itertools.zip_longest(lines, result[1]):
        assert ps_info_item == ps.PsInfo(*ref[0])
        assert cmd_line == ref[1:]
Exemplo n.º 2
0
def test_process_matches(ps_line, ps_pattern, user_pattern, result):
    psi = ps.PsInfo(ps_line[0])
    matches_attr = ps.process_attributes_match(psi, user_pattern,
                                               (None, False))
    matches_proc = ps.process_matches(ps_line[1:], ps_pattern)

    assert (matches_attr and matches_proc) == result
Exemplo n.º 3
0
def test_process_matches_match_groups(ps_line, ps_pattern, user_pattern,
                                      match_groups, result):
    psi = ps.PsInfo(ps_line[0])  # type: ignore[call-arg]
    matches_attr = ps.process_attributes_match(psi, user_pattern,
                                               (None, False))
    matches_proc = ps.process_matches(ps_line[1:], ps_pattern, match_groups)

    assert (matches_attr and matches_proc) == result
Exemplo n.º 4
0
             "1",
             "/sbin/init",
             "--ladida",
         ],
     ],
     (
         1,
         [
             (
                 ps.PsInfo(
                     user="******",
                     virtual=226036,
                     physical=9736,
                     cputime="00:00:09/05:14:30",
                     process_id="1",
                     pagefile=None,
                     usermode_time=None,
                     kernelmode_time=None,
                     handles=None,
                     threads=None,
                     uptime=None,
                     cgroup="1:name=systemd:/init.scope,",
                 ),
                 ["/sbin/init", "--ladida"],
             )
         ],
     ),
     id="standard_case",
 ),
 pytest.param(
     [
         ["[header]", "CGROUP", "USER", "VSZ", "RSS", "TIME", "ELAPSED", "PID", "COMMAND"],
Exemplo n.º 5
0
            ]


@pytest.mark.parametrize(
    "process_lines, params, expected_processes",
    [
        pytest.param(
            [(
                None,
                ps.PsInfo(
                    user="******",
                    virtual=12856,
                    physical=16160,
                    cputime="0.0",
                    process_id=None,
                    pagefile=None,
                    usermode_time=None,
                    kernelmode_time=None,
                    handles=None,
                    threads=None,
                    uptime=None,
                    cgroup=None,
                ),
                [
                    "/usr/lib/firefox/firefox",
                    "-contentproc",
                    "-childID",
                    "31",
                    "-isForBrowser",
                    "-prefsLen",
                    "9681",
                ],