Vagrantfile 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  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/contrib-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. invalid_uid = 666
  35. invalid_gid = 616
  36. some_date = "201601011234.56" # 1st January 2016, 12:34:56
  37. # Delete old testcases if they exist already.
  38. # This needs root because the generator does some sudo-ing.
  39. config.vm.provision :shell, privileged: true, inline:
  40. %[rm -rfv #{test_dir}]
  41. # Generate our awkward testcases.
  42. config.vm.provision :shell, privileged: false, inline:
  43. %[mkdir #{test_dir}]
  44. # Awkward file size testcases.
  45. config.vm.provision :shell, privileged: false, inline: <<-EOF
  46. set -xe
  47. mkdir "#{test_dir}/files"
  48. for i in {1..13}; do
  49. fallocate -l "$i" "#{test_dir}/files/$i"_bytes
  50. fallocate -l "$i"KiB "#{test_dir}/files/$i"_KiB
  51. fallocate -l "$i"MiB "#{test_dir}/files/$i"_MiB
  52. done
  53. touch -t #{some_date} "#{test_dir}/files/"*
  54. EOF
  55. # File name extension testcases.
  56. config.vm.provision :shell, privileged: false, inline: <<-EOF
  57. set -xe
  58. mkdir "#{test_dir}/file-types"
  59. touch "#{test_dir}/file-types/Makefile"
  60. touch "#{test_dir}/file-types/image.png"
  61. touch "#{test_dir}/file-types/image.svg"
  62. touch "#{test_dir}/file-types/video.avi"
  63. touch "#{test_dir}/file-types/video.wmv"
  64. touch "#{test_dir}/file-types/music.mp3"
  65. touch "#{test_dir}/file-types/music.ogg"
  66. touch "#{test_dir}/file-types/lossless.flac"
  67. touch "#{test_dir}/file-types/lossless.wav"
  68. touch "#{test_dir}/file-types/crypto.asc"
  69. touch "#{test_dir}/file-types/crypto.signature"
  70. touch "#{test_dir}/file-types/document.pdf"
  71. touch "#{test_dir}/file-types/document.xlsx"
  72. touch "#{test_dir}/file-types/compressed.zip"
  73. touch "#{test_dir}/file-types/compressed.tar.gz"
  74. touch "#{test_dir}/file-types/compressed.tgz"
  75. touch "#{test_dir}/file-types/backup~"
  76. touch "#{test_dir}/file-types/#SAVEFILE#"
  77. touch "#{test_dir}/file-types/file.tmp"
  78. touch "#{test_dir}/file-types/compiled.class"
  79. touch "#{test_dir}/file-types/compiled.o"
  80. touch "#{test_dir}/file-types/compiled.js"
  81. touch "#{test_dir}/file-types/compiled.coffee"
  82. EOF
  83. # Awkward symlink testcases.
  84. config.vm.provision :shell, privileged: false, inline: <<-EOF
  85. set -xe
  86. mkdir "#{test_dir}/links"
  87. ln -s / "#{test_dir}/links/root"
  88. ln -s /usr "#{test_dir}/links/usr"
  89. ln -s nowhere "#{test_dir}/links/broken"
  90. ln -s /proc/1/root "#{test_dir}/links/forbidden"
  91. EOF
  92. # Awkward passwd testcases.
  93. # sudo is needed for these because we technically aren’t a member
  94. # of the groups (because they don’t exist), and chown and chgrp
  95. # are smart enough to disallow it!
  96. config.vm.provision :shell, privileged: false, inline: <<-EOF
  97. set -xe
  98. mkdir "#{test_dir}/passwd"
  99. touch -t #{some_date} "#{test_dir}/passwd/unknown-uid"
  100. sudo chown #{invalid_uid} "#{test_dir}/passwd/unknown-uid"
  101. touch -t #{some_date} "#{test_dir}/passwd/unknown-gid"
  102. sudo chgrp #{invalid_gid} "#{test_dir}/passwd/unknown-gid"
  103. EOF
  104. # Awkward permission testcases.
  105. config.vm.provision :shell, privileged: false, inline: <<-EOF
  106. set -xe
  107. mkdir "#{test_dir}/permissions"
  108. touch "#{test_dir}/permissions/all-permissions"
  109. chmod 777 "#{test_dir}/permissions/all-permissions"
  110. touch "#{test_dir}/permissions/no-permissions"
  111. chmod 000 "#{test_dir}/permissions/no-permissions"
  112. mkdir "#{test_dir}/permissions/forbidden-directory"
  113. chmod 000 "#{test_dir}/permissions/forbidden-directory"
  114. touch -t #{some_date} "#{test_dir}/permissions/"*
  115. EOF
  116. # Awkward extended attribute testcases.
  117. config.vm.provision :shell, privileged: false, inline: <<-EOF
  118. set -xe
  119. mkdir "#{test_dir}/attributes"
  120. touch "#{test_dir}/attributes/none"
  121. touch "#{test_dir}/attributes/one"
  122. setfattr -n user.greeting -v hello "#{test_dir}/attributes/one"
  123. touch "#{test_dir}/attributes/two"
  124. setfattr -n user.greeting -v hello "#{test_dir}/attributes/two"
  125. setfattr -n user.another_greeting -v hi "#{test_dir}/attributes/two"
  126. #touch "#{test_dir}/attributes/forbidden"
  127. #setfattr -n user.greeting -v hello "#{test_dir}/attributes/forbidden"
  128. #chmod +a "$YOU deny readextattr" "#{test_dir}/attributes/forbidden"
  129. mkdir "#{test_dir}/attributes/dirs"
  130. mkdir "#{test_dir}/attributes/dirs/empty-with-attribute"
  131. setfattr -n user.greeting -v hello "#{test_dir}/attributes/dirs/empty-with-attribute"
  132. mkdir "#{test_dir}/attributes/dirs/full-with-attribute"
  133. touch "#{test_dir}/attributes/dirs/full-with-attribute/file"
  134. setfattr -n user.greeting -v hello "#{test_dir}/attributes/dirs/full-with-attribute"
  135. mkdir "#{test_dir}/attributes/dirs/full-but-forbidden"
  136. touch "#{test_dir}/attributes/dirs/full-but-forbidden/file"
  137. #setfattr -n user.greeting -v hello "#{test_dir}/attributes/dirs/full-but-forbidden"
  138. #chmod 000 "#{test_dir}/attributes/dirs/full-but-forbidden"
  139. #chmod +a "$YOU deny readextattr" "#{test_dir}/attributes/dirs/full-but-forbidden"
  140. touch -t #{some_date} "#{test_dir}/attributes"
  141. touch -t #{some_date} "#{test_dir}/attributes/"*
  142. touch -t #{some_date} "#{test_dir}/attributes/dirs/"*
  143. touch -t #{some_date} "#{test_dir}/attributes/dirs/"*/*
  144. EOF
  145. end