forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgtest_utils_test.py
executable file
·1046 lines (887 loc) · 38.5 KB
/
gtest_utils_test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/env vpython3
# Copyright 2021 The Chromium Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""Unit tests for classes in gtest_utils.py."""
import os
import unittest
import gtest_utils
from test_result_util import TestStatus
FAILURES = [
'NavigationControllerTest.Reload',
'NavigationControllerTest/SpdyNetworkTransTest.Constructor/0',
'BadTest.TimesOut', 'MoreBadTest.TimesOutAndFails',
'SomeOtherTest.SwitchTypes', 'SomeOtherTest.FAILS_ThisTestTimesOut'
]
FAILS_FAILURES = ['SomeOtherTest.FAILS_Bar']
FLAKY_FAILURES = ['SomeOtherTest.FLAKY_Baz']
CRASH_MESSAGE = ['Oops, this test crashed!']
TIMEOUT_MESSAGE = 'Killed (timed out).'
RELOAD_ERRORS = (r'C:\b\slave\chrome-release-snappy\build\chrome\browser'
r'\navigation_controller_unittest.cc:381: Failure' + """
Value of: -1
Expected: contents->controller()->GetPendingEntryIndex()
Which is: 0
""")
SPDY_ERRORS = (r'C:\b\slave\chrome-release-snappy\build\chrome\browser'
r'\navigation_controller_unittest.cc:439: Failure' + """
Value of: -1
Expected: contents->controller()->GetPendingEntryIndex()
Which is: 0
""")
SWITCH_ERRORS = (r'C:\b\slave\chrome-release-snappy\build\chrome\browser'
r'\navigation_controller_unittest.cc:615: Failure' + """
Value of: -1
Expected: contents->controller()->GetPendingEntryIndex()
Which is: 0
""" + r'C:\b\slave\chrome-release-snappy\build\chrome\browser'
r'\navigation_controller_unittest.cc:617: Failure' + """
Value of: contents->controller()->GetPendingEntry()
Actual: true
Expected: false
""")
# pylint: disable=line-too-long
TIMEOUT_ERRORS = (
'[61613:263:0531/042613:2887943745568888:ERROR:/b/slave'
'/chromium-rel-mac-builder/build/src/chrome/browser/extensions'
'/extension_error_reporter.cc(56)] Extension error: Could not load extension '
'from \'extensions/api_test/geolocation/no_permission\'. Manifest file is '
'missing or unreadable.')
MOREBAD_ERRORS = """
Value of: entry->page_type()
Actual: 2
Expected: NavigationEntry::NORMAL_PAGE
"""
TEST_DATA = (
"""
[==========] Running 7 tests from 3 test cases.
[----------] Global test environment set-up.
[----------] 1 test from HunspellTest
[ RUN ] HunspellTest.All
[ OK ] HunspellTest.All (62 ms)
[----------] 1 test from HunspellTest (62 ms total)
[----------] 4 tests from NavigationControllerTest
[ RUN ] NavigationControllerTest.Defaults
[ OK ] NavigationControllerTest.Defaults (48 ms)
[ RUN ] NavigationControllerTest.Reload
%(reload_errors)s
[ FAILED ] NavigationControllerTest.Reload (2 ms)
[ RUN ] NavigationControllerTest.Reload_GeneratesNewPage
[ OK ] NavigationControllerTest.Reload_GeneratesNewPage (22 ms)
[ RUN ] NavigationControllerTest/SpdyNetworkTransTest.Constructor/0
%(spdy_errors)s
[ FAILED ] NavigationControllerTest/SpdyNetworkTransTest.Constructor/0 (2 ms)
[----------] 4 tests from NavigationControllerTest (74 ms total)
YOU HAVE 2 FLAKY TESTS
[----------] 1 test from BadTest
[ RUN ] BadTest.TimesOut
%(timeout_errors)s
""" % {
'reload_errors': RELOAD_ERRORS,
'spdy_errors': SPDY_ERRORS,
'timeout_errors': TIMEOUT_ERRORS
} + '[0531/042642:ERROR:/b/slave/chromium-rel-mac-builder/build/src/chrome'
'/test/test_launcher/out_of_proc_test_runner.cc(79)] Test timeout (30000 ms) '
'exceeded for BadTest.TimesOut' + """
Handling SIGTERM.
Successfully wrote to shutdown pipe, resetting signal handler.
""" +
'[61613:19971:0531/042642:2887973024284693:INFO:/b/slave/chromium-rel-mac-'
'builder/build/src/chrome/browser/browser_main.cc(285)] Handling shutdown for '
'signal 15.' + """
[----------] 1 test from MoreBadTest
[ RUN ] MoreBadTest.TimesOutAndFails
%(morebad_errors)s
""" % {
'morebad_errors': MOREBAD_ERRORS
} +
'[0531/042642:ERROR:/b/slave/chromium-rel-mac-builder/build/src/chrome/test'
'/test_launcher/out_of_proc_test_runner.cc(79)] Test timeout (30000 ms) '
'exceeded for MoreBadTest.TimesOutAndFails' + """
Handling SIGTERM.
Successfully wrote to shutdown pipe, resetting signal handler.
[ FAILED ] MoreBadTest.TimesOutAndFails (31000 ms)
[----------] 5 tests from SomeOtherTest
[ RUN ] SomeOtherTest.SwitchTypes
%(switch_errors)s
[ FAILED ] SomeOtherTest.SwitchTypes (40 ms)
[ RUN ] SomeOtherTest.Foo
[ OK ] SomeOtherTest.Foo (20 ms)
[ RUN ] SomeOtherTest.FAILS_Bar
Some error message for a failing test.
[ FAILED ] SomeOtherTest.FAILS_Bar (40 ms)
[ RUN ] SomeOtherTest.FAILS_ThisTestTimesOut
""" % {
'switch_errors': SWITCH_ERRORS
} + '[0521/041343:ERROR:test_launcher.cc(384)] Test timeout (5000 ms) '
'exceeded for SomeOtherTest.FAILS_ThisTestTimesOut' + """
[ RUN ] SomeOtherTest.FLAKY_Baz
Some error message for a flaky test.
[ FAILED ] SomeOtherTest.FLAKY_Baz (40 ms)
[----------] 2 tests from SomeOtherTest (60 ms total)
[----------] Global test environment tear-down
[==========] 8 tests from 3 test cases ran. (3750 ms total)
[ PASSED ] 4 tests.
[ FAILED ] 4 tests, listed below:
[ FAILED ] NavigationControllerTest.Reload
[ FAILED ] NavigationControllerTest/SpdyNetworkTransTest.Constructor/0
[ FAILED ] SomeOtherTest.SwitchTypes
[ FAILED ] SomeOtherTest.FAILS_ThisTestTimesOut
1 FAILED TEST
YOU HAVE 10 DISABLED TESTS
YOU HAVE 2 FLAKY TESTS
program finished with exit code 1
""")
TEST_DATA_CRASH = """
[==========] Running 7 tests from 3 test cases.
[----------] Global test environment set-up.
[----------] 1 test from HunspellTest
[ RUN ] HunspellTest.Crashes
Oops, this test crashed!
"""
TEST_DATA_MIXED_STDOUT = """
[==========] Running 3 tests from 3 test cases.
[----------] Global test environment set-up.
[----------] 1 tests from WebSocketHandshakeHandlerSpdy3Test
[ RUN ] WebSocketHandshakeHandlerSpdy3Test.RequestResponse
[ OK ] WebSocketHandshakeHandlerSpdy3Test.RequestResponse (1 ms)
[----------] 1 tests from WebSocketHandshakeHandlerSpdy3Test (1 ms total)
[----------] 1 test from URLRequestTestFTP
[ RUN ] URLRequestTestFTP.UnsafePort
FTP server started on port 32841...
sending server_data: {"host": "127.0.0.1", "port": 32841} (36 bytes)
starting FTP server[ OK ] URLRequestTestFTP.UnsafePort (300 ms)
[----------] 1 test from URLRequestTestFTP (300 ms total)
[ RUN ] TestFix.TestCase
[1:2/3:WARNING:extension_apitest.cc(169)] Workaround for 177163,
prematurely stopping test
[ OK ] X (1000ms total)
[----------] 1 test from Crash
[ RUN ] Crash.Test
Oops, this test crashed!
"""
TEST_DATA_SKIPPED = """
[==========] Running 1 test from 1 test suite.
[----------] Global test environment set-up.
[----------] 1 test from ProcessReaderLinux
[ RUN ] ProcessReaderLinux.AbortMessage
../../third_party/crashpad/crashpad/snapshot/linux/process_reader_linux_test.cc:842: Skipped
Stack trace:
#00 pc 0x00000000002350b7 /data/local/tmp/crashpad_tests__dist/crashpad_tests
#01 pc 0x0000000000218183 /data/local/tmp/crashpad_tests__dist/crashpad_tests
[ SKIPPED ] ProcessReaderLinux.AbortMessage (1 ms)
[----------] 1 test from ProcessReaderLinux (2 ms total)
[----------] Global test environment tear-down
[==========] 1 test from 1 test suite ran. (2 ms total)
[ PASSED ] 0 tests.
[ SKIPPED ] 1 test, listed below:
[ SKIPPED ] ProcessReaderLinux.AbortMessage
"""
VALGRIND_HASH = 'B254345E4D3B6A00'
VALGRIND_REPORT = """Leak_DefinitelyLost
1 (1 direct, 0 indirect) bytes in 1 blocks are lost in loss record 1 of 1
operator new(unsigned long) (m_replacemalloc/vg_replace_malloc.c:1140)
content::NavigationControllerTest_Reload::TestBody() (a/b/c/d.cc:1150)
Suppression (error hash=#%(hash)s#):
{
<insert_a_suppression_name_here>
Memcheck:Leak
fun:_Znw*
fun:_ZN31NavigationControllerTest_Reload8TestBodyEv
}""" % {
'hash': VALGRIND_HASH
}
TEST_DATA_VALGRIND = """
[==========] Running 5 tests from 2 test cases.
[----------] Global test environment set-up.
[----------] 1 test from HunspellTest
[ RUN ] HunspellTest.All
[ OK ] HunspellTest.All (62 ms)
[----------] 1 test from HunspellTest (62 ms total)
[----------] 4 tests from NavigationControllerTest
[ RUN ] NavigationControllerTest.Defaults
[ OK ] NavigationControllerTest.Defaults (48 ms)
[ RUN ] NavigationControllerTest.Reload
[ OK ] NavigationControllerTest.Reload (2 ms)
[ RUN ] NavigationControllerTest.Reload_GeneratesNewPage
[ OK ] NavigationControllerTest.Reload_GeneratesNewPage (22 ms)
[ RUN ] NavigationControllerTest/SpdyNetworkTransTest.Constructor/0
[ OK ] NavigationControllerTest/SpdyNetworkTransTest.Constructor/0 (2 ms)
[----------] 4 tests from NavigationControllerTest (74 ms total)
[----------] Global test environment tear-down
[==========] 5 tests from 1 test cases ran. (136 ms total)
[ PASSED ] 5 tests.
### BEGIN MEMORY TOOL REPORT (error hash=#%(hash)s#)
%(report)s
### END MEMORY TOOL REPORT (error hash=#%(hash)s#)
program finished with exit code 255
""" % {
'report': VALGRIND_REPORT,
'hash': VALGRIND_HASH
}
FAILING_TESTS_OUTPUT = """
Failing tests:
ChromeRenderViewTest.FAILS_AllowDOMStorage
PrerenderBrowserTest.PrerenderHTML5VideoJs
"""
FAILING_TESTS_EXPECTED = [
'ChromeRenderViewTest.FAILS_AllowDOMStorage',
'PrerenderBrowserTest.PrerenderHTML5VideoJs'
]
TEST_DATA_SHARD_0 = (
"""Note: This is test shard 1 of 30.
[==========] Running 6 tests from 3 test cases.
[----------] Global test environment set-up.
[----------] 1 test from HunspellTest
[ RUN ] HunspellTest.All
[ OK ] HunspellTest.All (62 ms)
[----------] 1 test from HunspellTest (62 ms total)
[----------] 1 test from BadTest
[ RUN ] BadTest.TimesOut
%(timeout_errors)s
""" % {
'timeout_errors': TIMEOUT_ERRORS
} +
'[0531/042642:ERROR:/b/slave/chromium-rel-mac-builder/build/src/chrome/test'
'/test_launcher/out_of_proc_test_runner.cc(79)] Test timeout (30000 ms) '
'exceeded for BadTest.TimesOut' + """
Handling SIGTERM.
Successfully wrote to shutdown pipe, resetting signal handler.
""" +
'[61613:19971:0531/042642:2887973024284693:INFO:/b/slave/chromium-rel-mac-'
'builder/build/src/chrome/browser/browser_main.cc(285)] Handling shutdown for '
'signal 15.' + """
[----------] 4 tests from SomeOtherTest
[ RUN ] SomeOtherTest.SwitchTypes
%(switch_errors)s
[ FAILED ] SomeOtherTest.SwitchTypes (40 ms)
[ RUN ] SomeOtherTest.Foo
[ OK ] SomeOtherTest.Foo (20 ms)
[ RUN ] SomeOtherTest.FAILS_Bar
Some error message for a failing test.
[ FAILED ] SomeOtherTest.FAILS_Bar (40 ms)
[ RUN ] SomeOtherTest.FAILS_ThisTestTimesOut
""" % {
'switch_errors': SWITCH_ERRORS
} +
'[0521/041343:ERROR:test_launcher.cc(384)] Test timeout (5000 ms) exceeded '
'for SomeOtherTest.FAILS_ThisTestTimesOut' + """
[ RUN ] SomeOtherTest.FLAKY_Baz
Some error message for a flaky test.
[ FAILED ] SomeOtherTest.FLAKY_Baz (40 ms)
[----------] 2 tests from SomeOtherTest (60 ms total)
[----------] Global test environment tear-down
[==========] 7 tests from 3 test cases ran. (3750 ms total)
[ PASSED ] 5 tests.
[ FAILED ] 2 test, listed below:
[ FAILED ] SomeOtherTest.SwitchTypes
[ FAILED ] SomeOtherTest.FAILS_ThisTestTimesOut
1 FAILED TEST
YOU HAVE 10 DISABLED TESTS
YOU HAVE 2 FLAKY TESTS
""")
TEST_DATA_SHARD_1 = (
"""Note: This is test shard 13 of 30.
[==========] Running 5 tests from 2 test cases.
[----------] Global test environment set-up.
[----------] 4 tests from NavigationControllerTest
[ RUN ] NavigationControllerTest.Defaults
[ OK ] NavigationControllerTest.Defaults (48 ms)
[ RUN ] NavigationControllerTest.Reload
%(reload_errors)s
[ FAILED ] NavigationControllerTest.Reload (2 ms)
[ RUN ] NavigationControllerTest.Reload_GeneratesNewPage
[ OK ] NavigationControllerTest.Reload_GeneratesNewPage (22 ms)
[ RUN ] NavigationControllerTest/SpdyNetworkTransTest.Constructor/0
%(spdy_errors)s
""" % {
'reload_errors': RELOAD_ERRORS,
'spdy_errors': SPDY_ERRORS
} + '[ FAILED ] NavigationControllerTest/SpdyNetworkTransTest.Constructor'
'/0 (2 ms)' + """
[----------] 4 tests from NavigationControllerTest (74 ms total)
YOU HAVE 2 FLAKY TESTS
[----------] 1 test from MoreBadTest
[ RUN ] MoreBadTest.TimesOutAndFails
%(morebad_errors)s
""" % {
'morebad_errors': MOREBAD_ERRORS
} +
'[0531/042642:ERROR:/b/slave/chromium-rel-mac-builder/build/src/chrome/test'
'/test_launcher/out_of_proc_test_runner.cc(79)] Test timeout (30000 ms) '
'exceeded for MoreBadTest.TimesOutAndFails' + """
Handling SIGTERM.
Successfully wrote to shutdown pipe, resetting signal handler.
[ FAILED ] MoreBadTest.TimesOutAndFails (31000 ms)
[----------] Global test environment tear-down
[==========] 5 tests from 2 test cases ran. (3750 ms total)
[ PASSED ] 3 tests.
[ FAILED ] 2 tests, listed below:
[ FAILED ] NavigationControllerTest.Reload
[ FAILED ] NavigationControllerTest/SpdyNetworkTransTest.Constructor/0
1 FAILED TEST
YOU HAVE 10 DISABLED TESTS
YOU HAVE 2 FLAKY TESTS
""")
TEST_DATA_SHARD_EXIT = 'program finished with exit code '
TEST_DATA_CRASH_SHARD = """Note: This is test shard 5 of 5.
[==========] Running 7 tests from 3 test cases.
[----------] Global test environment set-up.
[----------] 1 test from HunspellTest
[ RUN ] HunspellTest.Crashes
Oops, this test crashed!"""
TEST_DATA_NESTED_RUNS = (
"""
[ 1/3] 1.0s Foo.Bar (45.5s)
Note: Google Test filter = Foo.Bar
[==========] Running 1 test from 1 test case.
[----------] Global test environment set-up.
[----------] 1 test from Foo, where TypeParam =
[ RUN ] Foo.Bar
""" +
'[0725/050653:ERROR:test_launcher.cc(380)] Test timeout (45000 ms) exceeded '
'for Foo.Bar' + """
Starting tests...
IMPORTANT DEBUGGING NOTE: each test is run inside its own process.
For debugging a test inside a debugger, use the
--gtest_filter=<your_test_name> flag along with either
--single_process (to run all tests in one launcher/browser process) or
--single-process (to do the above, and also run Chrome in single-
process mode).
1 test run
1 test failed (0 ignored)
Failing tests:
Foo.Bar
[ 2/2] 2.00s Foo.Pass (1.0s)""")
# Data generated with run_test_case.py
TEST_DATA_RUN_TEST_CASE_FAIL = """
[ 6/422] 7.45s SUIDSandboxUITest.testSUIDSandboxEnabled (1.49s) - retry #2
[ RUN ] SUIDSandboxUITest.testSUIDSandboxEnabled
[ FAILED ] SUIDSandboxUITest.testSUIDSandboxEnabled (771 ms)
[ 8/422] 7.76s PrintPreviewWebUITest.SourceIsPDFShowFitToPageOption (1.67s)
"""
TEST_DATA_RUN_TEST_CASE_TIMEOUT = """
[ 6/422] 7.45s SUIDSandboxUITest.testSUIDSandboxEnabled (1.49s) - retry #2
[ RUN ] SUIDSandboxUITest.testSUIDSandboxEnabled
(junk)
[ 8/422] 7.76s PrintPreviewWebUITest.SourceIsPDFShowFitToPageOption (1.67s)
"""
# Data generated by swarming.py
TEST_DATA_SWARM_TEST_FAIL = """
================================================================
Begin output from shard index 0 (machine tag: swarm12.c, id: swarm12)
================================================================
[==========] Running 2 tests from linux_swarm_trigg-8-base_unittests test run.
Starting tests (using 2 parallel jobs)...
IMPORTANT DEBUGGING NOTE: batches of tests are run inside their
own process. For debugging a test inside a debugger, use the
--gtest_filter=<your_test_name> flag along with
--single-process-tests.
[1/1242] HistogramDeathTest.BadRangesTest (62 ms)
[2/1242] OutOfMemoryDeathTest.New (22 ms)
[1242/1242] ThreadIdNameManagerTest.ThreadNameInterning (0 ms)
Retrying 1 test (retry #1)
[ RUN ] PickleTest.EncodeDecode
../../base/pickle_unittest.cc:69: Failure
Value of: false
Actual: false
Expected: true
[ FAILED ] PickleTest.EncodeDecode (0 ms)
[1243/1243] PickleTest.EncodeDecode (0 ms)
Retrying 1 test (retry #2)
[ RUN ] PickleTest.EncodeDecode
../../base/pickle_unittest.cc:69: Failure
Value of: false
Actual: false
Expected: true
[ FAILED ] PickleTest.EncodeDecode (1 ms)
[1244/1244] PickleTest.EncodeDecode (1 ms)
Retrying 1 test (retry #3)
[ RUN ] PickleTest.EncodeDecode
../../base/pickle_unittest.cc:69: Failure
Value of: false
Actual: false
Expected: true
[ FAILED ] PickleTest.EncodeDecode (0 ms)
[1245/1245] PickleTest.EncodeDecode (0 ms)
1245 tests run
1 test failed:
PickleTest.EncodeDecode
Summary of all itest iterations:
1 test failed:
PickleTest.EncodeDecode
End of the summary.
Tests took 31 seconds.
================================================================
End output from shard index 0 (machine tag: swarm12.c, id: swarm12). Return 1
================================================================
"""
TEST_DATA_COMPILED_FILE = """
Testing started
Wrote compiled tests to file: test_data/compiled_tests.json
[----------] 1 tests from test1
[ RUN ] test1.test_method1
[ OK ] test1.test_method1 (5 ms)
[----------] 1 tests from test1 (5 ms total)
"""
COMPILED_FILE_PATH = 'test_data/compiled_tests.json'
TEST_REPO = 'https://test'
# pylint: enable=line-too-long
class TestGTestLogParserTests(unittest.TestCase):
def testGTestLogParserNoSharding(self):
# Tests for log parsing without sharding.
parser = gtest_utils.GTestLogParser()
for line in TEST_DATA.splitlines():
parser.ProcessLine(line)
parser.Finalize()
self.assertEqual(0, len(parser.ParsingErrors()))
self.assertFalse(parser.RunningTests())
self.assertEqual(sorted(FAILURES), sorted(parser.FailedTests()))
self.assertEqual(
sorted(FAILURES + FAILS_FAILURES),
sorted(parser.FailedTests(include_fails=True)))
self.assertEqual(
sorted(FAILURES + FLAKY_FAILURES),
sorted(parser.FailedTests(include_flaky=True)))
self.assertEqual(
sorted(FAILURES + FAILS_FAILURES + FLAKY_FAILURES),
sorted(parser.FailedTests(include_fails=True, include_flaky=True)))
self.assertEqual(10, parser.DisabledTests())
self.assertEqual(2, parser.FlakyTests())
test_name = 'NavigationControllerTest.Reload'
self.assertEqual('\n'.join(['%s: ' % test_name, RELOAD_ERRORS]),
'\n'.join(parser.FailureDescription(test_name)))
self.assertEqual(['FAILURE'], parser.TriesForTest(test_name))
test_name = 'NavigationControllerTest/SpdyNetworkTransTest.Constructor/0'
self.assertEqual('\n'.join(['%s: ' % test_name, SPDY_ERRORS]),
'\n'.join(parser.FailureDescription(test_name)))
self.assertEqual(['FAILURE'], parser.TriesForTest(test_name))
test_name = 'SomeOtherTest.SwitchTypes'
self.assertEqual('\n'.join(['%s: ' % test_name, SWITCH_ERRORS]),
'\n'.join(parser.FailureDescription(test_name)))
self.assertEqual(['FAILURE'], parser.TriesForTest(test_name))
test_name = 'BadTest.TimesOut'
self.assertEqual(
'\n'.join(['%s: ' % test_name, TIMEOUT_ERRORS, TIMEOUT_MESSAGE]),
'\n'.join(parser.FailureDescription(test_name)))
self.assertEqual(['TIMEOUT'], parser.TriesForTest(test_name))
test_name = 'MoreBadTest.TimesOutAndFails'
self.assertEqual(
'\n'.join(['%s: ' % test_name, MOREBAD_ERRORS, TIMEOUT_MESSAGE]),
'\n'.join(parser.FailureDescription(test_name)))
self.assertEqual(['TIMEOUT'], parser.TriesForTest(test_name))
self.assertEqual(['SUCCESS'], parser.TriesForTest('SomeOtherTest.Foo'))
# Same unit tests (when applicable) using ResultCollection
collection = parser.GetResultCollection()
self.assertEqual(
sorted(FAILURES + FAILS_FAILURES + FLAKY_FAILURES),
sorted(collection.never_expected_tests()))
self.assertEqual(len(collection.test_results), 12)
# To know that each condition branch in for loop is covered.
cover_set = set()
for test_result in collection.test_results:
name = test_result.name
if name == 'NavigationControllerTest.Reload':
cover_set.add(name)
self.assertEqual('\n'.join([RELOAD_ERRORS]), test_result.test_log)
self.assertEqual(TestStatus.FAIL, test_result.status)
self.assertEqual(2, test_result.duration)
if name == 'NavigationControllerTest/SpdyNetworkTransTest.Constructor/0':
cover_set.add(name)
self.assertEqual('\n'.join([SPDY_ERRORS]), test_result.test_log)
self.assertEqual(TestStatus.FAIL, test_result.status)
self.assertEqual(2, test_result.duration)
if name == 'SomeOtherTest.SwitchTypes':
cover_set.add(name)
self.assertEqual('\n'.join([SWITCH_ERRORS]), test_result.test_log)
self.assertEqual(TestStatus.FAIL, test_result.status)
self.assertEqual(40, test_result.duration)
if name == 'BadTest.TimesOut':
cover_set.add(name)
self.assertEqual('\n'.join([TIMEOUT_ERRORS, TIMEOUT_MESSAGE]),
test_result.test_log)
self.assertEqual(TestStatus.ABORT, test_result.status)
self.assertEqual(None, test_result.duration)
if name == 'MoreBadTest.TimesOutAndFails':
cover_set.add(name)
self.assertEqual('\n'.join([MOREBAD_ERRORS, TIMEOUT_MESSAGE]),
test_result.test_log)
self.assertEqual(TestStatus.ABORT, test_result.status)
self.assertEqual(None, test_result.duration)
if name == 'SomeOtherTest.Foo':
cover_set.add(name)
self.assertEqual('', test_result.test_log)
self.assertEqual(TestStatus.PASS, test_result.status)
self.assertEqual(20, test_result.duration)
test_list = [
'BadTest.TimesOut', 'MoreBadTest.TimesOutAndFails',
'NavigationControllerTest.Reload',
'NavigationControllerTest/SpdyNetworkTransTest.Constructor/0',
'SomeOtherTest.Foo', 'SomeOtherTest.SwitchTypes'
]
self.assertEqual(sorted(test_list), sorted(cover_set))
parser = gtest_utils.GTestLogParser()
for line in TEST_DATA_CRASH.splitlines():
parser.ProcessLine(line)
parser.Finalize()
self.assertEqual(0, len(parser.ParsingErrors()))
self.assertTrue(parser.RunningTests())
self.assertEqual(['HunspellTest.Crashes'], parser.FailedTests())
self.assertEqual(0, parser.DisabledTests())
self.assertEqual(0, parser.FlakyTests())
test_name = 'HunspellTest.Crashes'
expected_log_lines = [
'Did not complete.',
'Potential test logs from crash until the end of test program:'
] + CRASH_MESSAGE
self.assertEqual('\n'.join(['%s: ' % test_name] + expected_log_lines),
'\n'.join(parser.FailureDescription(test_name)))
self.assertEqual(['UNKNOWN'], parser.TriesForTest(test_name))
collection = parser.GetResultCollection()
self.assertEqual(
set(['HunspellTest.Crashes']), collection.unexpected_tests())
for result in collection.test_results:
covered = False
if result.name == 'HunspellTest.Crashes':
covered = True
self.assertEqual('\n'.join(expected_log_lines), result.test_log)
self.assertEqual(TestStatus.CRASH, result.status)
self.assertTrue(covered)
def testGTestLogParserSharding(self):
# Same tests for log parsing with sharding_supervisor.
parser = gtest_utils.GTestLogParser()
test_data_shard = TEST_DATA_SHARD_0 + TEST_DATA_SHARD_1
for line in test_data_shard.splitlines():
parser.ProcessLine(line)
parser.ProcessLine(TEST_DATA_SHARD_EXIT + '2')
parser.Finalize()
self.assertEqual(0, len(parser.ParsingErrors()))
self.assertFalse(parser.RunningTests())
self.assertEqual(sorted(FAILURES), sorted(parser.FailedTests()))
self.assertEqual(
sorted(FAILURES + FAILS_FAILURES),
sorted(parser.FailedTests(include_fails=True)))
self.assertEqual(
sorted(FAILURES + FLAKY_FAILURES),
sorted(parser.FailedTests(include_flaky=True)))
self.assertEqual(
sorted(FAILURES + FAILS_FAILURES + FLAKY_FAILURES),
sorted(parser.FailedTests(include_fails=True, include_flaky=True)))
self.assertEqual(10, parser.DisabledTests())
self.assertEqual(2, parser.FlakyTests())
test_name = 'NavigationControllerTest.Reload'
self.assertEqual('\n'.join(['%s: ' % test_name, RELOAD_ERRORS]),
'\n'.join(parser.FailureDescription(test_name)))
self.assertEqual(['FAILURE'], parser.TriesForTest(test_name))
test_name = ('NavigationControllerTest/SpdyNetworkTransTest.Constructor/0')
self.assertEqual('\n'.join(['%s: ' % test_name, SPDY_ERRORS]),
'\n'.join(parser.FailureDescription(test_name)))
self.assertEqual(['FAILURE'], parser.TriesForTest(test_name))
test_name = 'SomeOtherTest.SwitchTypes'
self.assertEqual('\n'.join(['%s: ' % test_name, SWITCH_ERRORS]),
'\n'.join(parser.FailureDescription(test_name)))
self.assertEqual(['FAILURE'], parser.TriesForTest(test_name))
test_name = 'BadTest.TimesOut'
self.assertEqual(
'\n'.join(['%s: ' % test_name, TIMEOUT_ERRORS, TIMEOUT_MESSAGE]),
'\n'.join(parser.FailureDescription(test_name)))
self.assertEqual(['TIMEOUT'], parser.TriesForTest(test_name))
test_name = 'MoreBadTest.TimesOutAndFails'
self.assertEqual(
'\n'.join(['%s: ' % test_name, MOREBAD_ERRORS, TIMEOUT_MESSAGE]),
'\n'.join(parser.FailureDescription(test_name)))
self.assertEqual(['TIMEOUT'], parser.TriesForTest(test_name))
self.assertEqual(['SUCCESS'], parser.TriesForTest('SomeOtherTest.Foo'))
# Same unit tests (when applicable) using ResultCollection
collection = parser.GetResultCollection()
self.assertEqual(
sorted(FAILURES + FAILS_FAILURES + FLAKY_FAILURES),
sorted(collection.never_expected_tests()))
self.assertEqual(len(collection.test_results), 12)
# To know that each condition branch in for loop is covered.
cover_set = set()
for test_result in collection.test_results:
name = test_result.name
if name == 'NavigationControllerTest.Reload':
cover_set.add(name)
self.assertEqual('\n'.join([RELOAD_ERRORS]), test_result.test_log)
self.assertEqual(TestStatus.FAIL, test_result.status)
self.assertEqual(2, test_result.duration)
if name == 'NavigationControllerTest/SpdyNetworkTransTest.Constructor/0':
cover_set.add(name)
self.assertEqual('\n'.join([SPDY_ERRORS]), test_result.test_log)
self.assertEqual(TestStatus.FAIL, test_result.status)
self.assertEqual(2, test_result.duration)
if name == 'SomeOtherTest.SwitchTypes':
cover_set.add(name)
self.assertEqual('\n'.join([SWITCH_ERRORS]), test_result.test_log)
self.assertEqual(TestStatus.FAIL, test_result.status)
self.assertEqual(40, test_result.duration)
if name == 'BadTest.TimesOut':
cover_set.add(name)
self.assertEqual('\n'.join([TIMEOUT_ERRORS, TIMEOUT_MESSAGE]),
test_result.test_log)
self.assertEqual(TestStatus.ABORT, test_result.status)
self.assertEqual(None, test_result.duration)
if name == 'MoreBadTest.TimesOutAndFails':
cover_set.add(name)
self.assertEqual('\n'.join([MOREBAD_ERRORS, TIMEOUT_MESSAGE]),
test_result.test_log)
self.assertEqual(TestStatus.ABORT, test_result.status)
self.assertEqual(None, test_result.duration)
if name == 'SomeOtherTest.Foo':
cover_set.add(name)
self.assertEqual('', test_result.test_log)
self.assertEqual(TestStatus.PASS, test_result.status)
test_list = [
'BadTest.TimesOut', 'MoreBadTest.TimesOutAndFails',
'NavigationControllerTest.Reload',
'NavigationControllerTest/SpdyNetworkTransTest.Constructor/0',
'SomeOtherTest.Foo', 'SomeOtherTest.SwitchTypes'
]
self.assertEqual(sorted(test_list), sorted(cover_set))
parser = gtest_utils.GTestLogParser()
for line in TEST_DATA_CRASH.splitlines():
parser.ProcessLine(line)
parser.Finalize()
self.assertEqual(0, len(parser.ParsingErrors()))
self.assertTrue(parser.RunningTests())
self.assertEqual(['HunspellTest.Crashes'], parser.FailedTests())
self.assertEqual(0, parser.DisabledTests())
self.assertEqual(0, parser.FlakyTests())
test_name = 'HunspellTest.Crashes'
expected_log_lines = [
'Did not complete.',
'Potential test logs from crash until the end of test program:'
] + CRASH_MESSAGE
self.assertEqual('\n'.join(['%s: ' % test_name] + expected_log_lines),
'\n'.join(parser.FailureDescription(test_name)))
self.assertEqual(['UNKNOWN'], parser.TriesForTest(test_name))
collection = parser.GetResultCollection()
self.assertEqual(
set(['HunspellTest.Crashes']), collection.unexpected_tests())
for result in collection.test_results:
covered = False
if result.name == 'HunspellTest.Crashes':
covered = True
self.assertEqual('\n'.join(expected_log_lines), result.test_log)
self.assertEqual(TestStatus.CRASH, result.status)
self.assertTrue(covered)
def testGTestLogParserMixedStdout(self):
parser = gtest_utils.GTestLogParser()
for line in TEST_DATA_MIXED_STDOUT.splitlines():
parser.ProcessLine(line)
parser.Finalize()
self.assertEqual([], parser.ParsingErrors())
self.assertEqual(['Crash.Test'], parser.RunningTests())
self.assertEqual(['TestFix.TestCase', 'Crash.Test'], parser.FailedTests())
self.assertEqual(0, parser.DisabledTests())
self.assertEqual(0, parser.FlakyTests())
self.assertEqual(['UNKNOWN'], parser.TriesForTest('Crash.Test'))
self.assertEqual(['TIMEOUT'], parser.TriesForTest('TestFix.TestCase'))
self.assertEqual(['SUCCESS'],
parser.TriesForTest(
'WebSocketHandshakeHandlerSpdy3Test.RequestResponse'))
# Same unit tests (when applicable) using ResultCollection
collection = parser.GetResultCollection()
self.assertEqual(
sorted(['TestFix.TestCase', 'Crash.Test']),
sorted(collection.never_expected_tests()))
# To know that each condition branch in for loop is covered.
cover_set = set()
for test_result in collection.test_results:
name = test_result.name
if name == 'Crash.Test':
cover_set.add(name)
self.assertEqual(TestStatus.CRASH, test_result.status)
if name == 'TestFix.TestCase':
cover_set.add(name)
self.assertEqual(TestStatus.ABORT, test_result.status)
if name == 'WebSocketHandshakeHandlerSpdy3Test.RequestResponse':
cover_set.add(name)
self.assertEqual(TestStatus.PASS, test_result.status)
self.assertEqual(1, test_result.duration)
test_list = [
'Crash.Test', 'TestFix.TestCase',
'WebSocketHandshakeHandlerSpdy3Test.RequestResponse'
]
self.assertEqual(test_list, sorted(cover_set))
def testGtestLogParserSkipped(self):
parser = gtest_utils.GTestLogParser()
for line in TEST_DATA_SKIPPED.splitlines():
parser.ProcessLine(line)
parser.Finalize()
self.assertEqual([], parser.ParsingErrors())
self.assertEqual([], parser.RunningTests())
self.assertEqual([], parser.FailedTests())
self.assertEqual(['ProcessReaderLinux.AbortMessage'], parser.SkippedTests())
self.assertEqual(0, parser.DisabledTests())
self.assertEqual(0, parser.FlakyTests())
self.assertEqual(['SKIPPED'],
parser.TriesForTest('ProcessReaderLinux.AbortMessage'))
# Same unit tests (when applicable) using ResultCollection
collection = parser.GetResultCollection()
self.assertEqual(['ProcessReaderLinux.AbortMessage'],
sorted(
collection.tests_by_expression(lambda tr: tr.status ==
TestStatus.SKIP)))
self.assertEqual([], sorted(collection.unexpected_tests()))
covered = False
for test_result in collection.test_results:
if test_result.name == 'ProcessReaderLinux.AbortMessage':
covered = True
self.assertEqual(TestStatus.SKIP, test_result.status)
self.assertTrue(covered)
def testRunTestCaseFail(self):
parser = gtest_utils.GTestLogParser()
for line in TEST_DATA_RUN_TEST_CASE_FAIL.splitlines():
parser.ProcessLine(line)
parser.Finalize()
self.assertEqual(0, len(parser.ParsingErrors()))
self.assertEqual([], parser.RunningTests())
self.assertEqual(['SUIDSandboxUITest.testSUIDSandboxEnabled'],
parser.FailedTests())
self.assertEqual(
['SUIDSandboxUITest.testSUIDSandboxEnabled: '],
parser.FailureDescription('SUIDSandboxUITest.testSUIDSandboxEnabled'))
self.assertEqual(
['FAILURE'],
parser.TriesForTest('SUIDSandboxUITest.testSUIDSandboxEnabled'))
# Same unit tests (when applicable) using ResultCollection
collection = parser.GetResultCollection()
self.assertEqual(['SUIDSandboxUITest.testSUIDSandboxEnabled'],
sorted(collection.failed_tests()))
covered = False
for test_result in collection.test_results:
if test_result.name == 'SUIDSandboxUITest.testSUIDSandboxEnabled':
covered = True
self.assertEqual(TestStatus.FAIL, test_result.status)
self.assertEqual('', test_result.test_log)
self.assertEqual(771, test_result.duration)
self.assertTrue(covered)
def testRunTestCaseTimeout(self):
parser = gtest_utils.GTestLogParser()
for line in TEST_DATA_RUN_TEST_CASE_TIMEOUT.splitlines():
parser.ProcessLine(line)
parser.Finalize()
self.assertEqual(0, len(parser.ParsingErrors()))
self.assertEqual([], parser.RunningTests())
self.assertEqual(['SUIDSandboxUITest.testSUIDSandboxEnabled'],
parser.FailedTests())
self.assertEqual(
['SUIDSandboxUITest.testSUIDSandboxEnabled: ', '(junk)'],
parser.FailureDescription('SUIDSandboxUITest.testSUIDSandboxEnabled'))
self.assertEqual(
['TIMEOUT'],
parser.TriesForTest('SUIDSandboxUITest.testSUIDSandboxEnabled'))
# Same unit tests (when applicable) using ResultCollection
collection = parser.GetResultCollection()
self.assertEqual(['SUIDSandboxUITest.testSUIDSandboxEnabled'],
sorted(collection.never_expected_tests()))
covered = False
for test_result in collection.test_results:
if test_result.name == 'SUIDSandboxUITest.testSUIDSandboxEnabled':
covered = True
self.assertEqual(TestStatus.ABORT, test_result.status)
self.assertEqual('(junk)', test_result.test_log)
self.assertEqual(None, test_result.duration)
self.assertTrue(covered)
def testRunTestCaseParseSwarm(self):
parser = gtest_utils.GTestLogParser()
for line in TEST_DATA_SWARM_TEST_FAIL.splitlines():
parser.ProcessLine(line)
parser.Finalize()
self.assertEqual(0, len(parser.ParsingErrors()))
self.assertEqual([], parser.RunningTests())
self.assertEqual(['PickleTest.EncodeDecode'], parser.FailedTests())
log_lines = [
'PickleTest.EncodeDecode: ',
'../../base/pickle_unittest.cc:69: Failure',
'Value of: false',
' Actual: false',
'Expected: true',
]
self.assertEqual(log_lines,
parser.FailureDescription('PickleTest.EncodeDecode'))
self.assertEqual(['FAILURE'],
parser.TriesForTest('PickleTest.EncodeDecode'))
# Same unit tests (when applicable) using ResultCollection
collection = parser.GetResultCollection()
self.assertEqual(['PickleTest.EncodeDecode'],
sorted(collection.never_expected_tests()))
covered_count = 0
for test_result in collection.test_results:
if test_result.name == 'PickleTest.EncodeDecode':
covered_count += 1
self.assertEqual(TestStatus.FAIL, test_result.status)
self.assertEqual('\n'.join(log_lines[1:]), test_result.test_log)
self.assertEqual(3, covered_count)
def testNestedGtests(self):
parser = gtest_utils.GTestLogParser()
for line in TEST_DATA_NESTED_RUNS.splitlines():
parser.ProcessLine(line)
parser.Finalize()
self.assertEqual(['Foo.Bar'], parser.FailedTests(True, True))
# Same unit tests (when applicable) using ResultCollection
collection = parser.GetResultCollection()
self.assertEqual(['Foo.Bar'], sorted(collection.never_expected_tests()))
covered = False
for test_result in collection.test_results:
if test_result.name == 'Foo.Bar':
covered = True
self.assertEqual(TestStatus.ABORT, test_result.status)
self.assertTrue(covered)
def testParseCompiledFileLocation(self):
parser = gtest_utils.GTestLogParser()
for line in TEST_DATA_COMPILED_FILE.splitlines():
parser.ProcessLine(line)
parser.Finalize()
self.assertEqual(COMPILED_FILE_PATH, parser.compiled_tests_file_path)
# Just a hack so that we can point the compiled file path to right place
parser.compiled_tests_file_path = os.path.join(
os.getcwd(), parser.compiled_tests_file_path)
parser.ParseAndPopulateTestResultLocations(TEST_REPO, False)
collection = parser.GetResultCollection()
covered = False
for test_result in collection.test_results:
if test_result.name == 'test1.test_method1':
covered = True