#!/usr/bin/env expect ############################################################################ # Purpose: Test of Slurm functionality # Validate scontrol show hostnames. ############################################################################ # Copyright (C) 2013 SchedMD LLC # Written by Morris Jette # # 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 exit_code 0 # # test single bracket hostnames # set matches 0 spawn $scontrol show hostnames rack\[0-3\] expect { -re "rack0" { incr matches exp_continue } -re "rack1" { incr matches exp_continue } -re "rack2" { incr matches exp_continue } -re "rack3" { incr matches exp_continue } timeout { log_error "scontrol not responding" set exit_code 1 } eof { wait } } if {$matches != 4} { log_error "Show hostnames failure ($matches != 4)" set exit_code 1 } # # test double bracket hostnames # set matches 0 spawn $scontrol show hostnames rack\[0-1\]_blade\[2,3\] expect { -re "rack0_blade2" { incr matches exp_continue } -re "rack0_blade3" { incr matches exp_continue } -re "rack1_blade2" { incr matches exp_continue } -re "rack1_blade3" { incr matches exp_continue } timeout { log_error "scontrol not responding" set exit_code 1 } eof { wait } } if {$matches != 4} { log_error "Show hostnames failure ($matches != 4)" set exit_code 1 } # # test triple bracket hostnames # set matches 0 spawn $scontrol show hostnames row\[0,1\]_rack\[2-3\]_blade\[4,5\] expect { -re "row0_rack2_blade4" { incr matches exp_continue } -re "row0_rack2_blade5" { incr matches exp_continue } -re "row1_rack2_blade4" { incr matches exp_continue } -re "row1_rack2_blade5" { incr matches exp_continue } -re "row0_rack3_blade4" { incr matches exp_continue } -re "row0_rack3_blade5" { incr matches exp_continue } -re "row1_rack3_blade4" { incr matches exp_continue } -re "row1_rack3_blade5" { incr matches exp_continue } timeout { log_error "scontrol not responding" set exit_code 1 } eof { wait } } if {$matches != 8} { fail "Show hostnames failure ($matches != 8)" } if {$exit_code != 0} { fail "Test failed due to previous errors (\$exit_code = $exit_code)" }