[PATCH] D97472: [test] Use host platform specific error message substitution in lit tests

Abhina Sree via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 25 06:38:38 PST 2021


abhina.sreeskantharajan created this revision.
abhina.sreeskantharajan added reviewers: jhenderson, ASDenysPetrov.
Herald added a subscriber: delcypher.
abhina.sreeskantharajan requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

This patch uses the errno python library to print out the correct error messages instead of hardcoding the error message per platform.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D97472

Files:
  llvm/utils/lit/lit/llvm/config.py


Index: llvm/utils/lit/lit/llvm/config.py
===================================================================
--- llvm/utils/lit/lit/llvm/config.py
+++ llvm/utils/lit/lit/llvm/config.py
@@ -4,6 +4,7 @@
 import re
 import subprocess
 import sys
+import errno
 
 import lit.util
 from lit.llvm.subst import FindTool
@@ -346,21 +347,10 @@
         return True
 
     def add_err_msg_substitutions(self):
-        if (sys.platform == 'zos'):
-            self.config.substitutions.append(('%errc_ENOENT', '\'EDC5129I No such file or directory.\''))
-            self.config.substitutions.append(('%errc_EISDIR', '\'EDC5123I Is a directory.\''))
-            self.config.substitutions.append(('%errc_EINVAL', '\'EDC5121I Invalid argument.\''))
-            self.config.substitutions.append(('%errc_EACCES', '\'EDC5111I Permission denied.\''))
-        elif (sys.platform == 'win32'):
-            self.config.substitutions.append(('%errc_ENOENT', '\'no such file or directory\''))
-            self.config.substitutions.append(('%errc_EISDIR', '\'is a directory\''))
-            self.config.substitutions.append(('%errc_EINVAL', '\'invalid argument\''))
-            self.config.substitutions.append(('%errc_EACCES', '\'permission denied\''))
-        else:
-            self.config.substitutions.append(('%errc_ENOENT', '\'No such file or directory\''))
-            self.config.substitutions.append(('%errc_EISDIR', '\'Is a directory\''))
-            self.config.substitutions.append(('%errc_EINVAL', '\'Invalid argument\''))
-            self.config.substitutions.append(('%errc_EACCES', '\'Permission denied\''))
+        self.config.substitutions.append(('%errc_ENOENT', '\'' + os.strerror(errno.ENOENT) + '\''))
+        self.config.substitutions.append(('%errc_EISDIR', '\'' + os.strerror(errno.EISDIR) + '\''))
+        self.config.substitutions.append(('%errc_EINVAL', '\'' + os.strerror(errno.EINVAL) + '\''))
+        self.config.substitutions.append(('%errc_EACCES', '\'' + os.strerror(errno.EACCES) + '\''))
 
     def use_default_substitutions(self):
         tool_patterns = [


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D97472.326379.patch
Type: text/x-patch
Size: 2088 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210225/4e304737/attachment.bin>


More information about the llvm-commits mailing list