From 126d1e6176a490b9d4c73b1c7a75d697e9c7162c Mon Sep 17 00:00:00 2001
From: Larry Knox <lrknox@hdfgroup.org>
Date: Fri, 28 Dec 2018 16:50:48 -0600
Subject: Add .lsf batch scripts and insert the build directory into the
 scripts during configuration.

---
 bin/batch/ctestP.lsf.in.cmake          | 19 +++++++++++++++++++
 bin/batch/ctestS.lsf.in.cmake          | 18 ++++++++++++++++++
 config/cmake/scripts/CTestScript.cmake |  1 +
 src/CMakeLists.txt                     | 13 +++++++++++++
 4 files changed, 51 insertions(+)
 create mode 100644 bin/batch/ctestP.lsf.in.cmake
 create mode 100644 bin/batch/ctestS.lsf.in.cmake

diff --git a/bin/batch/ctestP.lsf.in.cmake b/bin/batch/ctestP.lsf.in.cmake
new file mode 100644
index 0000000..c410a1d
--- /dev/null
+++ b/bin/batch/ctestP.lsf.in.cmake
@@ -0,0 +1,19 @@
+#!/bin/tcsh
+### LSF syntax
+#BSUB -n 1                       #number of nodes
+#BSUB -W 30                      #walltime in minutes
+#BSUB -G guests                  #account
+#BSUB -e ctestPerrors.txt        #stderr
+#BSUB -o ctestPoutput.txt        #stdout
+#BSUB -J hdf5_ctestP             #job
+##BSUB -q pbatch                 #queue to use
+#BSUB -q pdebug
+
+##date; hostname
+##echo -n 'JobID is '; echo $LSB_JOBID
+
+cd @HDF5_BINARY_DIR@
+echo "Run parallel test command. Test output will be in build/ctestP.out"
+ctest . -R 'TEST_PAR|PH5DIFF|PERFORM' -E t_cache_image -C Release -T test >& ctestP.out
+
+echo "Done running ctest parallel command."
diff --git a/bin/batch/ctestS.lsf.in.cmake b/bin/batch/ctestS.lsf.in.cmake
new file mode 100644
index 0000000..a6f4ff8
--- /dev/null
+++ b/bin/batch/ctestS.lsf.in.cmake
@@ -0,0 +1,18 @@
+#!/bin/tcsh
+### LSF syntax
+#BSUB -n 1                  #number of nodes
+#BSUB -W 29                      #walltime in minutes
+#BSUB -G guests                  #account
+#BSUB -e ctestSerrors.txt        #stderr
+#BSUB -o ctestSoutput.txt        #stdout
+#BSUB -J hdf5_ctestS             #job
+##BSUB -q pbatch                 #queue to use
+#BSUB -q pdebug
+
+cd @HDF5_BINARY_DIR@
+echo "Run command. Test output will be in build/ctestS.out"
+ctest . -E 'TEST_PAR|H5DIFF|PERFORM' -C Release -j 32 -T test >& ctestS.out
+
+##$CMD  >& ctestS.out
+echo "Done running command."
+
diff --git a/config/cmake/scripts/CTestScript.cmake b/config/cmake/scripts/CTestScript.cmake
index 9534b1e..f4dffb3 100755
--- a/config/cmake/scripts/CTestScript.cmake
+++ b/config/cmake/scripts/CTestScript.cmake
@@ -281,6 +281,7 @@ message (STATUS "Dashboard script configuration:\n${vars}\n")
           endif ()
           message(STATUS "Found ${CTEST_BINARY_DIRECTORY}/Testing/${TAG_CONTENTS}/Test.xml for serial tests. Renaming to SerialTest.xml")
           file (RENAME ${CTEST_BINARY_DIRECTORY}/Testing/${TAG_CONTENTS}/Test.xml ${CTEST_BINARY_DIRECTORY}/Testing/${TAG_CONTENTS}/SerialTest.xml)
+          file (RENAME ${CTEST_BINARY_DIRECTORY}/Testing/Temporary/LastTest_${TAG_CONTENTS}.log ${CTEST_BINARY_DIRECTORY}/Testing/Temporary/LastTest_${TAG_CONTENTS}_Serial.log)
           unset(result CACHE)
           execute_process (COMMAND ${LOCAL_BATCH_SCRIPT_COMMAND} ${CTEST_SOURCE_DIRECTORY}/bin/batch/${LOCAL_BATCH_SCRIPT_PARALLEL_NAME})
           message(STATUS "Check for existence of ${CTEST_BINARY_DIRECTORY}/Testing/${TAG_CONTENTS}/Test.xml")
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 40b64f5..17325b0 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -943,6 +943,19 @@ if (BUILD_SHARED_LIBS)
   file (MAKE_DIRECTORY "${HDF5_BINARY_DIR}/shared")
 endif ()
 
+# This should perhaps be some kind of foreach or for loop for all of the files in the bin/batch directory.
+# For today I'll do it for the two that I want to try.
+if (LOCAL_BATCH_TEST)
+  configure_file (
+      ${HDF5_SOURCE_DIR}/bin/batch/ctestP.lsf.in.cmake
+      ${HDF5_SOURCE_DIR}/bin/batch/ctestP.lsf
+  )
+  configure_file (
+      ${HDF5_SOURCE_DIR}/bin/batch/ctestS.lsf.in.cmake
+      ${HDF5_SOURCE_DIR}/bin/batch/ctestS.lsf
+  )
+)
+
 if (NOT EXISTS ${HDF5_GENERATED_SOURCE_DIR}/H5Tinit.c)
   add_executable (H5detect ${HDF5_SRC_DIR}/H5detect.c)
   target_include_directories(H5detect PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
-- 
cgit v0.12