Skip to content

Commit

Permalink
Ensure module-path built agents are tested in mx hellomodule
Browse files Browse the repository at this point in the history
  • Loading branch information
olpaw committed Jun 23, 2021
1 parent af4d956 commit 09bb627
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions substratevm/mx.substratevm/mx_substratevm.py
Original file line number Diff line number Diff line change
Expand Up @@ -1088,17 +1088,28 @@ def hellomodule(args):
proj_dir = join(suite.dir, 'src', 'native-image-module-tests', 'hello.app')
mx.run_maven(['-e', 'install'], cwd=proj_dir)
module_path.append(join(proj_dir, 'target', 'hello-app-1.0-SNAPSHOT.jar'))
config = GraalVMConfig.build(native_images=['native-image'])
config = GraalVMConfig.build(native_images=['native-image', 'lib:native-image-agent', 'lib:native-image-diagnostics-agent'])
with native_image_context(hosted_assertions=False, config=config) as native_image:
module_path_sep = ';' if mx.is_windows() else ':'
moduletest_run_args = [
'--add-exports=moduletests.hello.lib/hello.privateLib=moduletests.hello.app',
'--add-opens=moduletests.hello.lib/hello.privateLib2=moduletests.hello.app',
'-p', module_path_sep.join(module_path), '-m', 'moduletests.hello.app'
]
mx.log('Running module-tests on JVM:')
build_dir = join(svmbuild_dir(), 'hellomodule')
mx.run([
vm_executable_path('java', config),
# also test if native-image-agent works
'-agentlib:native-image-agent=config-output-dir=' + join(build_dir, 'config-output-dir-{pid}-{datetime}/'),
] + moduletest_run_args)

# Build module into native image
mx.log('Building image from java modules: ' + str(module_path))
module_path_sep = ';' if mx.is_windows() else ':'
built_image = native_image([
'--verbose', '-ea', '-H:Path=' + build_dir,
'--add-exports=moduletests.hello.lib/hello.privateLib=moduletests.hello.app',
'--add-exports=moduletests.hello.lib/hello.privateLib2=moduletests.hello.app',
'-p', module_path_sep.join(module_path), '-m', 'moduletests.hello.app'])
'--verbose', '-H:Path=' + build_dir,
'--trace-class-initialization=hello.lib.Greeter', # also test native-image-diagnostics-agent
] + moduletest_run_args)
mx.log('Running image ' + built_image + ' built from module:')
mx.run([built_image])

Expand Down

0 comments on commit 09bb627

Please sign in to comment.