In [1] I suggested that we could catch the segfault fixed in
c6854508808 (ref-filter: fix NULL check for parse object failure,
2021-04-01) (and possibly other future bugs) my extending the mktag
tests.
Junio wanted the more isolated bug fix first[2], which is fair
enough. But now that the dust has settled I figured I'd submit this
test-only series which stresses mktag, fsck and various commands that
might deal with the broken objects the mktag tests creates.
1. https://lore.kernel.org/git/cover-0.6-00000000000-20210401T135419Z-avarab@gmail.com/
2. https://lore.kernel.org/git/xmqqeefs4dge.fsf@gitster.g/
Ævar Arnfjörð Bjarmason (6):
mktag tests: parse out options in helper
mktag tests: invert --no-strict test
mktag tests: test hash-object --literally and unreachable fsck
mktag tests: test update-ref and reachable fsck
mktag tests: test for-each-ref
mktag tests: test fast-export
t/t3800-mktag.sh | 112 ++++++++++++++++++++++++++++++++++++++++-------
1 file changed, 97 insertions(+), 15 deletions(-)
--
2.32.0.555.g0268d380f7b
Change check_verify_failure() helper to parse out options from
$@. This makes it easier to add new options in the future. See
06ce79152be (mktag: add a --[no-]strict option, 2021-01-06) for the
initial implementation.
Let's also replace "" quotes with '' for the test body, the varables
we need are eval'd into the body, so there's no need for the quoting
confusion.
Signed-off-by: Ævar Arnfjörð Bjarmason <redacted>
---
t/t3800-mktag.sh | 43 +++++++++++++++++++++++++++++++------------
1 file changed, 31 insertions(+), 12 deletions(-)
@@ -12,15 +12,29 @@ test_description='git mktag: tag object verify test'# given in the expect.pat file. check_verify_failure(){-test_expect_success"$1""-test_must_failgitmktag<tag.sig2>message&&-grep'$2'message&&-iftest'$3'!='--no-strict'+subject=$1&&+message=$2&&+shift2&&++no_strict=&&+whiletest$#!=0+do+case"$1"in+--no-strict)+no_strict=yes+;;+esac&&+shift+done&&++test_expect_success"fail with [--[no-]strict]: $subject"'+test_must_failgitmktag<tag.sig2>err&&+iftest-z"$no_strict"then-test_must_failgitmktag--no-strict<tag.sig2>message.no-strict&&-grep'$2'message.no-strict+test_must_failgitmktag<tag.sig2>err2&&+test_cmperrerr2fi-"+'} test_expect_mktag_success(){
@@ -257,7 +272,8 @@ This is filler EOF check_verify_failure'"tagger" line label check #1'\-'^error:.* missingTaggerEntry:''--no-strict'+'^error:.* missingTaggerEntry:'\+--no-strict############################################################# 12. tagger line label check #2
@@ -272,7 +288,8 @@ This is filler EOF check_verify_failure'"tagger" line label check #2'\-'^error:.* missingTaggerEntry:''--no-strict'+'^error:.* missingTaggerEntry:'\+--no-strict############################################################# 13. allow missing tag author name like fsck
@@ -301,7 +318,8 @@ tagger T A Gger < EOF check_verify_failure'disallow malformed tagger'\-'^error:.* badEmail:''--no-strict'+'^error:.* badEmail:'\+--no-strict############################################################# 15. allow empty tag email
@@ -425,7 +443,8 @@ this line should not be here EOF check_verify_failure'detect invalid header entry'\-'^error:.* extraHeaderEntry:''--no-strict'+'^error:.* extraHeaderEntry:'\+--no-strict test_expect_success'invalid header entry config & fsck''test_must_failgitmktag<tag.sig&&
Extend the mktag tests to pass the created bad tag through update-ref
and fsck.
The reason for passing it through update-ref is to guard against it
having a segfault as for-each-ref did before c6854508808 (ref-filter:
fix NULL check for parse object failure, 2021-04-01).
Signed-off-by: Ævar Arnfjörð Bjarmason <redacted>
---
t/t3800-mktag.sh | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
@@ -44,6 +44,8 @@ check_verify_failure () {'test_expect_success"setup: $subject"'+tag_ref=refs/tags/bad_tag&&+# Reset any leftover state from the last $subjectrm-rfbad-tag&&
@@ -59,6 +61,20 @@ check_verify_failure () {test_must_failgit-Cbad-tagfsck>out2>errfi'++test_expect_success"update-ref & fsck reachable: $subject"'+# The update-ref of the bad content will fail, do it+# anyway to see if it segfaults+test_might_failgit-Cbad-tagupdate-ref"$tag_ref""$bad_tag"&&++# Manually create the broken, we cannot do it with+# update-ref+echo"$bad_tag">"bad-tag/$tag_ref"&&++# Unlike fsck-ing unreachable content above, this+# will always fail.+test_must_failgit-Cbad-tagfsck+'} test_expect_mktag_success(){
Extend the mktag tests to pass the tag we've created through both
hash-object --literally and fsck.
This checks that fsck itself will not complain about certain invalid
content if a reachable tip isn't involved. Due to how fsck works and
walks the graph the failure will be different if the object is
reachable, so we might succeed before we've created the ref.
Signed-off-by: Ævar Arnfjörð Bjarmason <redacted>
---
t/t3800-mktag.sh | 48 +++++++++++++++++++++++++++++++++++++++---------
1 file changed, 39 insertions(+), 9 deletions(-)
@@ -37,6 +42,23 @@ check_verify_failure () {gitmktag--no-strict<tag.sigfi'++test_expect_success"setup: $subject"'+# Reset any leftover state from the last $subject+rm-rfbad-tag&&++gitinit--barebad-tag&&+git-Cbad-taghash-object-ttag-w--stdin--literally<tag.sig+'++test_expect_success"hash-object & fsck unreachable: $subject"'+iftest-n"$fsck_obj_ok"+then+git-Cbad-tagfsck+else+test_must_failgit-Cbad-tagfsck>out2>err+fi+'} test_expect_mktag_success(){
@@ -183,7 +205,8 @@ tagger . <> 0 +0000 EOF check_verify_failure'verify object (hash/type) check -- correct type, nonexisting object'\-'^fatal: could not read tagged object'+'^fatal: could not read tagged object'\+--fsck-obj-ok cat>tag.sig<<EOF object$head
@@ -275,7 +301,8 @@ EOF check_verify_failure'"tagger" line label check #1'\'^error:.* missingTaggerEntry:'\---no-strict+--no-strict\+--fsck-obj-ok############################################################# 12. tagger line label check #2
@@ -291,7 +318,8 @@ EOF check_verify_failure'"tagger" line label check #2'\'^error:.* missingTaggerEntry:'\---no-strict+--no-strict\+--fsck-obj-ok############################################################# 13. allow missing tag author name like fsck
Change the mktag --no-strict test to actually test success under
--no-strict, that test was added in 06ce79152be (mktag: add a
--[no-]strict option, 2021-01-06).
It doesn't make sense to check that we have the same failure except
when we want --no-strict, by doing that we're assuming that the
behavior will be different under --no-strict, bun nothing was testing
for that.
We should instead assert that --strict is the same as --no-strict,
except in the cases where we've declared that it's not.
Signed-off-by: Ævar Arnfjörð Bjarmason <redacted>
---
t/t3800-mktag.sh | 2 ++
1 file changed, 2 insertions(+)
Pass the bad tags we've created in the mktag tests through
fast-export, it will die on the bad object or ref, let's make sure
that happens.
Signed-off-by: Ævar Arnfjörð Bjarmason <redacted>
---
t/t3800-mktag.sh | 5 +++++
1 file changed, 5 insertions(+)
Add a "for-each-ref" for all the mktag tests. This test would have
caught the segfault which was fixed in c6854508808 (ref-filter: fix
NULL check for parse object failure, 2021-04-01). Let's make sure we
test that code more exhaustively.
Signed-off-by: Ævar Arnfjörð Bjarmason <redacted>
---
t/t3800-mktag.sh | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
From: Andrei Rybak <hidden> Date: 2021-06-15 10:34:17
On 14/06/2021 19:28, Ævar Arnfjörð Bjarmason wrote:
quoted hunk
Extend the mktag tests to pass the tag we've created through both
hash-object --literally and fsck.
This checks that fsck itself will not complain about certain invalid
content if a reachable tip isn't involved. Due to how fsck works and
walks the graph the failure will be different if the object is
reachable, so we might succeed before we've created the ref.
Signed-off-by: Ævar Arnfjörð Bjarmason <redacted>
---
t/t3800-mktag.sh | 48 +++++++++++++++++++++++++++++++++++++++---------
1 file changed, 39 insertions(+), 9 deletions(-)
On 14/06/2021 19:28, Ævar Arnfjörð Bjarmason wrote:
quoted
Extend the mktag tests to pass the tag we've created through both
hash-object --literally and fsck.
This checks that fsck itself will not complain about certain invalid
content if a reachable tip isn't involved. Due to how fsck works and
walks the graph the failure will be different if the object is
reachable, so we might succeed before we've created the ref.
Signed-off-by: Ævar Arnfjörð Bjarmason <redacted>
---
t/t3800-mktag.sh | 48 +++++++++++++++++++++++++++++++++++++++---------
1 file changed, 39 insertions(+), 9 deletions(-)
Change check_verify_failure() helper to parse out options from
$@. This makes it easier to add new options in the future. See
06ce79152be (mktag: add a --[no-]strict option, 2021-01-06) for the
initial implementation.
Let's also replace "" quotes with '' for the test body, the varables
we need are eval'd into the body, so there's no need for the quoting
confusion.
Signed-off-by: Ævar Arnfjörð Bjarmason <redacted>
---
t/t3800-mktag.sh | 43 +++++++++++++++++++++++++++++++------------
1 file changed, 31 insertions(+), 12 deletions(-)
@@ -12,15 +12,29 @@ test_description='git mktag: tag object verify test'# given in the expect.pat file. check_verify_failure(){-test_expect_success"$1""-test_must_failgitmktag<tag.sig2>message&&-grep'$2'message&&-iftest'$3'!='--no-strict'+subject=$1&&+message=$2&&+shift2&&++no_strict=&&+whiletest$#!=0+do+case"$1"in+--no-strict)+no_strict=yes+;;+esac&&+shift+done&&++test_expect_success"fail with [--[no-]strict]: $subject"'+test_must_failgitmktag<tag.sig2>err&&+iftest-z"$no_strict"then-test_must_failgitmktag--no-strict<tag.sig2>message.no-strict&&-grep'$2'message.no-strict+test_must_failgitmktag<tag.sig2>err2&&+test_cmperrerr2fi-"+'} test_expect_mktag_success(){
@@ -257,7 +272,8 @@ This is filler EOF check_verify_failure'"tagger" line label check #1'\-'^error:.* missingTaggerEntry:''--no-strict'+'^error:.* missingTaggerEntry:'\+--no-strict############################################################# 12. tagger line label check #2
@@ -272,7 +288,8 @@ This is filler EOF check_verify_failure'"tagger" line label check #2'\-'^error:.* missingTaggerEntry:''--no-strict'+'^error:.* missingTaggerEntry:'\+--no-strict############################################################# 13. allow missing tag author name like fsck
@@ -301,7 +318,8 @@ tagger T A Gger < EOF check_verify_failure'disallow malformed tagger'\-'^error:.* badEmail:''--no-strict'+'^error:.* badEmail:'\+--no-strict############################################################# 15. allow empty tag email
@@ -425,7 +443,8 @@ this line should not be here EOF check_verify_failure'detect invalid header entry'\-'^error:.* extraHeaderEntry:''--no-strict'+'^error:.* extraHeaderEntry:'\+--no-strict test_expect_success'invalid header entry config & fsck''test_must_failgitmktag<tag.sig&&
Change the mktag --no-strict test to actually test success under
--no-strict, that test was added in 06ce79152be (mktag: add a
--[no-]strict option, 2021-01-06).
It doesn't make sense to check that we have the same failure except
when we want --no-strict, by doing that we're assuming that the
behavior will be different under --no-strict, bun nothing was testing
for that.
We should instead assert that --strict is the same as --no-strict,
except in the cases where we've declared that it's not.
Signed-off-by: Ævar Arnfjörð Bjarmason <redacted>
---
t/t3800-mktag.sh | 2 ++
1 file changed, 2 insertions(+)
Extend the mktag tests to pass the tag we've created through both
hash-object --literally and fsck.
This checks that fsck itself will not complain about certain invalid
content if a reachable tip isn't involved. Due to how fsck works and
walks the graph the failure will be different if the object is
reachable, so we might succeed before we've created the ref.
Signed-off-by: Ævar Arnfjörð Bjarmason <redacted>
---
t/t3800-mktag.sh | 46 ++++++++++++++++++++++++++++++++++++++--------
1 file changed, 38 insertions(+), 8 deletions(-)
@@ -37,6 +42,23 @@ check_verify_failure () {gitmktag--no-strict<tag.sigfi'++test_expect_success"setup: $subject"'+# Reset any leftover state from the last $subject+rm-rfbad-tag&&++gitinit--barebad-tag&&+git-Cbad-taghash-object-ttag-w--stdin--literally<tag.sig+'++test_expect_success"hash-object & fsck unreachable: $subject"'+iftest-n"$fsck_obj_ok"+then+git-Cbad-tagfsck+else+test_must_failgit-Cbad-tagfsck+fi+'} test_expect_mktag_success(){
@@ -183,7 +205,8 @@ tagger . <> 0 +0000 EOF check_verify_failure'verify object (hash/type) check -- correct type, nonexisting object'\-'^fatal: could not read tagged object'+'^fatal: could not read tagged object'\+--fsck-obj-ok cat>tag.sig<<EOF object$head
@@ -275,7 +301,8 @@ EOF check_verify_failure'"tagger" line label check #1'\'^error:.* missingTaggerEntry:'\---no-strict+--no-strict\+--fsck-obj-ok############################################################# 12. tagger line label check #2
@@ -291,7 +318,8 @@ EOF check_verify_failure'"tagger" line label check #2'\'^error:.* missingTaggerEntry:'\---no-strict+--no-strict\+--fsck-obj-ok############################################################# 13. allow missing tag author name like fsck
Add a "for-each-ref" for all the mktag tests. This test would have
caught the segfault which was fixed in c6854508808 (ref-filter: fix
NULL check for parse object failure, 2021-04-01). Let's make sure we
test that code more exhaustively.
Signed-off-by: Ævar Arnfjörð Bjarmason <redacted>
---
t/t3800-mktag.sh | 13 +++++++++++++
1 file changed, 13 insertions(+)
@@ -78,6 +78,19 @@ check_verify_failure () {# will always fail.test_must_failgit-Cbad-tagfsck'++test_expect_success"for-each-ref: $subject"'+# Make sure the earlier test created it for us+gitrev-parse"$bad_tag"&&++echo"$bad_tag">"bad-tag/$tag_ref"&&++printf"%s tag\t%s\n""$bad_tag""$tag_ref">expected&&+git-Cbad-tagfor-each-ref"$tag_ref">actual&&+test_cmpexpectedactual&&++test_must_failgit-Cbad-tagfor-each-ref--format="%(*objectname)"+'} test_expect_mktag_success(){
Extend the mktag tests to pass the created bad tag through update-ref
and fsck.
The reason for passing it through update-ref is to guard against it
having a segfault as for-each-ref did before c6854508808 (ref-filter:
fix NULL check for parse object failure, 2021-04-01).
Signed-off-by: Ævar Arnfjörð Bjarmason <redacted>
---
t/t3800-mktag.sh | 21 ++++++++++++++++++++-
1 file changed, 20 insertions(+), 1 deletion(-)
@@ -44,11 +44,13 @@ check_verify_failure () {'test_expect_success"setup: $subject"'+tag_ref=refs/tags/bad_tag&&+# Reset any leftover state from the last $subjectrm-rfbad-tag&&gitinit--barebad-tag&&-git-Cbad-taghash-object-ttag-w--stdin--literally<tag.sig+bad_tag=$(git-Cbad-taghash-object-ttag-w--stdin--literally<tag.sig)'test_expect_success"hash-object & fsck unreachable: $subject"'
@@ -59,6 +61,23 @@ check_verify_failure () {test_must_failgit-Cbad-tagfsckfi'++test_expect_success"update-ref & fsck reachable: $subject"'+# Make sure the earlier test created it for us+gitrev-parse"$bad_tag"&&++# The update-ref of the bad content will fail, do it+# anyway to see if it segfaults+test_might_failgit-Cbad-tagupdate-ref"$tag_ref""$bad_tag"&&++# Manually create the broken, we cannot do it with+# update-ref+echo"$bad_tag">"bad-tag/$tag_ref"&&++# Unlike fsck-ing unreachable content above, this+# will always fail.+test_must_failgit-Cbad-tagfsck+'} test_expect_mktag_success(){
Pass the bad tags we've created in the mktag tests through
fast-export, it will die on the bad object or ref, let's make sure
that happens.
Signed-off-by: Ævar Arnfjörð Bjarmason <redacted>
---
t/t3800-mktag.sh | 8 ++++++++
1 file changed, 8 insertions(+)
@@ -91,6 +91,14 @@ check_verify_failure () {test_must_failgit-Cbad-tagfor-each-ref--format="%(*objectname)"'++test_expect_success"fast-export & fast-import: $subject"'+# Make sure the earlier test created it for us+gitrev-parse"$bad_tag"&&++test_must_failgit-Cbad-tagfast-export--all&&+test_must_failgit-Cbad-tagfast-export"$bad_tag"+'} test_expect_mktag_success(){