Vagrantfile 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  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]
  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. # Awkward symlink testcases.
  56. config.vm.provision :shell, privileged: false, inline: <<-EOF
  57. set -xe
  58. mkdir "#{test_dir}/links"
  59. ln -s / "#{test_dir}/links/root"
  60. ln -s /usr "#{test_dir}/links/usr"
  61. ln -s nowhere "#{test_dir}/links/broken"
  62. EOF
  63. # Awkward passwd testcases.
  64. # sudo is needed for these because we technically aren’t a member
  65. # of the groups (because they don’t exist), and chown and chgrp
  66. # are smart enough to disallow it!
  67. config.vm.provision :shell, privileged: false, inline: <<-EOF
  68. set -xe
  69. mkdir "#{test_dir}/passwd"
  70. touch -t #{some_date} "#{test_dir}/passwd/unknown-uid"
  71. sudo chown #{invalid_uid} "#{test_dir}/passwd/unknown-uid"
  72. touch -t #{some_date} "#{test_dir}/passwd/unknown-gid"
  73. sudo chgrp #{invalid_gid} "#{test_dir}/passwd/unknown-gid"
  74. EOF
  75. # Awkward permission testcases.
  76. config.vm.provision :shell, privileged: false, inline: <<-EOF
  77. set -xe
  78. mkdir "#{test_dir}/permissions"
  79. touch "#{test_dir}/permissions/all-permissions"
  80. chmod 777 "#{test_dir}/permissions/all-permissions"
  81. touch "#{test_dir}/permissions/no-permissions"
  82. chmod 000 "#{test_dir}/permissions/no-permissions"
  83. mkdir "#{test_dir}/permissions/forbidden-directory"
  84. chmod 000 "#{test_dir}/permissions/forbidden-directory"
  85. touch -t #{some_date} "#{test_dir}/permissions/"*
  86. EOF
  87. # Awkward extended attribute testcases.
  88. config.vm.provision :shell, privileged: false, inline: <<-EOF
  89. set -xe
  90. mkdir "#{test_dir}/attributes"
  91. touch "#{test_dir}/attributes/none"
  92. touch "#{test_dir}/attributes/one"
  93. setfattr -n user.greeting -v hello "#{test_dir}/attributes/one"
  94. touch "#{test_dir}/attributes/two"
  95. setfattr -n user.greeting -v hello "#{test_dir}/attributes/two"
  96. setfattr -n user.another_greeting -v hi "#{test_dir}/attributes/two"
  97. #touch "#{test_dir}/attributes/forbidden"
  98. #setfattr -n user.greeting -v hello "#{test_dir}/attributes/forbidden"
  99. #chmod +a "$YOU deny readextattr" "#{test_dir}/attributes/forbidden"
  100. mkdir "#{test_dir}/attributes/dirs"
  101. mkdir "#{test_dir}/attributes/dirs/empty-with-attribute"
  102. setfattr -n user.greeting -v hello "#{test_dir}/attributes/dirs/empty-with-attribute"
  103. mkdir "#{test_dir}/attributes/dirs/full-with-attribute"
  104. touch "#{test_dir}/attributes/dirs/full-with-attribute/file"
  105. setfattr -n user.greeting -v hello "#{test_dir}/attributes/dirs/full-with-attribute"
  106. mkdir "#{test_dir}/attributes/dirs/full-but-forbidden"
  107. touch "#{test_dir}/attributes/dirs/full-but-forbidden/file"
  108. #setfattr -n user.greeting -v hello "#{test_dir}/attributes/dirs/full-but-forbidden"
  109. #chmod 000 "#{test_dir}/attributes/dirs/full-but-forbidden"
  110. #chmod +a "$YOU deny readextattr" "#{test_dir}/attributes/dirs/full-but-forbidden"
  111. touch -t #{some_date} "#{test_dir}/attributes"
  112. touch -t #{some_date} "#{test_dir}/attributes/"*
  113. touch -t #{some_date} "#{test_dir}/attributes/dirs/"*
  114. touch -t #{some_date} "#{test_dir}/attributes/dirs/"*/*
  115. EOF
  116. end