Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failing tests with 10.0.0 on alpine linux #3433

Closed
a16bitsysop opened this issue May 13, 2023 · 4 comments
Closed

Failing tests with 10.0.0 on alpine linux #3433

a16bitsysop opened this issue May 13, 2023 · 4 comments

Comments

@a16bitsysop
Copy link

When running the tests for fmt 10.0.0 on alpine linux edge with gcc 12.2.1 some tests fail for x86_64 and x86, but all tests pass for ppc64le and s390x.

The failure is the same for both:

Test project /builds/a16bitsysop/aports/main/fmt/src/fmt-10.0.0
      Start  1: args-test
      Start  2: assert-test
      Start  3: color-test
      Start  4: core-test
      Start  5: gtest-extra-test
      Start  6: format-test
      Start  7: format-impl-test
      Start  8: ostream-test
      Start  9: compile-test
      Start 10: compile-fp-test
      Start 11: printf-test
      Start 12: ranges-test
      Start 13: scan-test
      Start 14: std-test
      Start 15: enforce-checks-test
      Start 16: posix-mock-test
      Start 17: os-test
 1/17 Test  #1: args-test ........................   Passed    0.02 sec
 2/17 Test  #2: assert-test ......................   Passed    0.02 sec
 3/17 Test  #3: color-test .......................   Passed    0.02 sec
 4/17 Test  #4: core-test ........................   Passed    0.02 sec
 5/17 Test  #5: gtest-extra-test .................   Passed    0.01 sec
 6/17 Test  #8: ostream-test .....................   Passed    0.01 sec
 7/17 Test  #9: compile-test .....................   Passed    0.01 sec
 8/17 Test #10: compile-fp-test ..................   Passed    0.01 sec
 9/17 Test #11: printf-test ......................   Passed    0.01 sec
10/17 Test #12: ranges-test ......................   Passed    0.01 sec
11/17 Test #13: scan-test ........................   Passed    0.01 sec
12/17 Test #14: std-test .........................   Passed    0.01 sec
13/17 Test #15: enforce-checks-test ..............   Passed    0.01 sec
14/17 Test  #6: format-test ......................***Failed    0.02 sec
[==========] Running 114 tests from 6 test suites.
[----------] Global test environment set-up.
[----------] 5 tests from uint128_test
[ RUN      ] uint128_test.ctor
[       OK ] uint128_test.ctor (0 ms)
[ RUN      ] uint128_test.shift
[       OK ] uint128_test.shift (0 ms)
[ RUN      ] uint128_test.minus
[       OK ] uint128_test.minus (0 ms)
[ RUN      ] uint128_test.plus_assign
[       OK ] uint128_test.plus_assign (0 ms)
[ RUN      ] uint128_test.multiply
[       OK ] uint128_test.multiply (0 ms)
[----------] 5 tests from uint128_test (0 ms total)
[----------] 2 tests from float_test
[ RUN      ] float_test.isfinite
[       OK ] float_test.isfinite (0 ms)
[ RUN      ] float_test.isnan
[       OK ] float_test.isnan (0 ms)
[----------] 2 tests from float_test (0 ms total)
[----------] 9 tests from util_test
[ RUN      ] util_test.bit_cast
[       OK ] util_test.bit_cast (0 ms)
[ RUN      ] util_test.increment
[       OK ] util_test.increment (0 ms)
[ RUN      ] util_test.parse_nonnegative_int
[       OK ] util_test.parse_nonnegative_int (0 ms)
[ RUN      ] util_test.utf8_to_utf16
[       OK ] util_test.utf8_to_utf16 (1 ms)
[ RUN      ] util_test.utf8_to_utf16_empty_string
[       OK ] util_test.utf8_to_utf16_empty_string (0 ms)
[ RUN      ] util_test.allocator_ref
[       OK ] util_test.allocator_ref (0 ms)
[ RUN      ] util_test.format_system_error
[       OK ] util_test.format_system_error (0 ms)
[ RUN      ] util_test.system_error
[       OK ] util_test.system_error (0 ms)
[ RUN      ] util_test.report_system_error
[       OK ] util_test.report_system_error (0 ms)
[----------] 9 tests from util_test (1 ms total)
[----------] 9 tests from memory_buffer_test
[ RUN      ] memory_buffer_test.ctor
[       OK ] memory_buffer_test.ctor (0 ms)
[ RUN      ] memory_buffer_test.move_ctor_inline_buffer
[       OK ] memory_buffer_test.move_ctor_inline_buffer (0 ms)
[ RUN      ] memory_buffer_test.move_ctor_dynamic_buffer
[       OK ] memory_buffer_test.move_ctor_dynamic_buffer (0 ms)
[ RUN      ] memory_buffer_test.move_assignment
[       OK ] memory_buffer_test.move_assignment (0 ms)
[ RUN      ] memory_buffer_test.grow
[       OK ] memory_buffer_test.grow (0 ms)
[ RUN      ] memory_buffer_test.allocator
[       OK ] memory_buffer_test.allocator (0 ms)
[ RUN      ] memory_buffer_test.exception_in_deallocate
[       OK ] memory_buffer_test.exception_in_deallocate (0 ms)
[ RUN      ] memory_buffer_test.max_size_allocator
[       OK ] memory_buffer_test.max_size_allocator (0 ms)
[ RUN      ] memory_buffer_test.max_size_allocator_overflow
[       OK ] memory_buffer_test.max_size_allocator_overflow (0 ms)
[----------] 9 tests from memory_buffer_test (0 ms total)
[----------] 87 tests from format_test
[ RUN      ] format_test.escape
[       OK ] format_test.escape (0 ms)
[ RUN      ] format_test.unmatched_braces
[       OK ] format_test.unmatched_braces (0 ms)
[ RUN      ] format_test.no_args
[       OK ] format_test.no_args (0 ms)
[ RUN      ] format_test.args_in_different_positions
[       OK ] format_test.args_in_different_positions (0 ms)
[ RUN      ] format_test.arg_errors
[       OK ] format_test.arg_errors (0 ms)
[ RUN      ] format_test.many_args
[       OK ] format_test.many_args (0 ms)
[ RUN      ] format_test.named_arg
[       OK ] format_test.named_arg (0 ms)
[ RUN      ] format_test.auto_arg_index
[       OK ] format_test.auto_arg_index (0 ms)
[ RUN      ] format_test.empty_specs
[       OK ] format_test.empty_specs (0 ms)
[ RUN      ] format_test.left_align
[       OK ] format_test.left_align (0 ms)
[ RUN      ] format_test.right_align
[       OK ] format_test.right_align (0 ms)
[ RUN      ] format_test.center_align
[       OK ] format_test.center_align (0 ms)
[ RUN      ] format_test.fill
[       OK ] format_test.fill (0 ms)
[ RUN      ] format_test.plus_sign
[       OK ] format_test.plus_sign (0 ms)
[ RUN      ] format_test.minus_sign
[       OK ] format_test.minus_sign (0 ms)
[ RUN      ] format_test.space_sign
[       OK ] format_test.space_sign (0 ms)
[ RUN      ] format_test.hash_flag
[       OK ] format_test.hash_flag (0 ms)
[ RUN      ] format_test.zero_flag
[       OK ] format_test.zero_flag (0 ms)
[ RUN      ] format_test.zero_flag_and_align
[       OK ] format_test.zero_flag_and_align (0 ms)
[ RUN      ] format_test.width
[       OK ] format_test.width (0 ms)
[ RUN      ] format_test.runtime_width
[       OK ] format_test.runtime_width (0 ms)
[ RUN      ] format_test.precision
[       OK ] format_test.precision (0 ms)
[ RUN      ] format_test.runtime_precision
[       OK ] format_test.runtime_precision (0 ms)
[ RUN      ] format_test.format_bool
[       OK ] format_test.format_bool (0 ms)
[ RUN      ] format_test.format_short
[       OK ] format_test.format_short (0 ms)
[ RUN      ] format_test.format_int
[       OK ] format_test.format_int (1 ms)
[ RUN      ] format_test.format_bin
[       OK ] format_test.format_bin (0 ms)
[ RUN      ] format_test.format_dec
[       OK ] format_test.format_dec (0 ms)
[ RUN      ] format_test.format_hex
[       OK ] format_test.format_hex (0 ms)
[ RUN      ] format_test.format_oct
[       OK ] format_test.format_oct (0 ms)
[ RUN      ] format_test.format_int_locale
[       OK ] format_test.format_int_locale (0 ms)
[ RUN      ] format_test.format_float
[       OK ] format_test.format_float (0 ms)
[ RUN      ] format_test.format_double
/builds/a16bitsysop/aports/main/fmt/src/fmt-10.0.0/test/format-test.cc:1359: Failure
Expected equality of these values:
  fmt::format("{:a}", ld)
    Which is: "0xf.ffffffffffp-3"
  buffer
    Which is: "0x1.ffffffffffep+0"
/builds/a16bitsysop/aports/main/fmt/src/fmt-10.0.0/test/format-test.cc:1361: Failure
Expected equality of these values:
  fmt::format("{:.10a}", ld)
    Which is: "0xf.ffffffffffp-3"
  buffer
    Which is: "0x2.0000000000p+0"
/builds/a16bitsysop/aports/main/fmt/src/fmt-10.0.0/test/format-test.cc:1363: Failure
Expected equality of these values:
  fmt::format("{:.9a}", ld)
    Which is: "0x1.000000000p+1"
  buffer
    Which is: "0x2.000000000p+0"
/builds/a16bitsysop/aports/main/fmt/src/fmt-10.0.0/test/format-test.cc:1383: Failure
Expected equality of these values:
  fmt::format("{:a}", ld)
    Which is: "0x8p-16385"
  buffer
    Which is: "0x1p-16382"
/builds/a16bitsysop/aports/main/fmt/src/fmt-10.0.0/test/format-test.cc:1387: Failure
Expected equality of these values:
  fmt::format("{:a}", ld)
    Which is: "0xf.fffffffffffffffp+16380"
  buffer
    Which is: "0x1.fffffffffffffffep+16383"
[  FAILED  ] format_test.format_double (1 ms)
[ RUN      ] format_test.precision_rounding
[       OK ] format_test.precision_rounding (0 ms)
[ RUN      ] format_test.prettify_float
[       OK ] format_test.prettify_float (0 ms)
[ RUN      ] format_test.format_nan
[       OK ] format_test.format_nan (0 ms)
[ RUN      ] format_test.format_infinity
[       OK ] format_test.format_infinity (0 ms)
[ RUN      ] format_test.format_long_double
/builds/a16bitsysop/aports/main/fmt/src/fmt-10.0.0/test/format-test.cc:1499: Failure
Expected equality of these values:
  buffer
    Which is: "0x1.a7ae147ae147ae14p+1"
  fmt::format("{:a}", ld)
    Which is: "0xd.3d70a3d70a3d70ap-2"
[  FAILED  ] format_test.format_long_double (0 ms)
[ RUN      ] format_test.format_char
[       OK ] format_test.format_char (1 ms)
[ RUN      ] format_test.format_volatile_char
[       OK ] format_test.format_volatile_char (0 ms)
[ RUN      ] format_test.format_unsigned_char
[       OK ] format_test.format_unsigned_char (0 ms)
[ RUN      ] format_test.format_cstring
[       OK ] format_test.format_cstring (1 ms)
[ RUN      ] format_test.format_pointer
[       OK ] format_test.format_pointer (1 ms)
[ RUN      ] format_test.write_uintptr_fallback
[       OK ] format_test.write_uintptr_fallback (0 ms)
[ RUN      ] format_test.format_enum_class
[       OK ] format_test.format_enum_class (0 ms)
[ RUN      ] format_test.format_string
[       OK ] format_test.format_string (0 ms)
[ RUN      ] format_test.format_string_view
[       OK ] format_test.format_string_view (0 ms)
[ RUN      ] format_test.format_std_string_view
[       OK ] format_test.format_std_string_view (0 ms)
[ RUN      ] format_test.format_explicitly_convertible_to_std_string_view
[       OK ] format_test.format_explicitly_convertible_to_std_string_view (0 ms)
[ RUN      ] format_test.format_custom
[       OK ] format_test.format_custom (0 ms)
[ RUN      ] format_test.format_to_custom
[       OK ] format_test.format_to_custom (0 ms)
[ RUN      ] format_test.format_string_from_speed_test
[       OK ] format_test.format_string_from_speed_test (0 ms)
[ RUN      ] format_test.format_examples
[       OK ] format_test.format_examples (0 ms)
[ RUN      ] format_test.print
[       OK ] format_test.print (0 ms)
[ RUN      ] format_test.variadic
[       OK ] format_test.variadic (0 ms)
[ RUN      ] format_test.dynamic
[       OK ] format_test.dynamic (0 ms)
[ RUN      ] format_test.bytes
[       OK ] format_test.bytes (0 ms)
[ RUN      ] format_test.group_digits_view
[       OK ] format_test.group_digits_view (0 ms)
[ RUN      ] format_test.join
[       OK ] format_test.join (0 ms)
[ RUN      ] format_test.join_bytes
[       OK ] format_test.join_bytes (0 ms)
[ RUN      ] format_test.format_message_example
[       OK ] format_test.format_message_example (0 ms)
[ RUN      ] format_test.unpacked_args
[       OK ] format_test.unpacked_args (0 ms)
[ RUN      ] format_test.compile_time_string
[       OK ] format_test.compile_time_string (0 ms)
[ RUN      ] format_test.custom_format_compile_time_string
[       OK ] format_test.custom_format_compile_time_string (0 ms)
[ RUN      ] format_test.named_arg_udl
[       OK ] format_test.named_arg_udl (0 ms)
[ RUN      ] format_test.enum
[       OK ] format_test.enum (0 ms)
[ RUN      ] format_test.formatter_not_specialized
[       OK ] format_test.formatter_not_specialized (0 ms)
[ RUN      ] format_test.non_null_terminated_format_string
[       OK ] format_test.non_null_terminated_format_string (0 ms)
[ RUN      ] format_test.to_string
[       OK ] format_test.to_string (0 ms)
[ RUN      ] format_test.output_iterators
[       OK ] format_test.output_iterators (0 ms)
[ RUN      ] format_test.formatted_size
[       OK ] format_test.formatted_size (0 ms)
[ RUN      ] format_test.format_to_no_args
[       OK ] format_test.format_to_no_args (0 ms)
[ RUN      ] format_test.format_to
[       OK ] format_test.format_to (0 ms)
[ RUN      ] format_test.format_to_memory_buffer
[       OK ] format_test.format_to_memory_buffer (0 ms)
[ RUN      ] format_test.format_to_vector
[       OK ] format_test.format_to_vector (0 ms)
[ RUN      ] format_test.format_to_propagates_exceptions
[       OK ] format_test.format_to_propagates_exceptions (0 ms)
[ RUN      ] format_test.format_to_n
[       OK ] format_test.format_to_n (0 ms)
[ RUN      ] format_test.format_to_n_output_iterator
[       OK ] format_test.format_to_n_output_iterator (0 ms)
[ RUN      ] format_test.vformat_to
[       OK ] format_test.vformat_to (0 ms)
[ RUN      ] format_test.char_traits_is_not_ambiguous
[       OK ] format_test.char_traits_is_not_ambiguous (0 ms)
[ RUN      ] format_test.back_insert_slicing
[       OK ] format_test.back_insert_slicing (0 ms)
[ RUN      ] format_test.format_as
[       OK ] format_test.format_as (0 ms)
[ RUN      ] format_test.test_formatters_enabled
[       OK ] format_test.test_formatters_enabled (0 ms)
[ RUN      ] format_test.format_facet
[       OK ] format_test.format_facet (0 ms)
[ RUN      ] format_test.format_facet_separator
[       OK ] format_test.format_facet_separator (0 ms)
[ RUN      ] format_test.format_facet_grouping
[       OK ] format_test.format_facet_grouping (0 ms)
[ RUN      ] format_test.format_named_arg_with_locale
[       OK ] format_test.format_named_arg_with_locale (0 ms)
[----------] 87 tests from format_test (9 ms total)
[----------] 2 tests from format_int_test
[ RUN      ] format_int_test.data
[       OK ] format_int_test.data (0 ms)
[ RUN      ] format_int_test.format_int
[       OK ] format_int_test.format_int (0 ms)
[----------] 2 tests from format_int_test (0 ms total)
[----------] Global test environment tear-down
[==========] 114 tests from 6 test suites ran. (11 ms total)
[  PASSED  ] 112 tests.
[  FAILED  ] 2 tests, listed below:
[  FAILED  ] format_test.format_double
[  FAILED  ] format_test.format_long_double
 2 FAILED TESTS
15/17 Test #16: posix-mock-test ..................   Passed    0.01 sec
16/17 Test #17: os-test ..........................   Passed    0.00 sec
17/17 Test  #7: format-impl-test .................   Passed    0.06 sec
94% tests passed, 1 tests failed out of 17
Total Test time (real) =   0.07 sec
The following tests FAILED:
	  6 - format-test (Failed)
Errors while running CTest

Full pipeline here:
https://gitlab.alpinelinux.org/a16bitsysop/aports/-/jobs/1031079

@phprus
Copy link
Contributor

phprus commented May 13, 2023

glibc, musl and freebsd libc use different rounding policies in their implementation of long double output.

test:

#include <stdio.h>

int main()
{
    auto ld = 0xf.ffffffffffp-3l;
    printf("%La\n\n", ld);
    printf("%.*La\n\n", 10, ld);
    printf("%.*La\n\n", 9, ld);

    return 0;
}

glibc test (x86-64 ubuntu:latest docker image):

phprus@phprus:~> podman run --rm -it --net=host ubuntu:latest bash
...........
root@phprus:/# g++-11 1.cpp
root@phprus:/# ./a.out
0xf.ffffffffffp-3

0xf.ffffffffffp-3

0x1.000000000p+1

musl test (x86-64 alpine:latest docker image):

phprus@phprus:~> podman run --rm -it --net=host alpine:latest sh
...........
/ # g++ 1.cpp
/ # ./a.out
0x1.ffffffffffep+0

0x2.0000000000p+0

0x2.000000000p+0

FreeBSD 11.3 (x86-64):

phprus@fbsd:~ % clang++ -O3 -Wall -std=c++17 1.cpp
phprus@fbsd:~ % ./a.out
0x1.ffffffffffep+0

0x1.0000000000p+1

0x1.000000000p+1

@vitaut, I think the test needs to be modified to compare the result with the output of sprintf or a predefined value (glibc based output).
What do you think about it?

@phprus
Copy link
Contributor

phprus commented May 13, 2023

Fix: #3434

@a16bitsysop
Copy link
Author

Fix: #3434

yes that passes on alpine with that patch:
https://gitlab.alpinelinux.org/a16bitsysop/aports/-/jobs/1031708

@vitaut
Copy link
Contributor

vitaut commented May 13, 2023

Closing, thanks @phprus for the fix and @a16bitsysop for reporting the issue.

@vitaut vitaut closed this as completed May 13, 2023
@fmtlib fmtlib deleted a comment from iksyy May 13, 2023
@fmtlib fmtlib deleted a comment from iksyy May 13, 2023
@phprus phprus mentioned this issue Jun 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants