]> git.ipfire.org Git - thirdparty/git.git/commitdiff
test-progress: fix test failures on big-endian systems
authorSZEDER Gábor <szeder.dev@gmail.com>
Sat, 19 Oct 2019 23:37:06 +0000 (01:37 +0200)
committerJunio C Hamano <gitster@pobox.com>
Mon, 21 Oct 2019 00:53:49 +0000 (09:53 +0900)
In 't0500-progress-display.sh' all tests running 'test-tool progress
--total=<N>' fail on big-endian systems, e.g. like this:

  + test-tool progress --total=3 Working hard
  [...]
  + test_i18ncmp expect out
  --- expect 2019-10-18 23:07:54.765523916 +0000
  +++ out 2019-10-18 23:07:54.773523916 +0000
  @@ -1,4 +1,2 @@
  -Working hard:  33% (1/3)<CR>
  -Working hard:  66% (2/3)<CR>
  -Working hard: 100% (3/3)<CR>
  -Working hard: 100% (3/3), done.
  +Working hard:   0% (1/12884901888)<CR>
  +Working hard:   0% (3/12884901888), done.

The reason for that bogus value is that '--total's parameter is parsed
via parse-options's OPT_INTEGER into a uint64_t variable [1], so the
two bits of 3 end up in the "wrong" bytes on big-endian systems
(12884901888 = 0x300000000).

Change the type of that variable from uint64_t to int, to match what
parse-options expects; in the tests of the progress output we won't
use values that don't fit into an int anyway.

[1] start_progress() expects the total number as an uint64_t, that's
    why I chose the same type when declaring the variable holding the
    value given on the command line.

Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
[jpag: Debian unstable/ppc64 (big-endian)]
Tested-By: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
[tz: Fedora s390x (big-endian)]
Tested-By: Todd Zullinger <tmz@pobox.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/helper/test-progress.c

index 4e9f7fafdfb0ecabcb7f8cd48f371be3cf088c6c..42b96cb103c6acee9ad2a9dfad8afbaa7ef854e9 100644 (file)
@@ -29,7 +29,7 @@ void progress_test_force_update(void);
 
 int cmd__progress(int argc, const char **argv)
 {
 
 int cmd__progress(int argc, const char **argv)
 {
-       uint64_t total = 0;
+       int total = 0;
        const char *title;
        struct strbuf line = STRBUF_INIT;
        struct progress *progress;
        const char *title;
        struct strbuf line = STRBUF_INIT;
        struct progress *progress;