diff options
author | fergus.henderson <fergus.henderson@01de4be4-8c4a-0410-9132-4925637da917> | 2008-08-02 01:27:58 +0000 |
---|---|---|
committer | fergus.henderson <fergus.henderson@01de4be4-8c4a-0410-9132-4925637da917> | 2008-08-02 01:27:58 +0000 |
commit | cd08c48cbda7de21a90cee3ba3f2fda5d38addec (patch) | |
tree | cea0434e40f96ba967dffccdfbaf4eaed51a8344 | |
parent | c264a9f94a7f5fd35471477ee5acb85ce7092514 (diff) | |
download | distcc-cd08c48cbda7de21a90cee3ba3f2fda5d38addec.tar.gz |
Add a test of C++ compilation, and refactor the tests of Objective-C
and Objective-C++ to share the common code.
Also, fix some bugs in the tests of Objective-C and Objective-C++.
These tests were never being activated, even when the right compiler is
installed, because in the test compilation (not using distcc) it was
compiling with "-o /dev/null" and then testing that testtmp.o exists,
which it never did. There was also a missing "std::" in the Objective-C++
test. I still haven't run the Objective-C++ test, because I still haven't
figured out how to install Objective-C++, but it's pretty similar to
the C++ and Objective-C tests, and both of those now run and pass.
Reviewers: Craig Silverstein
git-svn-id: http://distcc.googlecode.com/svn/trunk@587 01de4be4-8c4a-0410-9132-4925637da917
-rwxr-xr-x | test/testdistcc.py | 127 |
1 files changed, 97 insertions, 30 deletions
diff --git a/test/testdistcc.py b/test/testdistcc.py index 6e6212d..1dbe78a 100755 --- a/test/testdistcc.py +++ b/test/testdistcc.py @@ -908,7 +908,11 @@ class Compilation_Case(WithDaemon_Case): def linkCmd(self): """Return command to link object files""" return self.distcc() + \ - _gcc + " -o testtmp testtmp.o" + _gcc + " -o testtmp testtmp.o " + self.libraries() + + def libraries(self): + """Returns any '-l' options needed to link the program.""" + return "" def checkCompileMsgs(self, msgs): if msgs <> '': @@ -965,27 +969,89 @@ int main(void) { """ -class ObjectiveC_Case(Compilation_Case): - """Test building an Objective-C program.""" - +class LanguageSpecific_Case(Compilation_Case): + """Abstract base class to test building non-C programs.""" def runtest(self): - # Don't try to run the test if GNU Objective C is not installed + # Don't try to run the test if the language's compiler is not installed + source = self.sourceFilename() + lang = self.languageGccName() error_rc, _, _ = self.runcmd_unchecked( - "touch testtmp.m; " + + "touch " + source + "; " + "rm -f testtmp.o; " + - _gcc + " -x objective-c -c testtmp.m -o /dev/null && " + + _gcc + " -x " + lang + " -c " + source + " " + + self.libraries() + " && " + "test -f testtmp.o" ) if error_rc != 0: - raise comfychair.NotRunError ('GNU Objective C not installed') + raise comfychair.NotRunError ('GNU ' + self.languageName() + + ' not installed') else: Compilation_Case.runtest (self) def sourceFilename(self): - return "testtmp.m" + return "testtmp" + self.extension() + + def languageGccName(self): + """Language name suitable for use with 'gcc -x'""" + raise NotImplementedError + + def languageName(self): + """Human-readable language name.""" + raise NotImplementedError + + def extension(self): + """Filename extension, with leading '.'.""" + raise NotImplementedError + +class CPlusPlus_Case(LanguageSpecific_Case): + """Test building a C++ program.""" + + def languageName(self): + return "C++" + + def languageGccName(self): + return "c++" + + def extension(self): + return ".cpp" # Could also use ".cc", ".cxx", etc. + + def libraries(self): + return "-lstdc++" def headerSource(self): return """ -#define HELLO_WORLD "hello world" +#define MESSAGE "hello c++" +""" + + def source(self): + return """ +#import <iostream> +#import "testhdr.h" + +int main(void) { + std::cout << MESSAGE << std::endl; + return 0; +} +""" + + def checkBuiltProgramMsgs(self, msgs): + self.assert_equal(msgs, "hello c++\n") + + +class ObjectiveC_Case(LanguageSpecific_Case): + """Test building an Objective-C program.""" + + def languageName(self): + return "Objective-C" + + def languageGccName(self): + return "objective-c" + + def extension(self): + return ".m" + + def headerSource(self): + return """ +#define MESSAGE "hello objective-c" """ def source(self): @@ -993,33 +1059,32 @@ class ObjectiveC_Case(Compilation_Case): #import <stdio.h> #import "testhdr.h" +/* TODO: use objective-c features. */ + int main(void) { - puts(HELLO_WORLD); + puts(MESSAGE); return 0; } """ -class ObjectiveCPlusPlus_Case(Compilation_Case): +class ObjectiveCPlusPlus_Case(LanguageSpecific_Case): """Test building an Objective-C++ program.""" - def runtest(self): - # Don't try to run the test if GNU Objective C++ is not installed - error_rc, _, _ = self.runcmd_unchecked( - "touch testtmp.mm; " + - "rm -f testtmp.o; " + - _gcc + " -x objective-c++ -c testtmp.mm -o /dev/null && " + - "test -f testtmp.o" ) - if error_rc != 0: - raise comfychair.NotRunError ('GNU Objective C++ not installed') - else: - Compilation_Case.runtest (self) + def languageName(self): + return "Objective-C++" - def sourceFilename(self): - return "testtmp.mm" + def languageGccName(self): + return "objective-c++" + + def extension(self): + return ".mm" + + def libraries(self): + return "-lstdc++" def headerSource(self): return """ -#define HELLO_WORLD "hello world" +#define MESSAGE "hello objective-c++" """ def source(self): @@ -1027,15 +1092,16 @@ class ObjectiveCPlusPlus_Case(Compilation_Case): #import <iostream> #import "testhdr.h" +/* TODO: use Objective-C features. */ + int main(void) { - std::cout << HELLO_WORLD << endl; + std::cout << MESSAGE << std::endl; return 0; } """ def checkBuiltProgramMsgs(self, msgs): - self.assert_equal(msgs, "hello world\n") - + self.assert_equal(msgs, "hello objective-c++\n") class Gdb_Case(CompileHello_Case): """Test that distcc generates correct debugging information.""" @@ -1890,9 +1956,10 @@ for path in os.environ['PATH'].split (':'): # All the tests defined in this suite tests = [ CompileHello_Case, - SystemIncludeDirectories_Case, + CPlusPlus_Case, ObjectiveC_Case, ObjectiveCPlusPlus_Case, + SystemIncludeDirectories_Case, Gdb_Case, GdbOpt1_Case, GdbOpt2_Case, |