Skip to content

Commit 19f09bc

Browse files
committed
Add test for using a stripped C extension
1 parent 15b60ec commit 19f09bc

File tree

6 files changed

+39
-8
lines changed

6 files changed

+39
-8
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env ruby
2+
3+
require 'stripped/stripped'
4+
puts Stripped.stripped
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Stripped!
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
require 'mkmf'
2+
create_makefile('stripped')
3+
4+
contents = File.read('Makefile')
5+
contents = "hijack: all strip-ext\n\n" + contents + <<EOF
6+
strip-ext: $(DLLIB)
7+
$(ECHO) Stripping $(DLLIB)
8+
#{RbConfig::CONFIG['STRIP']} $(DLLIB)
9+
10+
.PHONY: strip-ext
11+
EOF
12+
File.write('Makefile', contents)
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#include <stdio.h>
2+
#include <ruby.h>
3+
4+
static VALUE stripped_stripped(VALUE self) {
5+
return rb_str_new_cstr("Stripped!");
6+
}
7+
8+
void Init_stripped() {
9+
VALUE mod = rb_define_module("Stripped");
10+
rb_define_singleton_method(mod, "stripped", stripped_stripped, 0);
11+
}

test/truffle/cexts/stripped/lib/stripped/.keep

Whitespace-only changes.

tool/jt.rb

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1338,16 +1338,17 @@ def retag(*args)
13381338
out.sub('-', '--vm.')
13391339
end
13401340

1341+
ALL_CEXTS_TESTS = %w[
1342+
tools postinstallhook
1343+
minimum method module globals backtraces xopenssl werror stripped
1344+
oily_png psd_native
1345+
puma sqlite3 unf_ext json RubyInline msgpack
1346+
]
1347+
13411348
private def test_cexts(*args)
1342-
all_tests = %w[
1343-
tools postinstallhook
1344-
minimum method module globals backtraces xopenssl werror
1345-
oily_png psd_native
1346-
puma sqlite3 unf_ext json RubyInline msgpack
1347-
]
13481349
no_openssl = args.delete('--no-openssl')
13491350
no_gems = args.delete('--no-gems')
1350-
tests = args.empty? ? all_tests : args
1351+
tests = args.empty? ? ALL_CEXTS_TESTS : args
13511352
tests -= %w[xopenssl] if no_openssl
13521353
tests.delete 'gems' if no_gems
13531354

@@ -1358,13 +1359,15 @@ def retag(*args)
13581359

13591360
private def run_single_cexts_test(test_name)
13601361
in_truffleruby_repo_root!
1362+
raise "#{test_name} not in ALL_CEXTS_TESTS" unless ALL_CEXTS_TESTS.include?(test_name)
1363+
13611364
time_test("jt test cexts #{test_name}") do
13621365
case test_name
13631366
when 'tools'
13641367
# Test tools
13651368
run_ruby 'test/truffle/cexts/test_preprocess.rb'
13661369

1367-
when 'minimum', 'method', 'module', 'globals', 'backtraces', 'xopenssl', 'werror'
1370+
when 'minimum', 'method', 'module', 'globals', 'backtraces', 'xopenssl', 'werror', 'stripped'
13681371
# Test that we can compile and run some very basic C extensions
13691372
begin
13701373
output_file = 'cext-output.txt'

0 commit comments

Comments
 (0)