Debian Codegraph @

llvm/test/tools/llvm-objcopy/ELF/mirror-permissions-unix.test

raw
1 ## Test that permissions for ouput files are mirrored
2 ## from their input files.
3
4 ## The Unix version of this test must use umask(1) because
5 ## llvm-objcopy respects the umask in setting output permissions.
6 ## Setting the umask to 0 ensures deterministic permissions across
7 ## test environments.
8 # UNSUPPORTED: system-windows
9
10 # RUN: touch %t
11 # RUN: chmod 0777 %t
12 # RUN: ls -l %t | cut -f 1 -d ' ' > %t.0777
13 # RUN: chmod 0666 %t
14 # RUN: ls -l %t | cut -f 1 -d ' ' > %t.0666
15 # RUN: chmod 0640 %t
16 # RUN: ls -l %t | cut -f 1 -d ' ' > %t.0640
17
18 ## Set umask to be permissive of all permissions,
19 ## only test mirroring of permissions.
20 # RUN: umask 0
21
22 # RUN: yaml2obj %s -o %t
23
24 # RUN: chmod 0777 %t
25 # RUN: llvm-objcopy %t %t1
26 # RUN: ls -l %t1 | cut -f 1 -d ' ' > %t1.perms
27 # RUN: cmp %t1.perms %t.0777
28
29 # RUN: chmod 0666 %t
30 # RUN: llvm-objcopy %t %t1
31 # RUN: ls -l %t1 | cut -f 1 -d ' ' > %t1.perms
32 # RUN: cmp %t1.perms %t.0666
33
34 # RUN: chmod 0640 %t
35 # RUN: llvm-objcopy %t %t1
36 # RUN: ls -l %t1 | cut -f 1 -d ' ' > %t1.perms
37 # RUN: cmp %t1.perms %t.0640
38
39 ## Drop S_ISUID/S_ISGID bits.
40 # RUN: chmod 6640 %t
41 # RUN: llvm-objcopy %t %t1
42 # RUN: ls -l %t1 | cut -f 1 -d ' ' > %t1.perms
43 # RUN: cmp %t1.perms %t.0640
44
45 ## Don't set the permission of a character special file, otherwise there will
46 ## be an EPERM error (or worse: root may change the permission).
47 # RUN: ls -l /dev/null | cut -f 1 -d ' ' > %tnull.perms
48 # RUN: llvm-objcopy %t /dev/null
49 # RUN: ls -l /dev/null | cut -f 1 -d ' ' | diff - %tnull.perms
50
51 ## Ignore umask if the output filename is the same as the input filename.
52 # RUN: umask 022
53 # RUN: cp %t %t1 && chmod 0777 %t1 && llvm-objcopy %t1
54 # RUN: ls -l %t1 | cut -f 1 -d ' ' > %t1.perms
55 # RUN: cmp %t1.perms %t.0777
56
57 --- !ELF
58 FileHeader:
59 Class: ELFCLASS64
60 Data: ELFDATA2LSB
61 Type: ET_EXEC
62 Machine: EM_X86_64