Skip to content

Commit a8b90c8

Browse files
authored
[libc][newheadergen]: adding entry_point testing (#99587)
1 parent 0f0cfcf commit a8b90c8

File tree

2 files changed

+26
-12
lines changed

2 files changed

+26
-12
lines changed

libc/newhdrgen/tests/input/test_small.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,13 @@ functions:
5454
standards:
5555
- stdc
5656
guard: LIBC_TYPES_HAS_FLOAT16_AND_FLOAT128
57+
- name: func_f
58+
return_type: _Float16
59+
arguments:
60+
- type: int
61+
- type: double
62+
- type: float
63+
standards:
64+
- stdc
65+
5766

libc/newhdrgen/tests/test_integration.py

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
class TestHeaderGenIntegration(unittest.TestCase):
1010
def setUp(self):
11-
1211
self.output_dir = Path(
1312
args.output_dir if args.output_dir else "libc/newhdrgen/tests/output"
1413
)
@@ -17,19 +16,24 @@ def setUp(self):
1716

1817
self.source_dir = Path(__file__).resolve().parent.parent.parent.parent
1918

20-
def run_script(self, yaml_file, h_def_file, output_dir):
19+
def run_script(self, yaml_file, h_def_file, output_dir, entry_points):
2120
yaml_file = self.source_dir / yaml_file
2221
h_def_file = self.source_dir / h_def_file
22+
command = [
23+
"python3",
24+
str(self.source_dir / "libc/newhdrgen/yaml_to_classes.py"),
25+
str(yaml_file),
26+
"--h_def_file",
27+
str(h_def_file),
28+
"--output_dir",
29+
str(output_dir),
30+
]
31+
32+
for entry_point in entry_points:
33+
command.extend(["--e", entry_point])
34+
2335
result = subprocess.run(
24-
[
25-
"python3",
26-
str(self.source_dir / "libc/newhdrgen/yaml_to_classes.py"),
27-
str(yaml_file),
28-
"--h_def_file",
29-
str(h_def_file),
30-
"--output_dir",
31-
str(output_dir),
32-
],
36+
command,
3337
capture_output=True,
3438
text=True,
3539
)
@@ -53,11 +57,12 @@ def test_generate_header(self):
5357
self.source_dir / "libc/newhdrgen/tests/expected_output/test_header.h"
5458
)
5559
output_file = self.output_dir / "test_small.h"
60+
entry_points = {"func_b", "func_a", "func_c", "func_d", "func_e"}
5661

5762
if not self.output_dir.exists():
5863
self.output_dir.mkdir(parents=True)
5964

60-
self.run_script(yaml_file, h_def_file, self.output_dir)
65+
self.run_script(yaml_file, h_def_file, self.output_dir, entry_points)
6166

6267
self.compare_files(output_file, expected_output_file)
6368

0 commit comments

Comments
 (0)