1# Test the 'N' count parameter. 2 3# Get a temp clean cwd to extract into. 4RUN: rm -rf %t && mkdir -p %t && cd %t 5 6RUN: mkdir -p %t/x %t/y %t/z 7RUN: echo hello > %t/x/foo.txt 8RUN: echo cool > %t/y/foo.txt 9RUN: echo world > %t/z/foo.txt 10RUN: echo fizz > %t/x/bar.txt 11RUN: echo buzz > %t/y/bar.txt 12RUN: echo fizbuz > %t/z/bar.txt 13RUN: llvm-ar rc %t/archive.a %t/x/foo.txt %t/y/foo.txt %t/z/foo.txt \ 14RUN: %t/x/bar.txt %t/y/bar.txt %t/z/bar.txt 15RUN: llvm-ar t %t/archive.a | FileCheck %s --check-prefix=LIST-MEMBERS 16 17# Make sure we set it up correctly. 18LIST-MEMBERS: foo.txt 19LIST-MEMBERS-NEXT: foo.txt 20LIST-MEMBERS-NEXT: foo.txt 21LIST-MEMBERS-NEXT: bar.txt 22LIST-MEMBERS-NEXT: bar.txt 23LIST-MEMBERS-NEXT: bar.txt 24 25# Must be a number. 26RUN: not llvm-ar xN abc %t/archive.a foo.txt 2>&1 | FileCheck %s --check-prefix=ERR-NOT-NUM 27RUN: not llvm-ar xN 0x1 %t/archive.a foo.txt 2>&1 | FileCheck %s --check-prefix=ERR-NOT-NUM 28# Only three members named foo, so 1 <= N <= 3. 29RUN: not llvm-ar xN 0 %t/archive.a foo.txt 2>&1 | FileCheck %s --check-prefix=ERR-NOT-POS 30RUN: not llvm-ar xN 4 %t/archive.a foo.txt 2>&1 | FileCheck %s --check-prefix=ERR-NOT-FOUND 31# N only applies to x/d. 32RUN: not llvm-ar rN 1 %t/archive.a foo.txt 2>&1 | FileCheck %s --check-prefix=ERR-BAD-OP 33 34ERR-NOT-NUM: error: value for [count] must be numeric 35ERR-NOT-POS: error: value for [count] must be positive 36ERR-BAD-OP: error: the 'N' modifier can only be specified with the 'x' or 'd' operations 37ERR-NOT-FOUND: error: 'foo.txt' was not found 38 39# Extract individual items. 40 41RUN: rm -f foo.txt bar.txt 42RUN: llvm-ar xN 1 %t/archive.a foo.txt bar.txt 43RUN: cat %t/foo.txt | FileCheck %s --check-prefix=FOO-1 44RUN: cat %t/bar.txt | FileCheck %s --check-prefix=BAR-1 45 46RUN: rm -f foo.txt bar.txt 47RUN: llvm-ar xN 2 %t/archive.a foo.txt bar.txt 48RUN: cat %t/foo.txt | FileCheck %s --check-prefix=FOO-2 49RUN: cat %t/bar.txt | FileCheck %s --check-prefix=BAR-2 50 51RUN: rm -f foo.txt bar.txt 52RUN: llvm-ar xN 3 %t/archive.a foo.txt bar.txt 53RUN: cat %t/foo.txt | FileCheck %s --check-prefix=FOO-3 54RUN: cat %t/bar.txt | FileCheck %s --check-prefix=BAR-3 55 56# Delete individual items. 57 58# Deleting the second member named foo means the new second member of the 59# archive is what used to be the third element. 60RUN: rm -f foo.txt bar.txt 61RUN: llvm-ar dN 2 %t/archive.a foo.txt 62RUN: llvm-ar xN 2 %t/archive.a foo.txt bar.txt 63RUN: cat %t/foo.txt | FileCheck %s --check-prefix=FOO-3 64RUN: cat %t/bar.txt | FileCheck %s --check-prefix=BAR-2 65 66# Deleting the first member from *both* archives means the new first member 67# named foo is the what used to be the third member, and the new first member 68# named bar is what used to be the second member. 69RUN: rm -f foo.txt bar.txt 70RUN: llvm-ar dN 1 %t/archive.a foo.txt bar.txt 71RUN: llvm-ar xN 1 %t/archive.a foo.txt bar.txt 72RUN: cat %t/foo.txt | FileCheck %s --check-prefix=FOO-3 73RUN: cat %t/bar.txt | FileCheck %s --check-prefix=BAR-2 74 75FOO-1: hello 76FOO-2: cool 77FOO-3: world 78BAR-1: fizz 79BAR-2: buzz 80BAR-3: fizbuz 81