17439a9a9SAlex Brachet## Test that permissions for ouput files are mirrored 27439a9a9SAlex Brachet## from their input files. 37439a9a9SAlex Brachet 47439a9a9SAlex Brachet## The Unix version of this test must use umask(1) because 57439a9a9SAlex Brachet## llvm-objcopy respects the umask in setting output permissions. 67439a9a9SAlex Brachet## Setting the umask to 0 ensures deterministic permissions across 77439a9a9SAlex Brachet## test environments. 87439a9a9SAlex Brachet# UNSUPPORTED: system-windows 99ec6f9e0SDavid Blaikie# REQUIRES: shell 107439a9a9SAlex Brachet 117439a9a9SAlex Brachet# RUN: touch %t 127439a9a9SAlex Brachet# RUN: chmod 0777 %t 137439a9a9SAlex Brachet# RUN: ls -l %t | cut -f 1 -d ' ' > %t.0777 147439a9a9SAlex Brachet# RUN: chmod 0666 %t 157439a9a9SAlex Brachet# RUN: ls -l %t | cut -f 1 -d ' ' > %t.0666 167439a9a9SAlex Brachet# RUN: chmod 0640 %t 177439a9a9SAlex Brachet# RUN: ls -l %t | cut -f 1 -d ' ' > %t.0640 187439a9a9SAlex Brachet 197439a9a9SAlex Brachet## Set umask to be permissive of all permissions, 207439a9a9SAlex Brachet## only test mirroring of permissions. 217439a9a9SAlex Brachet# RUN: umask 0 227439a9a9SAlex Brachet 237439a9a9SAlex Brachet# RUN: yaml2obj %s -o %t 247439a9a9SAlex Brachet 257439a9a9SAlex Brachet# RUN: chmod 0777 %t 267439a9a9SAlex Brachet# RUN: llvm-objcopy %t %t1 277439a9a9SAlex Brachet# RUN: ls -l %t1 | cut -f 1 -d ' ' > %t1.perms 287439a9a9SAlex Brachet# RUN: cmp %t1.perms %t.0777 297439a9a9SAlex Brachet 307439a9a9SAlex Brachet# RUN: chmod 0666 %t 317439a9a9SAlex Brachet# RUN: llvm-objcopy %t %t1 327439a9a9SAlex Brachet# RUN: ls -l %t1 | cut -f 1 -d ' ' > %t1.perms 337439a9a9SAlex Brachet# RUN: cmp %t1.perms %t.0666 347439a9a9SAlex Brachet 357439a9a9SAlex Brachet# RUN: chmod 0640 %t 367439a9a9SAlex Brachet# RUN: llvm-objcopy %t %t1 377439a9a9SAlex Brachet# RUN: ls -l %t1 | cut -f 1 -d ' ' > %t1.perms 387439a9a9SAlex Brachet# RUN: cmp %t1.perms %t.0640 397439a9a9SAlex Brachet 40*17b4e695SFangrui Song## Drop S_ISUID/S_ISGID bits. 41*17b4e695SFangrui Song# RUN: chmod 6640 %t 42*17b4e695SFangrui Song# RUN: llvm-objcopy %t %t1 43*17b4e695SFangrui Song# RUN: ls -l %t1 | cut -f 1 -d ' ' > %t1.perms 44*17b4e695SFangrui Song# RUN: cmp %t1.perms %t.0640 45*17b4e695SFangrui Song 466dc59629SFangrui Song## Don't set the permission of a character special file, otherwise there will 476dc59629SFangrui Song## be an EPERM error (or worse: root may change the permission). 486dc59629SFangrui Song# RUN: ls -l /dev/null | cut -f 1 -d ' ' > %tnull.perms 496dc59629SFangrui Song# RUN: llvm-objcopy %t /dev/null 506dc59629SFangrui Song# RUN: ls -l /dev/null | cut -f 1 -d ' ' | diff - %tnull.perms 516dc59629SFangrui Song 52*17b4e695SFangrui Song## Ignore umask if the output filename is the same as the input filename. 53*17b4e695SFangrui Song# RUN: umask 022 54*17b4e695SFangrui Song# RUN: cp %t %t1 && chmod 0777 %t1 && llvm-objcopy %t1 55*17b4e695SFangrui Song# RUN: ls -l %t1 | cut -f 1 -d ' ' > %t1.perms 56*17b4e695SFangrui Song# RUN: cmp %t1.perms %t.0777 57*17b4e695SFangrui Song 587439a9a9SAlex Brachet--- !ELF 597439a9a9SAlex BrachetFileHeader: 607439a9a9SAlex Brachet Class: ELFCLASS64 617439a9a9SAlex Brachet Data: ELFDATA2LSB 627439a9a9SAlex Brachet Type: ET_EXEC 637439a9a9SAlex Brachet Machine: EM_X86_64 64