test_report.py 1.3 KB
Newer Older
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
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""Tests for `pydarshan` package."""

import pytest

import darshan


@pytest.fixture
def response():
    """Sample pytest fixture.

    See more at: http://doc.pytest.org/en/latest/fixture.html
    """
    pass


def test_metadata():
    """Sample for an expected property in counters."""

    report = darshan.DarshanReport("tests/input/sample.darshan")

    # check a metadata field
Jakob Luettgau's avatar
PEP8.    
Jakob Luettgau committed
26
    assert 4478544 == report.metadata['job']['jobid']
27
28
29
30
31
32
33
34


def test_modules():
    """Sample for an expected number of modules."""

    report = darshan.DarshanReport("tests/input/sample.darshan")

    # check if number of modules matches
Jakob Luettgau's avatar
PEP8.    
Jakob Luettgau committed
35
36
    assert 4 == len(report.modules)
    assert 154 == report.modules['MPI-IO']['len']
37
38
39
40
41
42
43


def test_load_records():
    """Test if loaded records match."""

    report = darshan.DarshanReport("tests/input/sample.darshan")

Jakob Luettgau's avatar
PEP8.    
Jakob Luettgau committed
44
    report.mod_read_all_records("POSIX")
45
46
47
48
49

    assert 1 == len(report.data['records']['POSIX'])


def test_internal_references():
Jakob Luettgau's avatar
PEP8.    
Jakob Luettgau committed
50
51
52
53
    """
    Test if the reference ids match. This tests mainly serves to make
    regressions verbose when the behavior is changed.
    """
54
55

    report = darshan.DarshanReport()
Jakob Luettgau's avatar
PEP8.    
Jakob Luettgau committed
56

57
58
    # check the convienience refs are working fine
    check = id(report.records) == id(report.data['records'])
Jakob Luettgau's avatar
PEP8.    
Jakob Luettgau committed
59
    assert check is True