|
| 1 | +#! /bin/sh -e |
| 2 | +SCRATCH=scratch/$(basename "$0" .sh) |
| 3 | + |
| 4 | +./simple |
| 5 | + |
| 6 | +curInterpreter=$(../src/patchelf --print-interpreter ./simple) |
| 7 | +echo "current interpreter is $curInterpreter" |
| 8 | + |
| 9 | +rm -rf "${SCRATCH}" |
| 10 | +mkdir -p "${SCRATCH}" |
| 11 | + |
| 12 | +cp simple "${SCRATCH}"/ |
| 13 | + |
| 14 | +echo "set the same interpreter as the current one" |
| 15 | +before_checksum=$(sha256sum ${SCRATCH}/simple) |
| 16 | +../src/patchelf --set-interpreter "${curInterpreter}" "${SCRATCH}/simple" |
| 17 | +after_checksum=$(sha256sum ${SCRATCH}/simple) |
| 18 | + |
| 19 | +if [ "$before_checksum" != "$after_checksum" ]; then |
| 20 | + echo "--set-interpreter should be NOP, but the file has been changed." |
| 21 | + exit 1 |
| 22 | +fi |
| 23 | + |
| 24 | +${SCRATCH}/simple |
| 25 | + |
| 26 | +dummyInterpreter="aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" |
| 27 | + |
| 28 | +echo "set the dummy interpreter" |
| 29 | +before_checksum=$(sha256sum ${SCRATCH}/simple) |
| 30 | +../src/patchelf --set-interpreter "${dummyInterpreter}" "${SCRATCH}/simple" |
| 31 | +after_checksum=$(sha256sum ${SCRATCH}/simple) |
| 32 | + |
| 33 | +if [ "$before_checksum" = "$after_checksum" ]; then |
| 34 | + echo "--set-interpreter should be run, but the file has not been changed." |
| 35 | + exit 1 |
| 36 | +fi |
| 37 | + |
| 38 | +if "${SCRATCH}/simple"; then |
| 39 | + echo "simple works, but it shouldn't" |
| 40 | + exit 1 |
| 41 | +fi |
| 42 | + |
| 43 | +echo "set the same interpreter as the current one" |
| 44 | +before_checksum=$(sha256sum ${SCRATCH}/simple) |
| 45 | +../src/patchelf --set-interpreter "${dummyInterpreter}" "${SCRATCH}/simple" |
| 46 | +after_checksum=$(sha256sum ${SCRATCH}/simple) |
| 47 | + |
| 48 | +if [ "$before_checksum" != "$after_checksum" ]; then |
| 49 | + echo "--set-interpreter should be NOP, but the file has been changed." |
| 50 | + exit 1 |
| 51 | +fi |
| 52 | + |
| 53 | +if "${SCRATCH}/simple"; then |
| 54 | + echo "simple works, but it shouldn't" |
| 55 | + exit 1 |
| 56 | +fi |
0 commit comments