aboutsummaryrefslogtreecommitdiffstats
path: root/libtests/qtest/flate.test
blob: b7acae6057065ffd4ccf19d3a3c00d5687eb3f75 (plain) (blame)
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
#!/usr/bin/env perl
require 5.008;
BEGIN { $^W = 1; }
use strict;
use File::Copy;
use Digest::MD5;

chdir("flate") or die "chdir testdir failed: $!\n";

require TestDriver;

cleanup();

my $td = new TestDriver('flate');

cleanup();

open(F, ">farbage") or die;
binmode F;
print F "q" x 10000, "\n";
print F "w" x 10000, "\n";
print F "e" x 10000, "\n";
print F "r" x 10000, "\n";
print F "t" x 10000, "\n";
print F "y" x 10000, "\n";
print F "u" x 10000, "\n";
print F "i" x 10000, "\n";
print F "o" x 10000, "\n";
print F "p" x 10000, "\n";
close(F);

check_file("farbage", "a6449c61db5b0645c0693b7560b77a60");

$td->runtest("run driver",
	     {$td->COMMAND => "flate farbage"},,
	     {$td->STRING => "bytes written to o3: 100010\ndone\n",
	      $td->EXIT_STATUS => 0},
	     $td->NORMALIZE_NEWLINES);

check_file("farbage", "a6449c61db5b0645c0693b7560b77a60");

$td->runtest("compressed file correct",
	     {$td->FILE => "farbage.1"},
	     {$td->FILE => "compressed"});

$td->runtest("uncompress filter works",
	     {$td->FILE => "farbage"},
	     {$td->FILE => "farbage.2"});

$td->runtest("double filter works",
	     {$td->FILE => "farbage"},
	     {$td->FILE => "farbage.3"});

cleanup();

$td->report(6);

sub cleanup
{
    system("rm -f farbage*");
}

sub check_file
{
    my ($file, $sum) = @_;
    open(F, "<$file") or die "open $file";
    my $md5 = new Digest::MD5;
    $md5->addfile(*F);
    close(F);
    my $result = $md5->hexdigest;
    $td->runtest("check $file",
		 {$td->STRING => "$result\n"},
		 {$td->STRING => "$sum\n"});
}