#!/usr/bin/env expect
############################################################################
# Purpose: Test of Slurm functionality
#          Confirm that memory per cpu properly set on an srun job that
#          does not have a preexisting allocation.
############################################################################
# Copyright (C) SchedMD LLC.
#
# This file is part of Slurm, a resource management program.
# For details, see <https://slurm.schedmd.com/>.
# Please also read the included file: DISCLAIMER.
#
# Slurm is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free
# Software Foundation; either version 2 of the License, or (at your option)
# any later version.
#
# Slurm is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
# details.
#
# You should have received a copy of the GNU General Public License along
# with Slurm; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
############################################################################
source ./globals

set timeout		$max_job_delay
set job_id		0
set mem_spec		"100M"

#
# submit srun job with a specific mem-per-cpu request
#
set output [run_command_output -fail "$srun --mem-per-cpu=$mem_spec $bin_bash -c 'echo SLURM_JOB_ID=\$SLURM_JOB_ID'"]
if {![regexp "SLURM_JOB_ID=(\[0-9]+)" $output {} job_id]} {
	fail "Did not get job id"
}

#
# check that the memory reported matches the requested value
#
subtest {[get_job_param $job_id MinMemoryCPU] == $mem_spec} "Verify job's MinMemoryCPU is $mem_spec"
