Skip to content

Commit

Permalink
Showing 9 changed files with 69 additions and 2 deletions.
2 changes: 2 additions & 0 deletions test/truffle/cexts/globals/.jruby-cext-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
src: ext/globals/*.c
out: lib/globals/globals.su
12 changes: 12 additions & 0 deletions test/truffle/cexts/globals/bin/globals
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env ruby

require 'globals'

GlobalsExtension.global = :global
p GlobalsExtension.global

GlobalsExtension.static_global = :static_global
p GlobalsExtension.static_global

GlobalsExtension.extern_global = :extern_global
p GlobalsExtension.extern_global
3 changes: 3 additions & 0 deletions test/truffle/cexts/globals/expected.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
:global
:static_global
:extern_global
2 changes: 2 additions & 0 deletions test/truffle/cexts/globals/ext/globals/extconf.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
require 'mkmf'
create_makefile('minimum')
3 changes: 3 additions & 0 deletions test/truffle/cexts/globals/ext/globals/extern.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#include <ruby.h>

VALUE extern_global;
42 changes: 42 additions & 0 deletions test/truffle/cexts/globals/ext/globals/globals.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#include <ruby.h>

VALUE global;
static VALUE static_global;
extern VALUE extern_global;

VALUE set_global(VALUE self, VALUE value) {
global = value;
return Qnil;
}

VALUE get_global(VALUE self) {
return global;
}

VALUE set_static_global(VALUE self, VALUE value) {
static_global = value;
return Qnil;
}

VALUE get_static_global(VALUE self) {
return static_global;
}

VALUE set_extern_global(VALUE self, VALUE value) {
extern_global = value;
return Qnil;
}

VALUE get_extern_global(VALUE self) {
return extern_global;
}

void Init_globals() {
VALUE module = rb_define_module("GlobalsExtension");
rb_define_module_function(module, "global=", &set_global, 1);
rb_define_module_function(module, "global", &get_global, 0);
rb_define_module_function(module, "static_global=", &set_static_global, 1);
rb_define_module_function(module, "static_global", &get_static_global, 0);
rb_define_module_function(module, "extern_global=", &set_extern_global, 1);
rb_define_module_function(module, "extern_global", &get_extern_global, 0);
}
1 change: 1 addition & 0 deletions test/truffle/cexts/globals/lib/globals.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
require 'globals/globals'
Empty file.
6 changes: 4 additions & 2 deletions tool/jt.rb
Original file line number Diff line number Diff line change
@@ -732,10 +732,11 @@ def test_cexts(*args)

begin
output_file = 'cext-output.txt'
['minimum', 'method', 'module', 'xml', 'xopenssl'].each do |gem_name|
['minimum', 'method', 'module', 'globals', 'xml', 'xopenssl'].each do |gem_name|
dir = "#{JRUBY_DIR}/test/truffle/cexts/#{gem_name}"
cextc dir
name = File.basename(dir)
next if gem_name == 'globals' # globals is excluded just for running
run '--graal', "-I#{dir}/lib", "#{dir}/bin/#{name}", :out => output_file
unless File.read(output_file) == File.read("#{dir}/expected.txt")
abort "c extension #{dir} didn't work as expected"
@@ -755,10 +756,11 @@ def test_cexts(*args)
next if gem_name == 'nokogiri' # nokogiri totally excluded
config = "#{JRUBY_DIR}/test/truffle/cexts/#{gem_name}"
cextc config, '-Werror=implicit-function-declaration'
next if gem_name == 'psd_native' # psd_native is excluded just for running
run '--graal',
*dependencies.map { |d| "-I#{ENV['GEM_HOME']}/gems/#{d}/lib" },
*libs.map { |l| "-I#{JRUBY_DIR}/test/truffle/cexts/#{l}/lib" },
"#{JRUBY_DIR}/test/truffle/cexts/#{gem_name}/test.rb" unless gem_name == 'psd_native' # psd_native is excluded just for compilation
"#{JRUBY_DIR}/test/truffle/cexts/#{gem_name}/test.rb"
end
end
private :test_cexts

0 comments on commit a0cac8d

Please sign in to comment.