From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-3.5 required=3.0 tests=ALL_TRUSTED,AWL,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NORMAL_HTTP_TO_IP, NUMERIC_HTTP_ADDR shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 0779D1F852 for ; Thu, 22 Dec 2022 09:45:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=80x24.org; s=selector1; t=1671702348; bh=FUGc57Z6qBTK/jXKnOOKREWNM3HtTZ44tAMoc+/kOOw=; h=From:To:Subject:Date:From; b=G2px0DadF+sl9QfKTfqR0UGbTrYPHoHYVBd7sKiwvXgquZ2AiZSBG6gfM5PGTLRqU JreXyvA8QGjk4uPRtMH9HWP+ojMAbM/D3vuvumqJoqNu5jDIZrGBrw12WBBMCGKccW YENiYxaV/bAIS+Xt114E/S2RjcpdzEmCcNBA2tpM= From: Eric Wong To: mwrap-perl@80x24.org Subject: [PATCH] tests: quiet down various tests Date: Thu, 22 Dec 2022 09:45:47 +0000 Message-Id: <20221222094547.252562-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: We can check stderr in more places, avoid unused variable warnings, and drop some debug code. We'll allow the V=1 environment to make curl and rproxy verbose, but verbosity tends to hide problems. --- mwrap_core.h | 4 ++-- t/httpd-unit.t | 5 +++++ t/httpd.t | 32 +++++++++++++------------------- 3 files changed, 20 insertions(+), 21 deletions(-) diff --git a/mwrap_core.h b/mwrap_core.h index b014f5d..449dfa4 100644 --- a/mwrap_core.h +++ b/mwrap_core.h @@ -78,7 +78,7 @@ extern const char __attribute__((weak)) PL_memory_wrap[]; /* needed for -O0 */ #endif static MWRAP_TSD size_t locating; -#ifndef PERL_IMPLICIT_CONTEXT +#if MWRAP_PERL && !defined(PERL_IMPLICIT_CONTEXT) static size_t *root_locating; /* determines if PL_curcop is our thread */ #endif static struct cds_lfht *files, *totals; @@ -913,7 +913,7 @@ static void mwrap_reset(void) rcu_read_unlock(); } -static struct src_loc *mwrap_get(const char *str, size_t len) +static inline struct src_loc *mwrap_get(const char *str, size_t len) { void *p; diff --git a/t/httpd-unit.t b/t/httpd-unit.t index 768b2db..43fa67a 100644 --- a/t/httpd-unit.t +++ b/t/httpd-unit.t @@ -104,8 +104,13 @@ SKIP: { $len -= length("$tmp"); $len -= length("\0//$TEST_PID.sock"); my $max = "$tmp/".('x'x$len); + open STDERR, '>', $err; is(system(@vg, $exe, "socket_dir:$max"), 0, "listen dir on max"); + is($end_err->(), '', 'nothing in stderr on max'); + + open STDERR, '>', $err; isnt(system(@vg, $exe, "socket_dir:$max+"), 0, "listen dir too long"); + isnt($end_err->(), '', 'stderr contains error when too long'); } done_testing; diff --git a/t/httpd.t b/t/httpd.t index 53cf420..54d36e4 100644 --- a/t/httpd.t +++ b/t/httpd.t @@ -19,7 +19,7 @@ my $cleanup = sub { if (defined $spid) { if (kill('TERM', $spid)) { waitpid($spid, 0); - $? == 15 or warn "rproxy died with \$?=$?"; + $? == 0 or warn "rproxy died with \$?=$?"; } else { warn "kill $spid: $!"; } @@ -52,8 +52,9 @@ ok($c, 'socket connected'); is(send($c, 'GET', MSG_NOSIGNAL), 3, 'trickled 3 bytes') or diag "send: $!"; my $cout = "$mwrap_tmp/cout"; -my $rc = system(qw(curl -vsSf --unix-socket), $sock, '-o', $cout, - "http://0/$pid/each/2000"); +my @curl = (qw(curl -sf --unix-socket), $sock, '-o', $cout); +push @curl, '-vS' if $ENV{V}; +my $rc = system(@curl, "http://0/$pid/each/2000"); my $curl_unix; SKIP: { skip 'curl lacks --unix-socket support', 1 if $rc == 512; @@ -61,18 +62,15 @@ SKIP: { unlink($cout); $curl_unix = 1; - $rc = system(qw(curl -vsSf --unix-socket), $sock, '-o', $cout, - "http://0/$pid/each/2000"); + $rc = system(@curl, "http://0/$pid/each/2000"); is($rc, 0, 'curl /each'); unlink($cout); - $rc = system(qw(curl -vsSf --unix-socket), $sock, '-o', $cout, - "http://0/$pid/"); + $rc = system(@curl, "http://0/$pid/"); is($rc, 0, 'curl / (PID root)'); like(slurp($cout), qr//, 'root shown'); - $rc = system(qw(curl -vsSf -XPOST --unix-socket), $sock, '-o', $cout, - "http://0/$pid/trim"); + $rc = system(@curl, '-XPOST', "http://0/$pid/trim"); is($rc, 0, 'curl / (PID root)'); like(slurp($cout), qr/trimming/, 'trim started'); unlink($cout); @@ -103,6 +101,7 @@ SKIP: { if (fileno($srv) != 3) { dup2(fileno($srv), 3) or die "dup2: $!"; } + local $ENV{PLACK_ENV} = 'deployment' if !$ENV{V}; no warnings 'exec'; exec $^X, '-w', './blib/script/mwrap-rproxy', "--socket-dir=$mwrap_tmp"; @@ -137,8 +136,7 @@ SKIP: { SKIP: { skip 'no reset w/o curl --unix-socket', 1 if !$curl_unix; - $rc = system(qw(curl -vsSf --unix-socket), $sock, '-o', $cout, - "http://0/$pid/each/100.csv"); + $rc = system(@curl, "http://0/$pid/each/100.csv"); is($rc, 0, '.csv retrieved') or skip 'CSV failed', 1; my $db = "$mwrap_tmp/t.sqlite3"; $rc = system(qw(sqlite3), $db, ".import --csv $cout mwrap_each"); @@ -150,20 +148,16 @@ SKIP: { is($?, 0, 'sqlite3 count'); my $exp = split(/\n/, slurp($cout)); is($n + 1, $exp, 'imported all rows into sqlite'); - my $n = `sqlite3 $db 'SELECT COUNT(*) FROM mwrap_each'`; - # diag `sqlite3 $db .schema`; } - $rc = system(qw(curl -vsSf --unix-socket), $sock, '-o', $cout, - '-d', 'x=y', "http://0/$pid/reset"); + $rc = system(@curl, qw(-d x=y), "http://0/$pid/reset"); is($rc, 0, 'curl /reset'); - $rc = system(qw(curl -vsSf --unix-socket), $sock, '-o', $cout, - '-HX-Mwrap-BT-Depth:10', '-XPOST', "http://0/$pid/ctl"); + $rc = system(@curl, qw(-HX-Mwrap-BT-Depth:10 -XPOST), + "http://0/$pid/ctl"); is($rc, 0, 'curl /ctl (X-Mwrap-BT-Depth)'); like(slurp($cout), qr/\bMWRAP=bt:10\b/, 'changed bt depth'); - $rc = system(qw(curl -vsSf --unix-socket), $sock, '-o', $cout, - '-HX-Mwrap-BT-Depth:10', '-d', 'blah', "http://0/ctl"); + $rc = system(@curl, qw(-HX-Mwrap-BT-Depth:10 -d blah http://0/ctl)); is($rc >> 8, 22, '404 w/o PID prefix'); };