pgbench tests vs Windows

Started by Andrew Dunstanover 6 years ago5 messages
#1Andrew Dunstan
andrew.dunstan@2ndquadrant.com

In commit ed8a7c6fcf9 we added some extra tests to pgbench, including
this snippet:

\setshell two\
  expr \
    1 + :one

Unfortunately, this isn't portable, as I've just discovered at the cost
of quite a bit of time. In particular, you can't assume expr is present
and in the path on Windows. The Windows equivalent would be something like:

\setshell two\
  @set /a c = 1 + :one  && echo %c%

I propose to prepare a patch along these lines. Alternatively we could
just drop it - I don't think the test matters all that hugely.

cheers

andrew

--
Andrew Dunstan https://www.2ndQuadrant.com
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Andrew Dunstan (#1)
Re: pgbench tests vs Windows

Andrew Dunstan <andrew.dunstan@2ndquadrant.com> writes:

In commit ed8a7c6fcf9 we added some extra tests to pgbench, including
this snippet:
\setshell two\
  expr \
    1 + :one
Unfortunately, this isn't portable, as I've just discovered at the cost
of quite a bit of time. In particular, you can't assume expr is present
and in the path on Windows.

Ugh.

The Windows equivalent would be something like:
\setshell two\
  @set /a c = 1 + :one  && echo %c%

I wonder how universal that is, either.

I propose to prepare a patch along these lines. Alternatively we could
just drop it - I don't think the test matters all that hugely.

I'd say try that, but if it doesn't work right away, just skip the
test on Windows.

regards, tom lane

#3Michael Paquier
michael@paquier.xyz
In reply to: Tom Lane (#2)
Re: pgbench tests vs Windows

On Tue, Jul 23, 2019 at 07:13:51PM -0400, Tom Lane wrote:

Andrew Dunstan <andrew.dunstan@2ndquadrant.com> writes:

I propose to prepare a patch along these lines. Alternatively we could
just drop it - I don't think the test matters all that hugely.

I'd say try that, but if it doesn't work right away, just skip the
test on Windows.

+1.  I don't see exactly why we should drop it either.
--
Michael
#4Fabien COELHO
coelho@cri.ensmp.fr
In reply to: Andrew Dunstan (#1)
1 attachment(s)
Re: pgbench tests vs Windows

Hello Andrew,

Unfortunately, this isn't portable, as I've just discovered at the cost
of quite a bit of time. In particular, you can't assume expr is present
and in the path on Windows. The Windows equivalent would be something like:

\setshell two\
  @set /a c = 1 + :one  && echo %c%

Hmmm... Can we assume that echo is really always there on Windows? If so,
the attached patch does something only with "echo".

I propose to prepare a patch along these lines. Alternatively we could
just drop it - I don't think the test matters all that hugely.

The point is to have some minimal coverage so that unexpected changes are
caught. This is the only call to a working \setshell.

--
Fabien.

Attachments:

pgbench-setshell-test-1.pathtext/plain; charset=US-ASCII; name=pgbench-setshell-test-1.pathDownload
diff --git a/src/bin/pgbench/t/001_pgbench_with_server.pl b/src/bin/pgbench/t/001_pgbench_with_server.pl
index 5a2fdb9acb..b82d3f65c4 100644
--- a/src/bin/pgbench/t/001_pgbench_with_server.pl
+++ b/src/bin/pgbench/t/001_pgbench_with_server.pl
@@ -512,7 +512,7 @@ pgbench(
 		qr{processed: 1/1},
 		qr{shell-echo-output}
 	],
-	[qr{command=8.: int 2\b}],
+	[qr{command=8.: int 1\b}],
 	'pgbench backslash commands',
 	{
 		'001_pgbench_backslash_commands' => q{-- run set
@@ -524,10 +524,10 @@ pgbench(
 \sleep 0 s
 \sleep :zero
 -- setshell and continuation
-\setshell two\
-  expr \
-    1 + :one
-\set n debug(:two)
+\setshell another_one\
+  echo \
+    :one
+\set n debug(:another_one)
 -- shell
 \shell echo shell-echo-output
 }
#5Andrew Dunstan
andrew.dunstan@2ndquadrant.com
In reply to: Fabien COELHO (#4)
Re: pgbench tests vs Windows

On 7/24/19 3:56 AM, Fabien COELHO wrote:

Hello Andrew,

Unfortunately, this isn't portable, as I've just discovered at the cost
of quite a bit of time. In particular, you can't assume expr is present
and in the path on Windows. The Windows equivalent would be something
like:

   \setshell two\
     @set /a c = 1 + :one  && echo %c%

Hmmm... Can we assume that echo is really always there on Windows? If
so, the attached patch does something only with "echo".

Yes, it's built into the cmd processor (as is "set /a", to answer Tom's
earlier question about portability - I tested the above back to XP.)

echo is much more universal, and I can confirm that the suggested fix
works on the Windows test box I'm using.

I'll apply and backpatch that. Thanks

cheers

andrew

--
Andrew Dunstan https://www.2ndQuadrant.com
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services