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
--- /dev/null
+# 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
--- /dev/null
+## 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