Download raw body.
WIP Otto's Malloc Regression Integration
This is a WIP diff to give an option for regression tests.
Here is an example once you apply the patch
```
cd ./regress/cmdline/
MEM_CHECK=1 ./send.sh
```
You can set MEM_CHECK to {1,2,3,4} which will be passed down to MALLOC_OPTIONS.
If a regression produces a memory leak, then the kdump is left in $testroot, otherwise
it is deleted with $testroot. The kdump is also printed.
I currently only have this implemented in ./add.sh and ./send.sh. Trying to enable
MEM_CHECK on a regress without it being implemented will cause it to fail.
The current pain point with the diff below is that ktrace(1) has a return value, so
it may cause issues as we check got's return value in some regressions.
diff refs/heads/main refs/heads/regress_mem_check
commit - 8c5906074ad5756611aa1977542e314d8e3662bb
commit + ed50c840f77fd3e4b8b7b46b5b2b2d29228a18c1
blob - ebba1caf39b7ef4c28dcefcc7bb43a6ec5597c76
blob + 7720966abd677bd77f4523cefbc5a522b8d7b78f
--- regress/cmdline/add.sh
+++ regress/cmdline/add.sh
@@ -29,7 +29,7 @@ test_add_basic() {
echo "new file" > $testroot/wt/foo
echo 'A foo' > $testroot/stdout.expected
- (cd $testroot/wt && got add foo > $testroot/stdout)
+ (cd $testroot/wt && $(SHIM $testroot) got add foo > $testroot/stdout)
cmp -s $testroot/stdout.expected $testroot/stdout
ret=$?
@@ -52,7 +52,7 @@ test_double_add() {
echo "new file" > $testroot/wt/foo
(cd $testroot/wt && got add foo > /dev/null)
- (cd $testroot/wt && got add foo > $testroot/stdout)
+ (cd $testroot/wt && $(SHIM $testroot) got add foo > $testroot/stdout)
ret=$?
if [ $ret -ne 0 ]; then
echo "got add failed unexpectedly" >&2
@@ -100,7 +100,7 @@ test_add_multiple() {
echo "new file" > $testroot/wt/foo
echo "new file" > $testroot/wt/bar
echo "new file" > $testroot/wt/baz
- (cd $testroot/wt && got add foo bar baz > $testroot/stdout)
+ (cd $testroot/wt && $(SHIM $testroot) got add foo bar baz > $testroot/stdout)
ret=$?
if [ $ret -ne 0 ]; then
echo "got add failed unexpectedly" >&2
@@ -155,7 +155,7 @@ test_add_file_in_new_subdir() {
echo "new file" > $testroot/wt/new/foo
echo 'A new/foo' > $testroot/stdout.expected
- (cd $testroot/wt && got add new/foo > $testroot/stdout)
+ (cd $testroot/wt && $(SHIM $testroot) got add new/foo > $testroot/stdout)
cmp -s $testroot/stdout.expected $testroot/stdout
ret=$?
@@ -178,7 +178,7 @@ test_add_deleted() {
(cd $testroot/wt && got rm beta > /dev/null)
echo -n > $testroot/stdout.expected
- (cd $testroot/wt && got add beta > $testroot/stdout 2> $testroot/stderr)
+ (cd $testroot/wt && $(SHIM $testroot) got add beta > $testroot/stdout 2> $testroot/stderr)
ret=$?
if [ $ret -eq 0 ]; then
echo "got add command succeeded unexpectedly" >&2
@@ -239,7 +239,7 @@ test_add_force_delete_commit() {
# File 'new' was once in A status (locally added) but is now
# in "!" (missing) status since it was never committed.
# Removing it effectively reverts the local addition.
- (cd $testroot/wt && got remove -f new > $testroot/stdout \
+ (cd $testroot/wt && $(SHIM $testroot) got remove -f new > $testroot/stdout \
2> $testroot/stderr)
ret=$?
if [ $ret -ne 0 ]; then
@@ -334,7 +334,7 @@ test_add_directory() {
return 1
fi
- (cd $testroot/wt && got add -RI tree1 > $testroot/stdout)
+ (cd $testroot/wt && $(SHIM $testroot) got add -RI tree1 > $testroot/stdout)
echo 'A tree1/foo' > $testroot/stdout.expected
@@ -401,7 +401,7 @@ test_add_clashes_with_submodule() {
(cd $testroot/wt && got update > /dev/null)
# This currently fails with "work tree must be updated"...
- (cd $testroot/wt && got commit -m 'add file repo2' \
+ (cd $testroot/wt && $(SHIM $testroot) got commit -m 'add file repo2' \
> $testroot/stdout 2> $testroot/stderr)
ret=$?
if [ $ret -eq 0 ]; then
@@ -476,7 +476,7 @@ test_add_symlink() {
fi
echo "A nonexistent.link" > $testroot/stdout.expected
- (cd $testroot/wt && got add nonexistent.link > $testroot/stdout)
+ (cd $testroot/wt && $(SHIM $testroot) got add nonexistent.link > $testroot/stdout)
cmp -s $testroot/stdout.expected $testroot/stdout
ret=$?
if [ $ret -ne 0 ]; then
blob - 156415b56edfb4ef165638477f4d1a02d4b5d86f
blob + b63b4bd338c9185c2c5f0ac1c8bb4c27cbcb2ba4
--- regress/cmdline/common.sh
+++ regress/cmdline/common.sh
@@ -32,7 +32,13 @@ export GOT_TEST_ALGO="${GOT_TEST_ALGO:-sha1}"
export LC_ALL=C
+if [ -n "$MEM_CHECK" ] && [ "$MEM_CHECK" -gt 0 ] && [ "$MEM_CHECK" -lt 5 ]; then
+ export MALLOC_OPTIONS="$MEM_CHECK"S
+ echo $MALLOC_OPTIONS
+else
export MALLOC_OPTIONS=S
+fi
git_init()
{
@@ -287,6 +293,13 @@ test_done()
{
local testroot="$1"
local result="$2"
+ if [ -n "$MEM_CHECK" ]; then
+ if [ $(kdump -u malloc -f $testroot/ktrace.out | awk -v LINE="$MEM_CHECK" 'NR%LINE==1' | grep -c "got" ) -gt 2 ] ; then
+ kdump -u malloc -f $testroot/ktrace.out | sed 's/got/~\/bin\/got/' #| malloc_p
+ echo "FOUND MEMORY LEAK; leaving test data in $testroot"
+ return 1
+ fi
+ fi
if [ "$result" = "0" ]; then
test_cleanup "$testroot" || return 1
if [ -z "$GOT_TEST_QUIET" ]; then
@@ -300,3 +313,21 @@ test_done()
echo "test failed; leaving test data in $testroot"
fi
}
+
+SHIM()
+{
+ if [ -n "$MEM_CHECK" ]; then
+
+ if [ -z "$1" ]; then
+ echo "Testroot not passed"
+ exit 1
+ fi
+ local testroot="$1"
+ if [ ! -d "$testroot" ]; then
+ echo "Directory does not exist"
+ exit 1
+ fi
+ echo "ktrace -dtu -f $testroot/ktrace.out"
+ fi
+}
+
blob - 9d3971a3148f13aa50c0b1e2ec9a992d1f859e29
blob + 281962da0bea2b3ea4ea86ea3250a2c870385be7
--- regress/cmdline/send.sh
+++ regress/cmdline/send.sh
@@ -20,7 +20,6 @@ test_send_basic() {
local testroot=`test_init send_basic`
local testurl=ssh://127.0.0.1/$testroot
local commit_id=`git_show_head $testroot/repo`
-
got clone -q $testurl/repo $testroot/repo-clone
ret=$?
if [ $ret -ne 0 ]; then
@@ -48,7 +47,7 @@ EOF
git_commit $testroot/repo -m "modified alpha"
local commit_id2=`git_show_head $testroot/repo`
- got send -q -r $testroot/repo > $testroot/stdout 2> $testroot/stderr
+ $(SHIM $testroot) got send -q -r $testroot/repo > $testroot/stdout 2> $testroot/stderr
ret=$?
if [ $ret -ne 0 ]; then
echo "got send command failed unexpectedly" >&2
@@ -150,7 +149,6 @@ test_send_rebase_required() {
local testroot=`test_init send_rebase_required`
local testurl=ssh://127.0.0.1/$testroot
local commit_id=`git_show_head $testroot/repo`
-
got clone -q $testurl/repo $testroot/repo-clone
ret=$?
if [ $ret -ne 0 ]; then
@@ -173,7 +171,7 @@ EOF
echo "modified alpha, too" > $testroot/wt-clone/alpha
(cd $testroot/wt-clone && got commit -m 'change alpha' >/dev/null)
- got send -q -r $testroot/repo > $testroot/stdout 2> $testroot/stderr
+ $(SHIM $testroot ) got send -q -r $testroot/repo > $testroot/stdout 2> $testroot/stderr
ret=$?
if [ $ret -eq 0 ]; then
echo "got send command succeeded unexpectedly" >&2
@@ -241,7 +239,7 @@ EOF
local commit_id3=`git_show_head $testroot/repo-clone`
# non-default remote requires an explicit argument
- got send -q -r $testroot/repo -f > $testroot/stdout \
+ $(SHIM $testroot ) got send -q -r $testroot/repo -f > $testroot/stdout \
2> $testroot/stderr
ret=$?
if [ $ret -eq 0 ]; then
@@ -359,7 +357,7 @@ test_send_merge_commit() {
git -C $testroot/repo config receive.denyCurrentBranch ignore
- got send -q -r $testroot/repo-clone
+ $(SHIM $testroot ) got send -q -r $testroot/repo-clone
ret=$?
if [ $ret -ne 0 ]; then
test_done "$testroot" "$ret"
@@ -409,7 +407,7 @@ EOF
# Sending changes for a branch and deleting it at the same
# time is not allowed.
- got send -q -r $testroot/repo -d branch1 -b branch1 \
+ $(SHIM $testroot ) got send -q -r $testroot/repo -d branch1 -b branch1 \
> $testroot/stdout 2> $testroot/stderr
ret=$?
if [ $ret -eq 0 ]; then
@@ -572,7 +570,7 @@ test_send_clone_and_send() {
(cd $testroot/wt && got commit -m "modified alpha" >/dev/null)
local commit_id2=`git_show_head $testroot/repo-clone`
- (cd $testroot/wt && got send -q > $testroot/stdout 2> $testroot/stderr)
+ (cd $testroot/wt && $(SHIM $testroot ) got send -q > $testroot/stdout 2> $testroot/stderr)
ret=$?
if [ $ret -ne 0 ]; then
echo "got send command failed unexpectedly" >&2
@@ -671,7 +669,7 @@ EOF
tag_id2=`got ref -r $testroot/repo -l | grep "^refs/tags/2.0" \
| tr -d ' ' | cut -d: -f2`
- got send -q -r $testroot/repo -T > $testroot/stdout 2> $testroot/stderr
+ $(SHIM $testroot ) got send -q -r $testroot/repo -T > $testroot/stdout 2> $testroot/stderr
ret=$?
if [ $ret -ne 0 ]; then
echo "got send command failed unexpectedly" >&2
@@ -847,7 +845,7 @@ EOF
(cd $testroot/wt && got commit -m 'changing file alpha' > /dev/null)
# Send the new commit in isolation.
- got send -q -r $testroot/repo > $testroot/stdout \
+ $(SHIM $testroot ) got send -q -r $testroot/repo > $testroot/stdout \
2> $testroot/stderr
ret=$?
if [ $ret -ne 0 ]; then
@@ -932,7 +930,7 @@ EOF
git_commit $testroot/repo -m "modified alpha"
local commit_id3=`git_show_head $testroot/repo`
- got send -q -r $testroot/repo -T > $testroot/stdout 2> $testroot/stderr
+ $(SHIM $testroot ) got send -q -r $testroot/repo -T > $testroot/stdout 2> $testroot/stderr
ret=$?
if [ $ret -ne 0 ]; then
echo "got send command failed unexpectedly" >&2
@@ -1036,7 +1034,7 @@ test_send_new_branch() {
(cd $testroot/wt && got commit -m "modified alpha" >/dev/null)
local commit_id2=`git_show_branch_head $testroot/repo-clone foo`
- (cd $testroot/wt && got send -q > $testroot/stdout 2> $testroot/stderr)
+ (cd $testroot/wt && $(SHIM $testroot ) got send -q > $testroot/stdout 2> $testroot/stderr)
ret=$?
if [ $ret -ne 0 ]; then
echo "got send command failed unexpectedly" >&2
@@ -1171,7 +1169,7 @@ test_send_all_branches() {
return 1
fi
- got send -a -q -r $testroot/repo-clone > $testroot/stdout \
+ $(SHIM $testroot ) got send -a -q -r $testroot/repo-clone > $testroot/stdout \
2> $testroot/stderr
ret=$?
if [ $ret -ne 0 ]; then
@@ -1332,7 +1330,7 @@ EOF
return 1
fi
- got send -r $testroot/repo > $testroot/stdout 2> $testroot/stderr
+ $(SHIM $testroot ) got send -r $testroot/repo > $testroot/stdout 2> $testroot/stderr
ret=$?
if [ $ret -ne 0 ]; then
echo "got send command failed unexpectedly" >&2
@@ -1443,7 +1441,7 @@ EOF
fi
# send tag 1.0 to repo-clone
- got send -q -r $testroot/repo -t 1.0 > $testroot/stdout
+ $(SHIM $testroot ) got send -q -r $testroot/repo -t 1.0 > $testroot/stdout
ret=$?
if [ $ret -ne 0 ]; then
echo "got send command failed unexpectedly" >&2
@@ -1526,7 +1524,7 @@ EOF
got branch -r $testroot/repo foo
- got send -q -r $testroot/repo > $testroot/stdout 2> $testroot/stderr
+ $(SHIM $testroot ) got send -q -r $testroot/repo > $testroot/stdout 2> $testroot/stderr
ret=$?
if [ $ret -ne 0 ]; then
echo "got send command failed unexpectedly" >&2
@@ -1586,7 +1584,7 @@ cat >> $testroot/repo/.git/config <<EOF
EOF
# unset in a subshell to avoid affecting our environment
- (unset GOT_IGNORE_GITCONFIG && got send -q -r $testroot/repo foo)
+ (unset GOT_IGNORE_GITCONFIG && $(SHIM $testroot ) got send -q -r $testroot/repo foo)
ret=$?
if [ $ret -ne 0 ]; then
echo "got send command failed unexpectedly" >&2
@@ -1643,7 +1641,7 @@ EOF
echo "modified alpha" >$testroot/repo/alpha
git_commit "$testroot/repo" -m "modified alpha"
- got send -q -r "$testroot/repo" >$testroot/stdout 2>$testroot/stderr
+ $(SHIM $testroot ) got send -q -r "$testroot/repo" >$testroot/stdout 2>$testroot/stderr
ret=$?
if [ $ret -ne 0 ]; then
echo "got send command failed unexpectedly" >&2
@@ -1713,7 +1711,7 @@ EOF
git_commit $testroot/repo -m "modified alpha"
local commit_id2=`git_show_head $testroot/repo`
- got send -q -r $testroot/repo > $testroot/stdout 2> $testroot/stderr
+ $(SHIM $testroot ) got send -q -r $testroot/repo > $testroot/stdout 2> $testroot/stderr
ret=$?
if [ $ret -eq 0 ]; then
echo "got send command succeeded unexpectedly" >&2
Note: in the above patch you will see "# | malloc_p". I commented this out and will have to
replace it with the corresponding awk script. Awk script: https://www.drijf.net/malloc/
This, at the very least, should help kickstart something better :)
WIP Otto's Malloc Regression Integration