testing: Use expect-connection in swanctl scenarios
[strongswan.git] / testing / start-testing
1 #!/bin/bash
2
3 DIR=$(dirname `readlink -f $0`)
4 . $DIR/testing.conf
5 . $DIR/scripts/function.sh
6
7 NETWORKS="vnet1 vnet2 vnet3"
8 CONFDIR=$DIR/config/kvm
9 KNLSRC=$BUILDDIR/$KERNEL/arch/x86/boot/bzImage
10 KNLTARGET=/var/run/kvm-swan-kernel
11 HOSTFSTARGET=/var/run/kvm-swan-hostfs
12 MCASTBRS="test-br0 test-br1"
13
14 echo "Starting test environment"
15
16 [ `id -u` -eq 0 ] || die "You must be root to run $0"
17 running_any $STRONGSWANHOSTS && die "Please stop test environment before running $0"
18
19 check_commands kvm virsh
20
21 [ -f $KNLSRC ] || die "Kernel $KNLSRC not found"
22 log_action "Deploying kernel $KERNEL"
23 execute "ln -fs $KNLSRC $KNLTARGET"
24
25 log_action "Deploying $SHAREDDIR as hostfs"
26 execute "chown -R $KVMUSER:$KVMGROUP $SHAREDDIR" 0
27 execute "ln -Tfs $SHAREDDIR $HOSTFSTARGET"
28
29 for net in $NETWORKS
30 do
31         log_action "Network $net"
32         execute "virsh net-create $CONFDIR/$net.xml"
33 done
34
35 for host in $STRONGSWANHOSTS
36 do
37         ln -fs $IMGDIR/$host.$IMGEXT $VIRTIMGSTORE/$host.$IMGEXT
38         log_action "Guest $host"
39         execute "virsh create $CONFDIR/$host.xml"
40 done
41
42 # Enforce reception of multicast traffic on bridges
43 for br in $MCASTBRS
44 do
45         cd /sys/devices/virtual/net/$br/brif
46         for vnet in `find . -name "*eth?"`
47         do
48                 echo 2 > $vnet/multicast_router
49         done
50 done
51
52 echo 0x08 > /sys/devices/virtual/net/test-br0/bridge/group_fwd_mask
53