Blame SOURCES/0005-Add-helper-to-run-a-single-test-case.patch

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