def filterOneTest(self, test_name): """Check test filters for a test name. The first layer of filter is user defined test filters: if a include filter is not empty, only tests in include filter will be executed regardless whether they are also in exclude filter. Else if include filter is empty, only tests not in exclude filter will be executed. The second layer of filter is checking _skip_all_testcases flag: the subclass may set _skip_all_testcases to True in its implementation of setUpClass. If the flag is set, this method raises signals.TestSkip. The third layer of filter is checking abi bitness: if a test has a suffix indicating the intended architecture bitness, and the current abi bitness information is available, non matching tests will be skipped. By our convention, this function will look for bitness in suffix formated as "32bit", "32Bit", "32BIT", or 64 bit equivalents. This method assumes const.SUFFIX_32BIT and const.SUFFIX_64BIT are in lower cases. Args: test_name: string, name of a test Raises: signals.TestSilent if a test should not be executed signals.TestSkip if a test should be logged but not be executed """ if self.include_filter: if test_name not in self.include_filter: msg = "Test case '%s' not in include filter %s." % ( test_name, self.include_filter) logging.info(msg) raise signals.TestSilent(msg) elif test_name in self.exclude_filter: msg = "Test case '%s' in exclude filter %s." % ( test_name, self.exclude_filter) logging.info(msg) raise signals.TestSilent(msg) if self._skip_all_testcases: raise signals.TestSkip("All test cases skipped.") asserts.skipIf( self.abi_bitness and ((self.skip_on_32bit_abi is True) and self.abi_bitness == "32") or ((self.skip_on_64bit_abi is True) and self.abi_bitness == "64") or (test_name.lower().endswith(const.SUFFIX_32BIT) and self.abi_bitness != "32") or (test_name.lower().endswith(const.SUFFIX_64BIT) and self.abi_bitness != "64" and not self.run_32bit_on_64bit_abi), "Test case '{}' excluded as ABI bitness is {}.".format( test_name, self.abi_bitness))
def skipClass(self, class_name, reason): """Add a record to indicate all test cases in the class are skipped. Args: class_name: A string that is the name of the skipped test class. reason: A string that is the reason for skipping. """ record = TestResultRecord("unknown", class_name) record.testBegin() record.testSkip(signals.TestSkip(reason)) self.executed.append(record) self.skipped.append(record)
def _filterOneTestThroughTestFilter(self, test_name, test_filter=None): """Check test filter for the given test name. Args: test_name: string, name of a test Raises: signals.TestSilent if a test should not be executed signals.TestSkip if a test should be logged but not be executed """ if not test_filter: test_filter = self.test_filter if not test_filter.Filter(test_name): raise signals.TestSilent("Test case '%s' did not pass filters.") if self.isSkipAllTests(): raise signals.TestSkip(self.getSkipAllTestsReason())
def filterOneTest(self, test_name): """Check test filters for a test name. The first layer of filter is user defined test filters: if a include filter is not empty, only tests in include filter will be executed regardless whether they are also in exclude filter. Else if include filter is empty, only tests not in exclude filter will be executed. The second layer of filter is checking _skip_all_testcases flag: the subclass may set _skip_all_testcases to True in its implementation of setUpClass. If the flag is set, this method raises signals.TestSkip. The third layer of filter is checking abi bitness: if a test has a suffix indicating the intended architecture bitness, and the current abi bitness information is available, non matching tests will be skipped. By our convention, this function will look for bitness in suffix formated as "32bit", "32Bit", "32BIT", or 64 bit equivalents. This method assumes const.SUFFIX_32BIT and const.SUFFIX_64BIT are in lower cases. Args: test_name: string, name of a test Raises: signals.TestSilent if a test should not be executed signals.TestSkip if a test should be logged but not be executed """ if (hasattr(self, keys.ConfigKeys.KEY_INCLUDE_FILTER) and getattr(self, keys.ConfigKeys.KEY_INCLUDE_FILTER)): if test_name not in getattr(self, keys.ConfigKeys.KEY_INCLUDE_FILTER): logging.info("Test case '%s' not in include filter." % test_name) raise signals.TestSilent( "Test case '%s' not in include filter." % test_name) elif (hasattr(self, keys.ConfigKeys.KEY_EXCLUDE_FILTER) and test_name in getattr(self, keys.ConfigKeys.KEY_EXCLUDE_FILTER)): logging.info("Test case '%s' in exclude filter." % test_name) raise signals.TestSilent("Test case '%s' in exclude filter." % test_name) if self._skip_all_testcases: raise signals.TestSkip("All test cases skipped.") if hasattr(self, keys.ConfigKeys.IKEY_ABI_BITNESS): bitness = getattr(self, keys.ConfigKeys.IKEY_ABI_BITNESS) run_32bit_on_64bit_abi = getattr( self, keys.ConfigKeys.IKEY_RUN_32BIT_ON_64BIT_ABI, False) skip_on_32bit_abi = getattr( self, keys.ConfigKeys.IKEY_SKIP_ON_32BIT_ABI, False) skip_on_64bit_abi = getattr( self, keys.ConfigKeys.IKEY_SKIP_ON_64BIT_ABI, False) asserts.skipIf( ((skip_on_32bit_abi is True) and bitness == "32") or ( (skip_on_64bit_abi is True) and bitness == "64") or (test_name.lower().endswith(const.SUFFIX_32BIT) and bitness != "32") or ( test_name.lower().endswith(const.SUFFIX_64BIT) and bitness != "64" and not run_32bit_on_64bit_abi), "Test case '{}' excluded as ABI bitness is {}.".format( test_name, bitness))