benhoyt / goawk

A POSIX-compliant AWK interpreter written in Go, with CSV support
https://benhoyt.com/writings/goawk/
MIT License
1.95k stars 84 forks source link

Test failures on Linux/i386 #234

Closed guilherme-puida closed 5 months ago

guilherme-puida commented 6 months ago

I noticed that two tests were failing when building the Debian goawk package inside a i386 schroot.

?       github.com/benhoyt/goawk/scripts/csvbench/count [no test files]
?       github.com/benhoyt/goawk/scripts/csvbench/write [no test files]
--- FAIL: TestAWK (0.29s)
    --- FAIL: TestAWK/p.50 (0.01s)
        goawk_test.go:147: output differs, run: git diff testdata/output/p.50
FAIL
FAIL    github.com/benhoyt/goawk    0.832s
ok      github.com/benhoyt/goawk/internal/ast   0.003s
ok      github.com/benhoyt/goawk/internal/compiler  0.005s
ok      github.com/benhoyt/goawk/internal/cover 0.003s
ok      github.com/benhoyt/goawk/internal/parseutil 0.003s
ok      github.com/benhoyt/goawk/internal/resolver  0.004s
--- FAIL: TestInterp (0.64s)
    --- FAIL: TestInterp/{_print_$1+0_}__#_+posix (0.00s)
        interp_test.go:1223: expected/got:
            "0\n16\n78187493520\n11259375\n11259375\n-10\n10\n15.9375\n16320\n0.015564\n0.9375\n15\n0\n"
            "0\n16\n7.81875e+10\n11259375\n11259375\n-10\n10\n15.9375\n16320\n0.015564\n0.9375\n15\n0\n"
--- FAIL: TestNative (0.00s)
    --- FAIL: TestNative/_BEGIN_{__print__print_bool(),_bool(0),_bool(1),_bool(""),_bool("0"),_ (0.00s)
        interp_test.go:1223: expected/got:
            "\n0 0 1 0 1 1\n0 42 -5 3 -3\n0 42 -5 127 -128\n0 42 -5 32767 -32768\n0 42 -5 2147483647 -2147483648\n0 42 -5 2147483647000 -2147483647000\n0 42 0 1\n0 42 251 127 128 255\n0 42 65535 65535\n0 42 4294967295 4294967295\n0 42 1 4294967296 2147483647000\n..Foo bar.1234\n..Foo bar.1234\n"
            "\n0 0 1 0 1 1\n0 42 -5 3 -3\n0 42 -5 127 -128\n0 42 -5 32767 -32768\n0 42 -5 2147483647 -2147483648\n0 42 -5 2.14748e+12 -2.14748e+12\n0 42 0 1\n0 42 251 127 128 255\n0 42 65535 65535\n0 42 4.29497e+09 4.29497e+09\n0 42 1 4.29497e+09 2.14748e+12\n..Foo bar.1234\n..Foo bar.1234\n"
FAIL
FAIL    github.com/benhoyt/goawk/interp 0.708s
ok      github.com/benhoyt/goawk/lexer  0.003s
ok      github.com/benhoyt/goawk/parser 0.124s
FAIL

I initially thought this was a Debian-specific problem, but I can also reproduce it on alpine.

docker run --rm -v $(pwd):/goawk i386/golang:bookworm \
  sh -c "cd /goawk && apt-get update && apt-get install -y gawk procps && go test ./..."
docker run --rm -v $(pwd):/goawk i386/golang:alpine \
  sh -c "cd /goawk && pkg update && pkg add gawk && go test ./..."

The failures are related to number formatting. This is not a big deal, and I can probably skip them when building for non-64bit architectures, but maybe it's worth fixing upstream :^)

guilherme-puida commented 6 months ago

The TestAWK/p.50 failure is unrelated here. It only occurs on alpine since busybox sort does not support the -1 cli argument.

benhoyt commented 6 months ago

Thanks for the report. Ah yes, it looks like I'm making some assumptions that int==int64 around the place. I'll have to fire up an i386 VM to test this.

benhoyt commented 5 months ago

Hi @guilherme-puida, I don't have (and may not find) a lot of time to work on this at the moment. Would you be interested in diagnosing the cause and/or proposing a fix in a PR?

guilherme-puida commented 5 months ago

Yes, I would. I was already planning on hacking on this sometime soon, but it's been a busy couple of weeks.