summaryrefslogtreecommitdiffstats
path: root/llvm/test
diff options
context:
space:
mode:
authorJordan Rupprecht <rupprecht@google.com>2018-08-16 18:29:40 +0000
committerJordan Rupprecht <rupprecht@google.com>2018-08-16 18:29:40 +0000
commitd1767dc56f5be75bdff23f3fe33e54428fed704f (patch)
tree8d75c60dba6e982208745f6b768aac10e1b1f4a4 /llvm/test
parent8b5e6991d28c7a672b7d88bb15a755566dd66199 (diff)
downloadbcm5719-llvm-d1767dc56f5be75bdff23f3fe33e54428fed704f.tar.gz
bcm5719-llvm-d1767dc56f5be75bdff23f3fe33e54428fed704f.zip
[llvm-strip] Add support for -p/--preserve-dates
Summary: [llvm-strip] Preserve access/modification timestamps when -p is used. Reviewers: jakehehrlich, jhenderson, alexshap Reviewed By: jhenderson Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D50744 llvm-svn: 339921
Diffstat (limited to 'llvm/test')
-rw-r--r--llvm/test/tools/llvm-objcopy/strip-preserve-time.test70
1 files changed, 70 insertions, 0 deletions
diff --git a/llvm/test/tools/llvm-objcopy/strip-preserve-time.test b/llvm/test/tools/llvm-objcopy/strip-preserve-time.test
new file mode 100644
index 00000000000..d2f50b777eb
--- /dev/null
+++ b/llvm/test/tools/llvm-objcopy/strip-preserve-time.test
@@ -0,0 +1,70 @@
+# Note: ls -lu prints the accessed timestamp, ls -l prints the modified timestamp
+
+# Preserve dates when stripping to an output file.
+# RUN: yaml2obj %s > %t.1.o
+# RUN: touch -a -t 199505050555.55 %t.1.o
+# RUN: touch -m -t 199705050555.55 %t.1.o
+# RUN: llvm-strip -p %t.1.o -o %t-preserved.1.o
+# RUN: ls -lu %t-preserved.1.o | FileCheck %s --check-prefix=CHECK-PRESERVE-ATIME
+# RUN: ls -l %t-preserved.1.o | FileCheck %s --check-prefix=CHECK-PRESERVE-MTIME
+
+# Preserve dates available via objcopy interface as well.
+# RUN: yaml2obj %s > %t.2.o
+# RUN: touch -a -t 199505050555.55 %t.2.o
+# RUN: touch -m -t 199705050555.55 %t.2.o
+# RUN: llvm-objcopy -p %t.2.o %t-preserved.2.o
+# RUN: ls -lu %t-preserved.2.o | FileCheck %s --check-prefix=CHECK-PRESERVE-ATIME
+# RUN: ls -l %t-preserved.2.o | FileCheck %s --check-prefix=CHECK-PRESERVE-MTIME
+
+# Preserve dates when stripping in place.
+# RUN: yaml2obj %s > %t.3.o
+# RUN: touch -a -t 199505050555.55 %t.3.o
+# RUN: touch -m -t 199705050555.55 %t.3.o
+# RUN: llvm-strip -p %t.3.o
+# RUN: ls -lu %t.3.o | FileCheck %s --check-prefix=CHECK-PRESERVE-ATIME
+# RUN: ls -l %t.3.o | FileCheck %s --check-prefix=CHECK-PRESERVE-MTIME
+
+# Without -p set, don't preserve dates.
+# RUN: yaml2obj %s > %t.4.o
+# RUN: touch -a -t 199505050555.55 %t.4.o
+# RUN: touch -m -t 199705050555.55 %t.4.o
+# RUN: llvm-strip %t.4.o
+# RUN: ls -lu %t.4.o | FileCheck %s --check-prefix=CHECK-NO-PRESERVE-ATIME
+# RUN: ls -l %t.4.o | FileCheck %s --check-prefix=CHECK-NO-PRESERVE-MTIME
+
+# Preserve dates in archives.
+# RUN: yaml2obj %s > %t.5.o
+# RUN: rm -f %t.a
+# RUN: llvm-ar cr %t.a %t.5.o
+# RUN: touch -a -t 199505050555.55 %t.a
+# RUN: touch -m -t 199705050555.55 %t.a
+# RUN: llvm-strip -p %t.a
+# RUN: ls -lu %t.a | FileCheck %s --check-prefix=CHECK-PRESERVE-ATIME
+# RUN: ls -l %t.a | FileCheck %s --check-prefix=CHECK-PRESERVE-MTIME
+
+# Preserve dates in split DWO files.
+# RUN: cp %p/Inputs/dwarf.dwo %t-input.dwo
+# RUN: touch -a -t 199505050555.55 %t-input.dwo
+# RUN: touch -m -t 199705050555.55 %t-input.dwo
+# RUN: llvm-objcopy -p -split-dwo=%t-dwo %t-input.dwo %t-nondwo
+# RUN: ls -lu %t-dwo | FileCheck %s --check-prefix=CHECK-PRESERVE-ATIME
+# RUN: ls -l %t-dwo | FileCheck %s --check-prefix=CHECK-PRESERVE-MTIME
+# RUN: ls -lu %t-nondwo | FileCheck %s --check-prefix=CHECK-PRESERVE-ATIME
+# RUN: ls -l %t-nondwo | FileCheck %s --check-prefix=CHECK-PRESERVE-MTIME
+
+# CHECK-PRESERVE-ATIME: 1995
+# CHECK-PRESERVE-MTIME: 1997
+
+# CHECK-NO-PRESERVE-ATIME-NOT: 1995
+# CHECK-NO-PRESERVE-MTIME-NOT: 1997
+
+!ELF
+FileHeader:
+ Class: ELFCLASS64
+ Data: ELFDATA2LSB
+ Type: ET_REL
+ Machine: EM_X86_64
+Sections:
+ - Name: .text
+ Type: SHT_PROGBITS
+ Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
OpenPOWER on IntegriCloud