File tree 3 files changed +93
-0
lines changed
Inputs/googletest-sanitizer-error
3 files changed +93
-0
lines changed Original file line number Diff line number Diff line change
1
+ #!/usr/bin/env python
2
+
3
+ import os
4
+ import sys
5
+
6
+ if len (sys .argv ) == 3 and sys .argv [1 ] == "--gtest_list_tests" :
7
+ if sys .argv [2 ] != '--gtest_filter=-*DISABLED_*' :
8
+ raise ValueError ("unexpected argument: %s" % (sys .argv [2 ]))
9
+ print ("""\
10
+ FirstTest.
11
+ subTestA""" )
12
+ sys .exit (0 )
13
+ elif len (sys .argv ) != 1 :
14
+ # sharding and json output are specified using environment variables
15
+ raise ValueError ("unexpected argument: %r" % (' ' .join (sys .argv [1 :])))
16
+
17
+ for e in ['GTEST_TOTAL_SHARDS' , 'GTEST_SHARD_INDEX' , 'GTEST_OUTPUT' ]:
18
+ if e not in os .environ :
19
+ raise ValueError ("missing environment variables: " + e )
20
+
21
+ if not os .environ ['GTEST_OUTPUT' ].startswith ('json:' ):
22
+ raise ValueError ("must emit json output: " + os .environ ['GTEST_OUTPUT' ])
23
+
24
+ output = """\
25
+ {
26
+ "random_seed": 123,
27
+ "testsuites": [
28
+ {
29
+ "name": "FirstTest",
30
+ "testsuite": [
31
+ {
32
+ "name": "subTestA",
33
+ "result": "COMPLETED",
34
+ "time": "0.001s"
35
+ }
36
+ ]
37
+ }
38
+ ]
39
+ }"""
40
+
41
+ dummy_output = """\
42
+ {
43
+ "testsuites": [
44
+ ]
45
+ }"""
46
+
47
+ json_filename = os .environ ['GTEST_OUTPUT' ].split (':' , 1 )[1 ]
48
+ with open (json_filename , 'w' , encoding = 'utf-8' ) as f :
49
+ if os .environ ['GTEST_SHARD_INDEX' ] == '0' :
50
+ print ('[ RUN ] FirstTest.subTestA' , flush = True )
51
+ print ('[ OK ] FirstTest.subTestA (8 ms)' , flush = True )
52
+
53
+ f .write (output )
54
+ exit_code = 1
55
+ else :
56
+ f .write (dummy_output )
57
+ exit_code = 0
58
+
59
+ sys .exit (exit_code )
Original file line number Diff line number Diff line change
1
+ import lit.formats
2
+ config.name = ' googletest-sanitizer-error'
3
+ config.test_format = lit.formats.GoogleTest(' DummySubDir' , ' Test' )
Original file line number Diff line number Diff line change
1
+ # Check the output is expected when tests pass but sanitizer fails.
2
+ # Note that there is only one shard which has only one sub-test. However, the summary
3
+ # has one pass for the sub-test and one fail for the shard failure due to sanitizer
4
+ # reported errors.
5
+
6
+ # RUN: not %{lit} -v --order=random %{inputs}/googletest-sanitizer-error > %t.out
7
+ # FIXME: Temporarily dump test output so we can debug failing tests on
8
+ # buildbots.
9
+ # RUN: cat %t.out
10
+ # RUN: FileCheck < %t.out %s
11
+ #
12
+ # END.
13
+
14
+ # CHECK: -- Testing:
15
+ # CHECK: FAIL: googletest-sanitizer-error :: [[PATH:[Dd]ummy[Ss]ub[Dd]ir/]][[FILE:OneTest\.py]]/0
16
+ # CHECK: *** TEST 'googletest-sanitizer-error :: [[PATH]][[FILE]]/0{{.*}} FAILED ***
17
+ # CHECK-NEXT: Script(shard):
18
+ # CHECK-NEXT: --
19
+ # CHECK-NEXT: GTEST_OUTPUT=json:{{[^[:space:]]*}} GTEST_SHUFFLE=1 GTEST_TOTAL_SHARDS={{[1-6]}} GTEST_SHARD_INDEX=0 GTEST_RANDOM_SEED=123 {{.*}}[[FILE]]
20
+ # CHECK-NEXT: --
21
+ # CHECK-EMPTY:
22
+ # CHECK-EMPTY:
23
+ # CHECK: [ RUN ] FirstTest.subTestA
24
+ # CHECK-NEXT: [ OK ] FirstTest.subTestA (8 ms)
25
+ # CHECK: --
26
+ # CHECK-NEXT: exit: 1
27
+ # CHECK-NEXT: --
28
+ # CHECK: Failed Tests (1):
29
+ # CHECK-NEXT: googletest-sanitizer-error :: [[PATH]][[FILE]]/0/1
30
+ # CHECK: Passed{{ *}}: 1
31
+ # CHECK: Failed{{ *}}: 1
You can’t perform that action at this time.
0 commit comments