~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/tools/testing/kunit/kunit_tool_test.py

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /tools/testing/kunit/kunit_tool_test.py (Version linux-6.12-rc7) and /tools/testing/kunit/kunit_tool_test.py (Version linux-5.0.21)


  1 #!/usr/bin/env python3                            
  2 # SPDX-License-Identifier: GPL-2.0                
  3 #                                                 
  4 # A collection of tests for tools/testing/kuni    
  5 #                                                 
  6 # Copyright (C) 2019, Google LLC.                 
  7 # Author: Brendan Higgins <brendanhiggins@googl    
  8                                                   
  9 import unittest                                   
 10 from unittest import mock                         
 11                                                   
 12 import tempfile, shutil # Handling test_tmpdir    
 13                                                   
 14 import itertools                                  
 15 import json                                       
 16 import os                                         
 17 import signal                                     
 18 import subprocess                                 
 19 from typing import Iterable                       
 20                                                   
 21 import kunit_config                               
 22 import kunit_parser                               
 23 import kunit_kernel                               
 24 import kunit_json                                 
 25 import kunit                                      
 26                                                   
 27 test_tmpdir = ''                                  
 28 abs_test_data_dir = ''                            
 29                                                   
 30 def setUpModule():                                
 31         global test_tmpdir, abs_test_data_dir     
 32         test_tmpdir = tempfile.mkdtemp()          
 33         abs_test_data_dir = os.path.abspath(os    
 34                                                   
 35 def tearDownModule():                             
 36         shutil.rmtree(test_tmpdir)                
 37                                                   
 38 def test_data_path(path):                         
 39         return os.path.join(abs_test_data_dir,    
 40                                                   
 41 class KconfigTest(unittest.TestCase):             
 42                                                   
 43         def test_is_subset_of(self):              
 44                 kconfig0 = kunit_config.Kconfi    
 45                 self.assertTrue(kconfig0.is_su    
 46                                                   
 47                 kconfig1 = kunit_config.Kconfi    
 48                 kconfig1.add_entry('TEST', 'y'    
 49                 self.assertTrue(kconfig1.is_su    
 50                 self.assertTrue(kconfig0.is_su    
 51                 self.assertFalse(kconfig1.is_s    
 52                                                   
 53         def test_read_from_file(self):            
 54                 kconfig_path = test_data_path(    
 55                                                   
 56                 kconfig = kunit_config.parse_f    
 57                                                   
 58                 expected_kconfig = kunit_confi    
 59                 expected_kconfig.add_entry('UM    
 60                 expected_kconfig.add_entry('MM    
 61                 expected_kconfig.add_entry('TE    
 62                 expected_kconfig.add_entry('EX    
 63                 expected_kconfig.add_entry('MK    
 64                                                   
 65                 self.assertEqual(kconfig, expe    
 66                                                   
 67         def test_write_to_file(self):             
 68                 kconfig_path = os.path.join(te    
 69                                                   
 70                 expected_kconfig = kunit_confi    
 71                 expected_kconfig.add_entry('UM    
 72                 expected_kconfig.add_entry('MM    
 73                 expected_kconfig.add_entry('TE    
 74                 expected_kconfig.add_entry('EX    
 75                 expected_kconfig.add_entry('MK    
 76                                                   
 77                 expected_kconfig.write_to_file    
 78                                                   
 79                 actual_kconfig = kunit_config.    
 80                 self.assertEqual(actual_kconfi    
 81                                                   
 82 class KUnitParserTest(unittest.TestCase):         
 83         def setUp(self):                          
 84                 self.print_mock = mock.patch('    
 85                 self.addCleanup(mock.patch.sto    
 86                                                   
 87         def noPrintCallContains(self, substr:     
 88                 for call in self.print_mock.mo    
 89                         self.assertNotIn(subst    
 90                                                   
 91         def assertContains(self, needle: str,     
 92                 # Clone the iterator so we can    
 93                 copy, backup = itertools.tee(h    
 94                 for line in copy:                 
 95                         if needle in line:        
 96                                 return            
 97                 raise AssertionError(f'"{needl    
 98                                                   
 99         def test_output_isolated_correctly(sel    
100                 log_path = test_data_path('tes    
101                 with open(log_path) as file:      
102                         result = kunit_parser.    
103                 self.assertContains('TAP versi    
104                 self.assertContains('# Subtest    
105                 self.assertContains('1..2', re    
106                 self.assertContains('ok 1 - ex    
107                 self.assertContains('ok 2 - ex    
108                 self.assertContains('ok 1 - ex    
109                                                   
110         def test_output_with_prefix_isolated_c    
111                 log_path = test_data_path('tes    
112                 with open(log_path) as file:      
113                         result = kunit_parser.    
114                 self.assertContains('TAP versi    
115                 self.assertContains('# Subtest    
116                 self.assertContains('1..5', re    
117                 self.assertContains('ok 1 - ku    
118                 self.assertContains('ok 2 - ku    
119                 self.assertContains('ok 3 - ku    
120                 self.assertContains('foo bar      
121                 self.assertContains('ok 4 - ku    
122                 self.assertContains('ok 5 - ku    
123                 self.assertContains('ok 1 - ku    
124                 self.assertContains('foo bar      
125                 self.assertContains('# Subtest    
126                 self.assertContains('1..2', re    
127                 self.assertContains('ok 1 - ku    
128                                     result)       
129                 self.assertContains('ok 2 - ku    
130                                     result)       
131                 self.assertContains('ok 2 - ku    
132                 self.assertContains('# Subtest    
133                 self.assertContains('1..3', re    
134                 self.assertContains('ok 1 - st    
135                 self.assertContains('ok 2 - st    
136                 self.assertContains('ok 3 - st    
137                 self.assertContains('ok 3 - st    
138                                                   
139         def test_parse_successful_test_log(sel    
140                 all_passed_log = test_data_pat    
141                 with open(all_passed_log) as f    
142                         result = kunit_parser.    
143                 self.assertEqual(kunit_parser.    
144                 self.assertEqual(result.counts    
145                                                   
146         def test_parse_successful_nested_tests    
147                 all_passed_log = test_data_pat    
148                 with open(all_passed_log) as f    
149                         result = kunit_parser.    
150                 self.assertEqual(kunit_parser.    
151                 self.assertEqual(result.counts    
152                                                   
153         def test_kselftest_nested(self):          
154                 kselftest_log = test_data_path    
155                 with open(kselftest_log) as fi    
156                         result = kunit_parser.    
157                 self.assertEqual(kunit_parser.    
158                 self.assertEqual(result.counts    
159                                                   
160         def test_parse_failed_test_log(self):     
161                 failed_log = test_data_path('t    
162                 with open(failed_log) as file:    
163                         result = kunit_parser.    
164                 self.assertEqual(kunit_parser.    
165                 self.assertEqual(result.counts    
166                                                   
167         def test_no_header(self):                 
168                 empty_log = test_data_path('te    
169                 with open(empty_log) as file:     
170                         result = kunit_parser.    
171                                 kunit_parser.e    
172                 self.assertEqual(0, len(result    
173                 self.assertEqual(kunit_parser.    
174                 self.assertEqual(result.counts    
175                                                   
176         def test_missing_test_plan(self):         
177                 missing_plan_log = test_data_p    
178                         'missing_plan.log')       
179                 with open(missing_plan_log) as    
180                         result = kunit_parser.    
181                                 kunit_parser.e    
182                                 file.readlines    
183                 # A missing test plan is not a    
184                 self.assertEqual(result.counts    
185                 self.assertEqual(kunit_parser.    
186                                                   
187         def test_no_tests(self):                  
188                 header_log = test_data_path('t    
189                 with open(header_log) as file:    
190                         result = kunit_parser.    
191                                 kunit_parser.e    
192                 self.assertEqual(0, len(result    
193                 self.assertEqual(kunit_parser.    
194                 self.assertEqual(result.counts    
195                                                   
196         def test_no_tests_no_plan(self):          
197                 no_plan_log = test_data_path('    
198                 with open(no_plan_log) as file    
199                         result = kunit_parser.    
200                                 kunit_parser.e    
201                 self.assertEqual(0, len(result    
202                 self.assertEqual(                 
203                         kunit_parser.TestStatu    
204                         result.subtests[0].sub    
205                 self.assertEqual(result.counts    
206                                                   
207                                                   
208         def test_no_kunit_output(self):           
209                 crash_log = test_data_path('te    
210                 print_mock = mock.patch('kunit    
211                 with open(crash_log) as file:     
212                         result = kunit_parser.    
213                                 kunit_parser.e    
214                 print_mock.assert_any_call(Str    
215                 print_mock.stop()                 
216                 self.assertEqual(0, len(result    
217                 self.assertEqual(result.counts    
218                                                   
219         def test_skipped_test(self):              
220                 skipped_log = test_data_path('    
221                 with open(skipped_log) as file    
222                         result = kunit_parser.    
223                                                   
224                 # A skipped test does not fail    
225                 self.assertEqual(kunit_parser.    
226                 self.assertEqual(result.counts    
227                                                   
228         def test_skipped_all_tests(self):         
229                 skipped_log = test_data_path('    
230                 with open(skipped_log) as file    
231                         result = kunit_parser.    
232                                                   
233                 self.assertEqual(kunit_parser.    
234                 self.assertEqual(result.counts    
235                                                   
236         def test_ignores_hyphen(self):            
237                 hyphen_log = test_data_path('t    
238                 with open(hyphen_log) as file:    
239                         result = kunit_parser.    
240                                                   
241                 # A skipped test does not fail    
242                 self.assertEqual(kunit_parser.    
243                 self.assertEqual(                 
244                         "sysctl_test",            
245                         result.subtests[0].nam    
246                 self.assertEqual(                 
247                         "example",                
248                         result.subtests[1].nam    
249                                                   
250         def test_ignores_prefix_printk_time(se    
251                 prefix_log = test_data_path('t    
252                 with open(prefix_log) as file:    
253                         result = kunit_parser.    
254                 self.assertEqual(kunit_parser.    
255                 self.assertEqual('kunit-resour    
256                 self.assertEqual(result.counts    
257                                                   
258         def test_ignores_multiple_prefixes(sel    
259                 prefix_log = test_data_path('t    
260                 with open(prefix_log) as file:    
261                         result = kunit_parser.    
262                 self.assertEqual(kunit_parser.    
263                 self.assertEqual('kunit-resour    
264                 self.assertEqual(result.counts    
265                                                   
266         def test_prefix_mixed_kernel_output(se    
267                 mixed_prefix_log = test_data_p    
268                 with open(mixed_prefix_log) as    
269                         result = kunit_parser.    
270                 self.assertEqual(kunit_parser.    
271                 self.assertEqual('kunit-resour    
272                 self.assertEqual(result.counts    
273                                                   
274         def test_prefix_poundsign(self):          
275                 pound_log = test_data_path('te    
276                 with open(pound_log) as file:     
277                         result = kunit_parser.    
278                 self.assertEqual(kunit_parser.    
279                 self.assertEqual('kunit-resour    
280                 self.assertEqual(result.counts    
281                                                   
282         def test_kernel_panic_end(self):          
283                 panic_log = test_data_path('te    
284                 with open(panic_log) as file:     
285                         result = kunit_parser.    
286                 self.assertEqual(kunit_parser.    
287                 self.assertEqual('kunit-resour    
288                 self.assertGreaterEqual(result    
289                                                   
290         def test_pound_no_prefix(self):           
291                 pound_log = test_data_path('te    
292                 with open(pound_log) as file:     
293                         result = kunit_parser.    
294                 self.assertEqual(kunit_parser.    
295                 self.assertEqual('kunit-resour    
296                 self.assertEqual(result.counts    
297                                                   
298         def test_summarize_failures(self):        
299                 output = """                      
300                 KTAP version 1                    
301                 1..2                              
302                         # Subtest: all_failed_    
303                         1..2                      
304                         not ok 1 - test1          
305                         not ok 2 - test2          
306                 not ok 1 - all_failed_suite       
307                         # Subtest: some_failed    
308                         1..2                      
309                         ok 1 - test1              
310                         not ok 2 - test2          
311                 not ok 1 - some_failed_suite      
312                 """                               
313                 result = kunit_parser.parse_ru    
314                 self.assertEqual(kunit_parser.    
315                                                   
316                 self.assertEqual(kunit_parser.    
317                         'Failures: all_failed_    
318                                                   
319         def test_ktap_format(self):               
320                 ktap_log = test_data_path('tes    
321                 with open(ktap_log) as file:      
322                         result = kunit_parser.    
323                 self.assertEqual(result.counts    
324                 self.assertEqual('suite', resu    
325                 self.assertEqual('case_1', res    
326                 self.assertEqual('case_2', res    
327                                                   
328         def test_parse_subtest_header(self):      
329                 ktap_log = test_data_path('tes    
330                 with open(ktap_log) as file:      
331                         kunit_parser.parse_run    
332                 self.print_mock.assert_any_cal    
333                                                   
334         def test_parse_attributes(self):          
335                 ktap_log = test_data_path('tes    
336                 with open(ktap_log) as file:      
337                         result = kunit_parser.    
338                                                   
339                 # Test should pass with no err    
340                 self.assertEqual(result.counts    
341                 self.assertEqual(kunit_parser.    
342                                                   
343                 # Ensure suite header is parse    
344                 self.print_mock.assert_any_cal    
345                                                   
346                 # Ensure attributes in correct    
347                 self.assertContains('# module:    
348                 self.assertContains('# test.sp    
349                                                   
350         def test_show_test_output_on_failure(s    
351                 output = """                      
352                 KTAP version 1                    
353                 1..1                              
354                   Test output.                    
355                     Indented more.                
356                 not ok 1 test1                    
357                 """                               
358                 result = kunit_parser.parse_ru    
359                 self.assertEqual(kunit_parser.    
360                                                   
361                 self.print_mock.assert_any_cal    
362                 self.print_mock.assert_any_cal    
363                 self.noPrintCallContains('not     
364                                                   
365 def line_stream_from_strs(strs: Iterable[str])    
366         return kunit_parser.LineStream(enumera    
367                                                   
368 class LineStreamTest(unittest.TestCase):          
369                                                   
370         def test_basic(self):                     
371                 stream = line_stream_from_strs    
372                                                   
373                 self.assertTrue(stream, msg='S    
374                 self.assertEqual(stream.line_n    
375                 self.assertEqual(stream.peek()    
376                 self.assertEqual(stream.pop(),    
377                                                   
378                 self.assertTrue(stream, msg='S    
379                 self.assertEqual(stream.line_n    
380                 self.assertEqual(stream.peek()    
381                 self.assertEqual(stream.pop(),    
382                                                   
383                 self.assertFalse(stream, msg='    
384                 with self.assertRaisesRegex(Va    
385                         stream.pop()              
386                                                   
387         def test_is_lazy(self):                   
388                 called_times = 0                  
389                 def generator():                  
390                         nonlocal called_times     
391                         for _ in range(1,5):      
392                                 called_times +    
393                                 yield called_t    
394                                                   
395                 stream = kunit_parser.LineStre    
396                 self.assertEqual(called_times,    
397                                                   
398                 self.assertEqual(stream.pop(),    
399                 self.assertEqual(called_times,    
400                                                   
401                 self.assertEqual(stream.pop(),    
402                 self.assertEqual(called_times,    
403                                                   
404 class LinuxSourceTreeTest(unittest.TestCase):     
405                                                   
406         def setUp(self):                          
407                 mock.patch.object(signal, 'sig    
408                 self.addCleanup(mock.patch.sto    
409                                                   
410         def test_invalid_kunitconfig(self):       
411                 with self.assertRaisesRegex(ku    
412                         kunit_kernel.LinuxSour    
413                                                   
414         def test_valid_kunitconfig(self):         
415                 with tempfile.NamedTemporaryFi    
416                         kunit_kernel.LinuxSour    
417                                                   
418         def test_dir_kunitconfig(self):           
419                 with tempfile.TemporaryDirecto    
420                         with open(os.path.join    
421                                 pass              
422                         kunit_kernel.LinuxSour    
423                                                   
424         def test_multiple_kunitconfig(self):      
425                 want_kconfig = kunit_config.Kc    
426                 want_kconfig.add_entry('KUNIT'    
427                 want_kconfig.add_entry('KUNIT_    
428                                                   
429                 with tempfile.TemporaryDirecto    
430                         other = os.path.join(d    
431                         with open(os.path.join    
432                                 f.write('CONFI    
433                         with open(other, 'w')     
434                                 f.write('CONFI    
435                                 pass              
436                                                   
437                         tree = kunit_kernel.Li    
438                         self.assertTrue(want_k    
439                                                   
440                                                   
441         def test_multiple_kunitconfig_invalid(    
442                 with tempfile.TemporaryDirecto    
443                         other = os.path.join(d    
444                         with open(os.path.join    
445                                 f.write('CONFI    
446                         with open(other, 'w')     
447                                 f.write('CONFI    
448                                                   
449                         with self.assertRaises    
450                                 kunit_kernel.L    
451                                                   
452                                                   
453         def test_kconfig_add(self):               
454                 want_kconfig = kunit_config.Kc    
455                 want_kconfig.add_entry('NOT_RE    
456                                                   
457                 tree = kunit_kernel.LinuxSourc    
458                 self.assertTrue(want_kconfig.i    
459                                                   
460         def test_invalid_arch(self):              
461                 with self.assertRaisesRegex(ku    
462                         kunit_kernel.LinuxSour    
463                                                   
464         def test_run_kernel_hits_exception(sel    
465                 def fake_start(unused_args, un    
466                         return subprocess.Pope    
467                                                   
468                 with tempfile.TemporaryDirecto    
469                         tree = kunit_kernel.Li    
470                         mock.patch.object(tree    
471                                                   
472                         with self.assertRaises    
473                                 for line in tr    
474                                         self.a    
475                                         raise     
476                                                   
477                         with open(kunit_kernel    
478                                 self.assertEqu    
479                                                   
480         def test_build_reconfig_no_config(self    
481                 with tempfile.TemporaryDirecto    
482                         with open(kunit_kernel    
483                                 f.write('CONFI    
484                                                   
485                         tree = kunit_kernel.Li    
486                         # Stub out the source     
487                         # the defaults for any    
488                         # way.                    
489                         tree._ops = kunit_kern    
490                         mock_build_config = mo    
491                                                   
492                         # Should generate the     
493                         self.assertTrue(tree.b    
494                         mock_build_config.asse    
495                                                   
496         def test_build_reconfig_existing_confi    
497                 with tempfile.TemporaryDirecto    
498                         # Existing .config is     
499                         with open(kunit_kernel    
500                                 f.write('CONFI    
501                         with open(kunit_kernel    
502                                 f.write('CONFI    
503                         with open(kunit_kernel    
504                                 f.write('CONFI    
505                                                   
506                         tree = kunit_kernel.Li    
507                         # Stub out the source     
508                         # the defaults for any    
509                         # way.                    
510                         tree._ops = kunit_kern    
511                         mock_build_config = mo    
512                                                   
513                         self.assertTrue(tree.b    
514                         self.assertEqual(mock_    
515                                                   
516         def test_build_reconfig_remove_option(    
517                 with tempfile.TemporaryDirecto    
518                         # We removed CONFIG_KU    
519                         with open(kunit_kernel    
520                                 f.write('CONFI    
521                         with open(kunit_kernel    
522                                 f.write('CONFI    
523                         with open(kunit_kernel    
524                                 f.write('CONFI    
525                                                   
526                         tree = kunit_kernel.Li    
527                         # Stub out the source     
528                         # the defaults for any    
529                         # way.                    
530                         tree._ops = kunit_kern    
531                         mock_build_config = mo    
532                                                   
533                         # ... so we should tri    
534                         self.assertTrue(tree.b    
535                         mock_build_config.asse    
536                                                   
537         # TODO: add more test cases.              
538                                                   
539                                                   
540 class KUnitJsonTest(unittest.TestCase):           
541         def setUp(self):                          
542                 self.print_mock = mock.patch('    
543                 self.addCleanup(mock.patch.sto    
544                                                   
545         def _json_for(self, log_file):            
546                 with open(test_data_path(log_f    
547                         test_result = kunit_pa    
548                         json_obj = kunit_json.    
549                                 test=test_resu    
550                                 metadata=kunit    
551                 return json.loads(json_obj)       
552                                                   
553         def test_failed_test_json(self):          
554                 result = self._json_for('test_    
555                 self.assertEqual(                 
556                         {'name': 'example_simp    
557                         result["sub_groups"][1    
558                                                   
559         def test_crashed_test_json(self):         
560                 result = self._json_for('test_    
561                 self.assertEqual(                 
562                         {'name': '', 'status':    
563                         result["sub_groups"][2    
564                                                   
565         def test_skipped_test_json(self):         
566                 result = self._json_for('test_    
567                 self.assertEqual(                 
568                         {'name': 'example_skip    
569                         result["sub_groups"][1    
570                                                   
571         def test_no_tests_json(self):             
572                 result = self._json_for('test_    
573                 self.assertEqual(0, len(result    
574                                                   
575         def test_nested_json(self):               
576                 result = self._json_for('test_    
577                 self.assertEqual(                 
578                         {'name': 'example_simp    
579                         result["sub_groups"][0    
580                                                   
581 class StrContains(str):                           
582         def __eq__(self, other):                  
583                 return self in other              
584                                                   
585 class KUnitMainTest(unittest.TestCase):           
586         def setUp(self):                          
587                 path = test_data_path('test_is    
588                 with open(path) as file:          
589                         all_passed_log = file.    
590                                                   
591                 self.print_mock = mock.patch('    
592                 self.addCleanup(mock.patch.sto    
593                                                   
594                 self.mock_linux_init = mock.pa    
595                 self.linux_source_mock = self.    
596                 self.linux_source_mock.build_r    
597                 self.linux_source_mock.build_k    
598                 self.linux_source_mock.run_ker    
599                                                   
600         def test_config_passes_args_pass(self)    
601                 kunit.main(['config', '--build    
602                 self.assertEqual(self.linux_so    
603                 self.assertEqual(self.linux_so    
604                                                   
605         def test_build_passes_args_pass(self):    
606                 kunit.main(['build'])             
607                 self.assertEqual(self.linux_so    
608                 self.linux_source_mock.build_k    
609                 self.assertEqual(self.linux_so    
610                                                   
611         def test_exec_passes_args_pass(self):     
612                 kunit.main(['exec'])              
613                 self.assertEqual(self.linux_so    
614                 self.assertEqual(self.linux_so    
615                 self.linux_source_mock.run_ker    
616                         args=None, build_dir='    
617                 self.print_mock.assert_any_cal    
618                                                   
619         def test_run_passes_args_pass(self):      
620                 kunit.main(['run'])               
621                 self.assertEqual(self.linux_so    
622                 self.assertEqual(self.linux_so    
623                 self.linux_source_mock.run_ker    
624                         args=None, build_dir='    
625                 self.print_mock.assert_any_cal    
626                                                   
627         def test_exec_passes_args_fail(self):     
628                 self.linux_source_mock.run_ker    
629                 with self.assertRaises(SystemE    
630                         kunit.main(['exec'])      
631                 self.assertEqual(e.exception.c    
632                                                   
633         def test_run_passes_args_fail(self):      
634                 self.linux_source_mock.run_ker    
635                 with self.assertRaises(SystemE    
636                         kunit.main(['run'])       
637                 self.assertEqual(e.exception.c    
638                 self.assertEqual(self.linux_so    
639                 self.assertEqual(self.linux_so    
640                 self.print_mock.assert_any_cal    
641                                                   
642         def test_exec_no_tests(self):             
643                 self.linux_source_mock.run_ker    
644                 with self.assertRaises(SystemE    
645                         kunit.main(['run'])       
646                 self.assertEqual(e.exception.c    
647                 self.linux_source_mock.run_ker    
648                         args=None, build_dir='    
649                 self.print_mock.assert_any_cal    
650                                                   
651         def test_exec_raw_output(self):           
652                 self.linux_source_mock.run_ker    
653                 kunit.main(['exec', '--raw_out    
654                 self.assertEqual(self.linux_so    
655                 for call in self.print_mock.ca    
656                         self.assertNotEqual(ca    
657                         self.assertNotEqual(ca    
658                                                   
659         def test_run_raw_output(self):            
660                 self.linux_source_mock.run_ker    
661                 kunit.main(['run', '--raw_outp    
662                 self.assertEqual(self.linux_so    
663                 self.assertEqual(self.linux_so    
664                 for call in self.print_mock.ca    
665                         self.assertNotEqual(ca    
666                         self.assertNotEqual(ca    
667                                                   
668         def test_run_raw_output_kunit(self):      
669                 self.linux_source_mock.run_ker    
670                 kunit.main(['run', '--raw_outp    
671                 self.assertEqual(self.linux_so    
672                 self.assertEqual(self.linux_so    
673                 for call in self.print_mock.ca    
674                         self.assertNotEqual(ca    
675                         self.assertNotEqual(ca    
676                                                   
677         def test_run_raw_output_invalid(self):    
678                 self.linux_source_mock.run_ker    
679                 with self.assertRaises(SystemE    
680                         kunit.main(['run', '--    
681                 self.assertNotEqual(e.exceptio    
682                                                   
683         def test_run_raw_output_does_not_take_    
684                 # --raw_output is a string fla    
685                 # any positional arguments, on    
686                 self.linux_source_mock.run_ker    
687                 kunit.main(['run', '--raw_outp    
688                 self.linux_source_mock.run_ker    
689                         args=None, build_dir='    
690                                                   
691         def test_exec_timeout(self):              
692                 timeout = 3453                    
693                 kunit.main(['exec', '--timeout    
694                 self.linux_source_mock.run_ker    
695                         args=None, build_dir='    
696                 self.print_mock.assert_any_cal    
697                                                   
698         def test_run_timeout(self):               
699                 timeout = 3453                    
700                 kunit.main(['run', '--timeout'    
701                 self.assertEqual(self.linux_so    
702                 self.linux_source_mock.run_ker    
703                         args=None, build_dir='    
704                 self.print_mock.assert_any_cal    
705                                                   
706         def test_run_builddir(self):              
707                 build_dir = '.kunit'              
708                 kunit.main(['run', '--build_di    
709                 self.assertEqual(self.linux_so    
710                 self.linux_source_mock.run_ker    
711                         args=None, build_dir=b    
712                 self.print_mock.assert_any_cal    
713                                                   
714         def test_config_builddir(self):           
715                 build_dir = '.kunit'              
716                 kunit.main(['config', '--build    
717                 self.assertEqual(self.linux_so    
718                                                   
719         def test_build_builddir(self):            
720                 build_dir = '.kunit'              
721                 jobs = kunit.get_default_jobs(    
722                 kunit.main(['build', '--build_    
723                 self.linux_source_mock.build_k    
724                                                   
725         def test_exec_builddir(self):             
726                 build_dir = '.kunit'              
727                 kunit.main(['exec', '--build_d    
728                 self.linux_source_mock.run_ker    
729                         args=None, build_dir=b    
730                 self.print_mock.assert_any_cal    
731                                                   
732         def test_run_kunitconfig(self):           
733                 kunit.main(['run', '--kunitcon    
734                 # Just verify that we parsed a    
735                 self.mock_linux_init.assert_ca    
736                                                   
737                                                   
738                                                   
739                                                   
740                                                   
741                                                   
742                                                   
743         def test_config_kunitconfig(self):        
744                 kunit.main(['config', '--kunit    
745                 # Just verify that we parsed a    
746                 self.mock_linux_init.assert_ca    
747                                                   
748                                                   
749                                                   
750                                                   
751                                                   
752                                                   
753                                                   
754         def test_config_alltests(self):           
755                 kunit.main(['config', '--kunit    
756                 # Just verify that we parsed a    
757                 self.mock_linux_init.assert_ca    
758                                                   
759                                                   
760                                                   
761                                                   
762                                                   
763                                                   
764                                                   
765                                                   
766         @mock.patch.object(kunit_kernel, 'Linu    
767         def test_run_multiple_kunitconfig(self    
768                 mock_linux_init.return_value =    
769                 kunit.main(['run', '--kunitcon    
770                 # Just verify that we parsed a    
771                 mock_linux_init.assert_called_    
772                                                   
773                                                   
774                                                   
775                                                   
776                                                   
777                                                   
778                                                   
779         def test_run_kconfig_add(self):           
780                 kunit.main(['run', '--kconfig_    
781                 # Just verify that we parsed a    
782                 self.mock_linux_init.assert_ca    
783                                                   
784                                                   
785                                                   
786                                                   
787                                                   
788                                                   
789                                                   
790         def test_run_qemu_args(self):             
791                 kunit.main(['run', '--arch=x86    
792                 # Just verify that we parsed a    
793                 self.mock_linux_init.assert_ca    
794                                                   
795                                                   
796                                                   
797                                                   
798                                                   
799                                                   
800                                                   
801         def test_run_kernel_args(self):           
802                 kunit.main(['run', '--kernel_a    
803                 self.assertEqual(self.linux_so    
804                 self.linux_source_mock.run_ker    
805                       args=['a=1','b=2'], buil    
806                 self.print_mock.assert_any_cal    
807                                                   
808         def test_list_tests(self):                
809                 want = ['suite.test1', 'suite.    
810                 self.linux_source_mock.run_ker    
811                                                   
812                 got = kunit._list_tests(self.l    
813                                      kunit.Kun    
814                 self.assertEqual(got, want)       
815                 # Should respect the user's fi    
816                 self.linux_source_mock.run_ker    
817                         args=['kunit.action=li    
818                                                   
819         @mock.patch.object(kunit, '_list_tests    
820         def test_run_isolated_by_suite(self, m    
821                 mock_tests.return_value = ['su    
822                 kunit.main(['exec', '--run_iso    
823                                                   
824                 # Should respect the user's fi    
825                 mock_tests.assert_called_once_    
826                                      kunit.Kun    
827                 self.linux_source_mock.run_ker    
828                         mock.call(args=None, b    
829                         mock.call(args=None, b    
830                 ])                                
831                                                   
832         @mock.patch.object(kunit, '_list_tests    
833         def test_run_isolated_by_test(self, mo    
834                 mock_tests.return_value = ['su    
835                 kunit.main(['exec', '--run_iso    
836                                                   
837                 # Should respect the user's fi    
838                 mock_tests.assert_called_once_    
839                                      kunit.Kun    
840                 self.linux_source_mock.run_ker    
841                         mock.call(args=None, b    
842                         mock.call(args=None, b    
843                         mock.call(args=None, b    
844                 ])                                
845                                                   
846 if __name__ == '__main__':                        
847         unittest.main()                           
                                                      

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php