xref: /llvm-project/llvm/test/tools/llvm-objcopy/ELF/respect-umask.test (revision 9ec6f9e07e6b9529a26fc5e6382cf6548a21caf0)
17439a9a9SAlex Brachet## This tests that the umask is respected when
27439a9a9SAlex Brachet## assigning permissions of output files.
37439a9a9SAlex Brachet
47439a9a9SAlex Brachet## Windows has no umask so this test makes no sense, nor would
57439a9a9SAlex Brachet## it work because there is no umask(1) in a Windows environment
67439a9a9SAlex Brachet# UNSUPPORTED: system-windows
7*9ec6f9e0SDavid Blaikie# REQUIRES: shell
87439a9a9SAlex Brachet
93c47d38fSFangrui Song# RUN: rm -f %t
107439a9a9SAlex Brachet# RUN: touch %t
117439a9a9SAlex Brachet# RUN: chmod 0755 %t
127439a9a9SAlex Brachet# RUN: ls -l %t | cut -f 1 -d ' ' > %t.0755
13553c29faSAlex Brachet# RUN: chmod 0600 %t
14553c29faSAlex Brachet# RUN: ls -l %t | cut -f 1 -d ' ' > %t.0600
15553c29faSAlex Brachet# RUN: chmod 0655 %t
16553c29faSAlex Brachet# RUN: ls -l %t | cut -f 1 -d ' ' > %t.0655
177439a9a9SAlex Brachet
18553c29faSAlex Brachet# RUN: yaml2obj %s -o %t
197439a9a9SAlex Brachet
207439a9a9SAlex Brachet# RUN: umask 0022
217439a9a9SAlex Brachet# RUN: chmod 0777 %t
22553c29faSAlex Brachet# RUN: llvm-objcopy %t %t1
23553c29faSAlex Brachet# RUN: ls -l %t1 | cut -f 1 -d ' ' | cmp - %t.0755
24553c29faSAlex Brachet
25553c29faSAlex Brachet# RUN: umask 0177
26553c29faSAlex Brachet# RUN: llvm-objcopy %t %t2
27553c29faSAlex Brachet# RUN: ls -l %t2 | cut -f 1 -d ' ' | cmp - %t.0600
28553c29faSAlex Brachet
29553c29faSAlex Brachet# RUN: umask 0122
30553c29faSAlex Brachet# RUN: llvm-objcopy %t %t3
31553c29faSAlex Brachet# RUN: ls -l %t3 | cut -f 1 -d ' ' | cmp - %t.0655
327439a9a9SAlex Brachet
337439a9a9SAlex Brachet--- !ELF
347439a9a9SAlex BrachetFileHeader:
357439a9a9SAlex Brachet  Class:   ELFCLASS64
367439a9a9SAlex Brachet  Data:    ELFDATA2LSB
377439a9a9SAlex Brachet  Type:    ET_EXEC
387439a9a9SAlex Brachet  Machine: EM_X86_64
39