[clang] [clang][test] Rewrote test to work with lit internal shell syntax (PR #105902)

2024-08-26 Thread Connie Zhu via cfe-commits

https://github.com/connieyzhu updated 
https://github.com/llvm/llvm-project/pull/105902

>From 5801e58f5e89fb90a3b18414e1cb959d027b4fee Mon Sep 17 00:00:00 2001
From: Connie Zhu 
Date: Fri, 23 Aug 2024 17:23:22 +
Subject: [PATCH 1/2] [clang][test] Rewrote test to work with lit internal
 shell syntax

This patch rewrites a test that uses command substitution $() and the
stat command, which are not supported by lit's internal shell. Instead
of using this syntax to perform the file size comparison done in this
test, a Python script is used instead to perform the same operation.
---
 clang/test/Modules/compare-file-size.py  | 22 ++
 clang/test/Modules/reduced-bmi-size.cppm |  3 +--
 clang/test/lit.cfg.py|  2 ++
 3 files changed, 25 insertions(+), 2 deletions(-)
 create mode 100644 clang/test/Modules/compare-file-size.py

diff --git a/clang/test/Modules/compare-file-size.py 
b/clang/test/Modules/compare-file-size.py
new file mode 100644
index 00..ca3b16442353c7
--- /dev/null
+++ b/clang/test/Modules/compare-file-size.py
@@ -0,0 +1,22 @@
+import argparse
+import os
+
+def get_file_size(file_path):
+try:
+return os.path.getsize(file_path)
+except:
+print(f"Unable to get file size of {file_path}")
+return None
+
+def main():
+parser = argparse.ArgumentParser()
+
+parser.add_argument("file1", type=str)
+parser.add_argument("file2", type=str)
+
+args = parser.parse_args()
+
+return get_file_size(args.file1) < get_file_size(args.file2)
+
+if __name__ == "__main__":
+main()
diff --git a/clang/test/Modules/reduced-bmi-size.cppm 
b/clang/test/Modules/reduced-bmi-size.cppm
index 664f45f5c6a5a7..6d62573bc7aa39 100644
--- a/clang/test/Modules/reduced-bmi-size.cppm
+++ b/clang/test/Modules/reduced-bmi-size.cppm
@@ -10,7 +10,6 @@
 // RUN: %clang_cc1 -std=c++20 -emit-module-interface %s -o %t/a.pcm
 // RUN: %clang_cc1 -std=c++20 -emit-reduced-module-interface %s -o 
%t/a.reduced.pcm
 //
-// %s implies the current source file. So we can't use it directly.
-// RUN: [ $(stat -c%\s "%t/a.pcm") -le $(stat -c%\s "%t/a.reduced.pcm") ]
+// RUN: %{python} %S/compare-file-size.py %t/a.pcm %t/a.reduced.pcm
 
 export module a;
diff --git a/clang/test/lit.cfg.py b/clang/test/lit.cfg.py
index 92a3361ce672e2..59330a6d51a611 100644
--- a/clang/test/lit.cfg.py
+++ b/clang/test/lit.cfg.py
@@ -74,6 +74,8 @@
 
 config.substitutions.append(("%PATH%", config.environment["PATH"]))
 
+config.substitutions.append(("%{python}", '"%s"' % (sys.executable)))
+
 
 # For each occurrence of a clang tool name, replace it with the full path to
 # the build directory holding that tool.  We explicitly specify the directories

>From fa882e33eaab820219a704ba15a1cc10f2f93b07 Mon Sep 17 00:00:00 2001
From: Connie Zhu 
Date: Mon, 26 Aug 2024 18:47:31 +
Subject: [PATCH 2/2] [clang][test] Modified python program to return error
 code when failing to get file size

This patch removes the print statement that executes in the case of
exceptions, opting to let the system return its own error code when
failing to get the file size of a certain file. There are also some NFC
changes: adding description for compare-file-size.py and changing the
%{python} syntax to use the exisitng lit substitution %python.
---
 clang/test/Modules/compare-file-size.py  | 24 
 clang/test/Modules/reduced-bmi-size.cppm |  2 +-
 clang/test/lit.cfg.py|  2 --
 3 files changed, 9 insertions(+), 19 deletions(-)

diff --git a/clang/test/Modules/compare-file-size.py 
b/clang/test/Modules/compare-file-size.py
index ca3b16442353c7..30319726eff861 100644
--- a/clang/test/Modules/compare-file-size.py
+++ b/clang/test/Modules/compare-file-size.py
@@ -1,22 +1,14 @@
+# This program takes in two file path arguments and returns true if the
+# file size of the first file is smaller than the file size of the second file
+
 import argparse
 import os
 
-def get_file_size(file_path):
-try:
-return os.path.getsize(file_path)
-except:
-print(f"Unable to get file size of {file_path}")
-return None
-
-def main():
-parser = argparse.ArgumentParser()
-
-parser.add_argument("file1", type=str)
-parser.add_argument("file2", type=str)
+parser = argparse.ArgumentParser()
 
-args = parser.parse_args()
+parser.add_argument("file1", type=str)
+parser.add_argument("file2", type=str)
 
-return get_file_size(args.file1) < get_file_size(args.file2)
+args = parser.parse_args()
 
-if __name__ == "__main__":
-main()
+return os.path.getsize(args.file1) < os.path.getsize(args.file2)
diff --git a/clang/test/Modules/reduced-bmi-size.cppm 
b/clang/test/Modules/reduced-bmi-size.cppm
index 6d62573bc7aa39..6e3323266561e8 100644
--- a/clang/test/Modules/reduced-bmi-size.cppm
+++ b/clang/test/Modules/reduced-bmi-size.cppm
@@ -10,6 +10,6 @@
 // RUN: %clang_cc1 -std=c++20 -emit-module-interface %s -o %t/a.pcm
 // RUN: %clang_cc1 -std=c

[clang] [clang][test] Rewrote test to work with lit internal shell syntax (PR #105902)

2024-08-26 Thread Connie Zhu via cfe-commits


@@ -0,0 +1,22 @@
+import argparse
+import os
+
+def get_file_size(file_path):
+try:
+return os.path.getsize(file_path)
+except:
+print(f"Unable to get file size of {file_path}")
+return None

connieyzhu wrote:

Now that I look at it again, I think having an unhandled exception would be 
better. I didn't realize that my implementation doesn't actually return an 
error code, but I would think having the error code would be better for 
debugging. 

https://github.com/llvm/llvm-project/pull/105902
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][test] Rewrote test to work with lit internal shell syntax (PR #105902)

2024-08-26 Thread Connie Zhu via cfe-commits

https://github.com/connieyzhu updated 
https://github.com/llvm/llvm-project/pull/105902

>From 5801e58f5e89fb90a3b18414e1cb959d027b4fee Mon Sep 17 00:00:00 2001
From: Connie Zhu 
Date: Fri, 23 Aug 2024 17:23:22 +
Subject: [PATCH 1/3] [clang][test] Rewrote test to work with lit internal
 shell syntax

This patch rewrites a test that uses command substitution $() and the
stat command, which are not supported by lit's internal shell. Instead
of using this syntax to perform the file size comparison done in this
test, a Python script is used instead to perform the same operation.
---
 clang/test/Modules/compare-file-size.py  | 22 ++
 clang/test/Modules/reduced-bmi-size.cppm |  3 +--
 clang/test/lit.cfg.py|  2 ++
 3 files changed, 25 insertions(+), 2 deletions(-)
 create mode 100644 clang/test/Modules/compare-file-size.py

diff --git a/clang/test/Modules/compare-file-size.py 
b/clang/test/Modules/compare-file-size.py
new file mode 100644
index 00..ca3b16442353c7
--- /dev/null
+++ b/clang/test/Modules/compare-file-size.py
@@ -0,0 +1,22 @@
+import argparse
+import os
+
+def get_file_size(file_path):
+try:
+return os.path.getsize(file_path)
+except:
+print(f"Unable to get file size of {file_path}")
+return None
+
+def main():
+parser = argparse.ArgumentParser()
+
+parser.add_argument("file1", type=str)
+parser.add_argument("file2", type=str)
+
+args = parser.parse_args()
+
+return get_file_size(args.file1) < get_file_size(args.file2)
+
+if __name__ == "__main__":
+main()
diff --git a/clang/test/Modules/reduced-bmi-size.cppm 
b/clang/test/Modules/reduced-bmi-size.cppm
index 664f45f5c6a5a7..6d62573bc7aa39 100644
--- a/clang/test/Modules/reduced-bmi-size.cppm
+++ b/clang/test/Modules/reduced-bmi-size.cppm
@@ -10,7 +10,6 @@
 // RUN: %clang_cc1 -std=c++20 -emit-module-interface %s -o %t/a.pcm
 // RUN: %clang_cc1 -std=c++20 -emit-reduced-module-interface %s -o 
%t/a.reduced.pcm
 //
-// %s implies the current source file. So we can't use it directly.
-// RUN: [ $(stat -c%\s "%t/a.pcm") -le $(stat -c%\s "%t/a.reduced.pcm") ]
+// RUN: %{python} %S/compare-file-size.py %t/a.pcm %t/a.reduced.pcm
 
 export module a;
diff --git a/clang/test/lit.cfg.py b/clang/test/lit.cfg.py
index 92a3361ce672e2..59330a6d51a611 100644
--- a/clang/test/lit.cfg.py
+++ b/clang/test/lit.cfg.py
@@ -74,6 +74,8 @@
 
 config.substitutions.append(("%PATH%", config.environment["PATH"]))
 
+config.substitutions.append(("%{python}", '"%s"' % (sys.executable)))
+
 
 # For each occurrence of a clang tool name, replace it with the full path to
 # the build directory holding that tool.  We explicitly specify the directories

>From fa882e33eaab820219a704ba15a1cc10f2f93b07 Mon Sep 17 00:00:00 2001
From: Connie Zhu 
Date: Mon, 26 Aug 2024 18:47:31 +
Subject: [PATCH 2/3] [clang][test] Modified python program to return error
 code when failing to get file size

This patch removes the print statement that executes in the case of
exceptions, opting to let the system return its own error code when
failing to get the file size of a certain file. There are also some NFC
changes: adding description for compare-file-size.py and changing the
%{python} syntax to use the exisitng lit substitution %python.
---
 clang/test/Modules/compare-file-size.py  | 24 
 clang/test/Modules/reduced-bmi-size.cppm |  2 +-
 clang/test/lit.cfg.py|  2 --
 3 files changed, 9 insertions(+), 19 deletions(-)

diff --git a/clang/test/Modules/compare-file-size.py 
b/clang/test/Modules/compare-file-size.py
index ca3b16442353c7..30319726eff861 100644
--- a/clang/test/Modules/compare-file-size.py
+++ b/clang/test/Modules/compare-file-size.py
@@ -1,22 +1,14 @@
+# This program takes in two file path arguments and returns true if the
+# file size of the first file is smaller than the file size of the second file
+
 import argparse
 import os
 
-def get_file_size(file_path):
-try:
-return os.path.getsize(file_path)
-except:
-print(f"Unable to get file size of {file_path}")
-return None
-
-def main():
-parser = argparse.ArgumentParser()
-
-parser.add_argument("file1", type=str)
-parser.add_argument("file2", type=str)
+parser = argparse.ArgumentParser()
 
-args = parser.parse_args()
+parser.add_argument("file1", type=str)
+parser.add_argument("file2", type=str)
 
-return get_file_size(args.file1) < get_file_size(args.file2)
+args = parser.parse_args()
 
-if __name__ == "__main__":
-main()
+return os.path.getsize(args.file1) < os.path.getsize(args.file2)
diff --git a/clang/test/Modules/reduced-bmi-size.cppm 
b/clang/test/Modules/reduced-bmi-size.cppm
index 6d62573bc7aa39..6e3323266561e8 100644
--- a/clang/test/Modules/reduced-bmi-size.cppm
+++ b/clang/test/Modules/reduced-bmi-size.cppm
@@ -10,6 +10,6 @@
 // RUN: %clang_cc1 -std=c++20 -emit-module-interface %s -o %t/a.pcm
 // RUN: %clang_cc1 -std=c

[clang] [clang][test] Rewrote test using $() to work with lit internal shell syntax (PR #105902)

2024-08-26 Thread Connie Zhu via cfe-commits

https://github.com/connieyzhu edited 
https://github.com/llvm/llvm-project/pull/105902
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [compiler-rt] [clang][compiler-rt][test] Removed dirname command substitutions from tests (PR #105754)

2024-08-26 Thread Connie Zhu via cfe-commits

https://github.com/connieyzhu closed 
https://github.com/llvm/llvm-project/pull/105754
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][test] Rewrote test using $() to work with lit internal shell syntax (PR #105902)

2024-08-28 Thread Connie Zhu via cfe-commits

https://github.com/connieyzhu updated 
https://github.com/llvm/llvm-project/pull/105902

>From 5801e58f5e89fb90a3b18414e1cb959d027b4fee Mon Sep 17 00:00:00 2001
From: Connie Zhu 
Date: Fri, 23 Aug 2024 17:23:22 +
Subject: [PATCH 1/4] [clang][test] Rewrote test to work with lit internal
 shell syntax

This patch rewrites a test that uses command substitution $() and the
stat command, which are not supported by lit's internal shell. Instead
of using this syntax to perform the file size comparison done in this
test, a Python script is used instead to perform the same operation.
---
 clang/test/Modules/compare-file-size.py  | 22 ++
 clang/test/Modules/reduced-bmi-size.cppm |  3 +--
 clang/test/lit.cfg.py|  2 ++
 3 files changed, 25 insertions(+), 2 deletions(-)
 create mode 100644 clang/test/Modules/compare-file-size.py

diff --git a/clang/test/Modules/compare-file-size.py 
b/clang/test/Modules/compare-file-size.py
new file mode 100644
index 00..ca3b16442353c7
--- /dev/null
+++ b/clang/test/Modules/compare-file-size.py
@@ -0,0 +1,22 @@
+import argparse
+import os
+
+def get_file_size(file_path):
+try:
+return os.path.getsize(file_path)
+except:
+print(f"Unable to get file size of {file_path}")
+return None
+
+def main():
+parser = argparse.ArgumentParser()
+
+parser.add_argument("file1", type=str)
+parser.add_argument("file2", type=str)
+
+args = parser.parse_args()
+
+return get_file_size(args.file1) < get_file_size(args.file2)
+
+if __name__ == "__main__":
+main()
diff --git a/clang/test/Modules/reduced-bmi-size.cppm 
b/clang/test/Modules/reduced-bmi-size.cppm
index 664f45f5c6a5a7..6d62573bc7aa39 100644
--- a/clang/test/Modules/reduced-bmi-size.cppm
+++ b/clang/test/Modules/reduced-bmi-size.cppm
@@ -10,7 +10,6 @@
 // RUN: %clang_cc1 -std=c++20 -emit-module-interface %s -o %t/a.pcm
 // RUN: %clang_cc1 -std=c++20 -emit-reduced-module-interface %s -o 
%t/a.reduced.pcm
 //
-// %s implies the current source file. So we can't use it directly.
-// RUN: [ $(stat -c%\s "%t/a.pcm") -le $(stat -c%\s "%t/a.reduced.pcm") ]
+// RUN: %{python} %S/compare-file-size.py %t/a.pcm %t/a.reduced.pcm
 
 export module a;
diff --git a/clang/test/lit.cfg.py b/clang/test/lit.cfg.py
index 92a3361ce672e2..59330a6d51a611 100644
--- a/clang/test/lit.cfg.py
+++ b/clang/test/lit.cfg.py
@@ -74,6 +74,8 @@
 
 config.substitutions.append(("%PATH%", config.environment["PATH"]))
 
+config.substitutions.append(("%{python}", '"%s"' % (sys.executable)))
+
 
 # For each occurrence of a clang tool name, replace it with the full path to
 # the build directory holding that tool.  We explicitly specify the directories

>From fa882e33eaab820219a704ba15a1cc10f2f93b07 Mon Sep 17 00:00:00 2001
From: Connie Zhu 
Date: Mon, 26 Aug 2024 18:47:31 +
Subject: [PATCH 2/4] [clang][test] Modified python program to return error
 code when failing to get file size

This patch removes the print statement that executes in the case of
exceptions, opting to let the system return its own error code when
failing to get the file size of a certain file. There are also some NFC
changes: adding description for compare-file-size.py and changing the
%{python} syntax to use the exisitng lit substitution %python.
---
 clang/test/Modules/compare-file-size.py  | 24 
 clang/test/Modules/reduced-bmi-size.cppm |  2 +-
 clang/test/lit.cfg.py|  2 --
 3 files changed, 9 insertions(+), 19 deletions(-)

diff --git a/clang/test/Modules/compare-file-size.py 
b/clang/test/Modules/compare-file-size.py
index ca3b16442353c7..30319726eff861 100644
--- a/clang/test/Modules/compare-file-size.py
+++ b/clang/test/Modules/compare-file-size.py
@@ -1,22 +1,14 @@
+# This program takes in two file path arguments and returns true if the
+# file size of the first file is smaller than the file size of the second file
+
 import argparse
 import os
 
-def get_file_size(file_path):
-try:
-return os.path.getsize(file_path)
-except:
-print(f"Unable to get file size of {file_path}")
-return None
-
-def main():
-parser = argparse.ArgumentParser()
-
-parser.add_argument("file1", type=str)
-parser.add_argument("file2", type=str)
+parser = argparse.ArgumentParser()
 
-args = parser.parse_args()
+parser.add_argument("file1", type=str)
+parser.add_argument("file2", type=str)
 
-return get_file_size(args.file1) < get_file_size(args.file2)
+args = parser.parse_args()
 
-if __name__ == "__main__":
-main()
+return os.path.getsize(args.file1) < os.path.getsize(args.file2)
diff --git a/clang/test/Modules/reduced-bmi-size.cppm 
b/clang/test/Modules/reduced-bmi-size.cppm
index 6d62573bc7aa39..6e3323266561e8 100644
--- a/clang/test/Modules/reduced-bmi-size.cppm
+++ b/clang/test/Modules/reduced-bmi-size.cppm
@@ -10,6 +10,6 @@
 // RUN: %clang_cc1 -std=c++20 -emit-module-interface %s -o %t/a.pcm
 // RUN: %clang_cc1 -std=c

[clang] [clang][test] Rewrote test using $() to work with lit internal shell syntax (PR #105902)

2024-08-28 Thread Connie Zhu via cfe-commits

https://github.com/connieyzhu updated 
https://github.com/llvm/llvm-project/pull/105902

>From 5801e58f5e89fb90a3b18414e1cb959d027b4fee Mon Sep 17 00:00:00 2001
From: Connie Zhu 
Date: Fri, 23 Aug 2024 17:23:22 +
Subject: [PATCH 1/5] [clang][test] Rewrote test to work with lit internal
 shell syntax

This patch rewrites a test that uses command substitution $() and the
stat command, which are not supported by lit's internal shell. Instead
of using this syntax to perform the file size comparison done in this
test, a Python script is used instead to perform the same operation.
---
 clang/test/Modules/compare-file-size.py  | 22 ++
 clang/test/Modules/reduced-bmi-size.cppm |  3 +--
 clang/test/lit.cfg.py|  2 ++
 3 files changed, 25 insertions(+), 2 deletions(-)
 create mode 100644 clang/test/Modules/compare-file-size.py

diff --git a/clang/test/Modules/compare-file-size.py 
b/clang/test/Modules/compare-file-size.py
new file mode 100644
index 00..ca3b16442353c7
--- /dev/null
+++ b/clang/test/Modules/compare-file-size.py
@@ -0,0 +1,22 @@
+import argparse
+import os
+
+def get_file_size(file_path):
+try:
+return os.path.getsize(file_path)
+except:
+print(f"Unable to get file size of {file_path}")
+return None
+
+def main():
+parser = argparse.ArgumentParser()
+
+parser.add_argument("file1", type=str)
+parser.add_argument("file2", type=str)
+
+args = parser.parse_args()
+
+return get_file_size(args.file1) < get_file_size(args.file2)
+
+if __name__ == "__main__":
+main()
diff --git a/clang/test/Modules/reduced-bmi-size.cppm 
b/clang/test/Modules/reduced-bmi-size.cppm
index 664f45f5c6a5a7..6d62573bc7aa39 100644
--- a/clang/test/Modules/reduced-bmi-size.cppm
+++ b/clang/test/Modules/reduced-bmi-size.cppm
@@ -10,7 +10,6 @@
 // RUN: %clang_cc1 -std=c++20 -emit-module-interface %s -o %t/a.pcm
 // RUN: %clang_cc1 -std=c++20 -emit-reduced-module-interface %s -o 
%t/a.reduced.pcm
 //
-// %s implies the current source file. So we can't use it directly.
-// RUN: [ $(stat -c%\s "%t/a.pcm") -le $(stat -c%\s "%t/a.reduced.pcm") ]
+// RUN: %{python} %S/compare-file-size.py %t/a.pcm %t/a.reduced.pcm
 
 export module a;
diff --git a/clang/test/lit.cfg.py b/clang/test/lit.cfg.py
index 92a3361ce672e2..59330a6d51a611 100644
--- a/clang/test/lit.cfg.py
+++ b/clang/test/lit.cfg.py
@@ -74,6 +74,8 @@
 
 config.substitutions.append(("%PATH%", config.environment["PATH"]))
 
+config.substitutions.append(("%{python}", '"%s"' % (sys.executable)))
+
 
 # For each occurrence of a clang tool name, replace it with the full path to
 # the build directory holding that tool.  We explicitly specify the directories

>From fa882e33eaab820219a704ba15a1cc10f2f93b07 Mon Sep 17 00:00:00 2001
From: Connie Zhu 
Date: Mon, 26 Aug 2024 18:47:31 +
Subject: [PATCH 2/5] [clang][test] Modified python program to return error
 code when failing to get file size

This patch removes the print statement that executes in the case of
exceptions, opting to let the system return its own error code when
failing to get the file size of a certain file. There are also some NFC
changes: adding description for compare-file-size.py and changing the
%{python} syntax to use the exisitng lit substitution %python.
---
 clang/test/Modules/compare-file-size.py  | 24 
 clang/test/Modules/reduced-bmi-size.cppm |  2 +-
 clang/test/lit.cfg.py|  2 --
 3 files changed, 9 insertions(+), 19 deletions(-)

diff --git a/clang/test/Modules/compare-file-size.py 
b/clang/test/Modules/compare-file-size.py
index ca3b16442353c7..30319726eff861 100644
--- a/clang/test/Modules/compare-file-size.py
+++ b/clang/test/Modules/compare-file-size.py
@@ -1,22 +1,14 @@
+# This program takes in two file path arguments and returns true if the
+# file size of the first file is smaller than the file size of the second file
+
 import argparse
 import os
 
-def get_file_size(file_path):
-try:
-return os.path.getsize(file_path)
-except:
-print(f"Unable to get file size of {file_path}")
-return None
-
-def main():
-parser = argparse.ArgumentParser()
-
-parser.add_argument("file1", type=str)
-parser.add_argument("file2", type=str)
+parser = argparse.ArgumentParser()
 
-args = parser.parse_args()
+parser.add_argument("file1", type=str)
+parser.add_argument("file2", type=str)
 
-return get_file_size(args.file1) < get_file_size(args.file2)
+args = parser.parse_args()
 
-if __name__ == "__main__":
-main()
+return os.path.getsize(args.file1) < os.path.getsize(args.file2)
diff --git a/clang/test/Modules/reduced-bmi-size.cppm 
b/clang/test/Modules/reduced-bmi-size.cppm
index 6d62573bc7aa39..6e3323266561e8 100644
--- a/clang/test/Modules/reduced-bmi-size.cppm
+++ b/clang/test/Modules/reduced-bmi-size.cppm
@@ -10,6 +10,6 @@
 // RUN: %clang_cc1 -std=c++20 -emit-module-interface %s -o %t/a.pcm
 // RUN: %clang_cc1 -std=c

[clang] [clang][test] Rewrote test using command substitution to work with lit internal shell syntax (PR #105902)

2024-08-29 Thread Connie Zhu via cfe-commits

https://github.com/connieyzhu edited 
https://github.com/llvm/llvm-project/pull/105902
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][test] Rewrote test using command substitution to work with lit internal shell syntax (PR #105902)

2024-08-29 Thread Connie Zhu via cfe-commits

https://github.com/connieyzhu closed 
https://github.com/llvm/llvm-project/pull/105902
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [compiler-rt] [clang][compiler-rt][test] Removed dirname command substitutions from tests (PR #105754)

2024-08-22 Thread Connie Zhu via cfe-commits

https://github.com/connieyzhu created 
https://github.com/llvm/llvm-project/pull/105754

This patch rewrites tests in clang and compiler-rt that uses bash command 
substitution syntax $() to execute the dirname command. This is done so that 
the tests can be run using lit's internal shell.

Fixes https://github.com/llvm/llvm-project/issues/102384.

>From cfd90f666e9b6f65e277bc753de973a748a7b275 Mon Sep 17 00:00:00 2001
From: Connie Zhu 
Date: Thu, 22 Aug 2024 23:32:40 +
Subject: [PATCH] [clang][compiler-rt][test] Removed dirname command
 substitutions from tests

This patch rewrites tests that uses bash command substitution syntax $()
to execute the dirname command. This is done so that the tests can be
run using lit's internal shell.
---
 clang/test/Driver/offload-packager.c  | 99 ++-
 .../hwasan/TestCases/hwasan_symbolize.cpp | 11 ++-
 2 files changed, 56 insertions(+), 54 deletions(-)

diff --git a/clang/test/Driver/offload-packager.c 
b/clang/test/Driver/offload-packager.c
index 9adc202322521a..86363d6fa343bf 100644
--- a/clang/test/Driver/offload-packager.c
+++ b/clang/test/Driver/offload-packager.c
@@ -3,63 +3,64 @@
 // REQUIRES: amdgpu-registered-target
 // UNSUPPORTED: system-windows
 
-// RUN: %clang -cc1 %s -triple x86_64-unknown-linux-gnu -emit-obj -o %t.elf.o
+// RUN: rm -rf %t && mkdir -p %t
+// RUN: %clang -cc1 %s -triple x86_64-unknown-linux-gnu -emit-obj -o %t/elf.o
 
 // Check that we can extract files from the packaged binary.
-// RUN: clang-offload-packager -o %t.out \
-// RUN:   
--image=file=%t.elf.o,kind=openmp,triple=nvptx64-nvidia-cuda,arch=sm_70 \
-// RUN:   
--image=file=%t.elf.o,kind=openmp,triple=nvptx64-nvidia-cuda,arch=sm_80 \
-// RUN:   
--image=file=%t.elf.o,kind=openmp,triple=amdgcn-amd-amdhsa,arch=gfx908 \
-// RUN:   
--image=file=%t.elf.o,kind=openmp,triple=amdgcn-amd-amdhsa,arch=gfx90a \
-// RUN:   
--image=file=%t.elf.o,kind=openmp,triple=amdgcn-amd-amdhsa,arch=gfx90c 
-// RUN: clang-offload-packager %t.out \
-// RUN:   
--image=file=%t-sm_70.o,kind=openmp,triple=nvptx64-nvidia-cuda,arch=sm_70 \
-// RUN:   
--image=file=%t-gfx908.o,kind=openmp,triple=amdgcn-amd-amdhsa,arch=gfx908
-// RUN: diff %t-sm_70.o %t.elf.o
-// RUN: diff %t-gfx908.o %t.elf.o
+// RUN: clang-offload-packager -o %t/package.out \
+// RUN:   
--image=file=%t/elf.o,kind=openmp,triple=nvptx64-nvidia-cuda,arch=sm_70 \
+// RUN:   
--image=file=%t/elf.o,kind=openmp,triple=nvptx64-nvidia-cuda,arch=sm_80 \
+// RUN:   
--image=file=%t/elf.o,kind=openmp,triple=amdgcn-amd-amdhsa,arch=gfx908 \
+// RUN:   
--image=file=%t/elf.o,kind=openmp,triple=amdgcn-amd-amdhsa,arch=gfx90a \
+// RUN:   
--image=file=%t/elf.o,kind=openmp,triple=amdgcn-amd-amdhsa,arch=gfx90c 
+// RUN: clang-offload-packager %t/package.out \
+// RUN:   
--image=file=%t/sm_70.o,kind=openmp,triple=nvptx64-nvidia-cuda,arch=sm_70 \
+// RUN:   
--image=file=%t/gfx908.o,kind=openmp,triple=amdgcn-amd-amdhsa,arch=gfx908
+// RUN: diff %t/sm_70.o %t/elf.o
+// RUN: diff %t/gfx908.o %t/elf.o
 
 // Check that we generate a new name if one is not given
-// RUN: clang-offload-packager -o %t \
-// RUN:   
--image=file=%t.elf.o,kind=openmp,triple=nvptx64-nvidia-cuda,arch=sm_70 \
-// RUN:   
--image=file=%t.elf.o,kind=openmp,triple=nvptx64-nvidia-cuda,arch=sm_80 \
-// RUN:   
--image=file=%t.elf.o,kind=openmp,triple=amdgcn-amd-amdhsa,arch=gfx908 \
-// RUN:   
--image=file=%t.elf.o,kind=openmp,triple=amdgcn-amd-amdhsa,arch=gfx90a \
-// RUN:   --image=file=%t.elf.o,kind=hip,triple=amdgcn-amd-amdhsa,arch=gfx90c 
-// RUN: cd $(dirname "%t") && clang-offload-packager %t --image=kind=openmp
-// RUN: diff *-nvptx64-nvidia-cuda-sm_70.0.o %t.elf.o; rm 
*-nvptx64-nvidia-cuda-sm_70.0.o
-// RUN: diff *-nvptx64-nvidia-cuda-sm_80.1.o %t.elf.o; rm 
*-nvptx64-nvidia-cuda-sm_80.1.o
-// RUN: diff *-amdgcn-amd-amdhsa-gfx908.2.o %t.elf.o; rm 
*-amdgcn-amd-amdhsa-gfx908.2.o
-// RUN: diff *-amdgcn-amd-amdhsa-gfx90a.3.o %t.elf.o; rm 
*-amdgcn-amd-amdhsa-gfx90a.3.o
-// RUN: not diff *-amdgcn-amd-amdhsa-gfx90c.4.o %t.elf.o
+// RUN: clang-offload-packager -o %t/package \
+// RUN:   
--image=file=%t/elf.o,kind=openmp,triple=nvptx64-nvidia-cuda,arch=sm_70 \
+// RUN:   
--image=file=%t/elf.o,kind=openmp,triple=nvptx64-nvidia-cuda,arch=sm_80 \
+// RUN:   
--image=file=%t/elf.o,kind=openmp,triple=amdgcn-amd-amdhsa,arch=gfx908 \
+// RUN:   
--image=file=%t/elf.o,kind=openmp,triple=amdgcn-amd-amdhsa,arch=gfx90a \
+// RUN:   --image=file=%t/elf.o,kind=hip,triple=amdgcn-amd-amdhsa,arch=gfx90c 
+// RUN: cd %t && clang-offload-packager %t/package --image=kind=openmp
+// RUN: diff *-nvptx64-nvidia-cuda-sm_70.0.o %t/elf.o; rm 
*-nvptx64-nvidia-cuda-sm_70.0.o
+// RUN: diff *-nvptx64-nvidia-cuda-sm_80.1.o %t/elf.o; rm 
*-nvptx64-nvidia-cuda-sm_80.1.o
+// RUN: diff *-amdgcn-amd-amdhsa-gfx908.2.o %t/elf.o; rm 
*-amdgcn-amd-amdhsa-gfx908.2.o
+// RUN: diff *-amdgcn-amd-amdhsa-gfx90a.3.o %t/elf.o; rm 
*-amdgcn-amd-amdhsa-gfx90a.3.o
+// RUN: not diff *-amdgcn-amd-amdhsa-gfx90c.4

[clang] [clang][test] Rewrote test to work with lit internal shell syntax (PR #105902)

2024-08-23 Thread Connie Zhu via cfe-commits

https://github.com/connieyzhu created 
https://github.com/llvm/llvm-project/pull/105902

This patch rewrites a test that uses command substitution `$()` and the `stat` 
command, which are not supported by lit's internal shell. Instead of using this 
syntax to perform the file size comparison done in this test, a Python script 
is used instead to perform the same operation.

Fixes https://github.com/llvm/llvm-project/issues/102384.

>From ae8f575067ea7035911053b6994e856538c23c3f Mon Sep 17 00:00:00 2001
From: Connie Zhu 
Date: Fri, 23 Aug 2024 17:23:22 +
Subject: [PATCH] [clang][test] Rewrote test to work with lit internal shell
 syntax

This patch rewrites a test that uses command substitution $() and the
stat command, which are not supported by lit's internal shell. Instead
of using this syntax to perform the file size comparison done in this
test, a Python script is used instead to perform the same operation.
---
 clang/test/Modules/compare-file-size.py  | 22 ++
 clang/test/Modules/reduced-bmi-size.cppm |  3 +--
 clang/test/lit.cfg.py|  2 ++
 3 files changed, 25 insertions(+), 2 deletions(-)
 create mode 100644 clang/test/Modules/compare-file-size.py

diff --git a/clang/test/Modules/compare-file-size.py 
b/clang/test/Modules/compare-file-size.py
new file mode 100644
index 00..b5dc20642ea6ce
--- /dev/null
+++ b/clang/test/Modules/compare-file-size.py
@@ -0,0 +1,22 @@
+import argparse
+import os
+
+def get_file_size(file_path):
+try:
+return os.path.getsize(file_path)
+except:
+print(f"Unable to get file size of {file_path}")
+return None
+
+def main():
+parser = argparse.ArgumentParser()
+
+parser.add_argument("file1", type=str)
+parser.add_argument("file2", type=str)
+
+args = parser.parse_args()
+
+return get_file_size(args.file1) < get_file_size(args.file2)
+
+if __name__ ==  "__main__":
+main()
diff --git a/clang/test/Modules/reduced-bmi-size.cppm 
b/clang/test/Modules/reduced-bmi-size.cppm
index 664f45f5c6a5a7..6d62573bc7aa39 100644
--- a/clang/test/Modules/reduced-bmi-size.cppm
+++ b/clang/test/Modules/reduced-bmi-size.cppm
@@ -10,7 +10,6 @@
 // RUN: %clang_cc1 -std=c++20 -emit-module-interface %s -o %t/a.pcm
 // RUN: %clang_cc1 -std=c++20 -emit-reduced-module-interface %s -o 
%t/a.reduced.pcm
 //
-// %s implies the current source file. So we can't use it directly.
-// RUN: [ $(stat -c%\s "%t/a.pcm") -le $(stat -c%\s "%t/a.reduced.pcm") ]
+// RUN: %{python} %S/compare-file-size.py %t/a.pcm %t/a.reduced.pcm
 
 export module a;
diff --git a/clang/test/lit.cfg.py b/clang/test/lit.cfg.py
index 92a3361ce672e2..59330a6d51a611 100644
--- a/clang/test/lit.cfg.py
+++ b/clang/test/lit.cfg.py
@@ -74,6 +74,8 @@
 
 config.substitutions.append(("%PATH%", config.environment["PATH"]))
 
+config.substitutions.append(("%{python}", '"%s"' % (sys.executable)))
+
 
 # For each occurrence of a clang tool name, replace it with the full path to
 # the build directory holding that tool.  We explicitly specify the directories

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][test] Rewrote test to work with lit internal shell syntax (PR #105902)

2024-08-23 Thread Connie Zhu via cfe-commits

https://github.com/connieyzhu updated 
https://github.com/llvm/llvm-project/pull/105902

>From b7cf36a247e480ddefc1708cb68078b440011d63 Mon Sep 17 00:00:00 2001
From: Connie Zhu 
Date: Fri, 23 Aug 2024 17:23:22 +
Subject: [PATCH] [clang][test] Rewrote test to work with lit internal shell
 syntax

This patch rewrites a test that uses command substitution $() and the
stat command, which are not supported by lit's internal shell. Instead
of using this syntax to perform the file size comparison done in this
test, a Python script is used instead to perform the same operation.
---
 clang/test/Modules/compare-file-size.py  | 22 ++
 clang/test/Modules/reduced-bmi-size.cppm |  3 +--
 clang/test/lit.cfg.py|  2 ++
 3 files changed, 25 insertions(+), 2 deletions(-)
 create mode 100644 clang/test/Modules/compare-file-size.py

diff --git a/clang/test/Modules/compare-file-size.py 
b/clang/test/Modules/compare-file-size.py
new file mode 100644
index 00..ca3b16442353c7
--- /dev/null
+++ b/clang/test/Modules/compare-file-size.py
@@ -0,0 +1,22 @@
+import argparse
+import os
+
+def get_file_size(file_path):
+try:
+return os.path.getsize(file_path)
+except:
+print(f"Unable to get file size of {file_path}")
+return None
+
+def main():
+parser = argparse.ArgumentParser()
+
+parser.add_argument("file1", type=str)
+parser.add_argument("file2", type=str)
+
+args = parser.parse_args()
+
+return get_file_size(args.file1) < get_file_size(args.file2)
+
+if __name__ == "__main__":
+main()
diff --git a/clang/test/Modules/reduced-bmi-size.cppm 
b/clang/test/Modules/reduced-bmi-size.cppm
index 664f45f5c6a5a7..6d62573bc7aa39 100644
--- a/clang/test/Modules/reduced-bmi-size.cppm
+++ b/clang/test/Modules/reduced-bmi-size.cppm
@@ -10,7 +10,6 @@
 // RUN: %clang_cc1 -std=c++20 -emit-module-interface %s -o %t/a.pcm
 // RUN: %clang_cc1 -std=c++20 -emit-reduced-module-interface %s -o 
%t/a.reduced.pcm
 //
-// %s implies the current source file. So we can't use it directly.
-// RUN: [ $(stat -c%\s "%t/a.pcm") -le $(stat -c%\s "%t/a.reduced.pcm") ]
+// RUN: %{python} %S/compare-file-size.py %t/a.pcm %t/a.reduced.pcm
 
 export module a;
diff --git a/clang/test/lit.cfg.py b/clang/test/lit.cfg.py
index 92a3361ce672e2..59330a6d51a611 100644
--- a/clang/test/lit.cfg.py
+++ b/clang/test/lit.cfg.py
@@ -74,6 +74,8 @@
 
 config.substitutions.append(("%PATH%", config.environment["PATH"]))
 
+config.substitutions.append(("%{python}", '"%s"' % (sys.executable)))
+
 
 # For each occurrence of a clang tool name, replace it with the full path to
 # the build directory holding that tool.  We explicitly specify the directories

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [compiler-rt] [clang][compiler-rt][test] Removed dirname command substitutions from tests (PR #105754)

2024-08-23 Thread Connie Zhu via cfe-commits

https://github.com/connieyzhu updated 
https://github.com/llvm/llvm-project/pull/105754

>From cfd90f666e9b6f65e277bc753de973a748a7b275 Mon Sep 17 00:00:00 2001
From: Connie Zhu 
Date: Thu, 22 Aug 2024 23:32:40 +
Subject: [PATCH 1/2] [clang][compiler-rt][test] Removed dirname command
 substitutions from tests

This patch rewrites tests that uses bash command substitution syntax $()
to execute the dirname command. This is done so that the tests can be
run using lit's internal shell.
---
 clang/test/Driver/offload-packager.c  | 99 ++-
 .../hwasan/TestCases/hwasan_symbolize.cpp | 11 ++-
 2 files changed, 56 insertions(+), 54 deletions(-)

diff --git a/clang/test/Driver/offload-packager.c 
b/clang/test/Driver/offload-packager.c
index 9adc202322521a..86363d6fa343bf 100644
--- a/clang/test/Driver/offload-packager.c
+++ b/clang/test/Driver/offload-packager.c
@@ -3,63 +3,64 @@
 // REQUIRES: amdgpu-registered-target
 // UNSUPPORTED: system-windows
 
-// RUN: %clang -cc1 %s -triple x86_64-unknown-linux-gnu -emit-obj -o %t.elf.o
+// RUN: rm -rf %t && mkdir -p %t
+// RUN: %clang -cc1 %s -triple x86_64-unknown-linux-gnu -emit-obj -o %t/elf.o
 
 // Check that we can extract files from the packaged binary.
-// RUN: clang-offload-packager -o %t.out \
-// RUN:   
--image=file=%t.elf.o,kind=openmp,triple=nvptx64-nvidia-cuda,arch=sm_70 \
-// RUN:   
--image=file=%t.elf.o,kind=openmp,triple=nvptx64-nvidia-cuda,arch=sm_80 \
-// RUN:   
--image=file=%t.elf.o,kind=openmp,triple=amdgcn-amd-amdhsa,arch=gfx908 \
-// RUN:   
--image=file=%t.elf.o,kind=openmp,triple=amdgcn-amd-amdhsa,arch=gfx90a \
-// RUN:   
--image=file=%t.elf.o,kind=openmp,triple=amdgcn-amd-amdhsa,arch=gfx90c 
-// RUN: clang-offload-packager %t.out \
-// RUN:   
--image=file=%t-sm_70.o,kind=openmp,triple=nvptx64-nvidia-cuda,arch=sm_70 \
-// RUN:   
--image=file=%t-gfx908.o,kind=openmp,triple=amdgcn-amd-amdhsa,arch=gfx908
-// RUN: diff %t-sm_70.o %t.elf.o
-// RUN: diff %t-gfx908.o %t.elf.o
+// RUN: clang-offload-packager -o %t/package.out \
+// RUN:   
--image=file=%t/elf.o,kind=openmp,triple=nvptx64-nvidia-cuda,arch=sm_70 \
+// RUN:   
--image=file=%t/elf.o,kind=openmp,triple=nvptx64-nvidia-cuda,arch=sm_80 \
+// RUN:   
--image=file=%t/elf.o,kind=openmp,triple=amdgcn-amd-amdhsa,arch=gfx908 \
+// RUN:   
--image=file=%t/elf.o,kind=openmp,triple=amdgcn-amd-amdhsa,arch=gfx90a \
+// RUN:   
--image=file=%t/elf.o,kind=openmp,triple=amdgcn-amd-amdhsa,arch=gfx90c 
+// RUN: clang-offload-packager %t/package.out \
+// RUN:   
--image=file=%t/sm_70.o,kind=openmp,triple=nvptx64-nvidia-cuda,arch=sm_70 \
+// RUN:   
--image=file=%t/gfx908.o,kind=openmp,triple=amdgcn-amd-amdhsa,arch=gfx908
+// RUN: diff %t/sm_70.o %t/elf.o
+// RUN: diff %t/gfx908.o %t/elf.o
 
 // Check that we generate a new name if one is not given
-// RUN: clang-offload-packager -o %t \
-// RUN:   
--image=file=%t.elf.o,kind=openmp,triple=nvptx64-nvidia-cuda,arch=sm_70 \
-// RUN:   
--image=file=%t.elf.o,kind=openmp,triple=nvptx64-nvidia-cuda,arch=sm_80 \
-// RUN:   
--image=file=%t.elf.o,kind=openmp,triple=amdgcn-amd-amdhsa,arch=gfx908 \
-// RUN:   
--image=file=%t.elf.o,kind=openmp,triple=amdgcn-amd-amdhsa,arch=gfx90a \
-// RUN:   --image=file=%t.elf.o,kind=hip,triple=amdgcn-amd-amdhsa,arch=gfx90c 
-// RUN: cd $(dirname "%t") && clang-offload-packager %t --image=kind=openmp
-// RUN: diff *-nvptx64-nvidia-cuda-sm_70.0.o %t.elf.o; rm 
*-nvptx64-nvidia-cuda-sm_70.0.o
-// RUN: diff *-nvptx64-nvidia-cuda-sm_80.1.o %t.elf.o; rm 
*-nvptx64-nvidia-cuda-sm_80.1.o
-// RUN: diff *-amdgcn-amd-amdhsa-gfx908.2.o %t.elf.o; rm 
*-amdgcn-amd-amdhsa-gfx908.2.o
-// RUN: diff *-amdgcn-amd-amdhsa-gfx90a.3.o %t.elf.o; rm 
*-amdgcn-amd-amdhsa-gfx90a.3.o
-// RUN: not diff *-amdgcn-amd-amdhsa-gfx90c.4.o %t.elf.o
+// RUN: clang-offload-packager -o %t/package \
+// RUN:   
--image=file=%t/elf.o,kind=openmp,triple=nvptx64-nvidia-cuda,arch=sm_70 \
+// RUN:   
--image=file=%t/elf.o,kind=openmp,triple=nvptx64-nvidia-cuda,arch=sm_80 \
+// RUN:   
--image=file=%t/elf.o,kind=openmp,triple=amdgcn-amd-amdhsa,arch=gfx908 \
+// RUN:   
--image=file=%t/elf.o,kind=openmp,triple=amdgcn-amd-amdhsa,arch=gfx90a \
+// RUN:   --image=file=%t/elf.o,kind=hip,triple=amdgcn-amd-amdhsa,arch=gfx90c 
+// RUN: cd %t && clang-offload-packager %t/package --image=kind=openmp
+// RUN: diff *-nvptx64-nvidia-cuda-sm_70.0.o %t/elf.o; rm 
*-nvptx64-nvidia-cuda-sm_70.0.o
+// RUN: diff *-nvptx64-nvidia-cuda-sm_80.1.o %t/elf.o; rm 
*-nvptx64-nvidia-cuda-sm_80.1.o
+// RUN: diff *-amdgcn-amd-amdhsa-gfx908.2.o %t/elf.o; rm 
*-amdgcn-amd-amdhsa-gfx908.2.o
+// RUN: diff *-amdgcn-amd-amdhsa-gfx90a.3.o %t/elf.o; rm 
*-amdgcn-amd-amdhsa-gfx90a.3.o
+// RUN: not diff *-amdgcn-amd-amdhsa-gfx90c.4.o %t/elf.o
 
 // Check that we can extract from an ELF object file
-// RUN: clang-offload-packager -o %t.out \
-// RUN:   
--image=file=%t.elf.o,kind=openmp,triple=amdgcn-amd-amdhsa,arch=gfx908 \
-// RUN:   
--image=file=%t.elf.o,kind=openmp,triple=nvptx64-

[clang] [compiler-rt] [clang][compiler-rt][test] Removed dirname command substitutions from tests (PR #105754)

2024-08-23 Thread Connie Zhu via cfe-commits


@@ -1,8 +1,9 @@
-// RUN: %clang_hwasan -Wl,--build-id -g %s -o %t
-// RUN: echo '[{"prefix": "'"$(realpath $(dirname %s))"'/", "link": 
"http://test.invalid/{file}:{line}"}]' > %t.linkify
-// RUN: %env_hwasan_opts=symbolize=0 not %run %t 2>&1 | hwasan_symbolize 
--html --symbols $(dirname %t) --index | FileCheck %s
-// RUN: %env_hwasan_opts=symbolize=0 not %run %t 2>&1 | hwasan_symbolize 
--html --linkify %t.linkify --symbols $(dirname %t) --index | FileCheck 
--check-prefixes=CHECK,LINKIFY %s
-// RUN: %env_hwasan_opts=symbolize=0 not %run %t 2>&1 | hwasan_symbolize 
--symbols $(dirname %t) --index | FileCheck %s
+// RUN: rm -rf %t && mkdir -p %t
+// RUN: %clang_hwasan -Wl,--build-id -g %s -o %t/symbolize.exe

connieyzhu wrote:

I made this change in my latest commit. Thanks for the feedback!

https://github.com/llvm/llvm-project/pull/105754
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [compiler-rt] [clang][compiler-rt][test] Removed dirname command substitutions from tests (PR #105754)

2024-08-23 Thread Connie Zhu via cfe-commits

https://github.com/connieyzhu updated 
https://github.com/llvm/llvm-project/pull/105754

>From 52addf5d3e0e4752d9a1e6f5145dc37e9132bbe5 Mon Sep 17 00:00:00 2001
From: Connie Zhu 
Date: Thu, 22 Aug 2024 23:32:40 +
Subject: [PATCH 1/3] [clang][compiler-rt][test] Removed dirname command
 substitutions from tests

This patch rewrites tests that uses bash command substitution syntax $()
to execute the dirname command. This is done so that the tests can be
run using lit's internal shell.
---
 clang/test/Driver/offload-packager.c  | 99 ++-
 .../hwasan/TestCases/hwasan_symbolize.cpp | 11 ++-
 2 files changed, 56 insertions(+), 54 deletions(-)

diff --git a/clang/test/Driver/offload-packager.c 
b/clang/test/Driver/offload-packager.c
index 9adc202322521a..86363d6fa343bf 100644
--- a/clang/test/Driver/offload-packager.c
+++ b/clang/test/Driver/offload-packager.c
@@ -3,63 +3,64 @@
 // REQUIRES: amdgpu-registered-target
 // UNSUPPORTED: system-windows
 
-// RUN: %clang -cc1 %s -triple x86_64-unknown-linux-gnu -emit-obj -o %t.elf.o
+// RUN: rm -rf %t && mkdir -p %t
+// RUN: %clang -cc1 %s -triple x86_64-unknown-linux-gnu -emit-obj -o %t/elf.o
 
 // Check that we can extract files from the packaged binary.
-// RUN: clang-offload-packager -o %t.out \
-// RUN:   
--image=file=%t.elf.o,kind=openmp,triple=nvptx64-nvidia-cuda,arch=sm_70 \
-// RUN:   
--image=file=%t.elf.o,kind=openmp,triple=nvptx64-nvidia-cuda,arch=sm_80 \
-// RUN:   
--image=file=%t.elf.o,kind=openmp,triple=amdgcn-amd-amdhsa,arch=gfx908 \
-// RUN:   
--image=file=%t.elf.o,kind=openmp,triple=amdgcn-amd-amdhsa,arch=gfx90a \
-// RUN:   
--image=file=%t.elf.o,kind=openmp,triple=amdgcn-amd-amdhsa,arch=gfx90c 
-// RUN: clang-offload-packager %t.out \
-// RUN:   
--image=file=%t-sm_70.o,kind=openmp,triple=nvptx64-nvidia-cuda,arch=sm_70 \
-// RUN:   
--image=file=%t-gfx908.o,kind=openmp,triple=amdgcn-amd-amdhsa,arch=gfx908
-// RUN: diff %t-sm_70.o %t.elf.o
-// RUN: diff %t-gfx908.o %t.elf.o
+// RUN: clang-offload-packager -o %t/package.out \
+// RUN:   
--image=file=%t/elf.o,kind=openmp,triple=nvptx64-nvidia-cuda,arch=sm_70 \
+// RUN:   
--image=file=%t/elf.o,kind=openmp,triple=nvptx64-nvidia-cuda,arch=sm_80 \
+// RUN:   
--image=file=%t/elf.o,kind=openmp,triple=amdgcn-amd-amdhsa,arch=gfx908 \
+// RUN:   
--image=file=%t/elf.o,kind=openmp,triple=amdgcn-amd-amdhsa,arch=gfx90a \
+// RUN:   
--image=file=%t/elf.o,kind=openmp,triple=amdgcn-amd-amdhsa,arch=gfx90c 
+// RUN: clang-offload-packager %t/package.out \
+// RUN:   
--image=file=%t/sm_70.o,kind=openmp,triple=nvptx64-nvidia-cuda,arch=sm_70 \
+// RUN:   
--image=file=%t/gfx908.o,kind=openmp,triple=amdgcn-amd-amdhsa,arch=gfx908
+// RUN: diff %t/sm_70.o %t/elf.o
+// RUN: diff %t/gfx908.o %t/elf.o
 
 // Check that we generate a new name if one is not given
-// RUN: clang-offload-packager -o %t \
-// RUN:   
--image=file=%t.elf.o,kind=openmp,triple=nvptx64-nvidia-cuda,arch=sm_70 \
-// RUN:   
--image=file=%t.elf.o,kind=openmp,triple=nvptx64-nvidia-cuda,arch=sm_80 \
-// RUN:   
--image=file=%t.elf.o,kind=openmp,triple=amdgcn-amd-amdhsa,arch=gfx908 \
-// RUN:   
--image=file=%t.elf.o,kind=openmp,triple=amdgcn-amd-amdhsa,arch=gfx90a \
-// RUN:   --image=file=%t.elf.o,kind=hip,triple=amdgcn-amd-amdhsa,arch=gfx90c 
-// RUN: cd $(dirname "%t") && clang-offload-packager %t --image=kind=openmp
-// RUN: diff *-nvptx64-nvidia-cuda-sm_70.0.o %t.elf.o; rm 
*-nvptx64-nvidia-cuda-sm_70.0.o
-// RUN: diff *-nvptx64-nvidia-cuda-sm_80.1.o %t.elf.o; rm 
*-nvptx64-nvidia-cuda-sm_80.1.o
-// RUN: diff *-amdgcn-amd-amdhsa-gfx908.2.o %t.elf.o; rm 
*-amdgcn-amd-amdhsa-gfx908.2.o
-// RUN: diff *-amdgcn-amd-amdhsa-gfx90a.3.o %t.elf.o; rm 
*-amdgcn-amd-amdhsa-gfx90a.3.o
-// RUN: not diff *-amdgcn-amd-amdhsa-gfx90c.4.o %t.elf.o
+// RUN: clang-offload-packager -o %t/package \
+// RUN:   
--image=file=%t/elf.o,kind=openmp,triple=nvptx64-nvidia-cuda,arch=sm_70 \
+// RUN:   
--image=file=%t/elf.o,kind=openmp,triple=nvptx64-nvidia-cuda,arch=sm_80 \
+// RUN:   
--image=file=%t/elf.o,kind=openmp,triple=amdgcn-amd-amdhsa,arch=gfx908 \
+// RUN:   
--image=file=%t/elf.o,kind=openmp,triple=amdgcn-amd-amdhsa,arch=gfx90a \
+// RUN:   --image=file=%t/elf.o,kind=hip,triple=amdgcn-amd-amdhsa,arch=gfx90c 
+// RUN: cd %t && clang-offload-packager %t/package --image=kind=openmp
+// RUN: diff *-nvptx64-nvidia-cuda-sm_70.0.o %t/elf.o; rm 
*-nvptx64-nvidia-cuda-sm_70.0.o
+// RUN: diff *-nvptx64-nvidia-cuda-sm_80.1.o %t/elf.o; rm 
*-nvptx64-nvidia-cuda-sm_80.1.o
+// RUN: diff *-amdgcn-amd-amdhsa-gfx908.2.o %t/elf.o; rm 
*-amdgcn-amd-amdhsa-gfx908.2.o
+// RUN: diff *-amdgcn-amd-amdhsa-gfx90a.3.o %t/elf.o; rm 
*-amdgcn-amd-amdhsa-gfx90a.3.o
+// RUN: not diff *-amdgcn-amd-amdhsa-gfx90c.4.o %t/elf.o
 
 // Check that we can extract from an ELF object file
-// RUN: clang-offload-packager -o %t.out \
-// RUN:   
--image=file=%t.elf.o,kind=openmp,triple=amdgcn-amd-amdhsa,arch=gfx908 \
-// RUN:   
--image=file=%t.elf.o,kind=openmp,triple=nvptx64-