[llvm] 2ab260e - [llvm-ar][test] Add additional MRI script testing
via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 4 06:24:44 PDT 2022
Author: gbreynoo
Date: 2022-07-04T14:24:25+01:00
New Revision: 2ab260eecfab56aabc9cff979c1618859d3b883d
URL: https://github.com/llvm/llvm-project/commit/2ab260eecfab56aabc9cff979c1618859d3b883d
DIFF: https://github.com/llvm/llvm-project/commit/2ab260eecfab56aabc9cff979c1618859d3b883d.diff
LOG: [llvm-ar][test] Add additional MRI script testing
This commit adds:
- Additional test coverage of the DELETE and END commands.
- File names to be read in the line endings test.
- A use of ADDLIB in the nonascii test.
Differential Revision: https://reviews.llvm.org/D128838
Added:
Modified:
llvm/test/tools/llvm-ar/Inputs/mri-crlf.mri
llvm/test/tools/llvm-ar/mri-crlf.test
llvm/test/tools/llvm-ar/mri-delete.test
llvm/test/tools/llvm-ar/mri-end.test
llvm/test/tools/llvm-ar/mri-nonascii.test
Removed:
################################################################################
diff --git a/llvm/test/tools/llvm-ar/Inputs/mri-crlf.mri b/llvm/test/tools/llvm-ar/Inputs/mri-crlf.mri
index b8540304f2eeb..72d23d041ae80 100644
--- a/llvm/test/tools/llvm-ar/Inputs/mri-crlf.mri
+++ b/llvm/test/tools/llvm-ar/Inputs/mri-crlf.mri
@@ -1,2 +1,4 @@
; this file intentionally has crlf line endings
+create crlf.a
+addmod foo.txt
end
diff --git a/llvm/test/tools/llvm-ar/mri-crlf.test b/llvm/test/tools/llvm-ar/mri-crlf.test
index 3411b55095e19..626e3de738793 100644
--- a/llvm/test/tools/llvm-ar/mri-crlf.test
+++ b/llvm/test/tools/llvm-ar/mri-crlf.test
@@ -1 +1,8 @@
-; RUN: llvm-ar -M < %S/Inputs/mri-crlf.mri
+# RUN: rm -rf %t && mkdir -p %t
+# RUN: cd %t
+
+# RUN: echo "FOO" > foo.txt
+# RUN: llvm-ar -M < %S/Inputs/mri-crlf.mri
+# llvm-ar t crlf.a | FileCheck %s
+
+# CHECK: foo.txt
diff --git a/llvm/test/tools/llvm-ar/mri-delete.test b/llvm/test/tools/llvm-ar/mri-delete.test
index bb829ce13c72c..37dc5a2283570 100644
--- a/llvm/test/tools/llvm-ar/mri-delete.test
+++ b/llvm/test/tools/llvm-ar/mri-delete.test
@@ -1,20 +1,168 @@
-RUN: yaml2obj %S/Inputs/elf.yaml -o %t.o
-RUN: rm -f %t.ar
-
-RUN: echo "create %t.ar;comment" > %t.mri
-RUN: echo "addmod %t.o * comment" >> %t.mri
-RUN: echo "; comment" >> %t.mri
-RUN: echo " ;comment" >> %t.mri
-RUN: echo "* comment" >> %t.mri
-RUN: echo " *comment" >> %t.mri
-RUN: echo "" >> %t.mri
-RUN: echo " " >> %t.mri
-RUN: echo "addmod %S/Inputs/elf.yaml" >> %t.mri
-RUN: echo "delete %t.o" >> %t.mri
-RUN: echo " save" >> %t.mri
-RUN: echo "end" >> %t.mri
-
-RUN: llvm-ar -M < %t.mri
-RUN: llvm-ar tv %t.ar | FileCheck %s
-
-CHECK-NOT: mri-delete.test{{.*}}.o
+# RUN: rm -rf %t && split-file %s %t
+# RUN: cd %t
+
+# RUN: yaml2obj %S/Inputs/elf.yaml -o elf.o
+# RUN: llvm-ar -rc elf.a elf.o text.txt
+# RUN: llvm-ar -rc --thin thin-elf.a elf.o text.txt
+
+## Basic delete.
+# RUN: llvm-ar -M < delete.mri
+# RUN: llvm-ar tv delete.ar | FileCheck %s --check-prefixes=DELETE --implicit-check-not=elf.o
+
+# DELETE: text.txt
+
+## Delete so the archive is empty.
+# RUN: llvm-ar -M < empty.mri
+# RUN: llvm-ar tv empty.ar | FileCheck %s --check-prefixes=EMPTY --allow-empty
+
+# EMPTY-NOT: elf.o
+
+## Attempt to delete a file that is not in the archive.
+# RUN: llvm-ar -M < bad.mri
+# RUN: llvm-ar tv bad.ar | FileCheck %s --check-prefixes=BOTH
+
+## Delete operation in a script with comments.
+# RUN: llvm-ar -M < comment.mri
+# RUN: llvm-ar tv comment.ar | FileCheck %s --check-prefixes=DELETE --implicit-check-not=elf.o
+
+## Add a file that has been deleted.
+# RUN: llvm-ar -M < re-add.mri
+# RUN: llvm-ar tv re-add.ar | FileCheck %s --check-prefixes=BOTH
+
+# BOTH-DAG: text.txt
+# BOTH-DAG: elf.o
+
+## Add the same file twice and delete them. It is expected behaviour
+## that one delete command deletes all matching members.
+# RUN: llvm-ar -M < duplicate.mri
+# RUN: llvm-ar tv duplicate.ar | FileCheck %s --check-prefixes=DELETE --implicit-check-not=elf.o
+
+## Add and delete the same file twice.
+# RUN: llvm-ar -M < duplicate-re-add.mri
+# RUN: llvm-ar tv duplicate-re-add.ar | FileCheck %s --check-prefixes=DELETE --implicit-check-not=elf.o
+
+## Attempt to delete the same file twice.
+# RUN: llvm-ar -M < extra-delete.mri
+# RUN: llvm-ar tv extra-delete.ar | FileCheck %s --check-prefixes=DELETE --implicit-check-not=elf.o
+
+## Add the same file to a thin archive twice.
+# RUN: llvm-ar -M < thin-duplicate.mri
+# RUN: llvm-ar tv thin-duplicate.ar | FileCheck %s --check-prefixes=DELETE --implicit-check-not=elf.o
+
+## Delete a file after it was added via ADDLIB.
+# RUN: llvm-ar -M < addlib.mri
+# RUN: llvm-ar tv addlib.ar | FileCheck %s --check-prefixes=DELETE --implicit-check-not=elf.o
+
+## Attempt to delete an archive after it was added via ADDLIB.
+# RUN: llvm-ar -M < addlib-deletelib.mri
+# RUN: llvm-ar tv addlib-deletelib.ar | FileCheck %s --check-prefixes=BOTH
+
+## Add the same archive twice to a thin archive and then delete some members.
+# RUN: llvm-ar -M < addlib-thin-duplicate.mri
+# RUN: llvm-ar tv addlib-thin-duplicate.ar | FileCheck %s --check-prefixes=DELETE --implicit-check-not=elf.o
+
+#--- text.txt
+I AM A TEXT FILE
+
+#--- delete.mri
+create delete.ar
+addmod text.txt
+addmod elf.o
+delete elf.o
+save
+end
+
+#--- empty.mri
+create empty.ar
+addmod elf.o
+delete elf.o
+save
+end
+
+#--- bad.mri
+create bad.ar
+addmod text.txt
+addmod elf.o
+delete bad.o
+save
+end
+
+#--- comment.mri
+create comment.ar
+addmod elf.o
+; comment
+addmod text.txt
+ ;comment
+delete elf.o
+* comment
+save
+ *comment
+end
+
+#--- re-add.mri
+create re-add.ar
+addmod elf.o
+addmod text.txt
+delete elf.o
+addmod elf.o
+save
+end
+
+#--- duplicate.mri
+create duplicate.ar
+addmod elf.o
+addmod elf.o
+addmod text.txt
+delete elf.o
+save
+end
+
+#--- duplicate-re-add.mri
+create duplicate-re-add.ar
+addmod elf.o
+delete elf.o
+addmod text.txt
+addmod elf.o
+delete elf.o
+save
+end
+
+#--- extra-delete.mri
+create extra-delete.ar
+addmod elf.o
+addmod text.txt
+delete elf.o
+delete elf.o
+save
+end
+
+#--- thin-duplicate.mri
+createthin thin-duplicate.ar
+addmod elf.o
+addmod elf.o
+addmod text.txt
+delete elf.o
+save
+end
+
+#--- addlib.mri
+create addlib.ar
+addlib elf.a
+delete elf.o
+save
+end
+
+#--- addlib-deletelib.mri
+create addlib-deletelib.ar
+addlib elf.a
+delete elf.a
+save
+end
+
+#--- addlib-thin-duplicate.mri
+createthin addlib-thin-duplicate.ar
+addlib thin-elf.a
+addlib thin-elf.a
+delete elf.o
+save
+end
diff --git a/llvm/test/tools/llvm-ar/mri-end.test b/llvm/test/tools/llvm-ar/mri-end.test
index a00f2f53aee26..dd052e74672c8 100644
--- a/llvm/test/tools/llvm-ar/mri-end.test
+++ b/llvm/test/tools/llvm-ar/mri-end.test
@@ -1,48 +1,92 @@
-# The END MRI command is optional. Scripts that omit
-# or include END should be handled by llvm-ar.
-RUN: rm -rf %t && mkdir -p %t
-
-# Empty File
-RUN: yaml2obj %S/Inputs/elf.yaml -o %t/elf.o
-
-RUN: touch %t/empty.mri
-RUN: llvm-ar -M < %t/empty.mri
-
-RUN: echo "END" > %t/empty-end.mri
-RUN: llvm-ar -M < %t/empty-end.mri
-
-# Comment only
-RUN: echo "; a comment" > %t/comment.mri
-RUN: llvm-ar -M < %t/comment.mri
-
-RUN: echo "; a comment" > %t/comment-end.mri
-RUN: echo "END" > %t/comment-end.mri
-RUN: llvm-ar -M < %t/comment-end.mri
-
-# Without Save
-RUN: echo "create %t/mri.ar" > %t/no-save.mri
-RUN: echo "addmod %t/elf.o" >> %t/no-save.mri
-RUN: llvm-ar -M < %t/no-save.mri
-RUN: test ! -e %t/mri.ar
-
-RUN: echo "create %t/mri.ar" > %t/no-save-end.mri
-RUN: echo "addmod %t/elf.o" >> %t/no-save-end.mri
-RUN: echo "END" > %t/no-save-end.mri
-RUN: llvm-ar -M < %t/no-save-end.mri
-RUN: test ! -e %t/mri.ar
-
-# With Save
-RUN: echo "create %t/mri.ar" > %t/save.mri
-RUN: echo "addmod %t/elf.o" >> %t/save.mri
-RUN: echo "save" >> %t/save.mri
-RUN: llvm-ar -M < %t/save.mri
-RUN: llvm-ar t %t/mri.ar | FileCheck %s
-
-RUN: echo "create %t/mri.ar" > %t/save-end.mri
-RUN: echo "addmod %t/elf.o" >> %t/save-end.mri
-RUN: echo "save" >> %t/save-end.mri
-RUN: echo "END" > %t/no-save-end.mri
-RUN: llvm-ar -M < %t/save-end.mri
-RUN: llvm-ar t %t/mri.ar | FileCheck %s
-
-CHECK: elf.o
+## The END MRI command is optional. Scripts that omit
+## or include END should be handled by llvm-ar.
+
+# RUN: rm -rf %t && split-file %s %t
+# RUN: cd %t
+
+# RUN: yaml2obj %S/Inputs/elf.yaml -o elf.o
+
+## Empty file.
+# RUN: touch empty.mri
+# RUN: llvm-ar -M < empty.mri
+# RUN: llvm-ar -M < empty-end.mri
+
+## Comment only.
+# RUN: llvm-ar -M < comment.mri
+# RUN: llvm-ar -M < comment-end.mri
+
+## Without SAVE.
+# RUN: llvm-ar -M < no-save.mri
+# RUN: test ! -e no-save.ar
+
+# RUN: llvm-ar -M < no-save-end.mri
+# RUN: test ! -e no-save-end.ar
+
+## With SAVE.
+# RUN: llvm-ar -M < save.mri
+# RUN: llvm-ar t save.ar | FileCheck %s
+
+# RUN: llvm-ar -M < save-end.mri
+# RUN: llvm-ar t save-end.ar | FileCheck %s
+
+## Duplicate use of END.
+# RUN: llvm-ar -M < duplicate-end-no-save.mri
+# RUN: test ! -e duplicate-end-no-save.ar
+
+# RUN: llvm-ar -M < duplicate-end-save.mri
+# RUN: llvm-ar t duplicate-end-save.ar | FileCheck %s
+
+## Use of END before saving.
+# RUN: llvm-ar -M < end-before-save.mri
+# RUN: llvm-ar t end-before-save.ar | FileCheck %s
+
+# CHECK: elf.o
+
+#--- empty-end.mri
+END
+
+#--- comment.mri
+; a comment
+
+#--- comment-end.mri
+; a comment
+END
+
+#--- no-save.mri
+create no-save.ar
+addmod elf.o
+
+#--- no-save-end.mri
+create no-save-end.ar
+addmod elf.o
+END
+
+#--- save.mri
+create save.ar
+addmod elf.o
+save
+
+#--- save-end.mri
+create save-end.ar
+addmod elf.o
+save
+end
+
+#--- duplicate-end-no-save.mri
+create duplicate-end-no-save.ar
+addmod elf.o
+END
+END
+
+#--- duplicate-end-save.mri
+create duplicate-end-save.ar
+addmod elf.o
+save
+END
+END
+
+#--- end-before-save.mri
+create end-before-save.ar
+addmod elf.o
+end
+save
diff --git a/llvm/test/tools/llvm-ar/mri-nonascii.test b/llvm/test/tools/llvm-ar/mri-nonascii.test
index 2a6888747564b..e3a99e1c3ca0b 100644
--- a/llvm/test/tools/llvm-ar/mri-nonascii.test
+++ b/llvm/test/tools/llvm-ar/mri-nonascii.test
@@ -1,21 +1,26 @@
-# Test non-ascii archive members
+## Test non-ascii archive members
-RUN: rm -rf %t && mkdir -p %t/extracted
+# RUN: rm -rf %t && mkdir -p %t/extracted
+# RUN: cd %t
-# Note: lit's Python will read this UTF-8 encoded mri-nonascii.txt file,
-# decode it to unicode. The filename in the redirection below will then
-# be encoded in the system's filename encoding (e.g. UTF-16 for
-# Microsoft Windows).
-RUN: echo "contents" > %t/£.txt
+## Note: lit's Python will read this UTF-8 encoded mri-nonascii.txt file,
+## decode it to unicode. The filename in the redirection below will then
+## be encoded in the system's filename encoding (e.g. UTF-16 for
+## Microsoft Windows).
+# RUN: echo "contents" > £.txt
+# RUN: echo "contents" > €.txt
+# RUN: llvm-ar -rc ¥.a €.txt
-RUN: echo "CREATE %t/mri.ar" > %t/script.mri
-RUN: echo "ADDMOD %t/£.txt" >> %t/script.mri
-RUN: echo "SAVE" >> %t/script.mri
+# RUN: echo "CREATE mri.ar" > script.mri
+# RUN: echo "ADDMOD £.txt" >> script.mri
+# RUN: echo "ADDLIB ¥.a" >> script.mri
+# RUN: echo "SAVE" >> script.mri
-RUN: llvm-ar -M < %t/script.mri
-RUN: cd %t/extracted && llvm-ar x %t/mri.ar
+# RUN: llvm-ar -M < script.mri
+# RUN: cd %t/extracted && llvm-ar x %t/mri.ar
-# Same as above.
-RUN: FileCheck --strict-whitespace %s <£.txt
-CHECK:{{^}}
-CHECK-SAME:{{^}}contents{{$}}
+## Same as above.
+# RUN: FileCheck --strict-whitespace %s <£.txt
+# RUN: FileCheck --strict-whitespace %s <€.txt
+# CHECK:{{^}}
+# CHECK-SAME:{{^}}contents{{$}}
More information about the llvm-commits
mailing list