Skip to content

[SystemZ][z/OS] Enable lit testing for z/OS #107631

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 3 commits into from
Sep 9, 2024

Conversation

abhina-sree
Copy link
Contributor

This patch fixes various errors to enable llvm-lit to run on z/OS

@llvmbot
Copy link
Member

llvmbot commented Sep 6, 2024

@llvm/pr-subscribers-llvm-support

@llvm/pr-subscribers-testing-tools

Author: Abhina Sree (abhina-sree)

Changes

This patch fixes various errors to enable llvm-lit to run on z/OS


Full diff: https://github.com/llvm/llvm-project/pull/107631.diff

3 Files Affected:

  • (modified) llvm/lib/Support/raw_ostream.cpp (+4)
  • (modified) llvm/utils/lit/lit/run.py (+3-2)
  • (modified) llvm/utils/lit/lit/util.py (+4-1)
diff --git a/llvm/lib/Support/raw_ostream.cpp b/llvm/lib/Support/raw_ostream.cpp
index 2ce54faa9857e6..e39c03c918f735 100644
--- a/llvm/lib/Support/raw_ostream.cpp
+++ b/llvm/lib/Support/raw_ostream.cpp
@@ -843,6 +843,10 @@ size_t raw_fd_ostream::preferred_buffer_size() const {
   if (IsWindowsConsole)
     return 0;
   return raw_ostream::preferred_buffer_size();
+#elif defined(__MVS__)
+  // The buffer size on zOS is defined with macro BUFSIZ, which can be retrieved
+  // by invoking function raw_ostream::preferred_buffer_size().
+  return raw_ostream::preferred_buffer_size();
 #else
   assert(FD >= 0 && "File not yet open!");
   struct stat statbuf;
diff --git a/llvm/utils/lit/lit/run.py b/llvm/utils/lit/lit/run.py
index 535c859352cc4d..62070e824e87fa 100644
--- a/llvm/utils/lit/lit/run.py
+++ b/llvm/utils/lit/lit/run.py
@@ -1,5 +1,6 @@
 import multiprocessing
 import os
+import platform
 import time
 
 import lit.Test
@@ -136,6 +137,6 @@ def _increase_process_limit(self):
                     "Raised process limit from %d to %d" % (soft_limit, desired_limit)
                 )
         except Exception as ex:
-            # Warn, unless this is Windows, in which case this is expected.
-            if os.name != "nt":
+            # Warn, unless this is Windows or z/OS, in which case this is expected.
+            if os.name != "nt" and platform.system() != "OS/390":
                 self.lit_config.warning("Failed to raise process limit: %s" % ex)
diff --git a/llvm/utils/lit/lit/util.py b/llvm/utils/lit/lit/util.py
index a2452f5566b772..4e75cce092c672 100644
--- a/llvm/utils/lit/lit/util.py
+++ b/llvm/utils/lit/lit/util.py
@@ -502,7 +502,7 @@ def killProcessAndChildrenIsSupported():
         otherwise is contains a string describing why the function is
         not supported.
     """
-    if platform.system() == "AIX":
+    if platform.system() == "AIX" or platform.system() == "OS/390":
         return (True, "")
     try:
         import psutil  # noqa: F401
@@ -528,6 +528,9 @@ def killProcessAndChildren(pid):
     """
     if platform.system() == "AIX":
         subprocess.call("kill -kill $(ps -o pid= -L{})".format(pid), shell=True)
+    elif platform.system() == "OS/390":
+        # FIXME: Only the process is killed.
+        subprocess.call("kill -KILL $(ps -s {} -o pid=)".format(pid), shell=True)
     else:
         import psutil
 

Copy link
Contributor

@zibi2 zibi2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link

github-actions bot commented Sep 9, 2024

✅ With the latest revision this PR passed the C/C++ code formatter.

@abhina-sree abhina-sree merged commit eec1ee8 into llvm:main Sep 9, 2024
8 checks passed
@abhina-sree abhina-sree deleted the abhina/zos_lit branch September 9, 2024 18:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants