Cosmetic corrections for the KERBEROS library
[Samba/fernandojvsilva.git] / source4 / selftest / SocketWrapper.pm
blobe63605b8dfdbbf165303daf5434de121a7e78ccc
1 #!/usr/bin/perl
2 # Bootstrap Samba and run a number of tests against it.
3 # Copyright (C) 2005-2007 Jelmer Vernooij <jelmer@samba.org>
4 # Published under the GNU GPL, v3 or later.
6 package SocketWrapper;
8 use Exporter;
9 @ISA = qw(Exporter);
10 @EXPORT_OK = qw(setup_dir setup_pcap set_default_iface);
12 use strict;
13 use FindBin qw($RealBin);
15 sub setup_dir($$)
17 my ($dir, $pcap) = @_;
18 my $pcap_dir = undef;
20 if (defined($dir)) {
21 if ( -d $dir ) {
22 unlink <$dir/*>;
23 } else {
24 mkdir($dir, 0777);
27 if ($pcap) {
28 $pcap_dir = $dir."/pcap";
30 if ( -d $pcap_dir ) {
31 unlink <$pcap_dir/*>;
32 } else {
33 mkdir($pcap_dir, 0777);
38 if (defined($pcap_dir)) {
39 $ENV{SOCKET_WRAPPER_PCAP_DIR} = $pcap_dir;
40 } else {
41 delete $ENV{SOCKET_WRAPPER_PCAP_DIR};
44 if (defined($dir)) {
45 $ENV{SOCKET_WRAPPER_DIR} = $dir;
46 } else {
47 delete $ENV{SOCKET_WRAPPER_DIR};
50 return $dir;
53 sub setup_pcap($)
55 my ($pcap_file) = @_;
57 $ENV{SOCKET_WRAPPER_PCAP_FILE} = $pcap_file;
60 sub set_default_iface($)
62 my ($i) = @_;
63 $ENV{SOCKET_WRAPPER_DEFAULT_IFACE} = $i;