"Fossies" - the Fresh Open Source Software Archive

Member "memcached-1.6.15/t/daemonize.t" (13 Oct 2014, 738 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 use File::Temp qw(tempfile);
   10 
   11 my (undef, $tmpfn) = tempfile();
   12 
   13 my $server = new_memcached("-d -P $tmpfn");
   14 my $sock = $server->sock;
   15 sleep 0.5;
   16 
   17 ok(-e $tmpfn, "pid file exists");
   18 ok(-s $tmpfn, "pid file has length");
   19 
   20 open (my $fh, $tmpfn) or die;
   21 my $readpid = do { local $/; <$fh>; };
   22 chomp $readpid;
   23 close ($fh);
   24 
   25 ok(kill(0, $readpid), "process is still running");
   26 
   27 my $stats = mem_stats($sock);
   28 is($stats->{pid}, $readpid, "memcached reports same pid as file");
   29 
   30 ok($server->new_sock, "opened new socket");
   31 ok(kill(9, $readpid), "sent KILL signal");
   32 sleep 0.5;
   33 ok(! $server->new_sock, "failed to open new socket");