util: Add a simple junit test for the gem5 ops java wrapper.

If possible, this gets built into the jar which also holds the wrapper.
It can be run on its own through its own main function, or through the
junit mechanism directly.

Change-Id: Iaec7f6deb26bbad75da027c71edca50ef25697cf
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/28181
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Bobby R. Bruce <bbruce@ucdavis.edu>
Maintainer: Gabe Black <gabe.black@gmail.com>
This commit is contained in:
Gabe Black
2020-10-22 20:01:03 -07:00
parent 97aa8425d6
commit 742acde59a
3 changed files with 63 additions and 1 deletions

View File

@@ -97,13 +97,17 @@ if env['HAVE_JAVA']:
# A wrapper to make the m5 ops available in Java through the JNI.
#
java_env = shared_env.Clone()
pkg_dir = Dir('java').Dir('gem5')
srcs = [ pkg_dir.File('Ops.java') ]
if java_env['HAVE_JUNIT']:
srcs.append(pkg_dir.File('OpsTest.java'))
# SCons provides Java and JavaH builders, but the JavaH builder assumes
# that the javah tool exists. Java has dropped that tool in favor of a -h
# option on javac which the Java builder doesn't know how to use. To get
# around this, we set up our own builder which does the "right thing" here.
java_env.Command([ Dir('java').File('gem5_Ops.h'),
Dir('out').Dir('java').File('gem5Ops.jar') ],
Dir('java').Dir('gem5').File('Ops.java'),
srcs,
MakeAction([
'${JAVAC} ${JAVACFLAGS} -d ${OUT} '
'${SOURCES} -h ${JAVA_DIR}',