Commit 02f01e1c authored by Jakob Luettgau's avatar Jakob Luettgau
Browse files

Updata tests: stdio - cherry pick some value to verify, report - reflect...

Updata tests: stdio - cherry pick some value to verify, report - reflect switch from r.report to r.data.
parent 5de67837
......@@ -42,21 +42,24 @@ class DarshanReport(object):
self.data_format = data_format # Experimental: preferred internal representation: numpy useful for aggregations, dict good for export/REST
# might require alternative granularity: e.g., records, vs summaries?
self.automatic_summary = automatic_summary
self.record_provenance = True
# state dependent book-keeping
self.converted_records = False # true if convert_records() was called (unnumpyfy)
# initialize data namespace
self.data_revision = 0 # counter for consistency checks
self.data = {'version': 1}
self.data['records'] = {}
self.data['metadata'] = {}
self.data['records'] = {}
self.data['summary'] = {}
self.records = self.data['records']
# initialize report/summary namespace
self.summary_revision = 0 # counter to check if summary needs update
self.summary = {}
self.summary = self.data['summary']
......@@ -76,13 +79,20 @@ class DarshanReport(object):
def __add__(self, other):
# new report
nr = DarshanReport()
nr.provenance_reports[self.filename] = copy.copy(self)
nr.provenance_reports[other.filename] = copy.copy(other)
nr.provenance_log.append(("add", self, other, datetime.datetime.now()))
# pull in records
# copy over records
for report in [self, other]:
for key, records in report.data['records'].items():
print(report, key)
if key not in nr.records:
nr.records[key] = copy.copy(records)
else:
nr.records[key] += copy.copy(records)
return nr
......@@ -141,8 +151,8 @@ class DarshanReport(object):
"""
self.data['metadata']['job'] = backend.log_get_job(self.log)
self.data['metadata']['exe'] = backend.log_get_exe(self.log)
self.data['metadata']['mounts'] = backend.log_get_mounts(self.log)
self.data['mounts'] = backend.log_get_mounts(self.log)
self.data['modules'] = backend.log_get_modules(self.log)
......@@ -162,7 +172,7 @@ class DarshanReport(object):
unsupported.append('STDIO') # TODO: reenable when segfault resolved
if mod in unsupported:
print("Skipping. Currently unsupported:", mod)
print("Skipping. Currently unsupported:", mod, "in mod_read_all_records().")
# skip mod
return
......@@ -329,3 +339,18 @@ class DarshanReport(object):
self.converted_records = True
def as_json(self):
"""
Return JSON representatino of report data as string.
Args:
None
Return:
JSON String
"""
# TODO: decide how to best issue conversion
data = self.data
return json.dumps(data)
......@@ -45,7 +45,7 @@ def test_repeated_access():
rec1 = backend.log_get_stdio_record(log)
rec2 = backend.log_get_stdio_record(log)
assert rec2 == None
assert rec2['counters'][3] == 68
def test_ishouldrun():
......
#!/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
assert 4478544 == report.data['metadata']['job']['jobid']
def test_modules():
"""Sample for an expected number of modules."""
report = darshan.DarshanReport("tests/input/sample.darshan")
# check if number of modules matches
assert 4 == len(report.data['modules'])
assert 154 == report.data['modules']['MPI-IO']['len']
def test_load_records():
"""Test if loaded records match."""
report = darshan.DarshanReport("tests/input/sample.darshan")
report.mod_read_all_records("POSIX")
assert 1 == len(report.data['records']['POSIX'])
def test_internal_references():
"""Test if the reference ids match. This tests mainly serves to make regressions verbose when the behavior is changed."""
report = darshan.DarshanReport()
# check the convienience refs are working fine
check = id(report.records) == id(report.data['records'])
assert True == check
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment