#!/usr/bin/env expect ############################################################################ # Purpose: Test of Slurm functionality # Test that an srun program can move from the background to the # foreground. ############################################################################ # Copyright (C) 2011-2013 SchedMD LLC # Written by Nathan Yee # # This file is part of Slurm, a resource management program. # For details, see . # 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$test_id.bash" set test_timer "test$test_id.test_timer" set test_srun "test$test_id.test_srun" set job_id 0 set exit_code 0 # remove any remaining files exec $bin_rm -f $test_timer $test_srun $file_in make_bash_script $test_timer " for i in \{1..10\} do echo \"time \$i\" sleep 5 done echo \"Test finished\" " make_bash_script $test_srun " set -m $srun -t1 -v ./$test_timer & $bin_sleep 15 echo \"sending job to foreground\" fg " make_bash_script $file_in " bash -i ./$test_srun " set timeout $max_job_delay set send_match 0 set time_match 0 set fini_match 0 spawn bash -i $file_in expect { -re "sending job to foreground" { set send_match 1 if {$time_match == 0} { log_error "srun is not generating output" set exit_code 1 } exp_continue } -re "time ($number)" { incr time_match exp_continue } -re "Test finished" { set fini_match 1 exp_continue } timeout { log_error "srun is not responding" set exit_code 1 } eof { wait } } if {$send_match != 1} { fail "srun was not sent to the foreground" } if {$time_match != 10} { fail "srun is not generating output ($time_match != 10)" } if {$fini_match != 1} { fail "srun did not finish the program submitted" } if {$exit_code == 0} { exec $bin_rm -f $test_timer $test_srun $file_in } else { fail "Test failed due to previous errors (\$exit_code = $exit_code)" }