summaryrefslogtreecommitdiffstats
path: root/meta/lib
diff options
context:
space:
mode:
authorIonut Chisanovici <ionutx.chisanovici@intel.com>2014-06-30 11:41:39 +0300
committerRichard Purdie <richard.purdie@linuxfoundation.org>2014-06-30 10:32:51 +0100
commit9e1c86921ce1bb561bdef97b0f6da7d35f15c9d8 (patch)
tree39b8f4d18f472aa6c1532cde21aea982013e5e53 /meta/lib
parent676c1f5c67d1d55b6e8236785584672c87a7e5e2 (diff)
downloadpoky-9e1c86921ce1bb561bdef97b0f6da7d35f15c9d8.tar.gz
oeqa/selftest/_toaster.py: fix 'IndentationError' issues
There were some indentation errors when the _toaster.py was merged into master. This patch fix those errors. (From OE-Core rev: 173194493294574e49874858ee7003000f41b4d6) Signed-off-by: Ionut Chisanovici <ionutx.chisanovici@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib')
-rw-r--r--meta/lib/oeqa/selftest/_toaster.py560
1 files changed, 280 insertions, 280 deletions
diff --git a/meta/lib/oeqa/selftest/_toaster.py b/meta/lib/oeqa/selftest/_toaster.py
index 4ab6cbff11..5a42e937bc 100644
--- a/meta/lib/oeqa/selftest/_toaster.py
+++ b/meta/lib/oeqa/selftest/_toaster.py
@@ -18,82 +18,82 @@ from orm.models import *
18class ToasterSetup(oeSelfTest): 18class ToasterSetup(oeSelfTest):
19 19
20 def recipe_parse(self, file_path, var): 20 def recipe_parse(self, file_path, var):
21 for line in open(file_path,'r'): 21 for line in open(file_path,'r'):
22 if line.find(var) > -1: 22 if line.find(var) > -1:
23 val = line.split(" = ")[1].replace("\"", "").strip() 23 val = line.split(" = ")[1].replace("\"", "").strip()
24 return val 24 return val
25 25
26 def fix_file_path(self, file_path): 26 def fix_file_path(self, file_path):
27 if ":" in file_path: 27 if ":" in file_path:
28 file_path=file_path.split(":")[2] 28 file_path=file_path.split(":")[2]
29 return file_path 29 return file_path
30 30
31class Toaster_DB_Tests(ToasterSetup): 31class Toaster_DB_Tests(ToasterSetup):
32 32
33 # Check if build name is unique - tc_id=795 33 # Check if build name is unique - tc_id=795
34 def test_Build_Unique_Name_TC795(self): 34 def test_Build_Unique_Name_TC795(self):
35 all_builds = Build.objects.all().count() 35 all_builds = Build.objects.all().count()
36 distinct_builds = Build.objects.values('id').distinct().count() 36 distinct_builds = Build.objects.values('id').distinct().count()
37 self.assertEqual(distinct_builds, all_builds, msg = 'Build name is not unique') 37 self.assertEqual(distinct_builds, all_builds, msg = 'Build name is not unique')
38 38
39 # Check if build cooker log path is unique - tc_id=819 39 # Check if build coocker log path is unique - tc_id=819
40 def test_Build_Unique_Cooker_Log_Path_TC819(self): 40 def test_Build_Unique_Cooker_Log_Path_TC819(self):
41 distinct_path = Build.objects.values('cooker_log_path').distinct().count() 41 distinct_path = Build.objects.values('cooker_log_path').distinct().count()
42 total_builds = Build.objects.values('id').count() 42 total_builds = Build.objects.values('id').count()
43 self.assertEqual(distinct_path, total_builds, msg = 'Build cooker log path is not unique') 43 self.assertEqual(distinct_path, total_builds, msg = 'Build coocker log path is not unique')
44 44
45 # Check if the number of errors matches the number of orm_logmessage.level entries with value 2 - tc_id=820 45 # Check if the number of errors matches the number of orm_logmessage.level entries with value 2 - tc_id=820
46 def test_Build_Errors_No_TC820(self): 46 def test_Build_Errors_No_TC820(self):
47 builds = Build.objects.values('id', 'errors_no') 47 builds = Build.objects.values('id', 'errors_no')
48 cnt_err = [] 48 cnt_err = []
49 for build in builds: 49 for build in builds:
50 log_mess_err_no = LogMessage.objects.filter(build = build['id'], level = 2).count() 50 log_mess_err_no = LogMessage.objects.filter(build = build['id'], level = 2).count()
51 if (build['errors_no'] != log_mess_err_no): 51 if (build['errors_no'] != log_mess_err_no):
52 cnt_err.append(build['id']) 52 cnt_err.append(build['id'])
53 self.assertEqual(len(cnt_err), 0, msg = 'Errors for build id: %s' % cnt_err) 53 self.assertEqual(len(cnt_err), 0, msg = 'Errors for build id: %s' % cnt_err)
54 54
55 # Check if the number of warnings matches the number of orm_logmessage.level entries with value 1 - tc=821 55 # Check if the number of warnings matches the number of orm_logmessage.level entries with value 1 - tc=821
56 def test_Build_Warnings_No_TC821(self): 56 def test_Build_Warnings_No_TC821(self):
57 builds = Build.objects.values('id', 'warnings_no') 57 builds = Build.objects.values('id', 'warnings_no')
58 cnt_err = [] 58 cnt_err = []
59 for build in builds: 59 for build in builds:
60 log_mess_warn_no = LogMessage.objects.filter(build = build['id'], level = 1).count() 60 log_mess_warn_no = LogMessage.objects.filter(build = build['id'], level = 1).count()
61 if (build['warnings_no'] != log_mess_warn_no): 61 if (build['warnings_no'] != log_mess_warn_no):
62 cnt_err.append(build['id']) 62 cnt_err.append(build['id'])
63 self.assertEqual(len(cnt_err), 0, msg = 'Errors for build id: %s' % cnt_err) 63 self.assertEqual(len(cnt_err), 0, msg = 'Errors for build id: %s' % cnt_err)
64 64
65 # Check if the build succeeded then the errors_no is 0 - tc_id=822 65 # Check if the build succeeded then the errors_no is 0 - tc_id=822
66 def test_Build_Suceeded_Errors_No_TC822(self): 66 def test_Build_Suceeded_Errors_No_TC822(self):
67 builds = Build.objects.filter(outcome = 0).values('id', 'errors_no') 67 builds = Build.objects.filter(outcome = 0).values('id', 'errors_no')
68 cnt_err = [] 68 cnt_err = []
69 for build in builds: 69 for build in builds:
70 if (build['errors_no'] != 0): 70 if (build['errors_no'] != 0):
71 cnt_err.append(build['id']) 71 cnt_err.append(build['id'])
72 self.assertEqual(len(cnt_err), 0, msg = 'Errors for build id: %s' % cnt_err) 72 self.assertEqual(len(cnt_err), 0, msg = 'Errors for build id: %s' % cnt_err)
73 73
74 # Check if task order is unique for one build - tc=824 74 # Check if task order is unique for one build - tc=824
75 def test_Task_Unique_Order_TC824(self): 75 def test_Task_Unique_Order_TC824(self):
76 builds = builds = Build.objects.values('id') 76 builds = Build.objects.values('id')
77 cnt_err = [] 77 cnt_err = []
78 for build in builds: 78 for build in builds:
79 total_task_order = Task.objects.filter(build = build['id']).values('order').count() 79 total_task_order = Task.objects.filter(build = build['id']).values('order').count()
80 distinct_task_order = Task.objects.filter(build = build['id']).values('order').distinct().count() 80 distinct_task_order = Task.objects.filter(build = build['id']).values('order').distinct().count()
81 if (total_task_order != distinct_task_order): 81 if (total_task_order != distinct_task_order):
82 cnt_err.append(build['id']) 82 cnt_err.append(build['id'])
83 self.assertEqual(len(cnt_err), 0, msg = 'Errors for build id: %s' % cnt_err) 83 self.assertEqual(len(cnt_err), 0, msg = 'Errors for build id: %s' % cnt_err)
84 84
85 # Check task order sequence for one build - tc=825 85 # Check task order sequence for one build - tc=825
86 def test_Task_Order_Sequence_TC825(self): 86 def test_Task_Order_Sequence_TC825(self):
87 builds = builds = Build.objects.values('id') 87 builds = builds = Build.objects.values('id')
88 cnt_err = [] 88 cnt_err = []
89 for build in builds: 89 for build in builds:
90 tasks = Task.objects.filter(Q(build = build['id']), ~Q(order = None), ~Q(task_name__contains = '_setscene')).values('id', 'order').order_by("order") 90 tasks = Task.objects.filter(Q(build = build['id']), ~Q(order = None), ~Q(task_name__contains = '_setscene')).values('id', 'order').order_by("order")
91 cnt_tasks = 0 91 cnt_tasks = 0
92 for task in tasks: 92 for task in tasks:
93 cnt_tasks += 1 93 cnt_tasks += 1
94 if (task['order'] != cnt_tasks): 94 if (task['order'] != cnt_tasks):
95 cnt_err.append(task['id']) 95 cnt_err.append(task['id'])
96 self.assertEqual(len(cnt_err), 0, msg = 'Errors for task id: %s' % cnt_err) 96 self.assertEqual(len(cnt_err), 0, msg = 'Errors for task id: %s' % cnt_err)
97 97
98 # Check if disk_io matches the difference between EndTimeIO and StartTimeIO in build stats - tc=828 98 # Check if disk_io matches the difference between EndTimeIO and StartTimeIO in build stats - tc=828
99 ### this needs to be updated ### 99 ### this needs to be updated ###
@@ -101,311 +101,311 @@ class Toaster_DB_Tests(ToasterSetup):
101 101
102 # Check if outcome = 2 (SSTATE) then sstate_result must be 3 (RESTORED) - tc=832 102 # Check if outcome = 2 (SSTATE) then sstate_result must be 3 (RESTORED) - tc=832
103 def test_Task_If_Outcome_2_Sstate_Result_Must_Be_3_TC832(self): 103 def test_Task_If_Outcome_2_Sstate_Result_Must_Be_3_TC832(self):
104 tasks = Task.objects.filter(outcome = 2).values('id', 'sstate_result') 104 tasks = Task.objects.filter(outcome = 2).values('id', 'sstate_result')
105 cnt_err = [] 105 cnt_err = []
106 for task in tasks: 106 for task in tasks:
107 if (row['sstate_result'] != 3): 107 if (row['sstate_result'] != 3):
108 cnt_err.append(task['id']) 108 cnt_err.append(task['id'])
109 self.assertEqual(len(cnt_err), 0, msg = 'Errors for task id: %s' % cnt_err) 109 self.assertEqual(len(cnt_err), 0, msg = 'Errors for task id: %s' % cnt_err)
110 110
111 # Check if outcome = 1 (COVERED) or 3 (EXISTING) then sstate_result must be 0 (SSTATE_NA) - tc=833 111 # Check if outcome = 1 (COVERED) or 3 (EXISTING) then sstate_result must be 0 (SSTATE_NA) - tc=833
112 def test_Task_If_Outcome_1_3_Sstate_Result_Must_Be_0_TC833(self): 112 def test_Task_If_Outcome_1_3_Sstate_Result_Must_Be_0_TC833(self):
113 tasks = Task.objects.filter(outcome__in = (1, 3)).values('id', 'sstate_result') 113 tasks = Task.objects.filter(outcome__in = (1, 3)).values('id', 'sstate_result')
114 cnt_err = [] 114 cnt_err = []
115 for task in tasks: 115 for task in tasks:
116 if (task['sstate_result'] != 0): 116 if (task['sstate_result'] != 0):
117 cnt_err.append(task['id']) 117 cnt_err.append(task['id'])
118 self.assertEqual(len(cnt_err), 0, msg = 'Errors for task id: %s' % cnt_err) 118 self.assertEqual(len(cnt_err), 0, msg = 'Errors for task id: %s' % cnt_err)
119 119
120 # Check if outcome is 0 (SUCCESS) or 4 (FAILED) then sstate_result must be 0 (NA), 1 (MISS) or 2 (FAILED) - tc=834 120 # Check if outcome is 0 (SUCCESS) or 4 (FAILED) then sstate_result must be 0 (NA), 1 (MISS) or 2 (FAILED) - tc=834
121 def test_Task_If_Outcome_0_4_Sstate_Result_Must_Be_0_1_2_TC834(self): 121 def test_Task_If_Outcome_0_4_Sstate_Result_Must_Be_0_1_2_TC834(self):
122 tasks = Task.objects.filter(outcome__in = (0, 4)).values('id', 'sstate_result') 122 tasks = Task.objects.filter(outcome__in = (0, 4)).values('id', 'sstate_result')
123 cnt_err = [] 123 cnt_err = []
124 for task in tasks: 124 for task in tasks:
125 if (task['sstate_result'] not in [0, 1, 2]): 125 if (task['sstate_result'] not in [0, 1, 2]):
126 cnt_err.append(task['id']) 126 cnt_err.append(task['id'])
127 self.assertEqual(len(cnt_err), 0, msg = 'Errors for task id: %s' % cnt_err) 127 self.assertEqual(len(cnt_err), 0, msg = 'Errors for task id: %s' % cnt_err)
128 128
129 # Check if task_executed = TRUE (1), script_type must be 0 (CODING_NA), 2 (CODING_PYTHON), 3 (CODING_SHELL) - tc=891 129 # Check if task_executed = TRUE (1), script_type must be 0 (CODING_NA), 2 (CODING_PYTHON), 3 (CODING_SHELL) - tc=891
130 def test_Task_If_Task_Executed_True_Script_Type_0_2_3_TC891(self): 130 def test_Task_If_Task_Executed_True_Script_Type_0_2_3_TC891(self):
131 tasks = Task.objects.filter(task_executed = 1).values('id', 'script_type') 131 tasks = Task.objects.filter(task_executed = 1).values('id', 'script_type')
132 cnt_err = [] 132 cnt_err = []
133 for task in tasks: 133 for task in tasks:
134 if (task['script_type'] not in [0, 2, 3]): 134 if (task['script_type'] not in [0, 2, 3]):
135 cnt_err.append(task['id']) 135 cnt_err.append(task['id'])
136 self.assertEqual(len(cnt_err), 0, msg = 'Errors for task id: %s' % cnt_err) 136 self.assertEqual(len(cnt_err), 0, msg = 'Errors for task id: %s' % cnt_err)
137 137
138 # Check if task_executed = TRUE (1), outcome must be 0 (SUCCESS) or 4 (FAILED) - tc=836 138 # Check if task_executed = TRUE (1), outcome must be 0 (SUCCESS) or 4 (FAILED) - tc=836
139 def test_Task_If_Task_Executed_True_Outcome_0_4_TC836(self): 139 def test_Task_If_Task_Executed_True_Outcome_0_4_TC836(self):
140 tasks = Task.objects.filter(task_executed = 1).values('id', 'outcome') 140 tasks = Task.objects.filter(task_executed = 1).values('id', 'outcome')
141 cnt_err = [] 141 cnt_err = []
142 for task in tasks: 142 for task in tasks:
143 if (task['outcome'] not in [0, 4]): 143 if (task['outcome'] not in [0, 4]):
144 cnt_err.append(task['id']) 144 cnt_err.append(task['id'])
145 self.assertEqual(len(cnt_err), 0, msg = 'Errors for task id: %s' % cnt_err) 145 self.assertEqual(len(cnt_err), 0, msg = 'Errors for task id: %s' % cnt_err)
146 146
147 # Check if task_executed = FALSE (0), script_type must be 0 - tc=890 147 # Check if task_executed = FALSE (0), script_type must be 0 - tc=890
148 def test_Task_If_Task_Executed_False_Script_Type_0_TC890(self): 148 def test_Task_If_Task_Executed_False_Script_Type_0_TC890(self):
149 tasks = Task.objects.filter(task_executed = 0).values('id', 'script_type') 149 tasks = Task.objects.filter(task_executed = 0).values('id', 'script_type')
150 cnt_err = [] 150 cnt_err = []
151 for task in tasks: 151 for task in tasks:
152 if (task['script_type'] != 0): 152 if (task['script_type'] != 0):
153 cnt_err.append(task['id']) 153 cnt_err.append(task['id'])
154 self.assertEqual(len(cnt_err), 0, msg = 'Errors for task id: %s' % cnt_err) 154 self.assertEqual(len(cnt_err), 0, msg = 'Errors for task id: %s' % cnt_err)
155 155
156 # Check if task_executed = FALSE (0) and build outcome = SUCCEEDED (0), task outcome must be 1 (COVERED), 2 (CACHED), 3 (PREBUILT), 5 (EMPTY) - tc=837 156 # Check if task_executed = FALSE (0) and build outcome = SUCCEEDED (0), task outcome must be 1 (COVERED), 2 (CACHED), 3 (PREBUILT), 5 (EMPTY) - tc=837
157 def test_Task_If_Task_Executed_False_Outcome_1_2_3_5_TC837(self): 157 def test_Task_If_Task_Executed_False_Outcome_1_2_3_5_TC837(self):
158 builds = Build.objects.filter(outcome = 0).values('id') 158 builds = Build.objects.filter(outcome = 0).values('id')
159 cnt_err = [] 159 cnt_err = []
160 for build in builds: 160 for build in builds:
161 tasks = Task.objects.filter(build = build['id'], task_executed = 0).values('id', 'outcome') 161 tasks = Task.objects.filter(build = build['id'], task_executed = 0).values('id', 'outcome')
162 for task in tasks: 162 for task in tasks:
163 if (task['outcome'] not in [1, 2, 3, 5]): 163 if (task['outcome'] not in [1, 2, 3, 5]):
164 cnt_err.append(task['id']) 164 cnt_err.append(task['id'])
165 self.assertEqual(len(cnt_err), 0, msg = 'Errors for task id: %s' % cnt_err) 165 self.assertEqual(len(cnt_err), 0, msg = 'Errors for task id: %s' % cnt_err)
166 166
167 # Key verification - tc=888 167 # Key verification - tc=888
168 def test_Target_Installed_Package_TC888(self): 168 def test_Target_Installed_Package_TC888(self):
169 rows = Target_Installed_Package.objects.values('id', 'target_id', 'package_id') 169 rows = Target_Installed_Package.objects.values('id', 'target_id', 'package_id')
170 cnt_err = [] 170 cnt_err = []
171 for row in rows: 171 for row in rows:
172 target = Target.objects.filter(id = row['target_id']).values('id') 172 target = Target.objects.filter(id = row['target_id']).values('id')
173 package = Package.objects.filter(id = row['package_id']).values('id') 173 package = Package.objects.filter(id = row['package_id']).values('id')
174 if (not target or not package): 174 if (not target or not package):
175 cnt_err.append(row['id']) 175 cnt_err.append(row['id'])
176 self.assertEqual(len(cnt_err), 0, msg = 'Errors for target installed package id: %s' % cnt_err) 176 self.assertEqual(len(cnt_err), 0, msg = 'Errors for target installed package id: %s' % cnt_err)
177 177
178 # Key verification - tc=889 178 # Key verification - tc=889
179 def test_Task_Dependency_TC889(self): 179 def test_Task_Dependency_TC889(self):
180 rows = Task_Dependency.objects.values('id', 'task_id', 'depends_on_id') 180 rows = Task_Dependency.objects.values('id', 'task_id', 'depends_on_id')
181 cnt_err = [] 181 cnt_err = []
182 for row in rows: 182 for row in rows:
183 task_id = Task.objects.filter(id = row['task_id']).values('id') 183 task_id = Task.objects.filter(id = row['task_id']).values('id')
184 depends_on_id = Task.objects.filter(id = row['depends_on_id']).values('id') 184 depends_on_id = Task.objects.filter(id = row['depends_on_id']).values('id')
185 if (not task_id or not depends_on_id): 185 if (not task_id or not depends_on_id):
186 cnt_err.append(row['id']) 186 cnt_err.append(row['id'])
187 self.assertEqual(len(cnt_err), 0, msg = 'Errors for task dependency id: %s' % cnt_err) 187 self.assertEqual(len(cnt_err), 0, msg = 'Errors for task dependency id: %s' % cnt_err)
188 188
189 # Check if build target file_name is populated only if is_image=true AND orm_build.outcome=0 then if the file exists and its size matches the file_size value 189 # Check if build target file_name is populated only if is_image=true AND orm_build.outcome=0 then if the file exists and its size matches the file_size value
190 ### Need to add the tc in the test run 190 ### Need to add the tc in the test run
191 def test_Target_File_Name_Populated(self): 191 def test_Target_File_Name_Populated(self):
192 builds = Build.objects.filter(outcome = 0).values('id') 192 builds = Build.objects.filter(outcome = 0).values('id')
193 cnt_err = [] 193 for build in builds:
194 for build in builds: 194 targets = Target.objects.filter(build_id = build['id'], is_image = 1).values('id')
195 targets = Target.objects.filter(build_id = build['id'], is_image = 1).values('id') 195 for target in targets:
196 for target in targets: 196 target_files = Target_Image_File.objects.filter(target_id = target['id']).values('id', 'file_name', 'file_size')
197 target_files = Target_Image_File.objects.filter(target_id = target['id']).values('id', 'file_name', 'file_size') 197 cnt_err = []
198 for file_info in target_files: 198 for file_info in target_files:
199 target_id = file_info['id'] 199 target_id = file_info['id']
200 target_file_name = file_info['file_name'] 200 target_file_name = file_info['file_name']
201 target_file_size = file_info['file_size'] 201 target_file_size = file_info['file_size']
202 if (not target_file_name or not target_file_size): 202 if (not target_file_name or not target_file_size):
203 cnt_err.append(target_id) 203 cnt_err.append(target_id)
204 else: 204 else:
205 if (not os.path.exists(target_file_name)): 205 if (not os.path.exists(target_file_name)):
206 cnt_err.append(target_id) 206 cnt_err.append(target_id)
207 else: 207 else:
208 if (os.path.getsize(target_file_name) != target_file_size): 208 if (os.path.getsize(target_file_name) != target_file_size):
209 cnt_err.append(target_id) 209 cnt_err.append(target_id)
210 self.assertEqual(len(cnt_err), 0, msg = 'Errors for target image file id: %s' % cnt_err) 210 self.assertEqual(len(cnt_err), 0, msg = 'Errors for target image file id: %s' % cnt_err)
211 211
212 # Key verification - tc=884 212 # Key verification - tc=884
213 def test_Package_Dependency_TC884(self): 213 def test_Package_Dependency_TC884(self):
214 cnt_err = [] 214 cnt_err = []
215 deps = Package_Dependency.objects.values('id', 'package_id', 'depends_on_id') 215 deps = Package_Dependency.objects.values('id', 'package_id', 'depends_on_id')
216 for dep in deps: 216 for dep in deps:
217 if (dep['package_id'] == dep['depends_on_id']): 217 if (dep['package_id'] == dep['depends_on_id']):
218 cnt_err.append(dep['id']) 218 cnt_err.append(dep['id'])
219 self.assertEqual(len(cnt_err), 0, msg = 'Errors for package dependency id: %s' % cnt_err) 219 self.assertEqual(len(cnt_err), 0, msg = 'Errors for package dependency id: %s' % cnt_err)
220 220
221 # Check if recipe name does not start with a number (0-9) - tc=838 221 # Check if recipe name does not start with a number (0-9) - tc=838
222 def test_Recipe_Name_TC838(self): 222 def test_Recipe_Name_TC838(self):
223 recipes = Recipe.objects.values('id', 'name') 223 recipes = Recipe.objects.values('id', 'name')
224 cnt_err = [] 224 cnt_err = []
225 for recipe in recipes: 225 for recipe in recipes:
226 if (recipe['name'][0].isdigit() is True): 226 if (recipe['name'][0].isdigit() is True):
227 cnt_err.append(recipe['id']) 227 cnt_err.append(recipe['id'])
228 self.assertEqual(len(cnt_err), 0, msg = 'Errors for recipe id: %s' % cnt_err) 228 self.assertEqual(len(cnt_err), 0, msg = 'Errors for recipe id: %s' % cnt_err)
229 229
230 # Check if recipe section matches the content of the SECTION variable (if set) in file_path - tc=839 230 # Check if recipe section matches the content of the SECTION variable (if set) in file_path - tc=839
231 def test_Recipe_DB_Section_Match_Recipe_File_Section_TC839(self): 231 def test_Recipe_DB_Section_Match_Recipe_File_Section_TC839(self):
232 recipes = Recipe.objects.values('id', 'section', 'file_path') 232 recipes = Recipe.objects.values('id', 'section', 'file_path')
233 cnt_err = [] 233 cnt_err = []
234 for recipe in recipes: 234 for recipe in recipes:
235 file_path = self.fix_file_path(recipe['file_path']) 235 file_path = self.fix_file_path(recipe['file_path'])
236 file_exists = os.path.isfile(file_path) 236 file_exists = os.path.isfile(file_path)
237 if (not file_path or (file_exists is False)): 237 if (not file_path or (file_exists is False)):
238 cnt_err.append(recipe['id']) 238 cnt_err.append(recipe['id'])
239 else: 239 else:
240 file_section = self.recipe_parse(file_path, "SECTION = ") 240 file_section = self.recipe_parse(file_path, "SECTION = ")
241 db_section = recipe['section'] 241 db_section = recipe['section']
242 if file_section: 242 if file_section:
243 if (db_section != file_section): 243 if (db_section != file_section):
244 cnt_err.append(recipe['id']) 244 cnt_err.append(recipe['id'])
245 self.assertEqual(len(cnt_err), 0, msg = 'Errors for recipe id: %s' % cnt_err) 245 self.assertEqual(len(cnt_err), 0, msg = 'Errors for recipe id: %s' % cnt_err)
246 246
247 # Check if recipe license matches the content of the LICENSE variable (if set) in file_path - tc=840 247 # Check if recipe license matches the content of the LICENSE variable (if set) in file_path - tc=840
248 def test_Recipe_DB_License_Match_Recipe_File_License_TC840(self): 248 def test_Recipe_DB_License_Match_Recipe_File_License_TC840(self):
249 recipes = Recipe.objects.values('id', 'license', 'file_path') 249 recipes = Recipe.objects.values('id', 'license', 'file_path')
250 cnt_err = [] 250 cnt_err = []
251 for recipe in recipes: 251 for recipe in recipes:
252 file_path = self.fix_file_path(recipe['file_path']) 252 file_path = self.fix_file_path(recipe['file_path'])
253 file_exists = os.path.isfile(file_path) 253 file_exists = os.path.isfile(file_path)
254 if (not file_path or (file_exists is False)): 254 if (not file_path or (file_exists is False)):
255 cnt_err.append(recipe['id']) 255 cnt_err.append(recipe['id'])
256 else: 256 else:
257 file_license = self.recipe_parse(file_path, "LICENSE = ") 257 file_license = self.recipe_parse(file_path, "LICENSE = ")
258 db_license = recipe['license'] 258 db_license = recipe['license']
259 if file_license: 259 if file_license:
260 if (db_license != file_license): 260 if (db_license != file_license):
261 cnt_err.append(recipe['id']) 261 cnt_err.append(recipe['id'])
262 self.assertEqual(len(cnt_err), 0, msg = 'Errors for recipe id: %s' % cnt_err) 262 self.assertEqual(len(cnt_err), 0, msg = 'Errors for recipe id: %s' % cnt_err)
263 263
264 # Check if recipe homepage matches the content of the HOMEPAGE variable (if set) in file_path - tc=841 264 # Check if recipe homepage matches the content of the HOMEPAGE variable (if set) in file_path - tc=841
265 def test_Recipe_DB_Homepage_Match_Recipe_File_Homepage_TC841(self): 265 def test_Recipe_DB_Homepage_Match_Recipe_File_Homepage_TC841(self):
266 recipes = Recipe.objects.values('id', 'homepage', 'file_path') 266 recipes = Recipe.objects.values('id', 'homepage', 'file_path')
267 cnt_err = [] 267 cnt_err = []
268 for recipe in recipes: 268 for recipe in recipes:
269 file_path = self.fix_file_path(recipe['file_path']) 269 file_path = self.fix_file_path(recipe['file_path'])
270 file_exists = os.path.isfile(file_path) 270 file_exists = os.path.isfile(file_path)
271 if (not file_path or (file_exists is False)): 271 if (not file_path or (file_exists is False)):
272 cnt_err.append(recipe['id']) 272 cnt_err.append(recipe['id'])
273 else: 273 else:
274 file_homepage = self.recipe_parse(file_path, "HOMEPAGE = ") 274 file_homepage = self.recipe_parse(file_path, "HOMEPAGE = ")
275 db_homepage = recipe['homepage'] 275 db_homepage = recipe['homepage']
276 if file_homepage: 276 if file_homepage:
277 if (db_homepage != file_homepage): 277 if (db_homepage != file_homepage):
278 cnt_err.append(recipe['id']) 278 cnt_err.append(recipe['id'])
279 self.assertEqual(len(cnt_err), 0, msg = 'Errors for recipe id: %s' % cnt_err) 279 self.assertEqual(len(cnt_err), 0, msg = 'Errors for recipe id: %s' % cnt_err)
280 280
281 # Check if recipe bugtracker matches the content of the BUGTRACKER variable (if set) in file_path - tc=842 281 # Check if recipe bugtracker matches the content of the BUGTRACKER variable (if set) in file_path - tc=842
282 def test_Recipe_DB_Bugtracker_Match_Recipe_File_Bugtracker_TC842(self): 282 def test_Recipe_DB_Bugtracker_Match_Recipe_File_Bugtracker_TC842(self):
283 recipes = Recipe.objects.values('id', 'bugtracker', 'file_path') 283 recipes = Recipe.objects.values('id', 'bugtracker', 'file_path')
284 cnt_err = [] 284 cnt_err = []
285 for recipe in recipes: 285 for recipe in recipes:
286 file_path = self.fix_file_path(recipe['file_path']) 286 file_path = self.fix_file_path(recipe['file_path'])
287 file_exists = os.path.isfile(file_path) 287 file_exists = os.path.isfile(file_path)
288 if (not file_path or (file_exists is False)): 288 if (not file_path or (file_exists is False)):
289 cnt_err.append(recipe['id']) 289 cnt_err.append(recipe['id'])
290 else: 290 else:
291 file_bugtracker = self.recipe_parse(file_path, "BUGTRACKER = ") 291 file_bugtracker = self.recipe_parse(file_path, "BUGTRACKER = ")
292 db_bugtracker = recipe['bugtracker'] 292 db_bugtracker = recipe['bugtracker']
293 if file_bugtracker: 293 if file_bugtracker:
294 if (db_bugtracker != file_bugtracker): 294 if (db_bugtracker != file_bugtracker):
295 cnt_err.append(recipe['id']) 295 cnt_err.append(recipe['id'])
296 self.assertEqual(len(cnt_err), 0, msg = 'Errors for recipe id: %s' % cnt_err) 296 self.assertEqual(len(cnt_err), 0, msg = 'Errors for recipe id: %s' % cnt_err)
297 297
298 # Recipe key verification, recipe name does not depends on a recipe having the same name - tc=883 298 # Recipe key verification, recipe name does not depends on a recipe having the same name - tc=883
299 def test_Recipe_Dependency_TC883(self): 299 def test_Recipe_Dependency_TC883(self):
300 deps = Recipe_Dependency.objects.values('id', 'recipe_id', 'depends_on_id') 300 deps = Recipe_Dependency.objects.values('id', 'recipe_id', 'depends_on_id')
301 cnt_err = [] 301 cnt_err = []
302 for dep in deps: 302 for dep in deps:
303 if (not dep['recipe_id'] or not dep['depends_on_id']): 303 if (not dep['recipe_id'] or not dep['depends_on_id']):
304 cnt_err.append(dep['id']) 304 cnt_err.append(dep['id'])
305 else: 305 else:
306 name = Recipe.objects.filter(id = dep['recipe_id']).values('name') 306 name = Recipe.objects.filter(id = dep['recipe_id']).values('name')
307 dep_name = Recipe.objects.filter(id = dep['depends_on_id']).values('name') 307 dep_name = Recipe.objects.filter(id = dep['depends_on_id']).values('name')
308 if (name == dep_name): 308 if (name == dep_name):
309 cnt_err.append(dep['id']) 309 cnt_err.append(dep['id'])
310 self.assertEqual(len(cnt_err), 0, msg = 'Errors for recipe dependency id: %s' % cnt_err) 310 self.assertEqual(len(cnt_err), 0, msg = 'Errors for recipe dependency id: %s' % cnt_err)
311 311
312 # Check if package name does not start with a number (0-9) - tc=846 312 # Check if package name does not start with a number (0-9) - tc=846
313 def test_Package_Name_For_Number_TC846(self): 313 def test_Package_Name_For_Number_TC846(self):
314 packages = Package.objects.filter(~Q(size = -1)).values('id', 'name') 314 packages = Package.objects.filter(~Q(size = -1)).values('id', 'name')
315 cnt_err = [] 315 cnt_err = []
316 for package in packages: 316 for package in packages:
317 if (package['name'][0].isdigit() is True): 317 if (package['name'][0].isdigit() is True):
318 cnt_err.append(package['id']) 318 cnt_err.append(package['id'])
319 self.assertEqual(len(cnt_err), 0, msg = 'Errors for package id: %s' % cnt_err) 319 self.assertEqual(len(cnt_err), 0, msg = 'Errors for package id: %s' % cnt_err)
320 320
321 # Check if package version starts with a number (0-9) - tc=847 321 # Check if package version starts with a number (0-9) - tc=847
322 def test_Package_Version_Starts_With_Number_TC847(self): 322 def test_Package_Version_Starts_With_Number_TC847(self):
323 packages = Package.objects.filter(~Q(size = -1)).values('id', 'version') 323 packages = Package.objects.filter(~Q(size = -1)).values('id', 'version')
324 cnt_err = [] 324 cnt_err = []
325 for package in packages: 325 for package in packages:
326 if (package['version'][0].isdigit() is False): 326 if (package['version'][0].isdigit() is False):
327 cnt_err.append(package['id']) 327 cnt_err.append(package['id'])
328 self.assertEqual(len(cnt_err), 0, msg = 'Errors for package id: %s' % cnt_err) 328 self.assertEqual(len(cnt_err), 0, msg = 'Errors for package id: %s' % cnt_err)
329 329
330 # Check if package revision starts with 'r' - tc=848 330 # Check if package revision starts with 'r' - tc=848
331 def test_Package_Revision_Starts_With_r_TC848(self): 331 def test_Package_Revision_Starts_With_r_TC848(self):
332 packages = Package.objects.filter(~Q(size = -1)).values('id', 'revision') 332 packages = Package.objects.filter(~Q(size = -1)).values('id', 'revision')
333 cnt_err = [] 333 cnt_err = []
334 for package in packages: 334 for package in packages:
335 if (package['revision'][0].startswith("r") is False): 335 if (package['revision'][0].startswith("r") is False):
336 cnt_err.append(package['id']) 336 cnt_err.append(package['id'])
337 self.assertEqual(len(cnt_err), 0, msg = 'Errors for package id: %s' % cnt_err) 337 self.assertEqual(len(cnt_err), 0, msg = 'Errors for package id: %s' % cnt_err)
338 338
339 # Check the validity of the package build_id 339 # Check the validity of the package build_id
340 ### TC must be added in test run 340 ### TC must be added in test run
341 def test_Package_Build_Id(self): 341 def test_Package_Build_Id(self):
342 packages = Package.objects.filter(~Q(size = -1)).values('id', 'build_id') 342 packages = Package.objects.filter(~Q(size = -1)).values('id', 'build_id')
343 cnt_err = [] 343 cnt_err = []
344 for package in packages: 344 for package in packages:
345 build_id = Build.objects.filter(id = package['build_id']).values('id') 345 build_id = Build.objects.filter(id = package['build_id']).values('id')
346 if (not build_id): 346 if (not build_id):
347 cnt_err.append(package['id']) 347 cnt_err.append(package['id'])
348 self.assertEqual(len(cnt_err), 0, msg = 'Errors for package id: %s' % cnt_err) 348 self.assertEqual(len(cnt_err), 0, msg = 'Errors for package id: %s' % cnt_err)
349 349
350 # Check the validity of package recipe_id 350 # Check the validity of package recipe_id
351 ### TC must be added in test run 351 ### TC must be added in test run
352 def test_Package_Recipe_Id(self): 352 def test_Package_Recipe_Id(self):
353 packages = Package.objects.filter(~Q(size = -1)).values('id', 'recipe_id') 353 packages = Package.objects.filter(~Q(size = -1)).values('id', 'recipe_id')
354 cnt_err = [] 354 cnt_err = []
355 for package in packages: 355 for package in packages:
356 recipe_id = Recipe.objects.filter(id = package['recipe_id']).values('id') 356 recipe_id = Recipe.objects.filter(id = package['recipe_id']).values('id')
357 if (not recipe_id): 357 if (not recipe_id):
358 cnt_err.append(package['id']) 358 cnt_err.append(package['id'])
359 self.assertEqual(len(cnt_err), 0, msg = 'Errors for package id: %s' % cnt_err) 359 self.assertEqual(len(cnt_err), 0, msg = 'Errors for package id: %s' % cnt_err)
360 360
361 # Check if package installed_size field is not null 361 # Check if package installed_size field is not null
362 ### TC must be aded in test run 362 ### TC must be aded in test run
363 def test_Package_Installed_Size_Not_NULL(self): 363 def test_Package_Installed_Size_Not_NULL(self):
364 packages = Package.objects.filter(installed_size__isnull = True).values('id') 364 packages = Package.objects.filter(installed_size__isnull = True).values('id')
365 cnt_err = [] 365 cnt_err = []
366 for package in packages: 366 for package in packages:
367 cnt_err.append(package['id']) 367 cnt_err.append(package['id'])
368 self.assertEqual(len(cnt_err), 0, msg = 'Errors for package id: %s' % cnt_err) 368 self.assertEqual(len(cnt_err), 0, msg = 'Errors for package id: %s' % cnt_err)
369 369
370 # Check if all layers requests return exit code is 200 - tc=843 370 # Check if all layers requests return exit code is 200 - tc=843
371 def test_Layers_Requests_Exit_Code_TC843(self): 371 def test_Layers_Requests_Exit_Code_TC843(self):
372 layers = Layer.objects.values('id', 'layer_index_url') 372 layers = Layer.objects.values('id', 'layer_index_url')
373 cnt_err = [] 373 cnt_err = []
374 for layer in layers: 374 for layer in layers:
375 resp = urllib.urlopen(layer['layer_index_url']) 375 resp = urllib.urlopen(layer['layer_index_url'])
376 if (resp.getcode() != 200): 376 if (resp.getcode() != 200):
377 cnt_err.append(layer['id']) 377 cnt_err.append(layer['id'])
378 self.assertEqual(len(cnt_err), 0, msg = 'Errors for layer id: %s' % cnt_err) 378 self.assertEqual(len(cnt_err), 0, msg = 'Errors for layer id: %s' % cnt_err)
379 379
380 # Check if the output of bitbake-layers show_layers matches the info from database - tc=895 380 # Check if the output of bitbake-layers show_layers matches the info from database - tc=895
381 def test_Layers_Show_Layers_TC895(self): 381 def test_Layers_Show_Layers_TC895(self):
382 layers = Layer.objects.values('id', 'name', 'local_path') 382 layers = Layer.objects.values('id', 'name', 'local_path')
383 cmd = commands.getoutput('bitbake-layers show_layers') 383 cmd = commands.getoutput('bitbake-layers show_layers')
384 cnt_err = [] 384 cnt_err = []
385 for layer in layers: 385 for layer in layers:
386 if (layer['name'] or layer['local_path']) not in cmd: 386 if (layer['name'] or layer['local_path']) not in cmd:
387 cnt_err.append(layer['id']) 387 cnt_err.append(layer['id'])
388 self.assertEqual(len(cnt_err), 0, msg = 'Errors for layer id: %s' % cnt_err) 388 self.assertEqual(len(cnt_err), 0, msg = 'Errors for layer id: %s' % cnt_err)
389 389
390 # Check if django server starts regardless of the timezone set on the machine - tc=905 390 # Check if django server starts regardless of the timezone set on the machine - tc=905
391 def test_Start_Django_Timezone_TC905(self): 391 def test_Start_Django_Timezone_TC905(self):
392 current_path = os.getcwd() 392 current_path = os.getcwd()
393 zonefilelist = [] 393 zonefilelist = []
394 ZONEINFOPATH = '/usr/share/zoneinfo/' 394 ZONEINFOPATH = '/usr/share/zoneinfo/'
395 os.chdir("../bitbake/lib/toaster/") 395 os.chdir("../bitbake/lib/toaster/")
396 cnt_err = 0 396 cnt_err = 0
397 for filename in os.listdir(ZONEINFOPATH): 397 for filename in os.listdir(ZONEINFOPATH):
398 if os.path.isfile(os.path.join(ZONEINFOPATH, filename)): 398 if os.path.isfile(os.path.join(ZONEINFOPATH, filename)):
399 zonefilelist.append(filename) 399 zonefilelist.append(filename)
400 for k in range(len(zonefilelist)): 400 for k in range(len(zonefilelist)):
401 if k <= 5: 401 if k <= 5:
402 files = zonefilelist[k] 402 files = zonefilelist[k]
403 os.system("export TZ="+str(files)+"; python manage.py runserver > /dev/null 2>&1 &") 403 os.system("export TZ="+str(files)+"; python manage.py runserver > /dev/null 2>&1 &")
404 time.sleep(3) 404 time.sleep(3)
405 pid = subprocess.check_output("ps aux | grep '[/u]sr/bin/python manage.py runserver' | awk '{print $2}'", shell = True) 405 pid = subprocess.check_output("ps aux | grep '[/u]sr/bin/python manage.py runserver' | awk '{print $2}'", shell = True)
406 if pid: 406 if pid:
407 os.system("kill -9 "+str(pid)) 407 os.system("kill -9 "+str(pid))
408 else: 408 else:
409 cnt_err.append(zonefilelist[k]) 409 cnt_err.append(zonefilelist[k])
410 self.assertEqual(cnt_err, 0, msg = 'Errors django server does not start with timezone: %s' % cnt_err) 410 self.assertEqual(cnt_err, 0, msg = 'Errors django server does not start with timezone: %s' % cnt_err)
411 os.chdir(current_path) 411 os.chdir(current_path)