Commit 615f7363 authored by Jakob Luettgau's avatar Jakob Luettgau
Browse files

Replace with actual tests.

parent ff8e0a65
......@@ -30,7 +30,7 @@ lint: ## check style with flake8
flake8 darshan tests
test: ## run tests quickly with the default Python
py.test
py.test --verbose
test-all: ## run tests on every Python version with tox
tox
......
......@@ -24,7 +24,7 @@ libdutil = ffi.dlopen(DARSHAN_PATH + "/lib/libdarshan-util.so")
#print(DARSHAN_PATH + "/lib/libdarshan-util.so")
modules = {}
#modules = {}
def log_open(filename):
......@@ -51,7 +51,7 @@ def log_close(log):
Closes the logfile and releases allocated memory.
"""
libdutil.darshan_log_close(log)
modules = {}
#modules = {}
return
......@@ -120,6 +120,8 @@ def log_get_modules(log):
dict: Modules with additional info for current log.
"""
modules = {}
mods = ffi.new("struct darshan_mod_info **")
cnt = ffi.new("int *")
libdutil.darshan_log_get_modules(log, mods, cnt)
......@@ -171,6 +173,8 @@ def log_get_generic_record(log, mod_name, mod_type):
{'counters': array([...], dtype=uint64), 'fcounters': array([...])}
"""
modules = log_get_modules(log)
rec = {}
buf = ffi.new("void **")
r = libdutil.darshan_log_get_record(log, modules[mod_name]['idx'], buf)
......@@ -325,6 +329,9 @@ def log_get_apxc_record(log):
dict: log record
"""
rec = {}
modules = log_get_modules(log)
memory_modes = ['unknown', 'flat', 'equal', 'split', 'cache']
cluster_modes = ['unknown', 'all2all', 'quad', 'hemi', 'snc4', 'snc2']
buf = ffi.new("void **")
......
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import darshan
log = darshan.log_open("example.darshan")
record = darshan.log_get_stdio_record(log)
record['counters']
dict(zip(darshan.counter_names("STDIO"), record['counters']))
record = darshan.log_get_stdio_record(log)
record['counters']
dict(zip(darshan.counter_names("STDIO"), record['counters']))
#!/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
"""
# import requests
# return requests.get('https://github.com/audreyr/cookiecutter-pypackage')
def test_load(response):
"""Sample pytest test function with the pytest fixture as an argument."""
# from bs4 import BeautifulSoup
# assert 'GitHub' in BeautifulSoup(response.content).title.string
assert darshan.dummy_load() == 42
#!/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
"""
# import requests
# return requests.get('https://github.com/audreyr/cookiecutter-pypackage')
def test_load(response):
"""Sample pytest test function with the pytest fixture as an argument."""
# from bs4 import BeautifulSoup
# assert 'GitHub' in BeautifulSoup(response.content).title.string
assert darshan.dummy_load() == 42
......@@ -15,17 +15,39 @@ def response():
See more at: http://doc.pytest.org/en/latest/fixture.html
"""
# import requests
# return requests.get('https://github.com/audreyr/cookiecutter-pypackage')
pass
def test_load(response):
"""Sample pytest test function with the pytest fixture as an argument."""
# from bs4 import BeautifulSoup
# assert 'GitHub' in BeautifulSoup(response.content).title.string
def test_counters():
"""Sample for an expected property in counters."""
assert darshan.dummy_load() == 42
log = darshan.log_open("tests/input/sample.darshan")
rec = darshan.log_get_mpiio_record(log)
assert rec['counters'][1] == 2048
def test_fcounters():
"""Sample for an expected property in fcounters."""
log = darshan.log_open("tests/input/sample.darshan")
rec = darshan.log_get_mpiio_record(log)
assert rec['fcounters'][1] == 2.04800000e+03
def test_repeated_access():
""" Check if repeated access is working."""
log = darshan.log_open("tests/input/sample.darshan")
rec1 = darshan.log_get_mpiio_record(log)
rec2 = darshan.log_get_mpiio_record(log)
assert rec1 == rec2
def test_ishouldrun():
assert 1
......@@ -5,27 +5,45 @@
import pytest
import darshan
@pytest.fixture
def response():
def init():
"""Sample pytest fixture.
See more at: http://doc.pytest.org/en/latest/fixture.html
"""
# import requests
# return requests.get('https://github.com/audreyr/cookiecutter-pypackage')
pass
def test_counters():
"""Sample for an expected property in counters."""
log = darshan.log_open("tests/input/sample.darshan")
rec = darshan.log_get_posix_record(log)
assert rec['counters'][0] == 2049
def test_fcounters():
"""Sample for an expected property in fcounters."""
log = darshan.log_open("tests/input/sample.darshan")
rec = darshan.log_get_posix_record(log)
assert rec['fcounters'][0] == 2.04900000e+03
def test_load(response):
"""Sample pytest test function with the pytest fixture as an argument."""
# from bs4 import BeautifulSoup
# assert 'GitHub' in BeautifulSoup(response.content).title.string
def test_repeated_access():
""" Check if repeated access is working."""
assert darshan.dummy_load() == 42
log = darshan.log_open("tests/input/sample.darshan")
rec1 = darshan.log_get_posix_record(log)
rec2 = darshan.log_get_posix_record(log)
assert rec1 == rec2
def test_ishouldrun():
assert 1
......@@ -15,17 +15,41 @@ def response():
See more at: http://doc.pytest.org/en/latest/fixture.html
"""
# import requests
# return requests.get('https://github.com/audreyr/cookiecutter-pypackage')
pass
def test_load(response):
"""Sample pytest test function with the pytest fixture as an argument."""
# from bs4 import BeautifulSoup
# assert 'GitHub' in BeautifulSoup(response.content).title.string
assert darshan.dummy_load() == 42
def test_counters():
"""Sample for an expected property in counters."""
log = darshan.log_open("tests/input/sample.darshan")
rec = darshan.log_get_stdio_record(log)
assert rec['counters'][1] == 18446744073709551615
def test_fcounters():
"""Sample for an expected property in fcounters."""
log = darshan.log_open("tests/input/sample.darshan")
rec = darshan.log_get_stdio_record(log)
assert rec['fcounters'][3] == 6.
def test_repeated_access():
""" Check if repeated access is working."""
log = darshan.log_open("tests/input/sample.darshan")
rec1 = darshan.log_get_stdio_record(log)
rec2 = darshan.log_get_stdio_record(log)
assert rec1 == rec2
def test_ishouldrun():
import time
time.sleep(1)
assert 1
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