blob: d56899d5ae6ef01d847576cba69970e8ecaa3077 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
|
# $Id$
# This module contains a few miscellanous functions and some
# startup ARGV processing that is used by all tests.
use PerlACE::Process;
use PerlACE::ConfigList;
package PerlACE;
use Cwd;
# Figure out the svc.conf extension
$svcconf_ext = $ENV{"ACE_RUNTEST_SVCCONF_EXT"};
if (!defined $svcconf_ext) {
$svcconf_ext = ".conf";
}
# Turn on autoflush
$| = 1;
sub LocalFile ($)
{
my $file = shift;
my $newfile = getcwd () . '/' . $file;
if ($^O eq "MSWin32") {
$newfile =~ s/\//\\/g;
}
return $newfile;
}
# Returns a unique id, uid for unix, last digit of IP for NT
sub uniqueid
{
if ($^O eq "MSWin32")
{
my $uid = 1;
open (IPNUM, "ipconfig|") || die "Can't run ipconfig: $!\n";
while (<IPNUM>)
{
if (/Address/)
{
$uid = (split (/: (\d+)\.(\d+)\.(\d+)\.(\d+)/))[4];
}
}
close IPNUM;
return $uid;
}
else
{
return getpwnam (getlogin ());
}
}
# Waits until a file exists
sub waitforfile
{
local($file) = @_;
sleep 1 while (!(-e $file && -s $file));
}
sub waitforfile_timed
{
my $file = shift;
my $maxtime = shift;
$maxtime *= $PerlACE::Process::WAIT_DELAY_FACTOR;
while ($maxtime-- != 0) {
if (-e $file && -s $file) {
return 0;
}
sleep 1;
}
return -1;
}
sub check_n_cleanup_files
{
my $file = shift;
my @flist = glob ($file);
my $cntr = 0;
my $nfile = scalar(@flist);
if ($nfile != 0) {
for (; $cntr < $nfile; $cntr++) {
print STDERR "File <$flist[$cntr]> exists but should be cleaned up\n";
}
unlink @flist;
}
}
$sleeptime = 5;
1;
|