Vagrantfile 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. Vagrant.configure("2") do |config|
  2. config.vm.provider "virtualbox" do |v|
  3. v.memory = 1024
  4. v.cpus = 1
  5. end
  6. config.vm.box = "debian/jessie64"
  7. config.vm.hostname = "exa"
  8. # Install the dependencies needed for exa to build.
  9. config.vm.provision :shell, privileged: true, inline:
  10. %[apt-get install -y git cmake libgit2-dev libssh2-1-dev curl attr pkg-config]
  11. # Guarantee that the timezone is UTC -- some of the tests
  12. # depend on this (for now).
  13. config.vm.provision :shell, privileged: true, inline:
  14. %[timedatectl set-timezone UTC]
  15. # Install Rust.
  16. # This is done as vagrant, not root, because it’s vagrant
  17. # who actually uses it. Sent to /dev/null because the progress
  18. # bar produces a lot of output.
  19. config.vm.provision :shell, privileged: false, inline:
  20. %[hash rustc &>/dev/null || curl -sSf https://static.rust-lang.org/rustup.sh | sh &> /dev/null]
  21. # Use a different ‘target’ directory on the VM than on the host.
  22. # By default it just uses the one in /vagrant/target, which can
  23. # cause problems if it has different permissions than the other
  24. # directories, or contains object files compiled for the host.
  25. config.vm.provision :shell, privileged: false, inline:
  26. %[echo "export CARGO_TARGET_DIR=/home/vagrant/target" >> ~/.bashrc]
  27. # Test that wide columns work with a really long username.
  28. # The benefit of Vagrant is that we don’t need to set this up
  29. # on the *actual* system!
  30. longuser = "antidisestablishmentarienism"
  31. config.vm.provision :shell, privileged: true, inline:
  32. %[id -u #{longuser} &>/dev/null || useradd #{longuser}]
  33. test_dir = "/home/vagrant/testcases"
  34. # Because the timestamps are formatted differently depending on whether
  35. # they’re in the current year or not (see `details.rs`), we have to make
  36. # sure that the files are created in the current year, so they get shown
  37. # in the format we expect.
  38. current_year = Date.today.year
  39. some_date = "#{current_year}01011234.56" # 1st January, 12:34:56
  40. invalid_uid = 666
  41. invalid_gid = 616
  42. # Delete old testcases if they exist already.
  43. # This needs root because the generator does some sudo-ing.
  44. config.vm.provision :shell, privileged: true, inline:
  45. %[rm -rfv #{test_dir}]
  46. # Generate our awkward testcases.
  47. config.vm.provision :shell, privileged: false, inline:
  48. %[mkdir #{test_dir}]
  49. # Awkward file size testcases.
  50. config.vm.provision :shell, privileged: false, inline: <<-EOF
  51. set -xe
  52. mkdir "#{test_dir}/files"
  53. for i in {1..13}; do
  54. fallocate -l "$i" "#{test_dir}/files/$i"_bytes
  55. fallocate -l "$i"KiB "#{test_dir}/files/$i"_KiB
  56. fallocate -l "$i"MiB "#{test_dir}/files/$i"_MiB
  57. done
  58. touch -t #{some_date} "#{test_dir}/files/"*
  59. EOF
  60. # File name extension testcases.
  61. config.vm.provision :shell, privileged: false, inline: <<-EOF
  62. set -xe
  63. mkdir "#{test_dir}/file-types"
  64. touch "#{test_dir}/file-types/Makefile"
  65. touch "#{test_dir}/file-types/image.png"
  66. touch "#{test_dir}/file-types/image.svg"
  67. touch "#{test_dir}/file-types/video.avi"
  68. touch "#{test_dir}/file-types/video.wmv"
  69. touch "#{test_dir}/file-types/music.mp3"
  70. touch "#{test_dir}/file-types/music.ogg"
  71. touch "#{test_dir}/file-types/lossless.flac"
  72. touch "#{test_dir}/file-types/lossless.wav"
  73. touch "#{test_dir}/file-types/crypto.asc"
  74. touch "#{test_dir}/file-types/crypto.signature"
  75. touch "#{test_dir}/file-types/document.pdf"
  76. touch "#{test_dir}/file-types/document.xlsx"
  77. touch "#{test_dir}/file-types/compressed.zip"
  78. touch "#{test_dir}/file-types/compressed.tar.gz"
  79. touch "#{test_dir}/file-types/compressed.tgz"
  80. touch "#{test_dir}/file-types/backup~"
  81. touch "#{test_dir}/file-types/#SAVEFILE#"
  82. touch "#{test_dir}/file-types/file.tmp"
  83. touch "#{test_dir}/file-types/compiled.class"
  84. touch "#{test_dir}/file-types/compiled.o"
  85. touch "#{test_dir}/file-types/compiled.js"
  86. touch "#{test_dir}/file-types/compiled.coffee"
  87. EOF
  88. # Awkward symlink testcases.
  89. config.vm.provision :shell, privileged: false, inline: <<-EOF
  90. set -xe
  91. mkdir "#{test_dir}/links"
  92. ln -s / "#{test_dir}/links/root"
  93. ln -s /usr "#{test_dir}/links/usr"
  94. ln -s nowhere "#{test_dir}/links/broken"
  95. ln -s /proc/1/root "#{test_dir}/links/forbidden"
  96. EOF
  97. # Awkward passwd testcases.
  98. # sudo is needed for these because we technically aren’t a member
  99. # of the groups (because they don’t exist), and chown and chgrp
  100. # are smart enough to disallow it!
  101. config.vm.provision :shell, privileged: false, inline: <<-EOF
  102. set -xe
  103. mkdir "#{test_dir}/passwd"
  104. touch -t #{some_date} "#{test_dir}/passwd/unknown-uid"
  105. sudo chown #{invalid_uid} "#{test_dir}/passwd/unknown-uid"
  106. touch -t #{some_date} "#{test_dir}/passwd/unknown-gid"
  107. sudo chgrp #{invalid_gid} "#{test_dir}/passwd/unknown-gid"
  108. EOF
  109. # Awkward permission testcases.
  110. config.vm.provision :shell, privileged: false, inline: <<-EOF
  111. set -xe
  112. mkdir "#{test_dir}/permissions"
  113. touch "#{test_dir}/permissions/all-permissions"
  114. chmod 777 "#{test_dir}/permissions/all-permissions"
  115. touch "#{test_dir}/permissions/no-permissions"
  116. chmod 000 "#{test_dir}/permissions/no-permissions"
  117. mkdir "#{test_dir}/permissions/forbidden-directory"
  118. chmod 000 "#{test_dir}/permissions/forbidden-directory"
  119. touch -t #{some_date} "#{test_dir}/permissions/"*
  120. EOF
  121. # Awkward extended attribute testcases.
  122. config.vm.provision :shell, privileged: false, inline: <<-EOF
  123. set -xe
  124. mkdir "#{test_dir}/attributes"
  125. touch "#{test_dir}/attributes/none"
  126. touch "#{test_dir}/attributes/one"
  127. setfattr -n user.greeting -v hello "#{test_dir}/attributes/one"
  128. touch "#{test_dir}/attributes/two"
  129. setfattr -n user.greeting -v hello "#{test_dir}/attributes/two"
  130. setfattr -n user.another_greeting -v hi "#{test_dir}/attributes/two"
  131. #touch "#{test_dir}/attributes/forbidden"
  132. #setfattr -n user.greeting -v hello "#{test_dir}/attributes/forbidden"
  133. #chmod +a "$YOU deny readextattr" "#{test_dir}/attributes/forbidden"
  134. mkdir "#{test_dir}/attributes/dirs"
  135. mkdir "#{test_dir}/attributes/dirs/empty-with-attribute"
  136. setfattr -n user.greeting -v hello "#{test_dir}/attributes/dirs/empty-with-attribute"
  137. mkdir "#{test_dir}/attributes/dirs/full-with-attribute"
  138. touch "#{test_dir}/attributes/dirs/full-with-attribute/file"
  139. setfattr -n user.greeting -v hello "#{test_dir}/attributes/dirs/full-with-attribute"
  140. mkdir "#{test_dir}/attributes/dirs/full-but-forbidden"
  141. touch "#{test_dir}/attributes/dirs/full-but-forbidden/file"
  142. #setfattr -n user.greeting -v hello "#{test_dir}/attributes/dirs/full-but-forbidden"
  143. #chmod 000 "#{test_dir}/attributes/dirs/full-but-forbidden"
  144. #chmod +a "$YOU deny readextattr" "#{test_dir}/attributes/dirs/full-but-forbidden"
  145. touch -t #{some_date} "#{test_dir}/attributes"
  146. touch -t #{some_date} "#{test_dir}/attributes/"*
  147. touch -t #{some_date} "#{test_dir}/attributes/dirs/"*
  148. touch -t #{some_date} "#{test_dir}/attributes/dirs/"*/*
  149. EOF
  150. end