[distcc] sanity-check script

Martin Pool mbp at samba.org
Tue Jul 8 03:46:07 GMT 2003


The attached shell script is meant to allow people to do a quick
sanity check after installing distcc, to make sure that the hosts are
up and running and that the compilers are at least slightly compatible
and functioning.

At the moment it only looks at $DISTCC_HOSTS, not the files, but that
could easily be added.

What do you think?

-- 
Martin 
-------------- next part --------------
#! /bin/sh

# Copyright (C) 2003 by Martin Pool

# This program 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.
#
# This program 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 this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
# USA

# usage: distcc-check COMPILER

# Sanity check program for distcc: it tries to compile a simple C
# program on all the specified hosts.  This checks that they're
# reachable, that the server is running, and that they have a
# basically working compiler.  It does not check that the compilers
# are absolutely compatible, because that depends in a complicated way
# on the internal compiler versioning.

# TODO: Get distcc to check the host files and print out the hosts it
# thinks it should use.

# TODO: Test a named compiler.

# This can test cross-compilers, but only ones that target the client
# architecture.  But it could do so, if we only compiled and linked
# and did not execute the program.


# Is this method of creation secure?  I think so: if there is a
# symlink of the name then the mkdir will fail.
scratchdir="${TMPDIR-/tmp}/distcc-check-$$"
rm -r "$scratchdir" 2>/dev/null
mkdir "$scratchdir" || exit 2
cd "$scratchdir"

cat >hello.c <<EOF
#include <stdio.h>
int main(void) {
  printf("OK!\n");
return 0;
}
EOF

failed=0

# Note: intentionally no quoting on the next line, because we want to
# split into shell-style words.
for h in $DISTCC_HOSTS
do
  printf "%-40s" "$h"
  if DISTCC_HOSTS="$h" distcc -c -o hello.o hello.c &&
     DISTCC_HOSTS="$h" distcc -o hello hello.o 
  then
    ./hello 
  else
     echo failed >&2
     failed=1
  fi 
done

rm hello hello.o hello.c

exit $failed


More information about the distcc mailing list