Skip to contentSkip to conversation

Git v2.21.0-rc0 - t5318 (NonStop)

Breakage Randall S. Becker 5 participants 25 messages Feb 8, 2019 – Feb 10, 2019

lore
Share & tools
lore
#0 lore raw

Hi All,

t5318 is rather problematic and I have no good way to fix this. There is no /dev/zero on the platform, and the corrupt_graph_and_verify hard-codes if=/dev/zero, which is a linux-specific pseudo device. Please provide a more platform independent way of testing this feature. Pretty much all subtests from 46 onward fail as a result.

expecting success:

        corrupt_graph_and_verify 0 "\0" \
                "graph signature"

1+0 records in
1+0 records out
1 byte copied, 0.002248 s, 0.4 kB/s
0+0 records in
0+0 records out
0 bytes copied, 0.001815 s, 0.0 kB/s
dd: failed to open '/dev/zero': No such file or directory not ok 46 - detect bad signature
#
# corrupt_graph_and_verify 0 "\0" \
# "graph signature"
#

Regards,
Randall

#1 lore raw
Quoted 5 lines · Randall S. Becker

t5318 is rather problematic and I have no good way to fix this. There is no /dev/zero on the platform, and the corrupt_graph_and_verify hard-codes if=/dev/zero, which is a linux-specific pseudo device. Please provide a more platform independent way of testing this feature. Pretty much all subtests from 46 onward fail as a result.

We did discuss this at the time of the patch, but it seems we already use /dev/zero in a bunch of places:

https://public-inbox.org/git/[email protected]/

Were you just skipping the other tests before?

-Peff

#2 lore raw
Quoted 8 lines · Jeff King
Quoted 5 lines · Randall S. Becker

t5318 is rather problematic and I have no good way to fix this. There is no /dev/zero on the platform, and the corrupt_graph_and_verify hard-codes if=/dev/zero, which is a linux-specific pseudo device. Please provide a more platform independent way of testing this feature. Pretty much all subtests from 46 onward fail as a result.

Quoted 6 lines

We did discuss this at the time of the patch, but it seems we already use /dev/zero in a bunch of places:

https://public-inbox.org/git/[email protected]/

Were you just skipping the other tests before?

I did not catch the implications of the review at the time - my bad. We were not intentionally skipping the tests. It looks like some are automatically skipped. t4153 automatically skips (missing TTY), and t5562 fails also but for a different reason (hang - we don't have apache2 to serve up http content).

Would you object to something like this:

if [ ! -e /dev/zero ]; then

	# use shred or some other mechanism (still trying to figure out a solution)
else
	# existing dd
fi
#3 lore raw
Quoted 9 lines · Randall S. Becker
Quoted 6 lines

We did discuss this at the time of the patch, but it seems we already use /dev/zero in a bunch of places:

https://public-inbox.org/git/[email protected]/

Were you just skipping the other tests before?

I did not catch the implications of the review at the time - my bad. We were not intentionally skipping the tests. It looks like some are automatically skipped. t4153 automatically skips (missing TTY), and t5562 fails also but for a different reason (hang - we don't have apache2 to serve up http content).

Quoted 7 lines

Would you object to something like this:

if [ ! -e /dev/zero ]; then

	# use shred or some other mechanism (still trying to figure out a solution)
else
	# existing dd
fi

That's fine, as long as it's wrapped up in a function in order to keep the tests readable.

Though I suspect we may be able to just find a solution that works everywhere, without having two different implementations. If we know we need $count bytes for dd, we could probably just generate a file with that many NULs in it.

Other cases don't seem to actually care that they're getting NULs, and are just redirecting stdin from /dev/zero to get an infinite amount of input. They could probably use "yes" for that.

-Peff

#4 lore raw

Am 08.02.19 um 19:03 schrieb Jeff King:

Quoted 12 lines · Randall S. Becker
Quoted 7 lines

Would you object to something like this:

if [ ! -e /dev/zero ]; then

	# use shred or some other mechanism (still trying to figure out a solution)
else
	# existing dd
fi

That's fine, as long as it's wrapped up in a function in order to keep the tests readable.

Quoted 8 lines

Though I suspect we may be able to just find a solution that works everywhere, without having two different implementations. If we know we need $count bytes for dd, we could probably just generate a file with that many NULs in it.

Other cases don't seem to actually care that they're getting NULs, and are just redirecting stdin from /dev/zero to get an infinite amount of input. They could probably use "yes" for that.

If the data does not have to be a sequence of zero bytes, the alternatives are:

* test-genrandom seed-string $size for a sequence of reproducible "random" bytes

* printf "%0*d" $size 0 for a sequence of '0' characters.

In t5318, the zero bytes do matter, though.

-- Hannes

#5 lore raw
Quoted 9 lines · Johannes Sixt

If the data does not have to be a sequence of zero bytes, the alternatives are:

* test-genrandom seed-string $size for a sequence of reproducible "random" bytes

* printf "%0*d" $size 0 for a sequence of '0' characters.

In t5318, the zero bytes do matter, though.

Also some consumers of these bytes may not be easy to read from a pipe.

#6 lore raw
In reply to Jeff King
Quoted 29 lines · Jeff King

To: Randall S. Becker <[email protected]>
Cc: 'Junio C Hamano' <[email protected]>; [email protected]; 'Linux Kernel' <[email protected]>; [email protected]
Subject: Re: [Breakage] Git v2.21.0-rc0 - t5318 (NonStop)

Quoted 10 lines · Randall S. Becker
Quoted 8 lines

We did discuss this at the time of the patch, but it seems we already use /dev/zero in a bunch of places:

https://public-inbox.org/git/[email protected].
com/

Were you just skipping the other tests before?

I did not catch the implications of the review at the time - my bad. We

were not intentionally skipping the tests. It looks like some are automatically skipped. t4153 automatically skips (missing TTY), and t5562 fails also but for a different reason (hang - we don't have apache2 to serve up http content).

Quoted 8 lines

Would you object to something like this:

if [ ! -e /dev/zero ]; then

	# use shred or some other mechanism (still trying to figure out a
solution) else
	# existing dd
fi
Quoted 7 lines

That's fine, as long as it's wrapped up in a function in order to keep the tests readable.

Though I suspect we may be able to just find a solution that works everywhere, without having two different implementations. If we know we need $count bytes for dd, we could probably just generate a file with that many NULs in it.

For this, we could use truncate -s count file instead of dd to get a fixed size file of nulls. This would remove the need for /dev/zero in t5318 (the patch below probably will wrap badly in my mailer so I can submit a real patch separately.

@@ -383,7 +383,7 @@ corrupt_graph_and_verify() {
        cp $objdir/info/commit-graph commit-graph-backup &&
        printf "$data" | dd of="$objdir/info/commit-graph" bs=1 seek="$pos" conv=notrunc &&
        dd of="$objdir/info/commit-graph" bs=1 seek="$zero_pos" count=0 &&
-       dd if=/dev/zero of="$objdir/info/commit-graph" bs=1 seek="$zero_pos" count=$(($orig_size - $zero_pos)) &&
+       truncate -s $orig_size "$objdir/info/commit-graph" &&
        test_must_fail git commit-graph verify 2>test_err &&
        grep -v "^+" test_err >err &&
        test_i18ngrep "$grepstr" err

This passes on my platform.

Quoted 3 lines

Other cases don't seem to actually care that they're getting NULs, and are just redirecting stdin from /dev/zero to get an infinite amount of input. They could probably use "yes" for that.

What about reading from /dev/null?

Regards,
Randall

#7 lore raw
Quoted 9 lines · Randall S. Becker
Quoted 4 lines

Though I suspect we may be able to just find a solution that works everywhere, without having two different implementations. If we know we need $count bytes for dd, we could probably just generate a file with that many NULs in it.

For this, we could use truncate -s count file instead of dd to get a fixed size file of nulls. This would remove the need for /dev/zero in t5318 (the patch below probably will wrap badly in my mailer so I can submit a real patch separately.

I don't think "truncate" is portable, though.

Quoted 5 lines
Quoted 3 lines

Other cases don't seem to actually care that they're getting NULs, and are just redirecting stdin from /dev/zero to get an infinite amount of input. They could probably use "yes" for that.

What about reading from /dev/null?

That would yield zero bytes, not an infinite number of them.

-Peff

#8 lore raw
Quoted 7 lines · Jeff King
Quoted 5 lines · Randall S. Becker
Quoted 4 lines

Though I suspect we may be able to just find a solution that works everywhere, without having two different implementations. If we know we need $count bytes for dd, we could probably just generate a file with that many NULs in it.

Quoted 6 lines
Quoted 4 lines

For this, we could use truncate -s count file instead of dd to get a fixed size file of nulls. This would remove the need for /dev/zero in t5318 (the patch below probably will wrap badly in my mailer so I can submit a real patch separately.

I don't think "truncate" is portable, though.

It is available AFAIK on Linux, POSIX, and Windows under Cygwin. That's more than /dev/zero has anyway. I have the patch ready if you want it.

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines

Other cases don't seem to actually care that they're getting NULs, and are just redirecting stdin from /dev/zero to get an infinite amount of input. They could probably use "yes" for that.

What about reading from /dev/null?

That would yield zero bytes, not an infinite number of them.

So something like: yes | tr 'y' '\0' | stuff?

#9 lore raw
Quoted 10 lines · Randall S. Becker
Quoted 6 lines
Quoted 4 lines

For this, we could use truncate -s count file instead of dd to get a fixed size file of nulls. This would remove the need for /dev/zero in t5318 (the patch below probably will wrap badly in my mailer so I can submit a real patch separately.

I don't think "truncate" is portable, though.

It is available AFAIK on Linux, POSIX, and Windows under Cygwin. That's more than /dev/zero has anyway. I have the patch ready if you want it.

Is it POSIX? Certainly truncate() is, but I didn't think the command-line tool was. If it really is available everywhere, then yeah, I'd be fine with it.

Quoted 9 lines
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines

Other cases don't seem to actually care that they're getting NULs, and are just redirecting stdin from /dev/zero to get an infinite amount of input. They could probably use "yes" for that.

What about reading from /dev/null?

That would yield zero bytes, not an infinite number of them.

So something like: yes | tr 'y' '\0' | stuff?

Exactly (if we even care about them being NULs; otherwise, we can omit the "tr" invocation).

-Peff

#10 lore raw
Quoted 31 lines

-----Original Message-----
From: Jeff King <[email protected]>
Sent: February 8, 2019 14:32
To: Randall S. Becker <[email protected]>
Cc: 'Junio C Hamano' <[email protected]>; [email protected]; 'Linux Kernel' <[email protected]>; [email protected]
Subject: Re: [Breakage] Git v2.21.0-rc0 - t5318 (NonStop)

Quoted 11 lines · Randall S. Becker
Quoted 7 lines
Quoted 5 lines

For this, we could use truncate -s count file instead of dd to get a fixed size file of nulls. This would remove the need for /dev/zero in
t5318 (the patch below probably will wrap badly in my mailer so I can submit a real patch separately.

I don't think "truncate" is portable, though.

It is available AFAIK on Linux, POSIX, and Windows under Cygwin. That's more than /dev/zero has anyway. I have the patch ready if you want it.

Is it POSIX? Certainly truncate() is, but I didn't think the command-line tool was. If it really is available everywhere, then yeah, I'd be fine with it.

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 3 lines

Other cases don't seem to actually care that they're getting NULs, and are just redirecting stdin from /dev/zero to get an infinite amount of input. They could probably use "yes" for that.

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
Quoted 1 line

What about reading from /dev/null?

That would yield zero bytes, not an infinite number of them.

So something like: yes | tr 'y' '\0' | stuff?

Exactly (if we even care about them being NULs; otherwise, we can omit the "tr" invocation).

I'm a bit perplexed about this... Obviously added some debugging info, but why we're getting No REQUEST_METHOD is perplexing. Is this a lack of an apache2 instance?

expecting success:

        NOT_FIT_IN_SSIZE=$(ssize_b100dots) &&
        env \
                CONTENT_TYPE=application/x-git-upload-pack-request \
                QUERY_STRING=/repo.git/git-upload-pack \
                PATH_TRANSLATED="$PWD"/.git/git-upload-pack \
                GIT_HTTP_EXPORT_ALL=TRUE \
                REQUEST_METHOD=POST \
                CONTENT_LENGTH="$NOT_FIT_IN_SSIZE" \
                yes | tr "y" "\\0" | git http-backend 2>err &&
        echo "Err is" &&
        cat err &&
        grep "fatal:.*CONTENT_LENGTH" err

Status: 500 Internal Server Error
Expires: Fri, 01 Jan 1980 00:00:00 GMT
Pragma: no-cache
Cache-Control: no-cache, max-age=0, must-revalidate

Err is
fatal: No REQUEST_METHOD from server
not ok 15 - CONTENT_LENGTH overflow ssite_t

Cheers,
Randall

#11 lore raw

[-cc kernel and packagers; this is really just git development at this point]

Quoted 6 lines · Randall S. Becker
Quoted 2 lines

Exactly (if we even care about them being NULs; otherwise, we can omit the "tr" invocation).

I'm a bit perplexed about this... Obviously added some debugging info, but why we're getting No REQUEST_METHOD is perplexing. Is this a lack of an apache2 instance?

No, this shouldn't be using apache at all. But...

Quoted 14 lines

expecting success:

        NOT_FIT_IN_SSIZE=$(ssize_b100dots) &&
        env \
                CONTENT_TYPE=application/x-git-upload-pack-request \
                QUERY_STRING=/repo.git/git-upload-pack \
                PATH_TRANSLATED="$PWD"/.git/git-upload-pack \
                GIT_HTTP_EXPORT_ALL=TRUE \
                REQUEST_METHOD=POST \
                CONTENT_LENGTH="$NOT_FIT_IN_SSIZE" \
                yes | tr "y" "\\0" | git http-backend 2>err &&
        echo "Err is" &&
        cat err &&
        grep "fatal:.*CONTENT_LENGTH" err
Quoted 8 lines

Status: 500 Internal Server Error
Expires: Fri, 01 Jan 1980 00:00:00 GMT
Pragma: no-cache
Cache-Control: no-cache, max-age=0, must-revalidate

Err is
fatal: No REQUEST_METHOD from server
not ok 15 - CONTENT_LENGTH overflow ssite_t

The problem is that you're setting the environment now for "yes". You'd need:

  yes | tr "y" "\\0" | env \
    CONTENT_TYPE=... \
    REQUEST_METHOD=POST \
    ...etc...
    git http-backend

-Peff

#12 lore raw
Quoted 34 lines · Jeff King
Quoted 6 lines · Randall S. Becker
Quoted 2 lines

Exactly (if we even care about them being NULs; otherwise, we can omit the "tr" invocation).

I'm a bit perplexed about this... Obviously added some debugging info, but why we're getting No REQUEST_METHOD is perplexing. Is this a lack of an apache2 instance?

No, this shouldn't be using apache at all. But...

Quoted 14 lines

expecting success:

        NOT_FIT_IN_SSIZE=$(ssize_b100dots) &&
        env \
                CONTENT_TYPE=application/x-git-upload-pack-request \
                QUERY_STRING=/repo.git/git-upload-pack \
                PATH_TRANSLATED="$PWD"/.git/git-upload-pack \
                GIT_HTTP_EXPORT_ALL=TRUE \
                REQUEST_METHOD=POST \
                CONTENT_LENGTH="$NOT_FIT_IN_SSIZE" \
                yes | tr "y" "\\0" | git http-backend 2>err &&
        echo "Err is" &&
        cat err &&
        grep "fatal:.*CONTENT_LENGTH" err
Quoted 8 lines

Status: 500 Internal Server Error
Expires: Fri, 01 Jan 1980 00:00:00 GMT
Pragma: no-cache
Cache-Control: no-cache, max-age=0, must-revalidate

Err is
fatal: No REQUEST_METHOD from server
not ok 15 - CONTENT_LENGTH overflow ssite_t

Quoted 8 lines

The problem is that you're setting the environment now for "yes". You'd need:

  yes | tr "y" "\\0" | env \
    CONTENT_TYPE=... \
    REQUEST_METHOD=POST \
    ...etc...
    git http-backend

Aw crap. I feel really silly now. Thanks. Will advise.

#13 lore raw
In reply to Jeff King
Quoted 7 lines · Jeff King
Quoted 3 lines

It is available AFAIK on Linux, POSIX, and Windows under Cygwin. That's more than /dev/zero has anyway. I have the patch ready if you want it.

Is it POSIX? Certainly truncate() is, but I didn't think the command-line tool was. If it really is available everywhere, then yeah, I'd be fine with it.

It's not. POSIX doesn't specify the command, and macOS lacks it, I believe.

Signature · 2 lines
brian m. carlson: Houston, Texas, US
OpenPGP: https://keybase.io/bk2204
#14 lore raw
Quoted 10 lines · brian m. carlson
Quoted 7 lines · Jeff King
Quoted 3 lines

It is available AFAIK on Linux, POSIX, and Windows under Cygwin. That's more than /dev/zero has anyway. I have the patch ready if you want it.

Is it POSIX? Certainly truncate() is, but I didn't think the command-line tool was. If it really is available everywhere, then yeah, I'd be fine with it.

It's not. POSIX doesn't specify the command, and macOS lacks it, I believe.

I'm happy to modify the test (it is in one spot), to make a decision based on:
a) whether /dev/zero exists
b) whether the system is a NonStop
c) something else

What would you all prefer? It doesn't matter to me one way or another, as long as I can get the dependency to /dev/zero removed so tests will run here.

Thanks,
Randall

#15 lore raw
Quoted 6 lines · Randall S. Becker

I'm happy to modify the test (it is in one spot), to make a decision based on:
a) whether /dev/zero exists
b) whether the system is a NonStop
c) something else

What would you all prefer? It doesn't matter to me one way or another, as long as I can get the dependency to /dev/zero removed so tests will run here.

My preference is that we wrap the yes/tr invocation into a function (maybe "infinite_nul") and use that where we currently require /dev/zero.

Signature · 2 lines
brian m. carlson: Houston, Texas, US
OpenPGP: https://keybase.io/bk2204
#16 lore raw
Quoted 7 lines · brian m. carlson
Quoted 1 line · Randall S. Becker

I'm happy to modify the test (it is in one spot), to make a decision based

on:

Quoted 4 lines

a) whether /dev/zero exists
b) whether the system is a NonStop
c) something else

Quoted 5 lines
Quoted 1 line

What would you all prefer? It doesn't matter to me one way or another, as

long as I can get the dependency to /dev/zero removed so tests will run here.

My preference is that we wrap the yes/tr invocation into a function (maybe "infinite_nul") and use that where we currently require /dev/zero.

That's simple enough to do in test-lib-functions.sh for the situation where yes|tr is being piped, but that's t5562. In t5318 we have dd if=/dev/zero, and that's where truncate would need to work. The requirements of that test seem very specific to me and not that generalizable. I'm just dealing with new breakages on the platform.

#17 lore raw
In reply to Randall S. Becker
Quoted 12 lines · Randall S. Becker
Quoted 10 lines · brian m. carlson
Quoted 7 lines · Jeff King
Quoted 3 lines

It is available AFAIK on Linux, POSIX, and Windows under Cygwin. That's more than /dev/zero has anyway. I have the patch ready if you want it.

Is it POSIX? Certainly truncate() is, but I didn't think the command-line tool was. If it really is available everywhere, then yeah, I'd be fine with it.

It's not. POSIX doesn't specify the command, and macOS lacks it, I believe.

Quoted 8 lines

I'm happy to modify the test (it is in one spot), to make a decision based on:
a) whether /dev/zero exists
b) whether the system is a NonStop
c) something else

What would you all prefer? It doesn't matter to me one way or another, as long as I can get the dependency to /dev/zero removed so tests will run here.

For the case in t5318, I think we can just put the NULs in a file. Does this work on your platform?

---

t/t5318-commit-graph.sh +2 -1
index 16d10ebce8..6d0ccc7eba 100755
@@ -383,7 +383,8 @@ corrupt_graph_and_verify() {
 	cp $objdir/info/commit-graph commit-graph-backup &&
 	printf "$data" | dd of="$objdir/info/commit-graph" bs=1 seek="$pos" conv=notrunc &&
 	dd of="$objdir/info/commit-graph" bs=1 seek="$zero_pos" count=0 &&
-	dd if=/dev/zero of="$objdir/info/commit-graph" bs=1 seek="$zero_pos" count=$(($orig_size - $zero_pos)) &&
+	gen_zero_bytes $(($orig_size - $zero_pos)) >zeroes &&
+	dd if=zeroes of="$objdir/info/commit-graph" bs=1 seek="$zero_pos" &&
 	test_must_fail git commit-graph verify 2>test_err &&
 	grep -v "^+" test_err >err &&
 	test_i18ngrep "$grepstr" err
t/test-lib-functions.sh +5 -0
index 92cf8f812c..4afab14431 100644
@@ -1302,3 +1302,8 @@ test_set_port () {
 	port=$(($port + ${GIT_TEST_STRESS_JOB_NR:-0}))
 	eval $var=$port
 }
+
+# Generate an output of $1 bytes of all zeroes (NULs, not ASCII zeroes).
+gen_zero_bytes () {
+	perl -e 'print "\0" x $ARGV[0]' "$@"
+}

For the others that need infinite zeroes, I think using "yes" makes more sense, though we could also teach this function to accept an "infinity" parameter.

-Peff

#18 lore raw
Quoted 20 lines · Jeff King
Quoted 11 lines · Randall S. Becker
Quoted 10 lines · brian m. carlson
Quoted 7 lines · Jeff King
Quoted 3 lines

It is available AFAIK on Linux, POSIX, and Windows under Cygwin. That's more than /dev/zero has anyway. I have the patch ready if you want it.

Is it POSIX? Certainly truncate() is, but I didn't think the command-line tool was. If it really is available everywhere, then yeah, I'd be fine with it.

It's not. POSIX doesn't specify the command, and macOS lacks it, I

believe.

Quoted 2 lines

I'm happy to modify the test (it is in one spot), to make a decision based

on:

Quoted 4 lines

a) whether /dev/zero exists
b) whether the system is a NonStop
c) something else

Quoted 6 lines
Quoted 3 lines

What would you all prefer? It doesn't matter to me one way or another, as long as I can get the dependency to /dev/zero removed so tests will run here.

For the case in t5318, I think we can just put the NULs in a file. Does this work on your platform?

Yes, should work just fine.

Quoted 25 lines

---

t/t5318-commit-graph.sh index renamed from t/t5318-commit-graph.sh +0 -0

16d10ebce8..6d0ccc7eba 100755

t/t5318-commit-graph.sh +0 -0
@@ -383,7 +383,8 @@ corrupt_graph_and_verify() {
 	cp $objdir/info/commit-graph commit-graph-backup &&
 	printf "$data" | dd of="$objdir/info/commit-graph" bs=1

seek="$pos" conv=notrunc &&
dd of="$objdir/info/commit-graph" bs=1 seek="$zero_pos" count=0
&&

t/t5318-commit-graph.sh +0 -1
-	dd if=/dev/zero of="$objdir/info/commit-graph" bs=1

seek="$zero_pos" count=$(($orig_size - $zero_pos)) &&

t/t5318-commit-graph.sh +2 -0
+	gen_zero_bytes $(($orig_size - $zero_pos)) >zeroes &&
+	dd if=zeroes of="$objdir/info/commit-graph" bs=1 seek="$zero_pos"

&&

t/t5318-commit-graph.sh +0 -0
 	test_must_fail git commit-graph verify 2>test_err &&
 	grep -v "^+" test_err >err &&
 	test_i18ngrep "$grepstr" err
t/test-lib-functions.sh index renamed from t/test-lib-functions.sh +0 -0

92cf8f812c..4afab14431 100644

t/test-lib-functions.sh test_set_port () { · line 1309

Quoted 8 lines
t/test-lib-functions.sh +5 -0
@@ -1302,3 +1302,8 @@ test_set_port () {
 	port=$(($port + ${GIT_TEST_STRESS_JOB_NR:-0}))
 	eval $var=$port
 }
+
+# Generate an output of $1 bytes of all zeroes (NULs, not ASCII zeroes).
+gen_zero_bytes () {
+	perl -e 'print "\0" x $ARGV[0]' "$@"
+}

This function does work on platform, so it's good.

Quoted 3 lines

For the others that need infinite zeroes, I think using "yes" makes more sense, though we could also teach this function to accept an "infinity" parameter.

You could be sneaky about it, I suppose
+# Generate an output of $1 bytes of all zeroes (NULs, not ASCII zeroes).
+ gen_zero_bytes () {
+ if [ $1 -eq -1 ]; then
+ yes | tr 'y' '\0'
+ else
+ perl -e 'print "\0" x $ARGV[0]' "$@"
+ }
Or something alone those lines. It's not even slightly elegant, though. It would be better inside perl, so just

+# Generate an output of $1 bytes of all zeroes (NULs, not ASCII zeroes). If $1 is < 0, output forever.
+ gen_zero_bytes () {
+ perl -e ' if ($ARGV[0] < 0) { while (-1) { print "\0" } } else { print "\0" x $ARGV[0] }' "$@"
+ }

Cheers,
Randall

#19 lore raw
Quoted 7 lines · Randall S. Becker
Quoted 7 lines
t/test-lib-functions.sh index renamed from t/test-lib-functions.sh +0 -0

92cf8f812c..4afab14431 100644

t/test-lib-functions.sh +0 -0
@@ -1302,3 +1302,8 @@ test_set_port () {
 	port=$(($port + ${GIT_TEST_STRESS_JOB_NR:-0}))
 	eval $var=$port
Quoted 8 lines

t/test-lib-functions.sh test_set_port () { · line 1309

Quoted 6 lines
t/test-lib-functions.sh +5 -0
 }
+
+# Generate an output of $1 bytes of all zeroes (NULs, not ASCII zeroes).
+gen_zero_bytes () {
+	perl -e 'print "\0" x $ARGV[0]' "$@"
+}

This function does work on platform, so it's good.

Great. Since it sounds like you're preparing some patches to deal with /dev/zero elsewhere, do you want to wrap it up in a patch as part of that?

-Peff

#20 lore raw

Am 09.02.19 um 05:24 schrieb Jeff King:

Quoted 18 lines · Randall S. Becker
Quoted 16 lines
Quoted 6 lines
t/test-lib-functions.sh index renamed from t/test-lib-functions.sh +0 -0

92cf8f812c..4afab14431 100644

t/test-lib-functions.sh test_set_port () { · line 1309

Quoted 8 lines
t/test-lib-functions.sh +5 -0
@@ -1302,3 +1302,8 @@ test_set_port () {
 	port=$(($port + ${GIT_TEST_STRESS_JOB_NR:-0}))
 	eval $var=$port
 }
+
+# Generate an output of $1 bytes of all zeroes (NULs, not ASCII zeroes).
+gen_zero_bytes () {
+	perl -e 'print "\0" x $ARGV[0]' "$@"
+}

This function does work on platform, so it's good.

Quoted 3 lines

Great. Since it sounds like you're preparing some patches to deal with /dev/zero elsewhere, do you want to wrap it up in a patch as part of that?

Please do not use yes to generate an infinite amount of bytes. Our implementation of yes() in test-lib.sh generates only 99 lines.

Perhaps do this.

----- 8< -----
Subject: [PATCH] t5318: avoid /dev/zero

Some platforms do not offer /dev/zero. Use printf and tr to generate a certain amount of NUL bytes.

---
 t/t5318-commit-graph.sh | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
t/t5318-commit-graph.sh +2 -1
index 16d10ebce8..04d394274f 100755
@@ -383,7 +383,8 @@ corrupt_graph_and_verify() {
 	cp $objdir/info/commit-graph commit-graph-backup &&
 	printf "$data" | dd of="$objdir/info/commit-graph" bs=1 seek="$pos" conv=notrunc &&
 	dd of="$objdir/info/commit-graph" bs=1 seek="$zero_pos" count=0 &&
-	dd if=/dev/zero of="$objdir/info/commit-graph" bs=1 seek="$zero_pos" count=$(($orig_size - $zero_pos)) &&
+	printf "%0*d" $(($orig_size - $zero_pos)) 0 | tr 0 '\0' |
+		dd of="$objdir/info/commit-graph" bs=1 seek="$zero_pos" &&
 	test_must_fail git commit-graph verify 2>test_err &&
 	grep -v "^+" test_err >err &&
 	test_i18ngrep "$grepstr" err
Signature · 1 line
2.20.1.86.gb0de946387
#21 lore raw
Quoted 59 lines · Johannes Sixt

Am 09.02.19 um 05:24 schrieb Jeff King:

Quoted 18 lines · Randall S. Becker
Quoted 16 lines
Quoted 6 lines
t/test-lib-functions.sh index renamed from t/test-lib-functions.sh +0 -0

92cf8f812c..4afab14431 100644

t/test-lib-functions.sh test_set_port () { · line 1309

Quoted 8 lines
t/test-lib-functions.sh +5 -0
@@ -1302,3 +1302,8 @@ test_set_port () {
 	port=$(($port + ${GIT_TEST_STRESS_JOB_NR:-0}))
 	eval $var=$port
 }
+
+# Generate an output of $1 bytes of all zeroes (NULs, not ASCII zeroes).
+gen_zero_bytes () {
+	perl -e 'print "\0" x $ARGV[0]' "$@"
+}

This function does work on platform, so it's good.

Quoted 3 lines

Great. Since it sounds like you're preparing some patches to deal with /dev/zero elsewhere, do you want to wrap it up in a patch as part of that?

Please do not use yes to generate an infinite amount of bytes. Our implementation of yes() in test-lib.sh generates only 99 lines.

Perhaps do this.

----- 8< -----
Subject: [PATCH] t5318: avoid /dev/zero

Some platforms do not offer /dev/zero. Use printf and tr to generate a certain amount of NUL bytes.

---
 t/t5318-commit-graph.sh | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
t/t5318-commit-graph.sh index renamed from t/t5318-commit-graph.sh +0 -0

16d10ebce8..04d394274f 100755

t/t5318-commit-graph.sh +0 -0
@@ -383,7 +383,8 @@ corrupt_graph_and_verify() {
 	cp $objdir/info/commit-graph commit-graph-backup &&
 	printf "$data" | dd of="$objdir/info/commit-graph" bs=1

seek="$pos" conv=notrunc &&
dd of="$objdir/info/commit-graph" bs=1 seek="$zero_pos" count=0
&&

t/t5318-commit-graph.sh +0 -1
-	dd if=/dev/zero of="$objdir/info/commit-graph" bs=1

seek="$zero_pos" count=$(($orig_size - $zero_pos)) &&

t/t5318-commit-graph.sh +2 -0
+	printf "%0*d" $(($orig_size - $zero_pos)) 0 | tr 0 '\0' |
+		dd of="$objdir/info/commit-graph" bs=1 seek="$zero_pos"

&&

t/t5318-commit-graph.sh +0 -1
 	test_must_fail git commit-graph verify 2>test_err &&
 	grep -v "^+" test_err >err &&
 	test_i18ngrep "$grepstr" err
--
Quoted 1 line

2.20.1.86.gb0de946387

This would be fine with me. I'm going to prepare an alternative and let the committers decide.

#22 lore raw
In reply to Johannes Sixt
Quoted 6 lines · Johannes Sixt
Quoted 3 lines

Great. Since it sounds like you're preparing some patches to deal with /dev/zero elsewhere, do you want to wrap it up in a patch as part of that?

Please do not use yes to generate an infinite amount of bytes. Our implementation of yes() in test-lib.sh generates only 99 lines.

Ah, thanks. That doesn't matter here, but it would for the other patches under discussion.

t/t5318-commit-graph.sh corrupt_graph_and_verify() { · line 387

Quoted 6 lines

Perhaps do this.
[...]

t/t5318-commit-graph.sh +2 -1
 	dd of="$objdir/info/commit-graph" bs=1 seek="$zero_pos" count=0 &&
-	dd if=/dev/zero of="$objdir/info/commit-graph" bs=1 seek="$zero_pos" count=$(($orig_size - $zero_pos)) &&
+	printf "%0*d" $(($orig_size - $zero_pos)) 0 | tr 0 '\0' |
+		dd of="$objdir/info/commit-graph" bs=1 seek="$zero_pos" &&

Using stdin instead of the tmpfile is nice, and shouldn't have any problems. I do think your printf suggestion looks nice, but I wondered if it might run into portability issues (not because of anything in particular, but I often find that the more clever a shell solution, the more likely we run into obscure problems).

But if it works everywhere, that's fine by me.

-Peff

#23 lore raw

Am 10.02.19 um 00:29 schrieb Jeff King:

Quoted 12 lines · Johannes Sixt

t/t5318-commit-graph.sh corrupt_graph_and_verify() { · line 387

Quoted 4 lines
t/t5318-commit-graph.sh +2 -1
 	dd of="$objdir/info/commit-graph" bs=1 seek="$zero_pos" count=0 &&
-	dd if=/dev/zero of="$objdir/info/commit-graph" bs=1 seek="$zero_pos" count=$(($orig_size - $zero_pos)) &&
+	printf "%0*d" $(($orig_size - $zero_pos)) 0 | tr 0 '\0' |
+		dd of="$objdir/info/commit-graph" bs=1 seek="$zero_pos" &&

Using stdin instead of the tmpfile is nice, and shouldn't have any problems. I do think your printf suggestion looks nice, but I wondered if it might run into portability issues (not because of anything in particular, but I often find that the more clever a shell solution, the more likely we run into obscure problems).

Quoted 1 line

But if it works everywhere, that's fine by me.

Unfortunately, it does not work as intended: the printf solution cannot print nothing, but that should be the case in all but one of the tests.

-- Hannes

#24 lore raw
In reply to Jeff King
Quoted 18 lines · Jeff King
Quoted 7 lines · Randall S. Becker
Quoted 7 lines
t/test-lib-functions.sh index renamed from t/test-lib-functions.sh +0 -0

92cf8f812c..4afab14431 100644

t/test-lib-functions.sh +0 -0
@@ -1302,3 +1302,8 @@ test_set_port () {
 	port=$(($port + ${GIT_TEST_STRESS_JOB_NR:-0}))
 	eval $var=$port
Quoted 8 lines

t/test-lib-functions.sh test_set_port () { · line 1309

Quoted 6 lines
t/test-lib-functions.sh +5 -0
 }
+
+# Generate an output of $1 bytes of all zeroes (NULs, not ASCII zeroes).
+gen_zero_bytes () {
+	perl -e 'print "\0" x $ARGV[0]' "$@"
+}

This function does work on platform, so it's good.

Quoted 2 lines

Great. Since it sounds like you're preparing some patches to deal with /dev/zero elsewhere, do you want to wrap it up in a patch as part of that?

That's the plan. 😊 We're currently running a full test, so that takes time (32 hours on this box).

Cheers,
Randall