Skip to content

Commit

Permalink
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions tool/jt.rb
Original file line number Diff line number Diff line change
@@ -21,6 +21,8 @@

GRAALVM_VERSION = '0.12'

p ENV

JRUBY_DIR = File.expand_path('../..', __FILE__)
M2_REPO = File.expand_path('~/.m2/repository')
SULONG_HOME = ENV['SULONG_HOME']
@@ -32,7 +34,10 @@
METRICS_REPS = 10

LIBXML_HOME = ENV['LIBXML_HOME'] = ENV['LIBXML_HOME'] || '/usr'
LIBXML_LIB_HOME = ENV['LIBXML_LIB_HOME'] = ENV['LIBXML_LIB_HOME'] || "#{LIBXML_HOME}/lib"

OPENSSL_HOME = ENV['OPENSSL_HOME'] = ENV['OPENSSL_HOME'] || '/usr'
OPENSSL_LIB_HOME = ENV['OPENSSL_LIB_HOME'] = ENV['OPENSSL_LIB_HOME'] || "#{OPENSSL_HOME}/lib"

MAC = `uname -a`.include?('Darwin')

@@ -726,20 +731,20 @@ def test_cexts(*args)
# Test that we can compile and run some basic C code that uses libxml and openssl

clang '-S', '-emit-llvm', "-I#{LIBXML_HOME}/include/libxml2", 'test/truffle/cexts/xml/main.c', '-o', 'test/truffle/cexts/xml/main.ll'
out, _ = sulong_run("-l#{LIBXML_HOME}/lib/libxml2.#{so}", 'test/truffle/cexts/xml/main.ll', {capture: true})
out, _ = sulong_run("-l#{LIBXML_LIB_HOME}/libxml2.#{so}", 'test/truffle/cexts/xml/main.ll', {capture: true})
raise unless out == "7\n"

clang '-S', '-emit-llvm', "-I#{OPENSSL_HOME}/include", 'test/truffle/cexts/xopenssl/main.c', '-o', 'test/truffle/cexts/xopenssl/main.ll'
out, _ = sulong_run("-l#{OPENSSL_HOME}/lib/libssl.#{so}", 'test/truffle/cexts/xopenssl/main.ll', {capture: true})
out, _ = sulong_run("-l#{OPENSSL_LIB_HOME}/libssl.#{so}", 'test/truffle/cexts/xopenssl/main.ll', {capture: true})
raise unless out == "5d41402abc4b2a76b9719d911017c592\n"

# Test that we can run those same test when they're build as a .su and we load the code and libraries from that

sulong_link '-o', 'test/truffle/cexts/xml/main.su', '-l', "#{LIBXML_HOME}/lib/libxml2.#{so}", 'test/truffle/cexts/xml/main.ll'
sulong_link '-o', 'test/truffle/cexts/xml/main.su', '-l', "#{LIBXML_LIB_HOME}/libxml2.#{so}", 'test/truffle/cexts/xml/main.ll'
out, _ = sulong_run('test/truffle/cexts/xml/main.su', {capture: true})
raise unless out == "7\n"

sulong_link '-o', 'test/truffle/cexts/xopenssl/main.su', '-l', "#{OPENSSL_HOME}/lib/libssl.#{so}", 'test/truffle/cexts/xopenssl/main.ll'
sulong_link '-o', 'test/truffle/cexts/xopenssl/main.su', '-l', "#{OPENSSL_LIB_HOME}/libssl.#{so}", 'test/truffle/cexts/xopenssl/main.ll'
out, _ = sulong_run('test/truffle/cexts/xopenssl/main.su', {capture: true})
raise unless out == "5d41402abc4b2a76b9719d911017c592\n"

@@ -751,7 +756,7 @@ def test_cexts(*args)
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
#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"

0 comments on commit 15518e6

Please sign in to comment.