TESTS="memory_basic memory_cluster_nodememory "\
"memory_queue_defaultmemory memory_cluster_and_queue_nodememory_1 "\
"memory_cluster_and_queue_nodememory_2"

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

read -r -d '' general_arc_test_configuration <<EOF
[lrms]
slurm_bin_path=@PWD@/bin
EOF

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

cat "${SRCDIR}/memory-test-memory_basic.patch" | patch -sf -p1 -d ${SRCDIR} -o ${testdir}/expected_lrms_job_script.tmpl
}

function test_memory_cluster_nodememory() {
read -r -d '' arc_test_configuration <<'EOF'
[lrms]
slurm_bin_path=@PWD@/bin
defaultmemory=300
EOF

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

cat "${SRCDIR}/memory-test-memory_cluster_nodememory.patch" | patch -sf -p1 -d ${SRCDIR} -o ${testdir}/expected_lrms_job_script.tmpl
}

function test_memory_queue_defaultmemory() {
read -r -d '' arc_test_configuration <<'EOF'
[lrms]
slurm_bin_path=@PWD@/bin
[queue:nordugrid]
defaultmemory=200
EOF

read -r -d '' job_description_input <<'EOF'
&(executable = "/bin/true")
 (queue = "nordugrid")
EOF

cat "${SRCDIR}/memory-test-memory_queue_defaultmemory.patch" | patch -sf -p1 -d ${SRCDIR} -o ${testdir}/expected_lrms_job_script.tmpl
}

function test_memory_cluster_and_queue_nodememory_1() {
read -r -d '' arc_test_configuration <<'EOF'
[lrms]
slurm_bin_path=@PWD@/bin
defaultmemory=200

[queue:nordugrid]
defaultmemory=700
EOF

read -r -d '' job_description_input <<'EOF'
&(executable = "/bin/true")
 (queue = "nordugrid")
EOF

cat "${SRCDIR}/memory-test-memory_cluster_and_queue_nodememory_1.patch" | patch -sf -p1 -d ${SRCDIR} -o ${testdir}/expected_lrms_job_script.tmpl
}

function test_memory_cluster_and_queue_nodememory_2() {
read -r -d '' arc_test_configuration <<'EOF'
[lrms]
slurm_bin_path=@PWD@/bin
defaultmemory=200

[queue:nordugrid]
defaultmemory=700
EOF

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

cat "${SRCDIR}/memory-test-memory_cluster_and_queue_nodememory_2.patch" | patch -sf -p1 -d ${SRCDIR} -o ${testdir}/expected_lrms_job_script.tmpl
}
