logo

utils-std

Collection of commonly available Unix tools

chmod (1518B)


  1. #!/usr/bin/env atf-sh
  2. # SPDX-FileCopyrightText: 2017 Haelwenn (lanodan) Monnier <contact+utils@hacktivis.me>
  3. # SPDX-License-Identifier: MPL-2.0
  4. atf_test_case octal cleanup
  5. octal_body() {
  6. atf_check touch "${TMPDIR}/chmod_octal"
  7. atf_check -o "inline:chmod: Permissions changed from 00644/-rw-r--r-- to 00000/---------- for '${TMPDIR}/chmod_octal'\n" ../cmd/chmod -v 0 "${TMPDIR}/chmod_octal"
  8. atf_check -o "inline:chmod: Permissions already set to 00000/---------- for '${TMPDIR}/chmod_octal'\n" ../cmd/chmod -v 00 "${TMPDIR}/chmod_octal"
  9. atf_check -o "inline:chmod: Permissions already set to 00000/---------- for '${TMPDIR}/chmod_octal'\n" ../cmd/chmod -v 000 "${TMPDIR}/chmod_octal"
  10. atf_check -o "inline:chmod: Permissions already set to 00000/---------- for '${TMPDIR}/chmod_octal'\n" ../cmd/chmod -v 0000 "${TMPDIR}/chmod_octal"
  11. atf_check -o "inline:chmod: Permissions changed from 00000/---------- to 00444/-r--r--r-- for '${TMPDIR}/chmod_octal'\n" ../cmd/chmod -v 0444 "${TMPDIR}/chmod_octal"
  12. atf_check -o "inline:chmod: Permissions changed from 00444/-r--r--r-- to 00777/-rwxrwxrwx for '${TMPDIR}/chmod_octal'\n" ../cmd/chmod -v 0777 "${TMPDIR}/chmod_octal"
  13. atf_check -s not-exit:0 -e "inline:chmod: Failed parsing mode '0888': contains digit outside of [0-7]\n" ../cmd/chmod -v 0888 "${TMPDIR}/chmod_octal"
  14. }
  15. octal_cleanup() {
  16. atf_check chmod u=rw "${TMPDIR}/chmod_octal"
  17. atf_check rm "${TMPDIR}/chmod_octal"
  18. }
  19. atf_init_test_cases() {
  20. cd "$(atf_get_srcdir)" || exit 1
  21. atf_add_test_case octal
  22. }