[distcc] distcc 2.12.1 test suite patch

Albert Chin distcc at mlists.thewrittenword.com
Thu Feb 19 09:17:45 GMT 2004


Patch below to get test suite working on most of the platforms we
support:
  1. Not much use in testing with the native compiler so we *force*
     the test suite to use gcc.

  2. Rather than picking up gcc from $PATH, we pass the full path
     to GCC. This avoids problems when distccd is running.

  3. I've added known failures on some platforms. For example, the
     assembler test should only run on Linux x86. Where we know
     the test will fail, we print:
       DashONoSpace_Case              NOTRUN, GCC mips-tfile wants space after -o
       ...
       RemoteAssemble_Case            NOTRUN, Linux x86 only
       PreprocessAsm_Case             NOTRUN, Linux x86 only
       ...

The tests pass on:
  HP-UX 10.20, 11.00, 11i; IRIX 6.5;
  Redhat Linux 7.1, 9; Solaris 7, 8, 9; Tru64 UNIX 4.0d, 5.1

Failures:
  1. Solaris 2.5.1, 2.6 hang after NoDetachDaemon_Case.
  3. AIX 4.3.2, 5.1 hang at BigAssFile_Case and fail ImplicitCompiler_Case
     (the IBM C compiler wants the cwd to be writable). Should I disable
     ImplicitCompiler_Case or should distcc call 'gcc' as the default
     compiler rather than 'cc'?

One odd thing that happens on HP-UX and Tru64 UNIX is that the
distccd's run during the test don't end after the tests complete. Why?

Also, due to the large number of distccd processes run during the test
suite, I had to bump my process/user limit up (AIX, HP-UX, Tru64 UNIX).

-- 
albert chin (china at thewrittenword.com)

-- snip snip
--- test/testdistcc.py.orig	2004-02-19 00:16:08.000000000 -0600
+++ test/testdistcc.py	2004-02-19 02:19:10.000000000 -0600
@@ -177,6 +177,8 @@
 EXIT_COMPILER_MISSING        = 110
 EXIT_ACCESS_DENIED           = 113
 
+_gcc                         = None     # full path to gcc
+
 class SimpleDistCC_Case(comfychair.TestCase):
     '''Abstract base class for distcc tests'''
     def setup(self):
@@ -310,14 +312,15 @@
 
     Now that we support implicit compilers, this is passed to gcc, which returns 1."""
     def runtest(self):
-        self.runcmd("distcc --bogus-option", 1)
-        self.runcmd("distccd --bogus-option", EXIT_BAD_ARGUMENTS)
+        self.runcmd("distcc " + _gcc + " --bogus-option", 1)
+        self.runcmd("distccd " + _gcc + " --bogus-option", EXIT_BAD_ARGUMENTS)
 
 
 class GccOptionsPassed_Case(SimpleDistCC_Case):
     """Test that options following the compiler name are passed to the compiler."""
     def runtest(self):
-        out, err = self.runcmd("DISTCC_HOSTS=localhost distcc gcc --help")
+        out, err = self.runcmd("DISTCC_HOSTS=localhost distcc " + \
+                               _gcc + " --help")
         if re.search('distcc', out):
             raise ("gcc help contains \"distcc\": \"%s\"" % out)
         self.assert_re_match(r"^Usage: gcc", out)
@@ -556,10 +559,11 @@
 
     def compileCmd(self):
         """Return command to compile source and run tests"""
-        return "DISTCC_FALLBACK=0 distcc cc -o testtmp.o -c %s" % (self.sourceFilename())
+        return "DISTCC_FALLBACK=0 distcc " + \
+               _gcc + " -o testtmp.o -c %s" % (self.sourceFilename())
 
     def linkCmd(self):
-        return "distcc cc -o testtmp testtmp.o"
+        return "distcc " + _gcc + " -o testtmp testtmp.o"
 
     def checkCompileMsgs(self, msgs):
         if msgs <> '':
@@ -594,15 +598,24 @@
 
 class DashONoSpace_Case(CompileHello_Case):
     def compileCmd(self):
-        return "DISTCC_FALLBACK=0 distcc cc -otesttmp.o -c %s" % (self.sourceFilename())
+        return "DISTCC_FALLBACK=0 distcc " + _gcc + \
+               " -otesttmp.o -c %s" % (self.sourceFilename())
 
+    def runtest(self):
+        if sys.platform == 'sunos5':
+            raise comfychair.NotRunError ('Sun assembler wants space after -o')
+        elif sys.platform.startswith ('osf1'):
+            raise comfychair.NotRunError ('GCC mips-tfile wants space after -o')
+        else:
+            CompileHello_Case.runtest (self)
 
 class WriteDevNull_Case(CompileHello_Case):
     def runtest(self):
         self.compile()
         
     def compileCmd(self):
-        return "DISTCC_FALLBACK=0 distcc -c -o /dev/null -c %s" % (self.sourceFilename())
+        return "DISTCC_FALLBACK=0 distcc " + _gcc + \
+               " -c -o /dev/null -c %s" % (self.sourceFilename())
 
 
 class MultipleCompile_Case(Compilation_Case):
@@ -620,8 +633,8 @@
 """)
         
     def runtest(self):
-        self.runcmd("distcc cc -c test1.c test2.c")
-        self.runcmd("distcc cc -o test test1.o test2.o")
+        self.runcmd("distcc " + _gcc + " -c test1.c test2.c")
+        self.runcmd("distcc " + _gcc + " -o test test1.o test2.o")
         
 
 
@@ -631,7 +644,7 @@
         return '#error "not tonight dear"\n'
 
     def runtest(self):
-        cmd = "distcc -c testtmp.c"
+        cmd = "distcc " + _gcc + " -c testtmp.c"
         msgs, errs = self.runcmd(cmd, expectedResult=1)
         self.assert_re_search("not tonight dear", errs)
         self.assert_equal(msgs, '')
@@ -644,7 +657,7 @@
 """
 
     def runtest(self):
-        self.runcmd("distcc cc -o testtmp.o -c testtmp.c", 1)
+        self.runcmd("distcc " + _gcc + " -o testtmp.o -c testtmp.c", 1)
 
 
 class PreprocessPlainText_Case(Compilation_Case):
@@ -665,7 +678,7 @@
 
     def runtest(self):
         # -P means not to emit linemarkers
-        self.runcmd("distcc gcc -E testtmp.c -o testtmp.out")
+        self.runcmd("distcc " + _gcc + " -E testtmp.c -o testtmp.out")
         out = open("testtmp.out").read()
         # It's a bit hard to know the exact value, because different versions of
         # GNU cpp seem to handle the whitespace differently.
@@ -703,7 +716,13 @@
         # FIXME: Mozilla uses something like "distcc testtmp.o -o testtmp",
         # but that's broken at the moment.
         return "distcc -o testtmp testtmp.o "
-        
+
+    def runtest(self):
+        if sys.platform != 'hp-ux10':
+            CompileHello_Case.runtest (self)
+        else:
+            raise comfychair.NotRunError ('HP-UX bundled C compiler non-ANSI')
+
 
 class DashD_Case(Compilation_Case):
     """Test preprocessor arguments"""
@@ -719,7 +738,8 @@
 
     def compileCmd(self):
         # quoting is hairy because this goes through the shell
-        return "distcc cc -c -o testtmp.o '-DMESSAGE=\"hello world\"' testtmp.c"
+        return "distcc " + _gcc + \
+               " -c -o testtmp.o '-DMESSAGE=\"hello world\"' testtmp.c"
 
     def checkBuiltProgramMsgs(self, msgs):
         self.assert_equal(msgs, "hello world\n")
@@ -733,7 +753,7 @@
     def runtest(self):
         # may take about a minute or so
         for i in xrange(1000):
-            self.runcmd("distcc cc -o testtmp.o -c testtmp.c")
+            self.runcmd("distcc " + _gcc + " -o testtmp.o -c testtmp.c")
 
 
 class Concurrent_Case(CompileHello_Case):
@@ -744,8 +764,9 @@
     def runtest(self):
         # may take about a minute or so
         pids = {}
-        for i in xrange(100):
-            kid = self.runcmd_background("distcc cc -o testtmp.o -c testtmp.c")
+        for i in xrange(50):
+            kid = self.runcmd_background("distcc " + _gcc + \
+                                         " -o testtmp.o -c testtmp.c")
             pids[kid] = kid
         while len(pids):
             pid, status = os.wait()
@@ -773,8 +794,8 @@
         f.close()
 
     def runtest(self):
-        self.runcmd("distcc cc -c %s" % "testtmp.c")
-        self.runcmd("distcc cc -o testtmp testtmp.o")
+        self.runcmd("distcc " + _gcc + " -c %s" % "testtmp.c")
+        self.runcmd("distcc " + _gcc + " -o testtmp testtmp.o")
 
 
     def daemon_lifetime(self):
@@ -798,7 +819,12 @@
         open("testtmp.i", "wt").write("int main() {}")
         
     def runtest(self):
-        self.runcmd("distcc false -c testtmp.i", 1)
+        # On Solaris and IRIX 6, 'false' returns exit status 255
+        if sys.platform == 'sunos5' or \
+        sys.platform.startswith ('irix6'):
+            self.runcmd("distcc false -c testtmp.i", 255)
+        else:
+            self.runcmd("distcc false -c testtmp.i", 1)
 
 
 class BinTrue_Case(Compilation_Case):
@@ -827,7 +853,7 @@
     output filename in the same way as gcc."""
     # XXX: Are other compilers the same?
     def runtest(self):
-        self.runcmd("distcc gcc -c -S testtmp.c")
+        self.runcmd("distcc " + _gcc + " -c -S testtmp.c")
         if os.path.exists("testtmp.o"):
             self.fail("created testtmp.o but should not have")
         if not os.path.exists("testtmp.s"):
@@ -844,7 +870,7 @@
         self.createSource()
     
     def runtest(self):
-        self.runcmd("distcc gcc -c -o testtmp.o testtmp.c")
+        self.runcmd("distcc " + _gcc + " -c -o testtmp.o testtmp.c")
         msgs = open(self.distcc_log, 'r').read()
         self.assert_re_search(r'failed to distribute.*running locally instead',
                               msgs)            
@@ -853,7 +879,7 @@
 class ImpliedOutput_Case(CompileHello_Case):
     """Test handling absence of -o"""
     def compileCmd(self):
-        return "distcc cc -c testtmp.c"
+        return "distcc " + _gcc + " -c testtmp.c"
 
 
 class SyntaxError_Case(Compilation_Case):
@@ -900,7 +926,8 @@
 
     def compileCmd(self):
         """Return command to compile source and run tests"""
-        return "DISTCC_FALLBACK=1 distcc cc -o testtmp.o -c %s" % (self.sourceFilename())
+        return "DISTCC_FALLBACK=1 distcc " + _gcc + \
+               " -o testtmp.o -c %s" % (self.sourceFilename())
 
 
 
@@ -966,15 +993,21 @@
 
     def compile(self):
         # Need to build both the C file and the assembly file
-        self.runcmd("distcc cc -o test2.o -c test2.s")
-        self.runcmd("distcc cc -o testtmp.o -c testtmp.c")
+        self.runcmd("distcc " + _gcc + " -o test2.o -c test2.s")
+        self.runcmd("distcc " + _gcc + " -o testtmp.o -c testtmp.c")
         self.runcmd(self.linkCmd())
 
     def asmCmd(self):
-        return "distcc cc -o test2.o -c %s" % (self.asm_filename)
+        return "distcc " + _gcc + " -o test2.o -c %s" % (self.asm_filename)
 
     def linkCmd(self):
-        return "distcc cc -o testtmp testtmp.o test2.o"
+        return "distcc " + _gcc + " -o testtmp testtmp.o test2.o"
+
+    def runtest(self):
+        if sys.platform == 'linux2':
+            CompileHello_Case.runtest (self)
+        else:
+            raise comfychair.NotRunError ('Linux x86 only')
 
 
 class PreprocessAsm_Case(RemoteAssemble_Case):
@@ -996,15 +1029,22 @@
     asm_filename = 'test2.S'
     
     def compile(self):
-        self.runcmd("distcc cc -o test2.o -c test2.S")
-        self.runcmd("distcc cc -o testtmp.o -c testtmp.c")
-        self.runcmd("distcc cc -o testtmp testtmp.o test2.o")
+        if sys.platform == 'linux2':
+            self.runcmd("distcc " + _gcc + " -o test2.o -c test2.S")
+            self.runcmd("distcc " + _gcc + " -o testtmp.o -c testtmp.c")
+            self.runcmd("distcc " + _gcc + " -o testtmp testtmp.o test2.o")
+
+    def runtest(self):
+        if sys.platform == 'linux2':
+            RemoteAssemble_Case.runtest (self)
+        else:
+            raise comfychair.NotRunError ('Linux x86 only')
 
 
 class ModeBits_Case(CompileHello_Case):
     """Check distcc obeys umask"""
     def runtest(self):
-        self.runcmd("umask 0; distcc -c testtmp.c")
+        self.runcmd("umask 0; distcc " + _gcc + " -c testtmp.c")
         self.assert_equal(S_IMODE(os.stat("testtmp.o")[ST_MODE]), 0666)
 
 
@@ -1027,7 +1067,7 @@
         self.compile()
 
     def compile(self):
-        self.runcmd("distcc cc -c %s" % self.sourceFilename())
+        self.runcmd("distcc " + _gcc + " -c %s" % self.sourceFilename())
 
     def sourceFilename(self):
         return "testtmp.i"
@@ -1036,8 +1076,8 @@
     def runtest(self):
         self.runcmd("touch distcc.log")
         self.runcmd("chmod 0 distcc.log")
-        msgs, errs = self.runcmd("DISTCC_LOG=distcc.log distcc -c foo.c",
-                                expectedResult=1)
+        msgs, errs = self.runcmd("DISTCC_LOG=distcc.log distcc " + \
+                                 _gcc + " -c foo.c", expectedResult=1)
         self.assert_re_search("failed to open logfile", errs)
 
 
@@ -1053,7 +1093,7 @@
 
     def compileCmd(self):
         """Return command to compile source and run tests"""
-        return "DISTCC_FALLBACK=1 distcc cc -o testtmp.o -c %s" % (self.sourceFilename())
+        return "DISTCC_FALLBACK=1 distcc " + _gcc + " -o testtmp.o -c %s" % (self.sourceFilename())
 
     
     def runtest(self):
@@ -1101,6 +1141,13 @@
         CompileHello_Case.teardown(self)
 
 
+# When invoking compiler, use absolute path so distccd can find it
+for path in os.environ['PATH'].split (':'):
+  abs_path = os.path.join (path, 'gcc')
+
+  if os.path.isfile (abs_path):
+    _gcc = abs_path
+
 # All the tests defined in this suite
 tests = [BadLogFile_Case,
          ScanArgs_Case,



More information about the distcc mailing list