"Fossies" - the Fresh Open Source Software Archive

Member "memcached-1.6.15/t/misbehave.t" (21 Feb 2022, 639 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;
    5 use FindBin qw($Bin);
    6 use Socket qw(MSG_PEEK MSG_DONTWAIT);
    7 use lib "$Bin/lib";
    8 use MemcachedTest;
    9 
   10 if (!enabled_tls_testing() && supports_drop_priv()) {
   11     plan tests => 1;
   12 } else {
   13     plan skip_all => 'Privilege drop not supported';
   14     exit 0;
   15 }
   16 
   17 my $server = new_memcached('-o drop_privileges');
   18 my $sock = $server->sock;
   19 
   20 print $sock "misbehave\r\n";
   21 sleep(1);
   22 
   23 # check if the socket is dead now
   24 my $buff;
   25 my $ret = recv($sock, $buff, 1, MSG_PEEK | MSG_DONTWAIT);
   26 # ret = 0 means read 0 bytes, which means a closed socket
   27 ok($ret == 0, "did not allow misbehaving");
   28 
   29 $server->DESTROY();