logo

utils-std

Collection of commonly available Unix tools git clone https://anongit.hacktivis.me/git/utils-std.git

install.t (2383B)


  1. #!/usr/bin/env cram
  2. # SPDX-FileCopyrightText: 2017 Haelwenn (lanodan) Monnier <contact+utils@hacktivis.me>
  3. # SPDX-License-Identifier: MPL-2.0
  4. $ export PATH="$TESTDIR/../cmd:$PATH"
  5. # Using chmod -v + to get permission bits, + with no perm nor who doesn't changes mode bits
  6. $ test "$(command -v install)" = "$TESTDIR/../cmd/install"
  7. $ test "$(command -v chmod)" = "$TESTDIR/../cmd/chmod"
  8. $ umask 002
  9. $ test ! -e src
  10. $ touch src
  11. $ install -m 755 src dest
  12. $ chmod -v 755 dest
  13. chmod: Permissions already set to 00755/-rwxr-xr-x for 'dest'
  14. $ chmod -v 755 src
  15. chmod: Permissions changed from 00664/-rw-rw-r-- to 00755/-rwxr-xr-x for 'src'
  16. $ rm -f src dest
  17. Integrity check
  18. $ seq 1 2048 > content
  19. $ wc -c content
  20. 9133 content
  21. $ install content content.inst
  22. $ wc -c content content.inst
  23. 9133 content
  24. 9133 content.inst
  25. 18266 total
  26. $ cmp content content.inst
  27. $ rm content content.inst
  28. install -d
  29. $ test ! -e foo.d
  30. $ install -d foo.d
  31. $ test -d foo.d
  32. $ rm -fr foo.d
  33. $ test ! -e enoent.d
  34. $ install -d enoent.d/dir
  35. $ test -d enoent.d
  36. $ test -d enoent.d/dir
  37. $ rm -fr enoent.d
  38. $ install -d -m 755 dest.d
  39. $ chmod -v 755 dest.d
  40. chmod: Permissions already set to 00755/drwxr-xr-x for 'dest.d'
  41. $ rm -fr dest.d
  42. install -D, single src
  43. $ test ! -e gramps
  44. $ touch FooD
  45. $ install -D FooD gramps/parent/child
  46. $ test -d gramps/parent
  47. $ test -f gramps/parent/child
  48. $ test -e FooD
  49. $ rm -r FooD gramps
  50. install -D, multi src
  51. $ test ! -e gran
  52. $ touch sis bro
  53. $ install -D sis bro gran/dad
  54. $ test -f sis
  55. $ test -f bro
  56. $ test -d gran/dad
  57. $ test -f gran/dad/sis
  58. $ test -f gran/dad/bro
  59. $ rm -r sis bro gran
  60. install -T
  61. $ test ! -e src_T
  62. $ touch src_T
  63. $ test -e src_T
  64. $ install -T src_T dest_T
  65. $ test -e src_T
  66. $ test -e dest_T
  67. $ rm dest_T
  68. $ install -T src_T src2_T bogus_T
  69. install: error: Option -T passed, expected exactly 1 source operand, got 2
  70. [1]
  71. $ test -e src_T
  72. $ test ! -e src2_T
  73. $ test ! -e bogus_T
  74. $ rm src_T
  75. install -t
  76. $ touch src1_t src2_t
  77. $ test -e src1_t
  78. $ test -e src2_t
  79. $ mkdir dest_t
  80. $ test -d dest_t
  81. $ test ! -e dest_t/src1_t
  82. $ test ! -e dest_t/src2_t
  83. $ install -t dest_t src1_t src2_t
  84. $ test -e src1_t
  85. $ test -e src2_t
  86. $ test -e dest_t/src1_t
  87. $ test -e dest_t/src2_t
  88. $ rm -r dest_t src1_t src2_t
  89. No files should be left
  90. $ find .
  91. .