blob: 62c60f44a01bf4d939fdb3a8cdba9c967fe213a8 (
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
|
#!/usr/bin/env perl
#
# $FML: journaledfile.pl,v 1.4 2002/05/11 08:34:52 fukachan Exp $
#
use strict;
use lib qw(../../fml/lib);
use Tie::JournaledFile;
$| = 1;
#
# 1. read/write
#
print "Tie::JournaledFile write ... ";
my $debug = defined $ENV{'debug'} ? 1 : 0;
my %db = ();
my $file = '/tmp/fml5/cache.txt';
my $buf = '';
my $key = "rudo$$";
chop($buf = `date`);
tie %db, 'Tie::JournaledFile', { file => $file };
$db{ $key } = $buf;
untie %db;
print " ", `ls -l $file` if $debug;
tie %db, 'Tie::JournaledFile', { file => $file };
print "verify written string ... " if $debug;
if ($db{ $key } eq $buf) {
print "ok\n";
}
else {
print "fail\n";
print " >", $db{ $key }, "<\n";
print " >", $buf, "<\n";
}
#
# 2. keys
#
print "Tie::JournaledFile keys ... ";
my @p = keys %db;
my $count_orig = ` awk '{print $1}' $file | sort | uniq | wc -l `;
my $count = $#p + 1;
if ($count_orig == $count) {
print "ok\n";
}
else {
print "fail ($count_orig != $count)\n";
}
exit 0;
|