Skip to content

tests/ec: compare the poll counts with -eq, not == - #4823

Draft
ThalesBarretto wants to merge 1 commit into
gluster:develfrom
ThalesBarretto:fix/tests-gfapi-ec-open-truncate-posix-test
Draft

ThalesBarretto wants to merge 1 commit into
gluster:develfrom
ThalesBarretto:fix/tests-gfapi-ec-open-truncate-posix-test

Conversation

@ThalesBarretto

Copy link
Copy Markdown
Contributor

tests/ec: compare the poll counts with -eq, not ==

gfapi-ec-open-truncate.c polls for the brick count and for the open-fd count through system(3), i.e. through /bin/sh,
with [ $(... | wc -l) == 3 ]. POSIX test(1) has no ==: string equality is =, integer equality is -eq. bash accepts
== as an extension, so the poll works where /bin/sh is bash and fails where it is dash (Debian, Ubuntu and derivatives)
with sh: 1: [: 3: unexpected operator, after which the tester gives up with "Bricks didn't come up" and
tests/basic/ec/gfapi-ec-open-truncate.t fails at subtest 22 without ever exercising the open-fd heal it was written for
(since e16dd14, 2019). Details in #4822.

The change (tests/basic/ec/gfapi-ec-open-truncate.c, +2/-2)

== -> -eq at both poll sites. The counts are integers from wc -l, so the meaning is unchanged where == happened to
work. A sweep of the other C testers that shell out (ec-badfd.c, bug-1093594.c, glfs_vol_set_IO_ERR.c,
bug-824753-file-locker.c, bug-858242.c, bug-808400-{fcntl,flock}.c, bug-1126048.c, bug-1279730.c,
arequal-checksum.c) found no other == inside [ ].

Test

tests/basic/ec/gfapi-ec-open-truncate.t itself: red before / green after on a dash host, unchanged on a bash host.

Fixes: #4822

gfapi-ec-open-truncate.c polls for the brick count and for the open-fd count
through system(3), i.e. through /bin/sh, with

    [ $(... | wc -l) == 3 ]

POSIX test(1) has no '==' operator: string equality is '=' and integer
equality is '-eq'.  bash accepts '==' as an extension, so the poll works
where /bin/sh is bash (the CentOS-based CI), and fails where /bin/sh is
dash (Debian, Ubuntu and derivatives):

    sh: 1: [: 3: unexpected operator

repeated twenty times, after which the tester gives up with "Bricks
didn't come up" and exits 1, so tests/basic/ec/gfapi-ec-open-truncate.t
fails at the tester step without ever exercising the open-fd heal it was
written for.  Both sites date from the test's introduction (e16dd14,
"tests: Test openfd heal doesn't truncate files", 2019).

Use '-eq', which is the integer comparison every POSIX sh implements; the
counts are integers from wc -l, so the meaning is unchanged where '=='
happened to work.  No other tester under tests/ shells out with '=='.

Fixes: gluster#4822
Signed-off-by: Thales Antunes de Oliveira Barretto <thales.barretto.git@gmail.com>
@ThalesBarretto
ThalesBarretto marked this pull request as draft September 22, 2026 10:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

tests: gfapi-ec-open-truncate.c polls with a bash-only ==; the test is vacuous wherever /bin/sh is dash

1 participant