Blame lib/dmucs.exp

Packit 62fe53
# Copyright (C) 2016 Free Software Foundation, Inc.
Packit 62fe53
Packit 62fe53
# This file is part of DejaGnu.
Packit 62fe53
#
Packit 62fe53
# DejaGnu is free software; you can redistribute it and/or modify it
Packit 62fe53
# under the terms of the GNU General Public License as published by
Packit 62fe53
# the Free Software Foundation; either version 3 of the License, or
Packit 62fe53
# (at your option) any later version.
Packit 62fe53
#
Packit 62fe53
# DejaGnu is distributed in the hope that it will be useful, but
Packit 62fe53
# WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 62fe53
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit 62fe53
# General Public License for more details.
Packit 62fe53
#
Packit 62fe53
# You should have received a copy of the GNU General Public License
Packit 62fe53
# along with DejaGnu; if not, write to the Free Software Foundation,
Packit 62fe53
# Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
Packit 62fe53
Packit 62fe53
# This file requires a slightly modified dmucs, which has been
Packit 62fe53
# modified to support multiple architectures for toolchain
Packit 62fe53
# testing. DMUCS sends the CPU load to a server, which we can query
Packit 62fe53
# using the 'gethost' command to get the next available slave for a
Packit 62fe53
# remote test based on which one is the least busy. The code for this
Packit 62fe53
# enhanced DMUCS is at: http://git.linaro.org/git/toolchain/dmucs.git
Packit 62fe53
Packit 62fe53
proc dmucs_gethost { server arch } {
Packit 62fe53
    # gethost in debug mode returns this output:
Packit 62fe53
    # --node and --arch are unique to the Linaro branch of DMUCS
Packit 62fe53
    #
Packit 62fe53
    # Writing -->host 127.0.1.1 <-- to the server
Packit 62fe53
    # Calling Sgets
Packit 62fe53
    # Got -->10.6.1.24<-- from the server
Packit 62fe53
    # tmp is -->DISTCC_HOSTS=10.6.1.24/100<--
Packit 62fe53
    set slave ""
Packit 62fe53
    spawn gethost -s $server --node --arch $arch
Packit 62fe53
    expect {
Packit 62fe53
	# This is the IP number we want.
Packit 62fe53
	"^\[0-9\]*\.\[0-9\]*\.\[0-9\]*\.\[0-9\]*" {
Packit 62fe53
	    set pos [expr {[string first "/" $expect_out(buffer)] - 1}]
Packit 62fe53
	    set slave [string range $expect_out(buffer) 0 $pos]
Packit 62fe53
	}
Packit 62fe53
	timeout {
Packit 62fe53
	    perror "DMUCS gethost command timed out"
Packit 62fe53
	}
Packit 62fe53
	eof {
Packit 62fe53
	    perror "Failed to connect to DMUCS server"
Packit 62fe53
	}
Packit 62fe53
    }
Packit 62fe53
    return $slave
Packit 62fe53
}