1# 2# Copyright (C) 2020 The Android Open Source Project 3# 4# Licensed under the Apache License, Version 2.0 (the "License"); 5# you may not use this file except in compliance with the License. 6# You may obtain a copy of the License at 7# 8# http://www.apache.org/licenses/LICENSE-2.0 9# 10# Unless required by applicable law or agreed to in writing, software 11# distributed under the License is distributed on an "AS IS" BASIS, 12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13# See the License for the specific language governing permissions and 14# limitations under the License. 15# 16 17import os 18import re 19 20import ltp_enums 21import ltp_configs 22 23 24class TestCase(object): 25 """Stores name, path, and param information for each test case. 26 27 All class initiation inputs are assumed to be already validated by 28 test case parser. 29 30 Attributes: 31 testsuite: string, name of testsuite to which the testcase belongs 32 testname: string, name of the test case 33 command: string, the command to run the test case 34 _args: list of string, test case command line arguments 35 requirement_state: RequirementState, enum representing requirement 36 check results 37 note: string, a place to store additional note for the test case 38 such as what environment requirement did not satisfy. 39 is_staging: bool, whether test case is a staging test 40 is_filtered: bool, whether test case is excluded by filter 41 """ 42 43 def __init__(self, testsuite, testname, command): 44 self.testsuite = testsuite 45 self.testname = testname 46 self._command = command 47 self.requirement_state = ltp_enums.RequirementState.UNCHECKED 48 self.note = "" 49 self.is_staging = False 50 self.is_mandatory = False 51 self.is_filtered = False 52 53 @property 54 def note(self): 55 """Get the note""" 56 return self._note 57 58 @note.setter 59 def note(self, note): 60 """Set the note""" 61 self._note = note 62 63 @property 64 def requirement_state(self): 65 """Get the requirement state""" 66 return self._requirement_state 67 68 @requirement_state.setter 69 def requirement_state(self, requirement_state): 70 """Set the requirement state""" 71 self._requirement_state = requirement_state 72 73 @property 74 def testsuite(self): 75 """Get the test suite's name.""" 76 return self._testsuite 77 78 @testsuite.setter 79 def testsuite(self, testsuite): 80 """Set the test suite's name.""" 81 self._testsuite = testsuite 82 83 @property 84 def testname(self): 85 """Get the test case's name.""" 86 return self._testname 87 88 @testname.setter 89 def testname(self, testname): 90 """Set the test case's name.""" 91 self._testname = testname 92 93 @property 94 def command(self): 95 """Get the test case's command.""" 96 return self._command 97 98 @property 99 def fullname(self): 100 """Return full test name in <testsuite-testname> format""" 101 return "%s.%s" % (self.testsuite, self.testname) 102 103 def __str__(self): 104 return self.fullname 105 106 @property 107 def is_staging(self): 108 '''Whether this test is a staging test.''' 109 return self._is_staging 110 111 @is_staging.setter 112 def is_staging(self, is_staging): 113 '''Set whether this test is a staging test.''' 114 self._is_staging = is_staging 115 116 @property 117 def is_mandatory(self): 118 '''Whether this test is a mandatory test.''' 119 return self._is_mandatory 120 121 @is_mandatory.setter 122 def is_mandatory(self, is_mandatory): 123 '''Set whether this test is a mandatory test.''' 124 self._is_mandatory = is_mandatory 125 126 @property 127 def is_filtered(self): 128 '''Whether this test has been filtered out.''' 129 return self._is_filtered 130 131 @is_filtered.setter 132 def is_filtered(self, is_filtered): 133 '''Set whether this test has been filtered out.''' 134 self._is_filtered = is_filtered 135