The standard test is called without argument and without option. Here we just create a small, fresh tree of files only containing 0 or 1 (simply modulo the counter that counts the files), run trimtrees.pl on it and prove that we have saved the gain we can expect.

More refined (and time consuming) tests can be run by giving arguments and options.

Called with an argument, we use the tree in ./tmp/ instead of building a new one. We add $ARGV[0] new files to that tree and then let trimtrees.pl run.

In either case, we then create an overview of all inodes found in the tree, linkcount and one example file. This overview should tell the educated tester if trimtrees has worked correctly.

For example, if we are on a filesystem with a give maximum linkcount of 32000 (on my ext3 filesystem), then

perl t/trimtrees.t 64000

should create 2 files with linkcount being 32000 for each. Then

perl t/trimtrees.t -maxlinks 16000 0

should alter the tree to contain 4 files with linkcount 16000. After that

perl t/trimtrees.t -maxlinks 8000 0

should alter the tree to contain 8 files with linkcount 8000. After that

perl t/trimtrees.t 0

should again put the tree back to 2 x 32000 as after the first call.

perl t/trimtrees.t -maxlinks 8000 0

produces again 8 x 8000,

perl t/trimtrees.t -maxlinks 16000 0

produces again 4 files with 16000 linkcount foreach

This allows us to run

cp -al tmp tmp2

without an error. Then the following also gives no error:

perl t/trimtrees.t -maxlinks 16000 0
cp -al tmp tmp3

But then

cp -al tmp tmp4

immediately produces errors.