Skip to content

Commit

Permalink
tests/leaks.sh: workaround minor variation when run with shcomp
Browse files Browse the repository at this point in the history
For unknown reasons, the test for a memory leak in 'read -C stat
<<< "$data"' can show an intermittent minor variation in memory
usage when run with shcomp on certain versions of macOS.

The reported variations are 48 bytes or 80 bytes. This is too small
to be the result of an actual memory leak in the tested command;
it is repeated 500 times so that any real leak should show a
difference of at least 500 bytes.

src/cmd/ksh93/tests/leaks.sh:
- Add a tolerance of 128 bytes to get rid of the false failure.

Fixes #70 (hopefully).
  • Loading branch information
McDutchie committed Jul 10, 2020
1 parent 778fd6c commit 84e2f6d
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/cmd/ksh93/tests/leaks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ for ((i=0; i < 500; i++))
do read -C stat <<< "$data"
done
after=$(getmem)
(( after > before )) && err_exit "memory leak with read -C when using <<< (leaked $((after - before)) $unit)"
# this test can show minor variations in memory usage when run with shcomp: https://github.com/ksh93/ksh/issues/70
(( after > before+128 )) && err_exit "memory leak with read -C when using <<< (leaked $((after - before)) $unit)"

# ======
# Unsetting an associative array shouldn't cause a memory leak
Expand Down

0 comments on commit 84e2f6d

Please sign in to comment.