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=20 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 -j20 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=20 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 -j20 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 if ENV['NO_PKG'] != "true" 128 netbsd.vm.provision "shell", inline: <<-SHELL 129 export PKG_PATH="ftp://ftp.netbsd.org/pub/pkgsrc/packages/NetBSD/x86_64/7.0_2016Q2/All/" 130 pkg_add ncurses ninja-build automake cmake libtool 131 SHELL 132 end 133 134 if ENV['NO_CMAKE'] != "true" 135 netbsd.vm.provision "shell", privileged: false, inline: <<-SHELL 136 cd /vagrant 137 rm -fr .cmake-vagrant 138 mkdir -p .cmake-vagrant 139 cd .cmake-vagrant 140 cmake -G Ninja .. 141 142 export CTEST_TEST_TIMEOUT=1800 143 export CTEST_OUTPUT_ON_FAILURE=1 144 export CTEST_PARALLEL_LEVEL=20 145 cmake --build . --target verify 146 SHELL 147 end 148 149 if ENV['NO_AUTOTOOLS'] != "true" 150 netbsd.vm.provision "shell", privileged: false, inline: <<-SHELL 151 cd /vagrant 152 ./autogen.sh 153 ./configure 154 make -j20 verify 155 SHELL 156 end 157 end 158 159 config.vm.define "solaris" do |solaris| 160 system('tar --overwrite --transform=s/libevent/libevent-solaris/ -xf .vagrant/libevent.tar -C .vagrant/') 161 162 # XXX: 163 # - solaris do not have '-or' it only has '-o' for find(1), so we can't use 164 # rsync 165 # - and autoconf(1) doesn't work on virtualbox share, ugh 166 solaris.vm.synced_folder ".vagrant/libevent-solaris", "/vagrant-vbox", 167 type: "virtualbox" 168 169 solaris.vm.box = "tnarik/solaris10-minimal" 170 if ENV['NO_PKG'] != "true" 171 # TODO: opencsw does not include ninja(1) 172 solaris.vm.provision "shell", inline: <<-SHELL 173 pkgadd -d http://get.opencsw.org/now 174 pkgutil -U 175 pkgutil -y -i libssl_dev cmake rsync python gmake gcc5core automake autoconf libtool 176 SHELL 177 end 178 179 # copy from virtualbox mount to newly created folder 180 solaris.vm.provision "shell", privileged: false, inline: <<-SHELL 181 rm -fr ~/vagrant 182 cp -r /vagrant-vbox ~/vagrant 183 SHELL 184 185 if ENV['NO_CMAKE'] != "true" 186 # builtin compiler cc(1) is a wrapper, so we should use gcc5 manually, 187 # otherwise it will not work. 188 # Plus we should set some paths so that cmake/compiler can find tham. 189 solaris.vm.provision "shell", privileged: false, inline: <<-SHELL 190 export CMAKE_INCLUDE_PATH=/opt/csw/include 191 export CMAKE_LIBRARY_PATH=/opt/csw/lib 192 export CFLAGS=-I$CMAKE_INCLUDE_PATH 193 export LDFLAGS=-L$CMAKE_LIBRARY_PATH 194 195 cd ~/vagrant 196 rm -rf .cmake-vagrant 197 mkdir -p .cmake-vagrant 198 cd .cmake-vagrant 199 cmake -DCMAKE_C_COMPILER=gcc .. 200 201 export CTEST_TEST_TIMEOUT=1800 202 export CTEST_OUTPUT_ON_FAILURE=1 203 export CTEST_PARALLEL_LEVEL=20 204 cmake --build . --target verify 205 SHELL 206 end 207 208 if ENV['NO_AUTOTOOLS'] != "true" 209 # and we should set MAKE for `configure` otherwise it will try to use 210 # `make` 211 solaris.vm.provision "shell", privileged: false, inline: <<-SHELL 212 cd ~/vagrant 213 ./autogen.sh 214 MAKE=gmake ./configure 215 gmake -j20 verify 216 SHELL 217 end 218 end 219 220 # known failures: 221 # - sometimes vm hangs 222 config.vm.define "osx" do |osx| 223 system('tar --overwrite --transform=s/libevent/libevent-osx/ -xf .vagrant/libevent.tar -C .vagrant/') 224 225 osx.vm.synced_folder ".vagrant/libevent-osx", "/vagrant", 226 type: "rsync", group: "wheel" 227 228 osx.vm.box = "jhcook/osx-elcapitan-10.11" 229 if ENV['NO_PKG'] != "true" 230 osx.vm.provision "shell", privileged: false, inline: <<-SHELL 231 ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" 232 233 brew uninstall libtool 234 brew install libtool openssl ninja cmake autoconf automake 235 SHELL 236 end 237 238 if ENV['NO_CMAKE'] != "true" 239 # we should set some paths so that cmake/compiler can find tham 240 osx.vm.provision "shell", privileged: false, inline: <<-SHELL 241 export OPENSSL_ROOT=$(echo /usr/local/Cellar/openssl/*) 242 export CMAKE_INCLUDE_PATH=$OPENSSL_ROOT/include 243 export CMAKE_LIBRARY_PATH=$OPENSSL_ROOT/lib 244 245 cd /vagrant 246 mkdir -p .cmake-vagrant 247 cd .cmake-vagrant 248 cmake -G Ninja .. 249 250 export CTEST_TEST_TIMEOUT=1800 251 export CTEST_OUTPUT_ON_FAILURE=1 252 export CTEST_PARALLEL_LEVEL=20 253 cmake --build . --target verify 254 SHELL 255 end 256 257 if ENV['NO_AUTOTOOLS'] != "true" 258 osx.vm.provision "shell", privileged: false, inline: <<-SHELL 259 export OPENSSL_ROOT=$(echo /usr/local/Cellar/openssl/*) 260 export CFLAGS=-I$OPENSSL_ROOT/include 261 export LDFLAGS=-L$OPENSSL_ROOT/lib 262 263 cd /vagrant 264 ./autogen.sh 265 ./configure 266 make -j20 verify 267 SHELL 268 end 269 end 270 271 config.vm.define "centos" do |centos| 272 system('tar --overwrite --transform=s/libevent/libevent-centos/ -xf .vagrant/libevent.tar -C .vagrant/') 273 274 centos.vm.synced_folder ".vagrant/libevent-centos", "/vagrant", 275 type: "rsync", group: "wheel" 276 277 centos.vm.box = "centos/7" 278 if ENV['NO_PKG'] != "true" 279 centos.vm.provision "shell", inline: <<-SHELL 280 echo "[russianfedora]" > /etc/yum.repos.d/russianfedora.repo 281 echo name=russianfedora >> /etc/yum.repos.d/russianfedora.repo 282 echo baseurl=http://mirror.yandex.ru/fedora/russianfedora/russianfedora/free/el/releases/7/Everything/x86_64/os/ >> /etc/yum.repos.d/russianfedora.repo 283 echo enabled=1 >> /etc/yum.repos.d/russianfedora.repo 284 echo gpgcheck=0 >> /etc/yum.repos.d/russianfedora.repo 285 SHELL 286 centos.vm.provision "shell", inline: <<-SHELL 287 yum -y install zlib-devel openssl-devel python 288 yum -y install gcc cmake ninja-build 289 yum -y install autoconf automake libtool 290 SHELL 291 end 292 293 if ENV['NO_CMAKE'] != "true" 294 centos.vm.provision "shell", privileged: false, inline: <<-SHELL 295 cd /vagrant 296 rm -fr .cmake-vagrant 297 mkdir -p .cmake-vagrant 298 cd .cmake-vagrant 299 cmake -G Ninja .. 300 301 export CTEST_TEST_TIMEOUT=1800 302 export CTEST_OUTPUT_ON_FAILURE=1 303 export CTEST_PARALLEL_LEVEL=20 304 cmake --build . --target verify 305 SHELL 306 end 307 308 if ENV['NO_AUTOTOOLS'] != "true" 309 centos.vm.provision "shell", privileged: false, inline: <<-SHELL 310 cd /vagrant 311 ./autogen.sh 312 ./configure 313 make -j20 verify 314 SHELL 315 end 316 end 317 318 # known failures: 319 # - issues with timers (not enough allowed error) 320 config.vm.define "win" do |win| 321 system('tar --overwrite --transform=s/libevent/libevent-win/ -xf .vagrant/libevent.tar -C .vagrant/') 322 323 # 512MB not enough after libtool install, huh 324 win.vm.provider "virtualbox" do |vb| 325 vb.memory = "1024" 326 end 327 328 # windows does not have rsync builtin, let's use virtualbox for now 329 win.vm.synced_folder ".vagrant/libevent-win", "/vagrant", 330 type: "virtualbox" 331 332 win.vm.box = "senglin/win-10-enterprise-vs2015community" 333 if ENV['NO_PKG'] != "true" 334 # box with vs2015 does not have C++ support, so let's install it manually 335 # plus chocolatey that includes in this box, can't handle sha1 checksum for 336 # cmake.install, so let's update it< 337 win.vm.provision "shell", inline: <<-SHELL 338 choco upgrade -y chocolatey -pre -f 339 choco install -y VisualStudioCommunity2013 340 choco install -y openssl.light 341 choco install -y cygwin cyg-get 342 choco install -y cmake 343 choco install -y cmake.install 344 choco install -y python2 345 SHELL 346 347 # chocolatey openssl.light package does not contains headers 348 win.vm.provision "shell", inline: <<-SHELL 349 (new-object System.Net.WebClient).DownloadFile('http://strcpy.net/packages/Win32OpenSSL-1_0_2a.exe', '/openssl.exe') 350 /openssl.exe /silent /verysilent /sp- /suppressmsgboxes 351 SHELL 352 353 # XXX: 354 # - cyg-get depends from cygwinsetup.exe 355 # https://github.com/chocolatey/chocolatey-coreteampackages/issues/200 356 # - cyg-get only downloads, do not installs them, ugh. so let's do not use 357 # it 358 win.vm.provision "shell", privileged: false, inline: <<-SHELL 359 (new-object System.Net.WebClient).DownloadFile('https://cygwin.com/setup-x86_64.exe', '/tools/cygwin/cygwinsetup.exe') 360 361 $env:PATH="/tools/cygwin/bin;$($env:PATH);/tools/cygwin" 362 363 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 364 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 365 SHELL 366 end 367 368 if ENV['NO_CMAKE'] != "true" 369 win.vm.provision "shell", privileged: false, inline: <<-SHELL 370 $env:PATH="/Program Files/CMake/bin;/tools/python2;$($env:PATH)" 371 372 cd /vagrant 373 Remove-Item -Recurse -Force .cmake-vagrant 374 mkdir -p .cmake-vagrant 375 cd .cmake-vagrant 376 cmake -G "Visual Studio 12" .. 377 378 $env:CTEST_TEST_TIMEOUT = "1800" 379 $env:CTEST_OUTPUT_ON_FAILURE = "1" 380 $env:CTEST_PARALLEL_LEVEL = "10" 381 cmake --build . --target verify 382 SHELL 383 end 384 385 if ENV['NO_AUTOTOOLS'] != "true" 386 win.vm.provision "shell", privileged: false, inline: <<-SHELL 387 $env:PATH="/tools/cygwin/bin;$($env:PATH)" 388 389 bash -lc "echo 'C:/tools/mingw64 /mingw ntfs binary 0 0' > /etc/fstab" 390 bash -lc "echo 'C:/OpenSSL-Win32 /ssl ntfs binary 0 0' >> /etc/fstab" 391 bash -lc "echo 'C:/vagrant /vagrant ntfs binary 0 0' >> /etc/fstab" 392 393 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 -j20 verify" 394 SHELL 395 end 396 end 397end 398