"Fossies" - the Fresh Open Source Software Archive

Member "memcached-1.6.15/t/issue_163.t" (16 Jul 2020, 1068 Bytes) of package /linux/www/memcached-1.6.15.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Perl source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 #!/usr/bin/perl
    2 
    3 use strict;
    4 use Test::More tests => 7;
    5 use FindBin qw($Bin);
    6 use lib "$Bin/lib";
    7 use MemcachedTest;
    8 
    9 my $server = new_memcached();
   10 my $sock = $server->sock;
   11 my $value1 = "A"x66560;
   12 my $value2 = "B"x66570;
   13 
   14 print $sock "set key 0 1 66560\r\n$value1\r\n";
   15 is (scalar <$sock>, "STORED\r\n", "stored key");
   16 
   17 my $stats  = mem_stats($sock, "slabs");
   18 my $requested = $stats->{"31:mem_requested"};
   19 isnt ($requested, "0", "We should have requested some memory");
   20 
   21 sleep(3);
   22 print $sock "set key 0 0 66570\r\n$value2\r\n";
   23 is (scalar <$sock>, "STORED\r\n", "stored key");
   24 
   25 my $stats  = mem_stats($sock, "items");
   26 my $reclaimed = $stats->{"items:31:reclaimed"};
   27 is ($reclaimed, "1", "Objects should be reclaimed");
   28 
   29 print $sock "delete key\r\n";
   30 is (scalar <$sock>, "DELETED\r\n", "deleted key");
   31 
   32 print $sock "set key 0 0 66560\r\n$value1\r\n";
   33 is (scalar <$sock>, "STORED\r\n", "stored key");
   34 
   35 my $stats  = mem_stats($sock, "slabs");
   36 my $requested2 = $stats->{"31:mem_requested"};
   37 is ($requested2, $requested, "we've not allocated and freed the same amount");