+is($#filtered+1, 4, "4 results are at level 2");
+
+# test dumps_match_dumpspecs
+
+my @dumpspecs;
+
+@dumpspecs = Amanda::Cmdline::parse_dumpspecs(["thatbox", "/var"], 0);
+@filtered = Amanda::Logfile::dumps_match_dumpspecs([@results], [@dumpspecs], 0);
+is_deeply([ map { res2arr($_) } @filtered ],
+ [
+ [ '20071109010002', 'thatbox', '/var', 1, 'TESTCONF002', 3, 'OK', 'OK', '', 1, 1 ],
+ ], "filter with dumpspecs 'thatbox /var'");
+
+@dumpspecs = Amanda::Cmdline::parse_dumpspecs(["thatbox", "/var", "clihost"], 0);
+@filtered = Amanda::Logfile::dumps_match_dumpspecs([@results], [@dumpspecs], 0);
+@filtered = sort { $a->{'label'} cmp $b->{'label'} ||
+ $a->{'filenum'} <=> $b->{'filenum'} } @filtered;
+is_deeply([ map { res2arr($_) } @filtered ],
+ [
+ [ '20071109010002', 'clihost', '/usr', 0, 'TESTCONF002', 1, 'OK', 'OK', '', 1, 1 ],
+ [ '20071109010002', 'clihost', '/my documents', 0, 'TESTCONF002', 2, 'OK', 'OK', '', 1, 1 ],
+ [ '20071109010002', 'thatbox', '/var', 1, 'TESTCONF002', 3, 'OK', 'OK', '', 1, 1 ],
+ [ '20071109010002', 'clihost', '/home', 0, 'TESTCONF002', 4, 'OK', 'OK', '', 1, 5 ],
+ [ '20071109010002', 'clihost', '/home', 0, 'TESTCONF002', 5, 'OK', 'OK', '', 2, 5 ],
+ [ '20071109010002', 'clihost', '/home', 0, 'TESTCONF002', 6, 'OK', 'OK', '', 3, 5 ],
+ [ '20071109010002', 'clihost', '/home', 0, 'TESTCONF002', 7, 'OK', 'OK', '', 4, 5 ],
+ [ '20071109010002', 'clihost', '/home', 0, 'TESTCONF002', 8, 'OK', 'OK', '', 5, 5 ],
+ ], "filter with dumpspecs 'thatbox /var clihost' (union of two disjoint sets)");
+
+# if multiple dumpspecs specify the same dump, it will be included in the output multiple times
+@dumpspecs = Amanda::Cmdline::parse_dumpspecs([".*", "/var", "thatbox"], 0);
+@filtered = Amanda::Logfile::dumps_match_dumpspecs([@results], [@dumpspecs], 0);
+@filtered = sort { $a->{'label'} cmp $b->{'label'} ||
+ $a->{'filenum'} <=> $b->{'filenum'} } @filtered;
+is_deeply([ map { res2arr($_) } @filtered ],
+ [
+ [ '20071109010002', 'thatbox', '/var', 1, 'TESTCONF002', 3, 'OK', 'OK' , '', 1, 1 ],
+ [ '20071109010002', 'thatbox', '/u_lose', 2, 'TESTCONF002', 9, 'OK', 'FAIL', '"Oh no!"', 1, 4 ],
+ [ '20071109010002', 'thatbox', '/u_lose', 2, 'TESTCONF002', 10, 'OK', 'FAIL', '"Oh no!"', 2, 4 ],
+ [ '20071109010002', 'thatbox', '/u_lose', 2, 'TESTCONF002', 11, 'PARTIAL', 'FAIL', '"Oh no!"', 3, 4 ],
+ [ '20071109010002', 'thatbox', '/u_lose', 2, 'TESTCONF003', 1, 'OK', 'FAIL', '"Oh no!"', 3, 4 ],
+ [ '20071109010002', 'thatbox', '/u_win', 3, 'TESTCONF003', 2, 'OK', 'OK' , '', 1, 4 ],
+ [ '20071109010002', 'thatbox', '/u_win', 3, 'TESTCONF003', 3, 'OK', 'OK' , '', 2, 4 ],
+ [ '20071109010002', 'thatbox', '/u_win', 3, 'TESTCONF003', 4, 'PARTIAL', 'OK' , '', 3, 4 ],
+ [ '20071109010002', 'thatbox', '/u_win', 3, 'TESTCONF004', 1, 'OK', 'OK' , '', 3, 4 ],
+ [ '20071109010002', 'thatbox', '/u_win', 3, 'TESTCONF004', 2, 'OK', 'OK' , '', 4, 4 ],
+ ], "filter with dumpspecs '.* /var thatbox' (union of two overlapping sets includes dupes)");
+
+@dumpspecs = Amanda::Cmdline::dumpspec_t->new('thatbox', undef, undef, undef, '20071109010002');
+@filtered = Amanda::Logfile::dumps_match_dumpspecs([@results], [@dumpspecs], 0);
+@filtered = sort { $a->{'label'} cmp $b->{'label'} ||
+ $a->{'filenum'} <=> $b->{'filenum'} } @filtered;
+is_deeply([ map { res2arr($_) } @filtered ],
+ [
+ [ '20071109010002', 'thatbox', '/var', 1, 'TESTCONF002', 3, 'OK', 'OK' , '', 1, 1 ],
+ [ '20071109010002', 'thatbox', '/u_lose', 2, 'TESTCONF002', 9, 'OK', 'FAIL', '"Oh no!"', 1, 4 ],
+ [ '20071109010002', 'thatbox', '/u_lose', 2, 'TESTCONF002', 10, 'OK', 'FAIL', '"Oh no!"', 2, 4 ],
+ [ '20071109010002', 'thatbox', '/u_lose', 2, 'TESTCONF002', 11, 'PARTIAL', 'FAIL', '"Oh no!"', 3, 4 ],
+ [ '20071109010002', 'thatbox', '/u_lose', 2, 'TESTCONF003', 1, 'OK', 'FAIL', '"Oh no!"', 3, 4 ],
+ [ '20071109010002', 'thatbox', '/u_win', 3, 'TESTCONF003', 2, 'OK', 'OK' , '', 1, 4 ],
+ [ '20071109010002', 'thatbox', '/u_win', 3, 'TESTCONF003', 3, 'OK', 'OK' , '', 2, 4 ],
+ [ '20071109010002', 'thatbox', '/u_win', 3, 'TESTCONF003', 4, 'PARTIAL', 'OK' , '', 3, 4 ],
+ [ '20071109010002', 'thatbox', '/u_win', 3, 'TESTCONF004', 1, 'OK', 'OK' , '', 3, 4 ],
+ [ '20071109010002', 'thatbox', '/u_win', 3, 'TESTCONF004', 2, 'OK', 'OK' , '', 4, 4 ],
+ ], "filter with dumpspecs with host 'thatbox' and a write_timestamp");
+unlink($log_filename);
+
+# search_holding_disk and match_* are tested via Amanda::DB::Catalog's installcheck