* [PATCH] tests: quiet down various tests
@ 2022-12-22 9:45 Eric Wong
0 siblings, 0 replies; only message in thread
From: Eric Wong @ 2022-12-22 9:45 UTC (permalink / raw)
To: mwrap-perl
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/<html>/, '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');
};
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2022-12-22 9:45 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-22 9:45 [PATCH] tests: quiet down various tests Eric Wong
Code repositories for project(s) associated with this public inbox
https://80x24.org/mwrap-perl.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).