TESTS="no_shared_filesystem no_shared_filesystem_with_std_io multicore_scratch"

simulate_cmds="sbatch rm" # Simulate rm in order not to get job script deleted
read -r -d '' simulator_output <<'EOF'
rargs="/sbatch .*/"
output="Submitted batch job 1"

rargs="/rm .*/"
output=""
EOF

function test_no_shared_filesystem() {
read -r -d '' job_description_input <<'EOF'
&(executable = "/bin/true")
EOF

read -r -d '' arc_test_configuration <<'EOF'
[lrms]
slurm_bin_path=@PWD@/bin
[arex]
scratchdir=/local/scratch
shared_filesystem=no
EOF

cat "${SRCDIR}/config-options-test-no_shared_filesystem.patch" | patch -sf -p1 -d ${SRCDIR} -o ${testdir}/expected_lrms_job_script.tmpl
}

function test_no_shared_filesystem_with_std_io() {
read -r -d '' job_description_input <<'EOF'
&(executable = "/bin/true")
 (stdin = "in")
 (stdout = "out")
 (stderr = "error")
EOF

read -r -d '' arc_test_configuration <<'EOF'
[lrms]
slurm_bin_path=@PWD@/bin
[arex]
scratchdir=/local/scratch
shared_filesystem=no
EOF

cat "${SRCDIR}/config-options-test-no_shared_filesystem_with_std_io.patch" | patch -sf -p1 -d ${SRCDIR} -o ${testdir}/expected_lrms_job_script.tmpl
}

function test_multicore_scratch() {
read -r -d '' job_description_input <<'EOF'
&(executable = "/bin/true")
 (runtimeenvironment = "MULTICORE_SCRATCH")
 (count = 8)
EOF

read -r -d '' arc_test_configuration <<'EOF'
[lrms]
slurm_bin_path=@PWD@/bin
[arex]
scratchdir=/local/scratch
shared_filesystem=no
EOF

rtes="MULTICORE_SCRATCH"

read -r -d '' MULTICORE_SCRATCH <<'EOF'
export RUNTIME_ENABLE_MULTICORE_SCRATCH="yes"
EOF

cat "${SRCDIR}/config-options-test-multicore_scratch.patch" | patch -sf -p1 -d ${SRCDIR} -o ${testdir}/expected_lrms_job_script.tmpl
}
