Skip to content

Bug 5237: "make check" fails when ${TRUE} is a multicall binary#2442

Closed
renanrodrigo wants to merge 2 commits into
squid-cache:masterfrom
renanrodrigo:fix-true-test
Closed

Bug 5237: "make check" fails when ${TRUE} is a multicall binary#2442
renanrodrigo wants to merge 2 commits into
squid-cache:masterfrom
renanrodrigo:fix-true-test

Conversation

@renanrodrigo

@renanrodrigo renanrodrigo commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Authored-by: Renan Rodrigo rr@ubuntu.com

testHeaders copies the 'true' binary to a file named testHeaders relying
on the fact that GNU's true always exits 0. When 'true' implementation
is a multicall binary (e.g., in rust-coreutils and on Alpine Linux), it
cannot be called by other name. Create an empty executable file instead.

squid-conf-tests also copied the 'true' binary, but that Makefile target
is never executed and, hence, should not create an executable file.

@squid-anubis squid-anubis added the M-failed-description https://github.com/measurement-factory/anubis#pull-request-labels label Jun 9, 2026
@squid-anubis

This comment was marked as resolved.

@squid-anubis squid-anubis removed the M-failed-description https://github.com/measurement-factory/anubis#pull-request-labels label Jun 9, 2026
@yadij yadij self-requested a review June 10, 2026 03:55
@yadij

yadij commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Polished the description to fit Anubis requirements. No Substantive change.
Marking for review by myself as I want to look into the side effects of ':' command deeper - we had a lot of portability issues revealed while settling on use of $(TRUE) previously.

Comment thread test-suite/Makefile.am Outdated
yadij
yadij previously approved these changes Jun 11, 2026

@yadij yadij left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, the ':' command redirection support checks out as good for bash, dash, ksh and csh (for Linux, BSD, and ARM devices). I am not able to test MinGW, Cygwin or MacOS shells specifically for redirection but they should also be okay since we already know they support the command itself.

@yadij yadij requested a review from rousskov June 11, 2026 04:59
@yadij yadij added S-waiting-for-reviewer ready for review: Set this when requesting a (re)review using GitHub PR Reviewers box backport-to-v7 maintainer has approved these changes for v7 backporting labels Jun 11, 2026
kinkie
kinkie previously approved these changes Jun 11, 2026

@kinkie kinkie left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

output redirection is done by the calling shell, there's no reason it shouldn't work.
MacOs' shell is either bash or zsh, also not concerned about it.
Good catch!

Comment thread test-suite/Makefile.am Outdated
else break; fi; \
done; \
if test "$$failed" -eq 0; then cp $(TRUE) $@ ; else exit 1; fi
if test "$$failed" -eq 0; then : > $@ && chmod +x $@ ; else exit 1; fi

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to make $@ (i.e. squid-conf-tests) executable? Sorry, I cannot easily check this myself right now.

If the answer is "no", then should we switch from rather unusual/obscure redirection code that creates an empty executable file to simple and well-known touch that we already use in, for example, errors/Makefile.am?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do, because it is executed by other parts of automake. That is why it is true in the first place instead of just a touch (been there tried that years ago).

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about using install -m 775 /dev/null $@ to avoid the unusual redirection then? Assuming true is around, install should also be since it is part of coreutils as well.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i.e., s;cp $(TRUE);install -m 775 /dev/null/; instead of : > $@ && chmod +x

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do, because it is executed by other parts of automake.

Which one? AFAICT, no part requires that squid-conf-tests file is executable, and no part executes that file. Replacing our cp with touch worked in my quick-and-dirty test.

(been there tried that years ago).

Can you give a specific reference? FWIW, there are other use cases where we do execute the copied binary (e.g., testHeaders), but this question is specific to squid-conf-tests.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems @rousskov is right. This specific line is not building a target listed in TESTS, so it specifically does not need to be executable.

I have now run a complete re-test and the below change works well and simpler:

Suggested change
if test "$$failed" -eq 0; then : > $@ && chmod +x $@ ; else exit 1; fi
test "$$failed" -eq 0 && touch $@ || exit 1

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please keep if...else structure instead of switching to an a && b || c puzzle.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Off topic: @rousskov if that is such a "puzzle" why have you repeatedly asked me to implement it in other scripts instead of allowing if..else I design?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW I have tested it too, and from my results and at least the testHeaders file needs to be executable.
Just touching the file I get:

FAIL: testHeaders
=================

../cfgaux/test-driver: line 119: ./testHeaders: Permission denied
FAIL testHeaders (exit status: 126)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amos: Off topic: @rousskov if that is such a "puzzle" why have you repeatedly asked me to implement it in other scripts instead of allowing if..else I design?

I have not.

@renanrodrigo: FWIW I have tested it too, and from my results and at least the testHeaders file needs to be executable.

I am sorry you had wasted your time on this. My change request is about squid-conf-tests. It is not (and has never been) about testHeaders.

AFAICT, the minimal fix that would address this change request is the following (untested by me) change:

Suggested change
if test "$$failed" -eq 0; then : > $@ && chmod +x $@ ; else exit 1; fi
if test "$$failed" -eq 0; then touch $@ ; else exit 1; fi

FWIW, we already use the same approach for two similar errors/Makefile.am targets: translate-warn and .po.lang.

@rousskov rousskov added S-waiting-for-author author action is expected (and usually required) and removed S-waiting-for-reviewer ready for review: Set this when requesting a (re)review using GitHub PR Reviewers box labels Jun 11, 2026
@yadij

yadij commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

output redirection is done by the calling shell, there's no reason it shouldn't work. MacOs' shell is either bash or zsh, also not concerned about it. Good catch!

Thanks for that info. I have now also tested zsh - it does work as needed.

@yadij yadij requested a review from rousskov June 12, 2026 11:39
Comment thread test-suite/Makefile.am Outdated
else break; fi; \
done; \
if test "$$failed" -eq 0; then cp $(TRUE) $@ ; else exit 1; fi
if test "$$failed" -eq 0; then : > $@ && chmod +x $@ ; else exit 1; fi

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amos: Off topic: @rousskov if that is such a "puzzle" why have you repeatedly asked me to implement it in other scripts instead of allowing if..else I design?

I have not.

@renanrodrigo: FWIW I have tested it too, and from my results and at least the testHeaders file needs to be executable.

I am sorry you had wasted your time on this. My change request is about squid-conf-tests. It is not (and has never been) about testHeaders.

AFAICT, the minimal fix that would address this change request is the following (untested by me) change:

Suggested change
if test "$$failed" -eq 0; then : > $@ && chmod +x $@ ; else exit 1; fi
if test "$$failed" -eq 0; then touch $@ ; else exit 1; fi

FWIW, we already use the same approach for two similar errors/Makefile.am targets: translate-warn and .po.lang.

@renanrodrigo

Copy link
Copy Markdown
Contributor Author

@rousskov not a waste of time at all, just a double check (part of $dayjob anyway)

I will apply your suggested change both to this PR and to the Ubuntu patch.

Thanks for the review!

@rousskov rousskov changed the title Fix tests when using rust-coreutils (#5542) Bug 5237: "make check" fails when ${TRUE} is a multicall binary Jun 16, 2026

@rousskov rousskov left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add your entry to CONTRIBUTORS. See the diff inside the failed CI test log for the right place to insert that entry.

Comment thread src/TestHeaders.am Outdated

testHeaders: $(SOURCES) $(noinst_HEADERS) $(EXTRA_DIST) $(top_srcdir)/test-suite/testHeader.cc.in
$(MAKE) $(^:.h=.hdrtest) && cp $(TRUE) $@
$(MAKE) $(^:.h=.hdrtest) && : > $@ && chmod +x $@

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kinkie, will executing an empty file fail on native Windows builds? A "yes" answer is not necessarily a showstopper for this PR, especially if this testHeaders target is currently broken on native Windows builds for other reasons. Is it currently broken?

Comment thread src/TestHeaders.am Outdated

testHeaders: $(SOURCES) $(noinst_HEADERS) $(EXTRA_DIST) $(top_srcdir)/test-suite/testHeader.cc.in
$(MAKE) $(^:.h=.hdrtest) && cp $(TRUE) $@
$(MAKE) $(^:.h=.hdrtest) && : > $@ && chmod +x $@

@rousskov rousskov Jun 16, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we use the chmod command found by AC_PATH_PROG in our ./configure?

Suggested change
$(MAKE) $(^:.h=.hdrtest) && : > $@ && chmod +x $@
$(MAKE) $(^:.h=.hdrtest) && : > $@ && $(CHMOD) +x $@

or, if we also prefer to use touch for file creation:

Suggested change
$(MAKE) $(^:.h=.hdrtest) && : > $@ && chmod +x $@
$(MAKE) $(^:.h=.hdrtest) && touch $@ && $(CHMOD) +x $@

FWIW, I recommend the latter because we use touch for similar purposes elsewhere and because many readers will find it easier to grok than the : redirection trick.

@rousskov

Copy link
Copy Markdown
Contributor

I will apply your suggested change both to this PR and to the Ubuntu patch.

Thank you. I adjusted PR description to explain squid-conf-tests changes and to mention Alpine Linux as another environment where this fix is needed. I also adjusted PR title to refer to the original Bugzilla report about this bug. PR title and description will form a commit message when this PR is merged by Anubis...

@renanrodrigo renanrodrigo dismissed stale reviews from kinkie and yadij via 85d9a57 June 18, 2026 11:20
testHeaders copies the 'true' binary to a file named testHeaders relying
on the fact that GNU's true always exits 0. When 'true' implementation
is a multicall binary (e.g., in rust-coreutils and on Alpine Linux), it
cannot be called by other name. Create an empty executable file instead.

squid-conf-tests also copied the 'true' binary, but that Makefile target
is never executed and, hence, should not create an executable file.
@renanrodrigo

Copy link
Copy Markdown
Contributor Author

Just updated the changeset - please let me know if this is good now !

rousskov
rousskov previously approved these changes Jun 18, 2026

@rousskov rousskov left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for polishing this up!

Comment thread CONTRIBUTORS Outdated

@rousskov rousskov left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please note that there is no need to squash fixup commits (and force push). Our merge bot will do that for you.

Comment thread CONTRIBUTORS Outdated
@rousskov rousskov added S-could-use-an-approval An approval may speed this PR merger (but is not required) M-cleared-for-merge https://github.com/measurement-factory/anubis#pull-request-labels and removed S-waiting-for-author author action is expected (and usually required) labels Jun 18, 2026
@yadij yadij added S-could-use-an-approval An approval may speed this PR merger (but is not required) and removed S-could-use-an-approval An approval may speed this PR merger (but is not required) labels Jun 19, 2026
squid-anubis pushed a commit that referenced this pull request Jun 19, 2026
testHeaders copies the 'true' binary to a file named testHeaders relying
on the fact that GNU's true always exits 0. When 'true' implementation
is a multicall binary (e.g., in rust-coreutils and on Alpine Linux), it
cannot be called by other name. Create an empty executable file instead.

squid-conf-tests also copied the 'true' binary, but that Makefile target
is never executed and, hence, should not create an executable file.
@squid-anubis squid-anubis added the M-waiting-staging-checks https://github.com/measurement-factory/anubis#pull-request-labels label Jun 19, 2026
@squid-anubis squid-anubis added M-merged https://github.com/measurement-factory/anubis#pull-request-labels and removed M-waiting-staging-checks https://github.com/measurement-factory/anubis#pull-request-labels M-cleared-for-merge https://github.com/measurement-factory/anubis#pull-request-labels labels Jun 19, 2026
@squidadm squidadm removed the backport-to-v7 maintainer has approved these changes for v7 backporting label Jun 19, 2026
@squidadm

Copy link
Copy Markdown
Collaborator

queued for backport to v7

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

M-merged https://github.com/measurement-factory/anubis#pull-request-labels S-could-use-an-approval An approval may speed this PR merger (but is not required)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants