Skip to content

Commit

Permalink
test: reproduce an alpine symbol issue
Browse files Browse the repository at this point in the history
  • Loading branch information
flavorjones committed Dec 19, 2023
1 parent ef9bb33 commit 07967dd
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
14 changes: 14 additions & 0 deletions test/rcd_test/ext/mri/rcd_test_ext.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -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);
}
5 changes: 5 additions & 0 deletions test/rcd_test/ext/mri/rcd_test_ext.h
Original file line number Diff line number Diff line change
@@ -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 <fcntl.h>

#include "ruby.h"

#endif /* RCD_TEST_EXT_H */
7 changes: 7 additions & 0 deletions test/rcd_test/test/test_basic.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 07967dd

Please sign in to comment.