blob: e1c5eb7dcfbf1a0df05c5cac8b67e2402184ce07 [file] [log] [blame]
#!/usr/bin/env expect
############################################################################
# Purpose: Test of Slurm functionality
# Basic UPC (Unified Parallel C) test via srun.
############################################################################
# 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 file_in "$test_dir/input"
set file_out "$test_dir/output"
set file_err "$test_dir/error"
set test_prog "$test_name.prog"
set job_id 0
set task_cnt 2
set thread_cnt 4
#
# Test for existence of UPC compiler
#
if {[info exists upcc] == 0} {
skip "UPC compiler (upcc) not defined, can't perform UPC testing"
}
if {[file executable $upcc] == 0} {
skip "$upcc does not exist"
}
proc cleanup {} {
global job_id test_prog
cancel_job $job_id
file delete $test_prog ${test_prog}.o
}
#
# Delete left-over program and rebuild it
#
exec $upcc -o $test_prog ${test_prog}.upc
#
# Build input script file
#
make_bash_script $file_in "
GASNET_SPAWNFN=L $srun -n $task_cnt ./$test_prog $thread_cnt
"
#
# Spawn an sbatch job that uses stdout/err and confirm their contents
#
set timeout $max_job_delay
set no_start 0
spawn $sbatch -N1-$task_cnt -n $task_cnt --output=$file_out --error=$file_err -t1 $file_in
expect {
-re "Submitted batch job ($number)" {
set job_id $expect_out(1,string)
exp_continue
}
-re "Batch job submission failed" {
set no_start 1
exp_continue
}
-re "Unable to contact" {
fail "Slurm appears to be down"
}
timeout {
fail "srun not responding"
}
eof {
wait
}
}
if {$no_start != 0} {
skip "Partition too small for test"
}
if {$job_id == 0} {
fail "Batch submit failure"
}
#
# Wait for job to complete
#
wait_for_job -fail $job_id "DONE"
#
# Check for desired output in stdout
#
wait_for_file -fail $file_out
set matches 0
set sum 0
set total 0
spawn $bin_cat $file_out
expect {
-re "Hello from ($number) of $thread_cnt" {
incr matches
incr sum $expect_out(1,string)
exp_continue
}
-re "Total is ($number)" {
set total $expect_out(1,string)
exp_continue
}
-re "Failed to mmap" {
fail "Insufficient shared memory. Rebuild UPCC with --disable-pshm option."
}
eof {
wait
}
}
if {$matches == 0} {
fail "No UPC communications occurred"
} elseif {$matches != $task_cnt * $thread_cnt} {
fail "Unexpected output ($matches of $task_cnt * $thread_cnt)"
} elseif {$sum != $total * $task_cnt} {
fail "Problem with global variables ($sum != $total)"
}