[PATCH] D112583: [test][objcopy] Replace GNU sed extension with BSD compatible syntax.

Daniel Rodríguez Troitiño via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 26 17:06:54 PDT 2021


drodriguez created this revision.
drodriguez added reviewers: nuriamari, alexander-shaposhnikov, smeenai, gkm.
Herald added a reviewer: rupprecht.
Herald added a reviewer: jhenderson.
Herald added a subscriber: abrachet.
drodriguez requested review of this revision.
Herald added subscribers: llvm-commits, MaskRay.
Herald added a project: LLVM.

GNU sed offers the `,+4d` to delete the line a next four lines, but BSD
sed doesn't seem to support it (at least in macOS 10.15, but seems to do
in my 11.6 version).

Replace the usage of the extension with the equivalent syntax that works
both in BSD and GNU sed. I don't have a macOS 10.15 to check, but this
works in both my macOS 11.6 and Linux machines.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D112583

Files:
  llvm/test/tools/llvm-objcopy/MachO/code_signature_lc.test


Index: llvm/test/tools/llvm-objcopy/MachO/code_signature_lc.test
===================================================================
--- llvm/test/tools/llvm-objcopy/MachO/code_signature_lc.test
+++ llvm/test/tools/llvm-objcopy/MachO/code_signature_lc.test
@@ -13,24 +13,26 @@
 # RUN: obj2yaml %t.copy > %t.copy.yaml
 
 ## Verify that the copy still includes the load command
-# RUN: cat %t.copy.yaml | FileCheck %s --check-prefix=CHECK-COPY
+# RUN: FileCheck %s --check-prefix=CHECK-COPY < %t.copy.yaml
 # CHECK-COPY:      - cmd:             LC_CODE_SIGNATURE
 # CHECK-COPY-NEXT:   cmdsize:         16
 # CHECK-COPY-NEXT:   dataoff:         16544
 # CHECK-COPY-NEXT:   datasize:        304
 
 ## Remove information changed by regeneration of load command:
-## - __LINKEDIT segment filesize may change
-## - LC_CODE_SIGNATURE command dataoff and datasize may change
+## - __LINKEDIT segment filesize may change (4 lines)
+## - LC_CODE_SIGNATURE command dataoff and datasize may change (3 lines)
 ## - __LINKEDIT data locations may change
+## NOTE: The {N;N;N;N;d} means delete the next four lines for BSD and GNU sed.
+##       The ,+4d is a GNU extension which seems not to work in macOS 10.15
 
-# RUN: sed -e '/__LINKEDIT/,+4d' \
-# RUN:     -e '/LC_CODE_SIGNATURE/,+3d' \ 
+# RUN: sed -e '/__LINKEDIT/{N;N;N;N;d;}' \
+# RUN:     -e '/LC_CODE_SIGNATURE/{N;N;N;d}' \
 # RUN:     -e '/n_strx/d' \ 
 # RUN:     -e '/dyld_stub_binder/d' %t.yaml > %t.clean.yaml
 
-# RUN: sed -e '/__LINKEDIT/,+4d' \
-# RUN:     -e '/LC_CODE_SIGNATURE/,+3d' \ 
+# RUN: sed -e '/__LINKEDIT/{N;N;N;N;d;}' \
+# RUN:     -e '/LC_CODE_SIGNATURE/{N;N;N;d;}' \
 # RUN:     -e '/n_strx/d' \ 
 # RUN:     -e '/dyld_stub_binder/d' %t.copy.yaml > %t.copy.clean.yaml
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D112583.382488.patch
Type: text/x-patch
Size: 1738 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211027/c20b1002/attachment.bin>


More information about the llvm-commits mailing list