| """Command line interface tests for llvm.py run-test-suite. |
| |
| Note that although this uses the unittest framework, it does *not* contain unit |
| tests. |
| |
| """ |
| |
| from llvmtestcase import LLVMTestCase, require_command_arg, debug |
| |
| from re import escape |
| |
| class Testllvmsetuptestsuite(LLVMTestCase): |
| |
| @classmethod |
| def llvm_setup_test_suite(cls, *args, **kwargs): |
| return cls.command_with_defaults("setup-test-suite", *args, **kwargs) |
| |
| @require_command_arg("--sandbox") |
| def test_sandbox_is_compulsory(self): |
| """Test that we get an error if we don't pass the path to the sandbox.""" |
| self.run_with_output(self.llvm_setup_test_suite("--lnt=somewhere")) |
| |
| @require_command_arg("--lnt") |
| def test_lnt_is_compulsory(self): |
| """Test that we get an error if we don't pass the path to lnt.""" |
| self.run_with_output(self.llvm_setup_test_suite("--sandbox=somewhere")) |
| |
| def test_dry_run(self): |
| """Test that we get the correct commands for setting up a sandbox.""" |
| sandbox = "path/to/sandbox" |
| lnt = "path/to/lnt" |
| |
| output = self.run_with_output(self.llvm_setup_test_suite( |
| "--dry-run", "--sandbox", sandbox, "--lnt", lnt)) |
| |
| # We don't care about the directory where this is running. |
| self.assertRegex( |
| output, |
| "(.*)\$ virtualenv {0}\n" |
| "(.*)\$ {0}/bin/python {1}/setup.py develop\n".format( |
| sandbox, lnt)) |
| |
| class Testllvmruntestsuite(LLVMTestCase): |
| |
| @classmethod |
| def llvm_run_test_suite(cls, *args, **kwargs): |
| return cls.command_with_defaults("run-test-suite", *args, **kwargs) |
| |
| @require_command_arg("--sandbox") |
| def test_sandbox_is_compulsory(self): |
| """Test that we get an error if we don't pass the path to the sandbox.""" |
| self.run_with_output(self.llvm_run_test_suite("--test-suite=somewhere", |
| "--use-lit=somewhere" |
| "--cc=somewhere")) |
| |
| @require_command_arg("--test-suite") |
| def test_test_suite_repo_is_compulsory(self): |
| """ |
| Test that we get an error if we don't pass the path to the test-suite |
| repo. |
| """ |
| self.run_with_output(self.llvm_run_test_suite("--sandbox=somewhere", |
| "--use-lit=somewhere" |
| "--cc=somewhere")) |
| |
| @require_command_arg("--use-lit") |
| def test_llvm_lit_is_compulsory(self): |
| """Test that we get an error if we don't pass the path to llvm-lit.""" |
| self.run_with_output(self.llvm_run_test_suite("--sandbox=somewhere", |
| "--test-suite=somewhere" |
| "--cc=somewhere")) |
| |
| @require_command_arg("--cc") |
| def test_cc_is_compulsory(self): |
| """ |
| Test that we get an error if we don't pass the path to the C compiler. |
| """ |
| self.run_with_output(self.llvm_run_test_suite("--sandbox=somewhere", |
| "--test-suite=somewhere", |
| "--use-lit=somewhere")) |
| |
| def test_basic_command(self): |
| """ |
| Test that we can run a test-suite command with only the required args. |
| """ |
| sandbox = "path/to/sandbox" |
| testsuite = "path/to/testuite" |
| lit = "path/to/lit" |
| cc = "path/to/clang" |
| |
| output = self.run_with_output( |
| self.llvm_run_test_suite( |
| "--dry-run", |
| "--sandbox", sandbox, |
| "--test-suite", testsuite, |
| "--use-lit", lit, |
| "--cc", cc)) |
| |
| expectedCommand = escape( |
| "{0}/bin/python {0}/bin/lnt runtest test-suite " |
| "--sandbox={0} --test-suite={1} --use-lit={2} --cc={3}\n".format( |
| sandbox, testsuite, lit, cc)) |
| # We don't care about the directory where this is running. |
| self.assertRegex( |
| output, "(.*)\$ {}".format(expectedCommand)) |
| |
| def test_custom_flags(self): |
| """Test that we can run a test-suite command with custom flags.""" |
| sandbox = "path/to/sandbox" |
| testsuite = "path/to/testuite" |
| lit = "path/to/lit" |
| cc = "path/to/clang" |
| |
| output = self.run_with_output( |
| self.llvm_run_test_suite( |
| "--dry-run", |
| "--sandbox", sandbox, |
| "--test-suite", testsuite, |
| "--use-lit", lit, |
| "--cc", cc, |
| "--lnt-flag=--cppflags='-mcpu=cortex-a15 -marm'", |
| "--lnt-flag=--threads=4")) |
| |
| expectedCommand = escape( |
| "{0}/bin/python {0}/bin/lnt runtest test-suite " |
| "--sandbox={0} --test-suite={1} --use-lit={2} --cc={3} " |
| "--cppflags='-mcpu=cortex-a15 -marm' --threads=4\n".format( |
| sandbox, testsuite, lit, cc)) |
| # We don't care about the directory where this is running. |
| self.assertRegex( |
| output, "(.*)\$ {}".format(expectedCommand)) |
| |
| def test_cxx(self): |
| """Test that we can specify --cxx if we want to.""" |
| sandbox = "path/to/sandbox" |
| testsuite = "path/to/testuite" |
| lit = "path/to/lit" |
| cc = "path/to/clang" |
| cxx = "path/to/clang++" |
| |
| output = self.run_with_output( |
| self.llvm_run_test_suite( |
| "--dry-run", |
| "--sandbox", sandbox, |
| "--test-suite", testsuite, |
| "--use-lit", lit, |
| "--cc", cc, |
| "--cxx", cxx, |
| "--lnt-flag=--cppflags='-mcpu=cortex-a15 -marm'", |
| "--lnt-flag=--threads=4")) |
| |
| expectedCommand = escape( |
| "{0}/bin/python {0}/bin/lnt runtest test-suite " |
| "--sandbox={0} --test-suite={1} --use-lit={2} --cc={3} --cxx={4} " |
| "--cppflags='-mcpu=cortex-a15 -marm' --threads=4\n".format( |
| sandbox, testsuite, lit, cc, cxx)) |
| # We don't care about the directory where this is running. |
| self.assertRegex( |
| output, "(.*)\$ {}".format(expectedCommand)) |