File: info.t

package info (click to toggle)
apache2 2.4.66-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 59,324 kB
  • sloc: ansic: 212,315; python: 13,830; perl: 11,307; sh: 7,254; php: 1,320; javascript: 1,314; awk: 749; makefile: 715; lex: 374; yacc: 161; xml: 2
file content (69 lines) | stat: -rw-r--r-- 1,768 bytes parent folder | download | duplicates (6)
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
use strict;
use warnings FATAL => 'all';

use Apache::Test;
use Apache::TestRequest;

##
## mod_info quick test
##

plan tests => 1, need_module 'info';

my $uri = '/server-info';
my $info = GET_BODY $uri;
my $config = Apache::Test::config();
my $mods = $config->{modules};
my (@actual,@expected) = ((),());

## extract module names from html ##
foreach (split /\n/, $info) {
    if ($_ =~ /<a name=\"(\w+\.c)\">/) {
        if ($1 eq 'util_ldap.c') {
            push(@actual,'mod_ldap.c');
        } elsif ($1 eq 'mod_apreq2.c') {
            push(@actual,'mod_apreq.c');
        } else {
            push(@actual, $1);
        }
    }
}

foreach (sort keys %$mods) {
    ($mods->{$_} && !$config->should_skip_module($_)) or next;
    if ($_ =~ /^mod_mpm_(eventopt|event|motorz|prefork|worker)\.c$/) {
        push(@expected,"$1.c");
    } elsif ($_ eq 'mod_mpm_simple.c') {
        push(@expected,'simple_api.c');
    # statically linked mod_ldap
    } elsif ($_ eq 'util_ldap.c') {
        push(@expected,'mod_ldap.c');
    # statically linked mod_apreq2
    } elsif ($_ eq 'mod_apreq2.c') {
        push(@expected,'mod_apreq.c');
    } else {
        push(@expected,$_);
    }
}
@actual = sort @actual;
@expected = sort @expected;

## verify all mods are there ##
my $ok = 1;
if (@actual == @expected) {
    for (my $i=1 ; $i<@expected ; $i++) {
        if ($expected[$i] ne $actual[$i]) {
            $ok = 0;
            print "comparing expected ->$expected[$i]<-\n";
            print "to actual ->$actual[$i]<-\n";
            print "actual:\n@actual\nexpect:\n@expected\n";
            last;
        }
    }
} else {
    $ok = 0;
    my $a = @actual; my $e = @expected;
    print "actual($a modules):\n@actual\nexpect($e modules):\n@expected\n";
}

ok $ok;