skip-rootfs.sh 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #!/bin/sh
  2. # Test df's behavior for skipping the pseudo "rootfs" file system.
  3. # Copyright (C) 2012-2018 Free Software Foundation, Inc.
  4. # This program is free software: you can redistribute it and/or modify
  5. # it under the terms of the GNU General Public License as published by
  6. # the Free Software Foundation, either version 3 of the License, or
  7. # (at your option) any later version.
  8. # This program is distributed in the hope that it will be useful,
  9. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. # GNU General Public License for more details.
  12. # You should have received a copy of the GNU General Public License
  13. # along with this program. If not, see <https://www.gnu.org/licenses/>.
  14. . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
  15. print_ver_ df
  16. # Protect against inaccessible remote mounts etc.
  17. timeout 10 df || skip_ "df fails"
  18. # Verify that rootfs is in mtab (and shown when the -a option is specified).
  19. # Note this is the case when /proc/self/mountinfo is parsed
  20. # rather than /proc/mounts. I.e., when libmount is being used.
  21. df -a >out || fail=1
  22. grep '^rootfs' out || skip_ 'no rootfs in mtab'
  23. # Ensure that rootfs is suppressed when no options is specified.
  24. df >out || fail=1
  25. grep '^rootfs' out && { fail=1; cat out; }
  26. # Ensure that rootfs is yet skipped when explicitly specifying "-t rootfs".
  27. # As df emits "no file systems processed" in this case, it would be a failure
  28. # if df exited with status Zero.
  29. returns_ 1 df -t rootfs >out || fail=1
  30. grep '^rootfs' out && { fail=1; cat out; }
  31. # Ensure that the rootfs is shown when explicitly both specifying "-t rootfs"
  32. # and the -a option.
  33. df -t rootfs -a >out || fail=1
  34. grep '^rootfs' out || { fail=1; cat out; }
  35. # Ensure that the rootfs is omitted in all_fs mode when it is explicitly
  36. # black-listed.
  37. df -a -x rootfs >out || fail=1
  38. grep '^rootfs' out && { fail=1; cat out; }
  39. test "$fail" = 1 && dump_mount_list_
  40. Exit $fail