tests/ec: compare the poll counts with -eq, not == - #4823
Draft
ThalesBarretto wants to merge 1 commit into
Draft
ThalesBarretto wants to merge 1 commit into
ThalesBarretto wants to merge 1 commit into
Conversation
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
marked this pull request as draft
September 22, 2026 10:02
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
tests/ec: compare the poll counts with -eq, not ==
gfapi-ec-open-truncate.cpolls for the brick count and for the open-fd count throughsystem(3), i.e. through/bin/sh,with
[ $(... | wc -l) == 3 ]. POSIXtest(1)has no==: string equality is=, integer equality is-eq. bash accepts==as an extension, so the poll works where/bin/shis 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" andtests/basic/ec/gfapi-ec-open-truncate.tfails 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)==->-eqat both poll sites. The counts are integers fromwc -l, so the meaning is unchanged where==happened towork. 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.titself: red before / green after on a dash host, unchanged on a bash host.Fixes: #4822