Add VDE switch management functions.
authorJelmer Vernooij <jelmer@samba.org>
Tue, 19 Feb 2008 21:04:26 +0000 (22:04 +0100)
committerJelmer Vernooij <jelmer@samba.org>
Tue, 19 Feb 2008 21:04:26 +0000 (22:04 +0100)
source/selftest/selftest.pl

index 996b982e06ba748979d20b0b05ebde51f683f6cd..aa4423c7e2d551eb2068e6cacef2b3caebb1c085 100755 (executable)
@@ -1,6 +1,6 @@
 #!/usr/bin/perl
 # Bootstrap Samba and run a number of tests against it.
-# Copyright (C) 2005-2007 Jelmer Vernooij <jelmer@samba.org>
+# Copyright (C) 2005-2008 Jelmer Vernooij <jelmer@samba.org>
 # Published under the GNU GPL, v3 or later.
 
 =pod
@@ -455,6 +455,31 @@ if ($opt_target eq "samba4") {
        $target = new Kvm($opt_image, undef);
 }
 
+#
+# Start a Virtual Distributed Ethernet Switch
+# Returns the pid of the switch.
+#
+sub start_vde_switch($)
+{
+       my ($path) = @_;
+
+       system("vde_switch --pidfile $path/vde.pid --sock $path/vde.sock --daemon");
+
+       open(PID, "$path/vde.pid");
+       <PID> =~ /([0-9]+)/;
+       my $pid = $1;
+       close(PID);
+
+       return $pid;
+}
+
+# Stop a Virtual Distributed Ethernet Switch
+sub stop_vde_switch($)
+{
+       my ($pid) = @_;
+       kill 9, $pid;
+}
+
 sub read_test_regexes($)
 {
        my ($name) = @_;