Skip to content

[libc][newheadergen]: adding entry_point testing #99587

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions libc/newhdrgen/tests/input/test_small.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,13 @@ functions:
standards:
- stdc
guard: LIBC_TYPES_HAS_FLOAT16_AND_FLOAT128
- name: func_f
return_type: _Float16
arguments:
- type: int
- type: double
- type: float
standards:
- stdc


29 changes: 17 additions & 12 deletions libc/newhdrgen/tests/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

class TestHeaderGenIntegration(unittest.TestCase):
def setUp(self):

self.output_dir = Path(
args.output_dir if args.output_dir else "libc/newhdrgen/tests/output"
)
Expand All @@ -17,19 +16,24 @@ def setUp(self):

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

def run_script(self, yaml_file, h_def_file, output_dir):
def run_script(self, yaml_file, h_def_file, output_dir, entry_points):
yaml_file = self.source_dir / yaml_file
h_def_file = self.source_dir / h_def_file
command = [
"python3",
str(self.source_dir / "libc/newhdrgen/yaml_to_classes.py"),
str(yaml_file),
"--h_def_file",
str(h_def_file),
"--output_dir",
str(output_dir),
]

for entry_point in entry_points:
command.extend(["--e", entry_point])

result = subprocess.run(
[
"python3",
str(self.source_dir / "libc/newhdrgen/yaml_to_classes.py"),
str(yaml_file),
"--h_def_file",
str(h_def_file),
"--output_dir",
str(output_dir),
],
command,
capture_output=True,
text=True,
)
Expand All @@ -53,11 +57,12 @@ def test_generate_header(self):
self.source_dir / "libc/newhdrgen/tests/expected_output/test_header.h"
)
output_file = self.output_dir / "test_small.h"
entry_points = {"func_b", "func_a", "func_c", "func_d", "func_e"}

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

self.run_script(yaml_file, h_def_file, self.output_dir)
self.run_script(yaml_file, h_def_file, self.output_dir, entry_points)

self.compare_files(output_file, expected_output_file)

Expand Down
Loading