1# -*- mode: ruby -*- 2# vi: set ft=ruby : 3 4# DESCRIPTION: 5# ============ 6# Vagrant for running libevent tests with: 7# - timeout 30min, to avoid hungs 8# - run tests in parallel under ctest (10 concurency) 9# - if you have uncommited changes, you should commit them first to check 10# - unix only, because of some tar'ing to avoid one vm affect another 11# 12# ENVIRONMENT: 13# ============ 14# - NO_PKG -- do not install packages 15# - NO_CMAKE -- do not run with cmake 16# - NO_AUTOTOOLS -- do not run with autoconf/automake 17 18Vagrant.configure("2") do |config| 19 # to allow running boxes provisions in parallel, we can't share the same dirs 20 # via virtualbox, however sometimes it is the only way, so instead let's 21 # create an archive of HEAD (this way we will not have any trash there) and 22 # extract it for every box to the separate folder. 23 # 24 # P.S. we will change this --prefix with tar(1) --trasnform 25 system('git archive --prefix=libevent/ --output=.vagrant/libevent.tar HEAD') 26 27 config.vm.provider "virtualbox" do |vb| 28 vb.memory = "512" 29 30 # otherwise osx fails, anyway we do not need this 31 vb.customize ["modifyvm", :id, "--usb", "off"] 32 vb.customize ["modifyvm", :id, "--usbehci", "off"] 33 end 34 35 # disable /vagrant share, in case we will not use default mount 36 config.vm.synced_folder ".", "/vagrant", disabled: true 37 38 config.vm.define "ubuntu" do |ubuntu| 39 system('tar --overwrite --transform=s/libevent/libevent-linux/ -xf .vagrant/libevent.tar -C .vagrant/') 40 41 ubuntu.vm.box = "ubuntu/xenial64" 42 ubuntu.vm.synced_folder ".vagrant/libevent-linux", "/vagrant", 43 type: "rsync" 44 45 if ENV['NO_PKG'] != "true" 46 ubuntu.vm.provision "shell", inline: <<-SHELL 47 apt-get update 48 apt-get install -y zlib1g-dev libssl-dev python2.7 49 apt-get install -y build-essential cmake ninja-build 50 apt-get install -y autoconf automake libtool 51 SHELL 52 end 53 54 if ENV['NO_CMAKE'] != "true" 55 ubuntu.vm.provision "shell", privileged: false, inline: <<-SHELL 56 cd /vagrant 57 rm -fr .cmake-vagrant 58 mkdir -p .cmake-vagrant 59 cd .cmake-vagrant 60 cmake -G Ninja .. 61 62 export CTEST_TEST_TIMEOUT=1800 63 export CTEST_OUTPUT_ON_FAILURE=1 64 export CTEST_PARALLEL_LEVEL=10 65 cmake --build . --target verify 66 SHELL 67 end 68 69 if ENV['NO_AUTOTOOLS'] != "true" 70 ubuntu.vm.provision "shell", privileged: false, inline: <<-SHELL 71 cd /vagrant 72 ./autogen.sh 73 ./configure 74 make -j4 verify 75 SHELL 76 end 77 end 78 79 config.vm.define "freebsd" do |freebsd| 80 system('tar --overwrite --transform=s/libevent/libevent-freebsd/ -xf .vagrant/libevent.tar -C .vagrant/') 81 82 freebsd.vm.box = "freebsd/FreeBSD-11.0-STABLE" 83 freebsd.vm.synced_folder ".vagrant/libevent-freebsd", "/vagrant", 84 type: "rsync", group: "wheel" 85 86 # otherwise reports error 87 freebsd.ssh.shell = "sh" 88 89 if ENV['NO_PKG'] != "true" 90 freebsd.vm.provision "shell", inline: <<-SHELL 91 pkg install --yes openssl cmake ninja automake autotools 92 SHELL 93 end 94 95 if ENV['NO_CMAKE'] != "true" 96 freebsd.vm.provision "shell", privileged: false, inline: <<-SHELL 97 cd /vagrant 98 rm -fr .cmake-vagrant 99 mkdir -p .cmake-vagrant 100 cd .cmake-vagrant 101 cmake -G Ninja .. 102 103 export CTEST_TEST_TIMEOUT=1800 104 export CTEST_OUTPUT_ON_FAILURE=1 105 export CTEST_PARALLEL_LEVEL=10 106 cmake --build . --target verify 107 SHELL 108 end 109 110 if ENV['NO_AUTOTOOLS'] != "true" 111 freebsd.vm.provision "shell", privileged: false, inline: <<-SHELL 112 cd /vagrant 113 ./autogen.sh 114 ./configure 115 make -j4 verify 116 SHELL 117 end 118 end 119 120 config.vm.define "netbsd" do |netbsd| 121 system('tar --overwrite --transform=s/libevent/libevent-netbsd/ -xf .vagrant/libevent.tar -C .vagrant/') 122 123 netbsd.vm.box = "kja/netbsd-7-amd64" 124 netbsd.vm.synced_folder ".vagrant/libevent-netbsd", "/vagrant", 125 type: "rsync", group: "wheel" 126 127 # TODO: more reliable way to install packages 128 if ENV['NO_PKG'] != "true" 129 netbsd.vm.provision "shell", inline: <<-SHELL 130 pkg_add ftp://ftp.netbsd.org/pub/pkgsrc/packages/NetBSD/x86_64/7.0_2016Q2/All/ncurses-6.0nb1.tgz 131 pkg_add ftp://ftp.netbsd.org/pub/pkgsrc/packages/NetBSD/x86_64/7.0_2016Q2/All/ninja-build-1.7.1.tgz 132 pkg_add ftp://ftp.netbsd.org/pub/pkgsrc/packages/NetBSD/x86_64/7.0_2016Q2/All/automake-1.15nb3.tgz 133 pkg_add ftp://ftp.netbsd.org/pub/pkgsrc/packages/NetBSD/x86_64/7.0_2016Q2/All/cmake-3.5.2.tgz 134 SHELL 135 end 136 137 if ENV['NO_CMAKE'] != "true" 138 netbsd.vm.provision "shell", privileged: false, inline: <<-SHELL 139 cd /vagrant 140 rm -fr .cmake-vagrant 141 mkdir -p .cmake-vagrant 142 cd .cmake-vagrant 143 cmake -G Ninja .. 144 145 export CTEST_TEST_TIMEOUT=1800 146 export CTEST_OUTPUT_ON_FAILURE=1 147 export CTEST_PARALLEL_LEVEL=10 148 cmake --build . --target verify 149 SHELL 150 end 151 152 if ENV['NO_AUTOTOOLS'] != "true" 153 netbsd.vm.provision "shell", privileged: false, inline: <<-SHELL 154 cd /vagrant 155 ./autogen.sh 156 ./configure 157 make -j4 verify 158 SHELL 159 end 160 end 161 162 config.vm.define "solaris" do |solaris| 163 system('tar --overwrite --transform=s/libevent/libevent-solaris/ -xf .vagrant/libevent.tar -C .vagrant/') 164 165 # XXX: 166 # - solaris do not have '-or' it only has '-o' for find(1), so we can't use 167 # rsync 168 # - and autoconf(1) doesn't work on virtualbox share, ugh 169 solaris.vm.synced_folder ".vagrant/libevent-solaris", "/vagrant-vbox", 170 type: "virtualbox" 171 172 solaris.vm.box = "tnarik/solaris10-minimal" 173 if ENV['NO_PKG'] != "true" 174 # TODO: opencsw does not include ninja(1) 175 solaris.vm.provision "shell", inline: <<-SHELL 176 pkgadd -d http://get.opencsw.org/now 177 pkgutil -U 178 pkgutil -y -i libssl_dev cmake rsync python gmake gcc5core automake autoconf libtool 179 SHELL 180 end 181 182 # copy from virtualbox mount to newly created folder 183 solaris.vm.provision "shell", privileged: false, inline: <<-SHELL 184 rm -fr ~/vagrant 185 cp -r /vagrant-vbox ~/vagrant 186 SHELL 187 188 if ENV['NO_CMAKE'] != "true" 189 # builtin compiler cc(1) is a wrapper, so we should use gcc5 manually, 190 # otherwise it will not work. 191 # Plus we should set some paths so that cmake/compiler can find tham. 192 solaris.vm.provision "shell", privileged: false, inline: <<-SHELL 193 export CMAKE_INCLUDE_PATH=/opt/csw/include 194 export CMAKE_LIBRARY_PATH=/opt/csw/lib 195 export CFLAGS=-I$CMAKE_INCLUDE_PATH 196 export LDFLAGS=-L$CMAKE_LIBRARY_PATH 197 198 cd ~/vagrant 199 rm -rf .cmake-vagrant 200 mkdir -p .cmake-vagrant 201 cd .cmake-vagrant 202 cmake -DCMAKE_C_COMPILER=gcc .. 203 204 export CTEST_TEST_TIMEOUT=1800 205 export CTEST_OUTPUT_ON_FAILURE=1 206 export CTEST_PARALLEL_LEVEL=10 207 cmake --build . --target verify 208 SHELL 209 end 210 211 if ENV['NO_AUTOTOOLS'] != "true" 212 # and we should set MAKE for `configure` otherwise it will try to use 213 # `make` 214 solaris.vm.provision "shell", privileged: false, inline: <<-SHELL 215 cd ~/vagrant 216 ./autogen.sh 217 MAKE=gmake ./configure 218 gmake -j4 verify 219 SHELL 220 end 221 end 222 223 # known failures: 224 # - sometimes vm hangs 225 config.vm.define "osx" do |osx| 226 system('tar --overwrite --transform=s/libevent/libevent-osx/ -xf .vagrant/libevent.tar -C .vagrant/') 227 228 osx.vm.synced_folder ".vagrant/libevent-osx", "/vagrant", 229 type: "rsync", group: "wheel" 230 231 osx.vm.box = "jhcook/osx-elcapitan-10.11" 232 if ENV['NO_PKG'] != "true" 233 osx.vm.provision "shell", privileged: false, inline: <<-SHELL 234 ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" 235 236 brew uninstall libtool 237 brew install libtool openssl ninja cmake autoconf automake 238 SHELL 239 end 240 241 if ENV['NO_CMAKE'] != "true" 242 # we should set some paths so that cmake/compiler can find tham 243 osx.vm.provision "shell", privileged: false, inline: <<-SHELL 244 export OPENSSL_ROOT=$(echo /usr/local/Cellar/openssl/*) 245 export CMAKE_INCLUDE_PATH=$OPENSSL_ROOT/include 246 export CMAKE_LIBRARY_PATH=$OPENSSL_ROOT/lib 247 248 cd /vagrant 249 mkdir -p .cmake-vagrant 250 cd .cmake-vagrant 251 cmake -G Ninja .. 252 253 export CTEST_TEST_TIMEOUT=1800 254 export CTEST_OUTPUT_ON_FAILURE=1 255 export CTEST_PARALLEL_LEVEL=10 256 cmake --build . --target verify 257 SHELL 258 end 259 260 if ENV['NO_AUTOTOOLS'] != "true" 261 osx.vm.provision "shell", privileged: false, inline: <<-SHELL 262 export OPENSSL_ROOT=$(echo /usr/local/Cellar/openssl/*) 263 export CFLAGS=-I$OPENSSL_ROOT/include 264 export LDFLAGS=-L$OPENSSL_ROOT/lib 265 266 cd /vagrant 267 ./autogen.sh 268 ./configure 269 gmake -j4 verify 270 SHELL 271 end 272 end 273 274 # known failures: 275 # - issues with timers (not enough allowed error) 276 config.vm.define "win" do |win| 277 system('tar --overwrite --transform=s/libevent/libevent-win/ -xf .vagrant/libevent.tar -C .vagrant/') 278 279 # 512MB not enough after libtool install, huh 280 win.vm.provider "virtualbox" do |vb| 281 vb.memory = "1024" 282 end 283 284 # windows does not have rsync builtin, let's use virtualbox for now 285 win.vm.synced_folder ".vagrant/libevent-win", "/vagrant", 286 type: "virtualbox" 287 288 win.vm.box = "senglin/win-10-enterprise-vs2015community" 289 if ENV['NO_PKG'] != "true" 290 # box with vs2015 does not have C++ support, so let's install it manually 291 # plus chocolatey that includes in this box, can't handle sha1 checksum for 292 # cmake.install, so let's update it< 293 win.vm.provision "shell", inline: <<-SHELL 294 choco upgrade -y chocolatey -pre -f 295 choco install -y VisualStudioCommunity2013 296 choco install -y openssl.light 297 choco install -y cygwin cyg-get 298 choco install -y cmake 299 choco install -y cmake.install 300 choco install -y python2 301 SHELL 302 303 # chocolatey openssl.light package does not contains headers 304 win.vm.provision "shell", inline: <<-SHELL 305 (new-object System.Net.WebClient).DownloadFile('http://strcpy.net/packages/Win32OpenSSL-1_0_2a.exe', '/openssl.exe') 306 /openssl.exe /silent /verysilent /sp- /suppressmsgboxes 307 SHELL 308 309 # XXX: 310 # - cyg-get depends from cygwinsetup.exe 311 # https://github.com/chocolatey/chocolatey-coreteampackages/issues/200 312 # - cyg-get only downloads, do not installs them, ugh. so let's do not use 313 # it 314 win.vm.provision "shell", privileged: false, inline: <<-SHELL 315 (new-object System.Net.WebClient).DownloadFile('https://cygwin.com/setup-x86_64.exe', '/tools/cygwin/cygwinsetup.exe') 316 317 $env:PATH="/tools/cygwin/bin;$($env:PATH);/tools/cygwin" 318 319 cygwinsetup --root c:/tools/cygwin/ --local-package-dir c:/tools/cygwin/packages/ --no-desktop --no-startmenu --verbose --quiet-mode --download --packages automake,autoconf,gcc-core,libtool,make,python,openssl-devel 320 cygwinsetup --root c:/tools/cygwin/ --local-package-dir c:/tools/cygwin/packages/ --no-desktop --no-startmenu --verbose --quiet-mode --local-install --packages automake,autoconf,gcc-core,libtool,make,python,openssl-devel 321 SHELL 322 end 323 324 if ENV['NO_CMAKE'] != "true" 325 win.vm.provision "shell", privileged: false, inline: <<-SHELL 326 $env:PATH="/Program Files/CMake/bin;/tools/python2;$($env:PATH)" 327 328 cd /vagrant 329 Remove-Item -Recurse -Force .cmake-vagrant 330 mkdir -p .cmake-vagrant 331 cd .cmake-vagrant 332 cmake -G "Visual Studio 12" .. 333 334 $env:CTEST_TEST_TIMEOUT = "1800" 335 $env:CTEST_OUTPUT_ON_FAILURE = "1" 336 $env:CTEST_PARALLEL_LEVEL = "10" 337 cmake --build . --target verify 338 SHELL 339 end 340 341 if ENV['NO_AUTOTOOLS'] != "true" 342 win.vm.provision "shell", privileged: false, inline: <<-SHELL 343 $env:PATH="/tools/cygwin/bin;$($env:PATH)" 344 345 bash -lc "echo 'C:/tools/mingw64 /mingw ntfs binary 0 0' > /etc/fstab" 346 bash -lc "echo 'C:/OpenSSL-Win32 /ssl ntfs binary 0 0' >> /etc/fstab" 347 bash -lc "echo 'C:/vagrant /vagrant ntfs binary 0 0' >> /etc/fstab" 348 349 bash -lc "exec 0</dev/null; exec 2>&1; cd /vagrant; bash -x ./autogen.sh && ./configure LDFLAGS='-L/ssl -L/ssl/lib -L/ssl/lib/MinGW' CFLAGS=-I/ssl/include && make -j4 verify" 350 SHELL 351 end 352 end 353end 354