1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-05-30 02:06:12 +02:00

Merge branch 'ab/valgrind-fixes'

A bit of test framework fixes with a few fixes to issues found by
valgrind.

* ab/valgrind-fixes:
  commit-graph.c: don't assume that stat() succeeds
  object-file: fix a unpack_loose_header() regression in 3b6a8db3b0
  log test: skip a failing mkstemp() test under valgrind
  tests: using custom GIT_EXEC_PATH breaks --valgrind tests
This commit is contained in:
Junio C Hamano 2022-05-23 14:39:54 -07:00
commit 1b8138fb08
7 changed files with 39 additions and 14 deletions

View File

@ -2209,7 +2209,8 @@ static void mark_commit_graphs(struct write_commit_graph_context *ctx)
struct stat st;
struct utimbuf updated_time;
stat(ctx->commit_graph_filenames_before[i], &st);
if (stat(ctx->commit_graph_filenames_before[i], &st) < 0)
continue;
updated_time.actime = st.st_atime;
updated_time.modtime = now;
@ -2250,7 +2251,8 @@ static void expire_commit_graphs(struct write_commit_graph_context *ctx)
strbuf_setlen(&path, dirnamelen);
strbuf_addstr(&path, de->d_name);
stat(path.buf, &st);
if (stat(path.buf, &st) < 0)
continue;
if (st.st_mtime > expire_time)
continue;

View File

@ -2623,8 +2623,12 @@ int read_loose_object(const char *path,
goto out;
}
if (unpack_loose_header(&stream, map, mapsize, hdr, sizeof(hdr),
NULL) < 0) {
switch (unpack_loose_header(&stream, map, mapsize, hdr, sizeof(hdr),
NULL)) {
case ULHR_OK:
break;
case ULHR_BAD:
case ULHR_TOO_LONG:
error(_("unable to unpack header of %s"), path);
goto out;
}

View File

@ -542,7 +542,7 @@ test_lazy_prereq CAN_EXEC_IN_PWD '
./git rev-parse
'
test_expect_success RUNTIME_PREFIX,CAN_EXEC_IN_PWD 'RUNTIME_PREFIX works' '
test_expect_success !VALGRIND,RUNTIME_PREFIX,CAN_EXEC_IN_PWD 'RUNTIME_PREFIX works' '
mkdir -p pretend/bin pretend/libexec/git-core &&
echo "echo HERE" | write_script pretend/libexec/git-core/git-here &&
cp "$GIT_EXEC_PATH"/git$X pretend/bin/ &&
@ -550,7 +550,7 @@ test_expect_success RUNTIME_PREFIX,CAN_EXEC_IN_PWD 'RUNTIME_PREFIX works' '
echo HERE >expect &&
test_cmp expect actual'
test_expect_success RUNTIME_PREFIX,CAN_EXEC_IN_PWD '%(prefix)/ works' '
test_expect_success !VALGRIND,RUNTIME_PREFIX,CAN_EXEC_IN_PWD '%(prefix)/ works' '
mkdir -p pretend/bin &&
cp "$GIT_EXEC_PATH"/git$X pretend/bin/ &&
git config yes.path "%(prefix)/yes" &&

View File

@ -681,7 +681,7 @@ test_expect_success 'cat-file -t and -s on corrupt loose object' '
# Setup and create the empty blob and its path
empty_path=$(git rev-parse --git-path objects/$(test_oid_to_path "$EMPTY_BLOB")) &&
git hash-object -w --stdin </dev/null &&
empty_blob=$(git hash-object -w --stdin </dev/null) &&
# Create another blob and its path
echo other >other.blob &&
@ -722,7 +722,13 @@ test_expect_success 'cat-file -t and -s on corrupt loose object' '
# content out as-is. Try to make it zlib-invalid.
mv -f other.blob "$empty_path" &&
test_must_fail git fsck 2>err.fsck &&
grep "^error: inflate: data stream error (" err.fsck
cat >expect <<-EOF &&
error: inflate: data stream error (incorrect header check)
error: unable to unpack header of ./$empty_path
error: $empty_blob: object corrupt or missing: ./$empty_path
EOF
grep "^error: " err.fsck >actual &&
test_cmp expect actual
)
'

View File

@ -774,10 +774,19 @@ test_expect_success 'fsck finds problems in duplicate loose objects' '
# no "-d" here, so we end up with duplicates
git repack &&
# now corrupt the loose copy
file=$(sha1_file "$(git rev-parse HEAD)") &&
oid="$(git rev-parse HEAD)" &&
file=$(sha1_file "$oid") &&
rm "$file" &&
echo broken >"$file" &&
test_must_fail git fsck
test_must_fail git fsck 2>err &&
cat >expect <<-EOF &&
error: inflate: data stream error (incorrect header check)
error: unable to unpack header of $file
error: $oid: object corrupt or missing: $file
EOF
grep "^error: " err >actual &&
test_cmp expect actual
)
'

View File

@ -1992,10 +1992,13 @@ test_expect_success GPG 'log --show-signature for merged tag with GPG failure' '
git tag -s -m signed_tag_msg signed_tag_fail &&
git checkout plain-fail &&
git merge --no-ff -m msg signed_tag_fail &&
TMPDIR="$(pwd)/bogus" git log --show-signature -n1 plain-fail >actual &&
grep "^merged tag" actual &&
grep "^No signature" actual &&
! grep "^gpg: Signature made" actual
if ! test_have_prereq VALGRIND
then
TMPDIR="$(pwd)/bogus" git log --show-signature -n1 plain-fail >actual &&
grep "^merged tag" actual &&
grep "^No signature" actual &&
! grep "^gpg: Signature made" actual
fi
'
test_expect_success GPGSM 'log --graph --show-signature for merged tag x509' '

View File

@ -1667,6 +1667,7 @@ test -n "$USE_LIBPCRE2" && test_set_prereq PCRE
test -n "$USE_LIBPCRE2" && test_set_prereq LIBPCRE2
test -z "$NO_GETTEXT" && test_set_prereq GETTEXT
test -n "$SANITIZE_LEAK" && test_set_prereq SANITIZE_LEAK
test -n "$GIT_VALGRIND_ENABLED" && test_set_prereq VALGRIND
if test -z "$GIT_TEST_CHECK_CACHE_TREE"
then