xref: /libevent-2.1.12/Vagrantfile (revision ca591c5b)
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  config.vm.define "centos" do |centos|
275    system('tar --overwrite --transform=s/libevent/libevent-centos/ -xf .vagrant/libevent.tar -C .vagrant/')
276
277    centos.vm.synced_folder ".vagrant/libevent-centos", "/vagrant",
278      type: "rsync", group: "wheel"
279
280    centos.vm.box = "centos/7"
281    if ENV['NO_PKG'] != "true"
282      centos.vm.provision "shell", inline: <<-SHELL
283        echo "[russianfedora]" > /etc/yum.repos.d/russianfedora.repo
284        echo name=russianfedora >> /etc/yum.repos.d/russianfedora.repo
285        echo baseurl=http://mirror.yandex.ru/fedora/russianfedora/russianfedora/free/el/releases/7/Everything/x86_64/os/ >> /etc/yum.repos.d/russianfedora.repo
286        echo enabled=1 >> /etc/yum.repos.d/russianfedora.repo
287        echo gpgcheck=0 >> /etc/yum.repos.d/russianfedora.repo
288      SHELL
289      centos.vm.provision "shell", inline: <<-SHELL
290        yum -y install zlib-devel openssl-devel python
291        yum -y install gcc cmake ninja-build
292        yum -y install autoconf automake libtool
293      SHELL
294    end
295
296    if ENV['NO_CMAKE'] != "true"
297      centos.vm.provision "shell", privileged: false, inline: <<-SHELL
298        cd /vagrant
299        rm -fr .cmake-vagrant
300        mkdir -p .cmake-vagrant
301        cd .cmake-vagrant
302        cmake -G Ninja ..
303
304        export CTEST_TEST_TIMEOUT=1800
305        export CTEST_OUTPUT_ON_FAILURE=1
306        export CTEST_PARALLEL_LEVEL=10
307        cmake --build . --target verify
308      SHELL
309    end
310
311    if ENV['NO_AUTOTOOLS'] != "true"
312      centos.vm.provision "shell", privileged: false, inline: <<-SHELL
313        cd /vagrant
314        ./autogen.sh
315        ./configure
316        make -j4 verify
317      SHELL
318    end
319  end
320
321  # known failures:
322  # - issues with timers (not enough allowed error)
323  config.vm.define "win" do |win|
324    system('tar --overwrite --transform=s/libevent/libevent-win/ -xf .vagrant/libevent.tar -C .vagrant/')
325
326    # 512MB not enough after libtool install, huh
327    win.vm.provider "virtualbox" do |vb|
328      vb.memory = "1024"
329    end
330
331    # windows does not have rsync builtin, let's use virtualbox for now
332    win.vm.synced_folder ".vagrant/libevent-win", "/vagrant",
333      type: "virtualbox"
334
335    win.vm.box = "senglin/win-10-enterprise-vs2015community"
336    if ENV['NO_PKG'] != "true"
337      # box with vs2015 does not have C++ support, so let's install it manually
338      # plus chocolatey that includes in this box, can't handle sha1 checksum for
339      # cmake.install, so let's update it<
340      win.vm.provision "shell", inline: <<-SHELL
341        choco upgrade -y chocolatey -pre -f
342        choco install -y VisualStudioCommunity2013
343        choco install -y openssl.light
344        choco install -y cygwin cyg-get
345        choco install -y cmake
346        choco install -y cmake.install
347        choco install -y python2
348      SHELL
349
350      # chocolatey openssl.light package does not contains headers
351      win.vm.provision "shell", inline: <<-SHELL
352        (new-object System.Net.WebClient).DownloadFile('http://strcpy.net/packages/Win32OpenSSL-1_0_2a.exe', '/openssl.exe')
353        /openssl.exe /silent /verysilent /sp- /suppressmsgboxes
354      SHELL
355
356      # XXX:
357      # - cyg-get depends from cygwinsetup.exe
358      #   https://github.com/chocolatey/chocolatey-coreteampackages/issues/200
359      # - cyg-get only downloads, do not installs them, ugh. so let's do not use
360      #   it
361      win.vm.provision "shell", privileged: false, inline: <<-SHELL
362        (new-object System.Net.WebClient).DownloadFile('https://cygwin.com/setup-x86_64.exe', '/tools/cygwin/cygwinsetup.exe')
363
364        $env:PATH="/tools/cygwin/bin;$($env:PATH);/tools/cygwin"
365
366        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
367        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
368      SHELL
369    end
370
371    if ENV['NO_CMAKE'] != "true"
372      win.vm.provision "shell", privileged: false, inline: <<-SHELL
373        $env:PATH="/Program Files/CMake/bin;/tools/python2;$($env:PATH)"
374
375        cd /vagrant
376        Remove-Item -Recurse -Force .cmake-vagrant
377        mkdir -p .cmake-vagrant
378        cd .cmake-vagrant
379        cmake -G "Visual Studio 12" ..
380
381        $env:CTEST_TEST_TIMEOUT = "1800"
382        $env:CTEST_OUTPUT_ON_FAILURE = "1"
383        $env:CTEST_PARALLEL_LEVEL = "10"
384        cmake --build . --target verify
385      SHELL
386    end
387
388    if ENV['NO_AUTOTOOLS'] != "true"
389      win.vm.provision "shell", privileged: false, inline: <<-SHELL
390        $env:PATH="/tools/cygwin/bin;$($env:PATH)"
391
392        bash -lc "echo 'C:/tools/mingw64 /mingw ntfs binary 0 0' > /etc/fstab"
393        bash -lc "echo 'C:/OpenSSL-Win32 /ssl ntfs binary 0 0' >> /etc/fstab"
394        bash -lc "echo 'C:/vagrant /vagrant ntfs binary 0 0' >> /etc/fstab"
395
396        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"
397      SHELL
398    end
399  end
400end
401