[libc-commits] [libc] [libc][newheadergen]: adding entry_point testing (PR #99587)

via libc-commits libc-commits at lists.llvm.org
Fri Jul 19 11:03:01 PDT 2024


https://github.com/aaryanshukla updated https://github.com/llvm/llvm-project/pull/99587

>From f3880431eb4e844a5de68cba5d5cde75591b8d71 Mon Sep 17 00:00:00 2001
From: Aaryan Shukla <aaryanshukla at google.com>
Date: Fri, 19 Jul 2024 00:01:21 +0000
Subject: [PATCH 1/2] [libc][newheadergen]: adding entry_point testing

---
 .../tests/expected_output/test_header.h       |  4 ---
 libc/newhdrgen/tests/test_integration.py      | 29 +++++++++++--------
 2 files changed, 17 insertions(+), 16 deletions(-)

diff --git a/libc/newhdrgen/tests/expected_output/test_header.h b/libc/newhdrgen/tests/expected_output/test_header.h
index a777976134b04..6533faf284a87 100644
--- a/libc/newhdrgen/tests/expected_output/test_header.h
+++ b/libc/newhdrgen/tests/expected_output/test_header.h
@@ -40,10 +40,6 @@ _Float16 func_c(int, float) __NOEXCEPT;
 _Float16 func_d(int, float) __NOEXCEPT;
 #endif // LIBC_TYPES_HAS_FLOAT16
 
-#ifdef LIBC_TYPES_HAS_FLOAT16_AND_FLOAT128
-_Float16 func_e(float128) __NOEXCEPT;
-#endif // LIBC_TYPES_HAS_FLOAT16_AND_FLOAT128
-
 extern obj object_1;
 extern obj object_2;
 
diff --git a/libc/newhdrgen/tests/test_integration.py b/libc/newhdrgen/tests/test_integration.py
index 628a37b11c309..f9fa956077f56 100644
--- a/libc/newhdrgen/tests/test_integration.py
+++ b/libc/newhdrgen/tests/test_integration.py
@@ -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"
         )
@@ -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,
         )
@@ -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"}
 
         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)
 

>From 468e8110c8cf3371f87368c4f7ab52f51dd57090 Mon Sep 17 00:00:00 2001
From: Aaryan Shukla <aaryanshukla at google.com>
Date: Fri, 19 Jul 2024 18:02:23 +0000
Subject: [PATCH 2/2] changed entrypoints test case

---
 libc/newhdrgen/tests/expected_output/test_header.h | 4 ++++
 libc/newhdrgen/tests/input/test_small.yaml         | 9 +++++++++
 libc/newhdrgen/tests/test_integration.py           | 2 +-
 3 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/libc/newhdrgen/tests/expected_output/test_header.h b/libc/newhdrgen/tests/expected_output/test_header.h
index 6533faf284a87..a777976134b04 100644
--- a/libc/newhdrgen/tests/expected_output/test_header.h
+++ b/libc/newhdrgen/tests/expected_output/test_header.h
@@ -40,6 +40,10 @@ _Float16 func_c(int, float) __NOEXCEPT;
 _Float16 func_d(int, float) __NOEXCEPT;
 #endif // LIBC_TYPES_HAS_FLOAT16
 
+#ifdef LIBC_TYPES_HAS_FLOAT16_AND_FLOAT128
+_Float16 func_e(float128) __NOEXCEPT;
+#endif // LIBC_TYPES_HAS_FLOAT16_AND_FLOAT128
+
 extern obj object_1;
 extern obj object_2;
 
diff --git a/libc/newhdrgen/tests/input/test_small.yaml b/libc/newhdrgen/tests/input/test_small.yaml
index f1f9f020ce6a4..a2e96939b4be0 100644
--- a/libc/newhdrgen/tests/input/test_small.yaml
+++ b/libc/newhdrgen/tests/input/test_small.yaml
@@ -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
+
 
diff --git a/libc/newhdrgen/tests/test_integration.py b/libc/newhdrgen/tests/test_integration.py
index f9fa956077f56..33353785af233 100644
--- a/libc/newhdrgen/tests/test_integration.py
+++ b/libc/newhdrgen/tests/test_integration.py
@@ -57,7 +57,7 @@ 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"}
+        entry_points = {"func_b", "func_a", "func_c", "func_d", "func_e"}
 
         if not self.output_dir.exists():
             self.output_dir.mkdir(parents=True)



More information about the libc-commits mailing list