~yolanda.robla/ubuntu/trusty/memcached/add_distribution

« back to all changes in this revision

Viewing changes to t/issue_67.t

  • Committer: Bazaar Package Importer
  • Author(s): David Martínez Moreno
  • Date: 2010-05-12 11:41:22 UTC
  • mfrom: (1.1.7 upstream) (3.3.3 squeeze)
  • Revision ID: james.westby@ubuntu.com-20100512114122-e2dphwiezevuny1t
Tags: 1.4.5-1
* New upstream release.  Main changes since 1.4.2 are:
  New features:
  - Support for SASL authentication.
  - New script damemtop - a memcached top.
  - Slab optimizations.
  - New stats, for reclaimed memory and SASL events.
  Bugs fixed:
  - Malicious input can crash server (CVE-2010-1152).  Closes: #579913.
  - Fixed several problems with slab handling and growth.
  - Provide better error reporting.
  - Fix get stats accounting.
  - Fixed backwards compatibility with delete 0.
  - Documentation fixes.
  - Various build fixes, among others, fixed FTBFS with gcc-4.5 (closes:
    #565033).
* Refreshed and renamed 01_init_script_compliant_with_LSB.patch.
* Fixed lintian warnings by adding $remote_fs to init.d script.
* Removed non-existent document (doc/memory_management.txt).
* debian/control: Bumped Standards-Version to 3.8.4 (no changes).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/perl
 
2
 
 
3
use strict;
 
4
use Test::More tests => 22;
 
5
use FindBin qw($Bin);
 
6
use lib "$Bin/lib";
 
7
use MemcachedTest;
 
8
use Carp qw(croak);
 
9
 
 
10
use Cwd;
 
11
my $builddir = getcwd;
 
12
 
 
13
$ENV{'MEMCACHED_PORT_FILENAME'} = "/tmp/ports.$$";
 
14
 
 
15
sub read_ports {
 
16
    my %rv = ();
 
17
    open(my $f, "/tmp/ports.$$") || die("Can't open ports file.");
 
18
    while(<$f>) {
 
19
        my ($type, $port) = split(/:\s+/);
 
20
        $rv{$type} = $port + 0;
 
21
    }
 
22
    unlink "/tmp/ports.$$";
 
23
    return %rv;
 
24
}
 
25
 
 
26
sub validate_port {
 
27
    my ($name, $got, $expected) = @_;
 
28
    # diag "Wanted $expected, got $got";
 
29
    if ($expected == -1) {
 
30
        ok(!defined($got), "$name expected no port, got $got");
 
31
    } elsif ($expected == 0) {
 
32
        ok($got != 11211, "$name expected random port (got $got)");
 
33
    } else {
 
34
        is($got, $expected, "$name");
 
35
    }
 
36
}
 
37
 
 
38
sub run_server {
 
39
    my ($args) = @_;
 
40
 
 
41
    my $exe = "$builddir/memcached-debug";
 
42
    croak("memcached binary doesn't exist.  Haven't run 'make' ?\n") unless -e $exe;
 
43
 
 
44
    my $childpid = fork();
 
45
 
 
46
    my $cmd = "$builddir/timedrun 10 $exe $args";
 
47
 
 
48
    unless($childpid) {
 
49
        exec $cmd;
 
50
        exit; # NOTREACHED
 
51
    }
 
52
 
 
53
    for (1..20) {
 
54
        if (-f "/tmp/ports.$$") {
 
55
            return Memcached::Handle->new(pid  => $childpid);
 
56
        }
 
57
        select undef, undef, undef, 0.10;
 
58
    }
 
59
    croak "Failed to start server.";
 
60
}
 
61
 
 
62
sub when {
 
63
    my ($name, $params, $expected_tcp, $expected_udp) = @_;
 
64
 
 
65
    my $server = run_server($params);
 
66
    my %ports = read_ports();
 
67
 
 
68
    validate_port($name, $ports{'TCP INET'}, $expected_tcp);
 
69
    validate_port($name, $ports{'UDP INET'}, $expected_udp);
 
70
}
 
71
 
 
72
# Disabling the defaults since it conflicts with a running instance.
 
73
# when('no arguments', '', 11211, 11211);
 
74
when('specifying tcp port', '-p 11212', 11212, 11212);
 
75
when('specifying udp port', '-U 11222', 11222, 11222);
 
76
when('specifying tcp ephemeral port', '-p -1', 0, 0);
 
77
when('specifying udp ephemeral port', '-U -1', 0, 0);
 
78
when('tcp port disabled', '-p 0', -1, -1);
 
79
when('udp port disabled', '-U 0', -1, -1);
 
80
when('specifying tcp and udp ports', '-p 11232 -U 11233', 11232, 11233);
 
81
when('specifying tcp and disabling udp', '-p 11242 -U 0', 11242, -1);
 
82
when('specifying udp and disabling tcp', '-p -1 -U 11252', 0, 11252);
 
83
when('specifying tcp and ephemeral udp', '-p 11262 -U -1', 11262, 0);
 
84
when('specifying udp and ephemeral tcp', '-p -1 -U 11272', 0, 11272);