Skip to content

Commit

Permalink
Merge branch 'jgfouca/cime/fix_mem_div_by_zero' (PR #1360)
Browse files Browse the repository at this point in the history
Guard against div-by-zero in memory baseline comparison:
Fail the MEMCOMP phase if the baseline memory is zero.

Fixes #1349

[BFB]
  • Loading branch information
amametjanov committed Apr 5, 2017
2 parents 27c7fa4 + 10acd03 commit 5f9fdae
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions utils/python/CIME/SystemTests/system_tests_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,14 +352,20 @@ def _compare_baseline(self):
if not os.path.isfile(baselog):
# for backward compatibility
baselog = os.path.join(basecmp_dir, "cpl.log")

if os.path.isfile(baselog) and len(memlist) > 3:
blmem = self._get_mem_usage(baselog)[-1][1]
curmem = memlist[-1][1]
diff = (curmem-blmem)/blmem
if(diff < 0.1):
self._test_status.set_status(MEMCOMP_PHASE, TEST_PASS_STATUS)
if blmem != 0:
diff = (curmem - blmem) / blmem
if diff < 0.1:
self._test_status.set_status(MEMCOMP_PHASE, TEST_PASS_STATUS)
else:
comment = "Error: Memory usage increase > 10% from baseline"
self._test_status.set_status(MEMCOMP_PHASE, TEST_FAIL_STATUS, comments=comment)
append_status(comment, sfile="TestStatus.log")
else:
comment = "Error: Memory usage increase > 10% from baseline"
comment = "Error: Could not determine baseline memory usage"
self._test_status.set_status(MEMCOMP_PHASE, TEST_FAIL_STATUS, comments=comment)
append_status(comment, sfile="TestStatus.log")

Expand Down

0 comments on commit 5f9fdae

Please sign in to comment.