From 7d1c481e947edf0786223ef43a359c8d5771a214 Mon Sep 17 00:00:00 2001
From: Alexander Scheel <ascheel@redhat.com>
Date: Wed, 28 Aug 2019 09:23:41 -0400
Subject: [PATCH 1/3] Add helper to run a single test case
run_test.sh.in is templated by CMake to build/run_test.sh, fully
configured to your test execution environment. In particular, it writes
the classpath and loads the JSS native library.
Signed-off-by: Alexander Scheel <ascheel@redhat.com>
---
cmake/JSSConfig.cmake | 29 +++++++++++++++++++----------
tools/run_test.sh.in | 15 +++++++++++++++
2 files changed, 34 insertions(+), 10 deletions(-)
create mode 100755 tools/run_test.sh.in
diff --git a/cmake/JSSConfig.cmake b/cmake/JSSConfig.cmake
index 27b2a9bf..6295a6e3 100644
--- a/cmake/JSSConfig.cmake
+++ b/cmake/JSSConfig.cmake
@@ -13,6 +13,9 @@ macro(jss_config)
# Configure java-related flags
jss_config_java()
+
+ # Template auto-generated files
+ jss_config_template()
endmacro()
macro(jss_config_version MAJOR MINOR PATCH BETA)
@@ -45,16 +48,6 @@ macro(jss_config_version MAJOR MINOR PATCH BETA)
set(JSS_VERSION "${JSS_VERSION} beta ${JSS_VERSION_BETA}")
set(JSS_VERSION_STR "${JSS_VERSION_STR}_b${JSS_VERSION_BETA}")
endif()
-
- # Template files
- configure_file(
- "${PROJECT_SOURCE_DIR}/org/mozilla/jss/util/jssver.h.in"
- "${PROJECT_SOURCE_DIR}/org/mozilla/jss/util/jssver.h"
- )
- configure_file(
- "${PROJECT_SOURCE_DIR}/lib/MANIFEST.MF.in"
- "${CMAKE_BINARY_DIR}/MANIFEST.MF"
- )
endmacro()
macro(jss_config_outputs)
@@ -326,3 +319,19 @@ macro(jss_config_java)
math(EXPR JSS_TEST_PORT_CLIENTAUTH ${JSS_BASE_PORT}+0)
math(EXPR JSS_TEST_PORT_CLIENTAUTH_FIPS ${JSS_BASE_PORT}+1)
endmacro()
+
+macro(jss_config_template)
+ # Template files
+ configure_file(
+ "${PROJECT_SOURCE_DIR}/org/mozilla/jss/util/jssver.h.in"
+ "${PROJECT_SOURCE_DIR}/org/mozilla/jss/util/jssver.h"
+ )
+ configure_file(
+ "${PROJECT_SOURCE_DIR}/lib/MANIFEST.MF.in"
+ "${CMAKE_BINARY_DIR}/MANIFEST.MF"
+ )
+ configure_file(
+ "${PROJECT_SOURCE_DIR}/tools/run_test.sh.in"
+ "${CMAKE_BINARY_DIR}/run_test.sh"
+ )
+endmacro()
diff --git a/tools/run_test.sh.in b/tools/run_test.sh.in
new file mode 100755
index 00000000..60233c05
--- /dev/null
+++ b/tools/run_test.sh.in
@@ -0,0 +1,15 @@
+#!/bin/bash
+
+# This utility gets templated to build/run_test.sh to help with running a
+# single test after building JSS. This gives the caller more flexibility
+# with command line arguments and ensures that the correct build artifacts
+# get used.
+
+export LD_LIBRARY_PATH="${CMAKE_BINARY_DIR}"
+
+if [ "$1" == "--gdb" ]; then
+ shift
+ gdb --args "${Java_JAVA_EXECUTABLE}" -classpath "${TEST_CLASSPATH}" -ea -Djava.library.path="${CMAKE_BINARY_DIR}" "$@"
+else
+ "${Java_JAVA_EXECUTABLE}" -classpath "${TEST_CLASSPATH}" -ea -Djava.library.path="${CMAKE_BINARY_DIR}" "$@"
+fi
--
2.21.0