commercialhaskell / static-bytes

A Haskell library providing types representing 8, 16, 32, 64 or 128 bytes of data.
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

Tests fail on big-endian systems #1

Open iliastsi opened 11 hours ago

iliastsi commented 11 hours ago

Tests fails on big-endian systems. Here is an example:

  test/Data/StaticBytesSpec.hs:65:20: 
  14) Data.StaticBytes, Primitive Vector, handles bytes16
       Falsifiable (after 4 tests and 3 shrinks):
         [1]
       expected: [1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
        but got: [0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0]

  To rerun use: --match "/Data.StaticBytes/Primitive Vector/handles bytes16/" --seed 1014189549

  test/Data/StaticBytesSpec.hs:75:20: 
  15) Data.StaticBytes, Primitive Vector, handles bytes32
       Falsifiable (after 4 tests and 3 shrinks):
         [1]
       expected: [1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
        but got: [0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]

  To rerun use: --match "/Data.StaticBytes/Primitive Vector/handles bytes32/" --seed 1014189549

  test/Data/StaticBytesSpec.hs:83:21: 
  16) Data.StaticBytes, Primitive Vector, fuzz with encodeUtf8
       Falsifiable (after 2 tests and 1 shrink):
         "a"
       expected: [97,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
        but got: [0,0,0,0,0,0,0,97,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]

  To rerun use: --match "/Data.StaticBytes/Primitive Vector/fuzz with encodeUtf8/" --seed 1014189549

For the full build log see https://buildd.debian.org/status/fetch.php?pkg=haskell-static-bytes&arch=s390x&ver=0.1.0-1&stamp=1729262862&raw=0

mpilgrem commented 6 hours ago

@iliastsi, thanks for reporting. In case the build log is ephemeral, I'm posting more from it below:

Data.StaticBytes
  ByteString
    padding is the same as trailing nulls [✘]
    handles bytes16 [✘]
    handles bytes32 [✘]
    fuzz with encodeUtf8 [✘]
  Storable Vector
    padding is the same as trailing nulls [✘]
    handles bytes16 [✘]
    handles bytes32 [✘]
    fuzz with encodeUtf8 [✘]
  Unboxed Vector
    padding is the same as trailing nulls [✘]
    handles bytes16 [✘]
    handles bytes32 [✘]
    fuzz with encodeUtf8 [✘]
  Primitive Vector
    padding is the same as trailing nulls [✘]
    handles bytes16 [✘]
    handles bytes32 [✘]
    fuzz with encodeUtf8 [✘]

and

test/Data/StaticBytesSpec.hs:60:47: 
  13) Data.StaticBytes, Primitive Vector, padding is the same as trailing nulls
       Falsifiable (after 1 test and 2 shrinks):
         (0,0,1,0)
       expected: Right "\NUL\NUL\SOH\NUL\NUL\NUL\NUL\NUL"
        but got: Right "\NUL\NUL\NUL\NUL\NUL\SOH\NUL\NUL"

  To rerun use: --match "/Data.StaticBytes/Primitive Vector/padding is the same as trailing nulls/" --seed 1014189549
mpilgrem commented 5 hours ago

As an accident of its history (spun out of Stack via pantry), I think this package implicitly assumes the architecture, and Word64 values, are little endian. Possibly because the GHC project only distributes GHC binaries for little endian architectures (x86_64, AArch64).