From 13cfd05f91a975fb2d60b8361a2ff2f237cbe7ec Mon Sep 17 00:00:00 2001 From: Mike Dalessio Date: Tue, 19 Dec 2023 17:40:57 -0500 Subject: [PATCH] test: reproduce an alpine symbol issue see https://github.com/sparklemotion/sqlite3-ruby/issues/434 --- test/rcd_test/ext/mri/rcd_test_ext.c | 14 ++++++++++++++ test/rcd_test/ext/mri/rcd_test_ext.h | 5 +++++ test/rcd_test/test/test_basic.rb | 7 +++++++ 3 files changed, 26 insertions(+) diff --git a/test/rcd_test/ext/mri/rcd_test_ext.c b/test/rcd_test/ext/mri/rcd_test_ext.c index b85a47de..1a06eb51 100644 --- a/test/rcd_test/ext/mri/rcd_test_ext.c +++ b/test/rcd_test/ext/mri/rcd_test_ext.c @@ -40,6 +40,19 @@ rcdt_darwin_builtin_available_eh(VALUE self) #endif } +static VALUE +rcdt_largefile_op_removed_from_musl(VALUE self) +{ + // Reference a symbol that was removed in Musl 1.24 🙄 + // https://github.com/sparklemotion/sqlite3-ruby/issues/434 +#ifdef __linux__ + posix_fallocate(STDERR_FILENO, 0, 0); + return Qtrue; +#else + return Qfalse; +#endif +} + void Init_rcd_test_ext(void) { @@ -48,4 +61,5 @@ Init_rcd_test_ext(void) rb_define_singleton_method(rb_mRcdTest, "darwin_builtin_available?", rcdt_darwin_builtin_available_eh, 0); rb_define_singleton_method(rb_mRcdTest, "isinf?", rcdt_isinf_eh, 1); rb_define_singleton_method(rb_mRcdTest, "isnan?", rcdt_isnan_eh, 1); + rb_define_singleton_method(rb_mRcdTest, "largefile_op_removed_from_musl", rcdt_largefile_op_removed_from_musl, 0); } diff --git a/test/rcd_test/ext/mri/rcd_test_ext.h b/test/rcd_test/ext/mri/rcd_test_ext.h index 14e8d9eb..0b3c1a62 100644 --- a/test/rcd_test/ext/mri/rcd_test_ext.h +++ b/test/rcd_test/ext/mri/rcd_test_ext.h @@ -1,6 +1,11 @@ #ifndef RCD_TEST_EXT_H #define RCD_TEST_EXT_H 1 +// see rcdt_largefile_op_removed_from_musl +#define _LARGEFILE_SOURCE 1 +#define _FILE_OFFSET_BITS 64 +#include + #include "ruby.h" #endif /* RCD_TEST_EXT_H */ diff --git a/test/rcd_test/test/test_basic.rb b/test/rcd_test/test/test_basic.rb index 9f3659a6..ddbc437d 100644 --- a/test/rcd_test/test/test_basic.rb +++ b/test/rcd_test/test/test_basic.rb @@ -22,10 +22,17 @@ def test_check_darwin_compiler_rt_symbol_resolution def test_floating_point_classification_macros skip("jruby should not run libc-specific tests") if RUBY_ENGINE == "jruby" + refute(RcdTest.isinf?(42.0)) assert(RcdTest.isinf?(Float::INFINITY)) refute(RcdTest.isnan?(42.0)) assert(RcdTest.isnan?(Float::NAN)) end + def test_largefile_op_removed_from_musl + skip("jruby should not run libc-specific tests") if RUBY_ENGINE == "jruby" + + is_linux = RUBY_PLATFORM.include?("linux") + assert_equal(is_linux, RcdTest.largefile_op_removed_from_musl) + end end