Skip to content

Commit

Permalink
Guard against div-by-zero in memory baseline comparison
Browse files Browse the repository at this point in the history
Fail the MEMCOMP phase if the baseline memory is zero.

[BFB]
  • Loading branch information
jgfouca committed Mar 30, 2017
1 parent f4963b0 commit 10acd03
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 10acd03

Please sign in to comment.