Skip to content

Commit

Permalink
added to skip memory intensive tests when on personal PC
Browse files Browse the repository at this point in the history
  • Loading branch information
Olender committed Nov 7, 2024
1 parent f011fc7 commit 5fb8c38
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions test/test_elastic_local_abc.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,43 @@
expected_mechanical_energy = 0.25


def has_sufficient_memory():
meminfo = {}
with open('/proc/meminfo') as f:
for line in f:
parts = line.split(':')
if len(parts) == 2:
meminfo[parts[0].strip()] = parts[1].strip()
total_memory_kb = int(meminfo.get('MemTotal', '0 kB').split()[0])
total_memory_gb = total_memory_kb / 1024 / 1024
print(f"Total system memory {total_memory_gb}")
return total_memory_gb > 16


@pytest.mark.skipif(not has_sufficient_memory(), reason="Insufficient memory")
def test_stacey_abc():
wave = build_solver("Stacey", "backward")
wave.forward_solve()
last_mechanical_energy = wave.field_logger.get("mechanical_energy")
assert last_mechanical_energy < expected_mechanical_energy


@pytest.mark.skipif(not has_sufficient_memory(), reason="Insufficient memory")
def test_clayton_engquist_abc():
wave = build_solver("CE_A1", "backward")
wave.forward_solve()
last_mechanical_energy = wave.field_logger.get("mechanical_energy")
assert last_mechanical_energy < expected_mechanical_energy


@pytest.mark.skipif(not has_sufficient_memory(), reason="Insufficient memory")
def test_with_central():
wave = build_solver("Stacey", "central")
with pytest.raises(AssertionError):
wave.forward_solve()


@pytest.mark.skipif(not has_sufficient_memory(), reason="Insufficient memory")
def test_with_backward_2nd():
wave = build_solver("Stacey", "backward_2nd")
wave.forward_solve()
Expand Down

0 comments on commit 5fb8c38

Please sign in to comment.