1*2d543d20SAndroid Build Coastguard Worker# -*- mode: ruby -*- 2*2d543d20SAndroid Build Coastguard Worker# vi: set ft=ruby : 3*2d543d20SAndroid Build Coastguard Worker# Vagrant configuration file which creates a virtual machine that can run the 4*2d543d20SAndroid Build Coastguard Worker# test suite using fedora-test-runner.sh, in an environment similar to the one 5*2d543d20SAndroid Build Coastguard Worker# used for automated continuous integration tests (GitHub Actions) 6*2d543d20SAndroid Build Coastguard Worker# 7*2d543d20SAndroid Build Coastguard Worker# To create a new virtual machine: 8*2d543d20SAndroid Build Coastguard Worker# 9*2d543d20SAndroid Build Coastguard Worker# vagrant up --provision 10*2d543d20SAndroid Build Coastguard Worker# 11*2d543d20SAndroid Build Coastguard Worker# To launch tests (for example after modifications to libsepol, libselinux... are made): 12*2d543d20SAndroid Build Coastguard Worker# 13*2d543d20SAndroid Build Coastguard Worker# vagrant rsync && echo ./run-selinux-test.sh | vagrant ssh 14*2d543d20SAndroid Build Coastguard Worker# 15*2d543d20SAndroid Build Coastguard Worker# To destroy the virtual machine (for example to start again from a clean environment): 16*2d543d20SAndroid Build Coastguard Worker# 17*2d543d20SAndroid Build Coastguard Worker# vagrant destroy 18*2d543d20SAndroid Build Coastguard Worker 19*2d543d20SAndroid Build Coastguard Worker# Create a helper script in the VM to run the testsuite as root from a clean environment 20*2d543d20SAndroid Build Coastguard Worker$script = <<SCRIPT 21*2d543d20SAndroid Build Coastguard Workercat > /home/vagrant/run-selinux-test.sh << EOF 22*2d543d20SAndroid Build Coastguard Worker#/bin/sh 23*2d543d20SAndroid Build Coastguard Workerset -e -v 24*2d543d20SAndroid Build Coastguard Worker 25*2d543d20SAndroid Build Coastguard Worker# Run the tests 26*2d543d20SAndroid Build Coastguard Workersudo /root/selinux/scripts/ci/fedora-test-runner.sh 27*2d543d20SAndroid Build Coastguard Workerecho 'All tests passed :)' 28*2d543d20SAndroid Build Coastguard WorkerEOF 29*2d543d20SAndroid Build Coastguard Workerchmod +x /home/vagrant/run-selinux-test.sh 30*2d543d20SAndroid Build Coastguard WorkerSCRIPT 31*2d543d20SAndroid Build Coastguard Worker 32*2d543d20SAndroid Build Coastguard Worker# All Vagrant configuration is done below. The "2" in Vagrant.configure 33*2d543d20SAndroid Build Coastguard Worker# configures the configuration version (we support older styles for 34*2d543d20SAndroid Build Coastguard Worker# backwards compatibility). Please don't change it unless you know what 35*2d543d20SAndroid Build Coastguard Worker# you're doing. 36*2d543d20SAndroid Build Coastguard WorkerVagrant.configure("2") do |config| 37*2d543d20SAndroid Build Coastguard Worker config.vm.box = "fedora/39-cloud-base" 38*2d543d20SAndroid Build Coastguard Worker config.vm.synced_folder "../..", "/root/selinux" 39*2d543d20SAndroid Build Coastguard Worker 40*2d543d20SAndroid Build Coastguard Worker config.vm.provider "virtualbox" do |v| 41*2d543d20SAndroid Build Coastguard Worker v.memory = 4096 42*2d543d20SAndroid Build Coastguard Worker end 43*2d543d20SAndroid Build Coastguard Worker config.vm.provider "libvirt" do |v| 44*2d543d20SAndroid Build Coastguard Worker v.memory = 4096 45*2d543d20SAndroid Build Coastguard Worker end 46*2d543d20SAndroid Build Coastguard Worker 47*2d543d20SAndroid Build Coastguard Worker config.vm.provision :shell, inline: $script 48*2d543d20SAndroid Build Coastguard Workerend 49