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
# ===----------------------------------------------------------------------===##
#
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
# See https://llvm.org/LICENSE.txt for license information.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#
# ===----------------------------------------------------------------------===##
"""
Lit test format for LLVM libc tests.
This format discovers pre-built test executables in the build directory
and runs them. It extends lit's ExecutableTest format.
The lit config sets test_source_root == test_exec_root (both to the build
directory), following the pattern used by llvm/test/Unit/lit.cfg.py.
Test executables are discovered by _isTestExecutable() and run by execute().
Integration tests that require command-line arguments or environment variables
have a sidecar <executable>.params file generated by CMake. The format is
one arg per line, a "---" separator, then one KEY=VALUE env entry per line.
"""
"""
Test format for libc unit tests.
Extends ExecutableTest to discover pre-built test executables in the
build directory rather than the source directory.
"""
"""
Discover test executables in the build directory.
Since test_source_root == test_exec_root (both point to build dir),
we use getSourcePath() to find test executables.
"""
=
# Look for test executables in the build directory
return
# Sort for deterministic test discovery/output ordering.
=
# Match our test executable pattern
# Create a test with the executable name
yield
"""
Check if a file is a libc test executable we should run.
Recognized patterns (all must end with .__build__):
libc.test.src.<category>.<test_name>.__build__
libc.test.src.<category>.<test_name>.__unit__[.<opts>...].__build__
libc.test.src.<category>.<test_name>.__hermetic__[.<opts>...].__build__
libc.test.include.<test_name>.__unit__[.<opts>...].__build__
libc.test.include.<test_name>.__hermetic__[.<opts>...].__build__
libc.test.integration.<category>.<test_name>.__build__
"""
return False
pass # Accept all src tests ending in .__build__
return False
pass # Accept all integration tests ending in .__build__
return False
return False
return False
return True
"""
Execute a test by running the test executable.
Runs from the executable's directory so relative paths (like
testdata/test.txt) work correctly.
If a sidecar <executable>.params file exists, it supplies the
command-line arguments and environment variables for the test.
"""
=
=
# Read optional sidecar .params file generated by CMake for tests that
# need specific args/env (e.g. integration tests with ARGS/ENV).
# Format: one arg per line, "---" separator, then KEY=VALUE env lines.
=
=
= +
=
, , =
=
, , =
=
# Build the environment: inherit the current process environment, then
# set PWD to exec_dir so getenv("PWD") matches getcwd(), then overlay
# any test-specific variables from the .params file.
=
=
=
=
=
=
= +
, , =
, , =
return ,
return , +