1# Before `make install' is performed this script should be runnable with
2# `make test'. After `make install' it should work as `perl test.pl'
3
4######################### We start with some black magic to print on failure.
5
6# Change 1..1 below to 1..last_test_to_print .
7# (It may become useful if the test is moved to ./t subdirectory.)
8
9BEGIN { $| = 1; print "1..2\n"; }
10END {print "not ok 1\n" unless $loaded;}
11require 5.006;
12use Config qw(%Config);
13use Filesys::Df;
14$loaded = 1;
15print "ok 1\n";
16
17######################### End of black magic.
18
19my $dir = "/";
20
21my $ref = Filesys::Df::df($dir);
22
23defined($ref) and
24	print"ok 2\n" or
25	die "not ok 2\ndf\(\) call failed for \"$dir\" $!\n";
26
27open(FILE, "./test.pl") or die "$! ./test.pl\n";
28my $fh_ref = Filesys::Df::df(\*FILE);
29close(FILE);
30
31defined($fh_ref) and
32	print"ok 3\n\n" or
33	die "not ok 3\ndf\(\) call failed for \"test.pl\" $!\n";
34
35print"Results for directory: \"$dir\" in 1K blocks:\n";
36print "Total: $ref->{blocks}\n";
37print "Free: $ref->{bfree}\n";
38print "Available: $ref->{bavail}\n";
39print "Used: $ref->{used}\n";
40print "Percent Full: $ref->{per}\n";
41if(exists($ref->{files})) {
42	print "Total Inodes: $ref->{files}\n";
43	print "Free Inodes: $ref->{ffree}\n";
44	print "Inode Percent Full: $ref->{fper}\n";
45}
46
47
48print "\nResults for \"test.pl\" filehandle in 1K blocks:\n";
49print "Total: $fh_ref->{blocks}\n";
50print "Free: $fh_ref->{bfree}\n";
51print "Available: $fh_ref->{bavail}\n";
52print "Used: $fh_ref->{used}\n";
53print "Percent Full: $fh_ref->{per}\n";
54if(exists($fh_ref->{files})) {
55	print "Total Inodes: $fh_ref->{files}\n";
56	print "Free Inodes: $fh_ref->{ffree}\n";
57	print "Inode Percent Full: $fh_ref->{fper}\n\n";
58}
59
60
61print"All tests successful!\n\n";
62
63