[llvm] 399b127 - [llvm-ar] Add more tests for errors in opening archives

Shoaib Meenai via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 5 10:39:27 PDT 2020


Author: Sameer Arora
Date: 2020-06-05T10:36:58-07:00
New Revision: 399b12700b41cd58484c23639e61cace819229f6

URL: https://github.com/llvm/llvm-project/commit/399b12700b41cd58484c23639e61cace819229f6
DIFF: https://github.com/llvm/llvm-project/commit/399b12700b41cd58484c23639e61cace819229f6.diff

LOG: [llvm-ar] Add more tests for errors in opening archives

Add 2 more tests for the function performOperation under llvm-ar.cpp. It
tests the scenario when the archive could not be opened for reasons
other than `no_such_file_or_directory` In particular, it tests for the
cases `permission_denied` and `is_a_directory` for the target archive.

Reviewed By: alexshap, jhenderson, smeenai, MaskRay

Differential Revision: https://reviews.llvm.org/D80838

Added: 
    llvm/test/tools/llvm-ar/error-opening-directory.test
    llvm/test/tools/llvm-ar/error-opening-permission.test

Modified: 
    

Removed: 
    


################################################################################
diff  --git a/llvm/test/tools/llvm-ar/error-opening-directory.test b/llvm/test/tools/llvm-ar/error-opening-directory.test
new file mode 100644
index 000000000000..63d0c653c37a
--- /dev/null
+++ b/llvm/test/tools/llvm-ar/error-opening-directory.test
@@ -0,0 +1,8 @@
+# RUN: rm -rf %t && mkdir -p %t
+
+## Passing in a directory:
+# RUN: mkdir -p %t/tmpDir
+# RUN: not llvm-ar p %t/tmpDir 2>&1 | \
+# RUN:    FileCheck %s --check-prefix=IS-DIR -DARCHIVE=%t/tmpDir
+
+# IS-DIR: error: error opening '[[ARCHIVE]]': {{[iI]}}s a directory

diff  --git a/llvm/test/tools/llvm-ar/error-opening-permission.test b/llvm/test/tools/llvm-ar/error-opening-permission.test
new file mode 100644
index 000000000000..e78e76cd9513
--- /dev/null
+++ b/llvm/test/tools/llvm-ar/error-opening-permission.test
@@ -0,0 +1,14 @@
+## Unsupported on windows as marking files "unreadable"
+## is non-trivial on windows.
+# UNSUPPORTED: system-windows
+
+# RUN: rm -rf %t && mkdir -p %t
+# RUN: echo file1 > %t/1.txt
+
+## No Permission:
+# RUN: llvm-ar rc %t/permission.b %t/1.txt
+# RUN: chmod 100 %t/permission.b
+# RUN: not llvm-ar p %t/permission.b 2>&1 | \
+# RUN:   FileCheck %s --check-prefix=NO-PERMISSION -DARCHIVE=%t/permission.b
+
+# NO-PERMISSION: error: error opening '[[ARCHIVE]]': {{[pP]}}ermission denied


        


More information about the llvm-commits mailing list