Skip to content

Fix tests when using rust-coreutils (#5542)#2442

Open
renanrodrigo wants to merge 1 commit into
squid-cache:masterfrom
renanrodrigo:fix-true-test
Open

Fix tests when using rust-coreutils (#5542)#2442
renanrodrigo wants to merge 1 commit into
squid-cache:masterfrom
renanrodrigo:fix-true-test

Conversation

@renanrodrigo

@renanrodrigo renanrodrigo commented Jun 9, 2026

Copy link
Copy Markdown

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. The 'true'
implementation in rust-coreutils is a multicall binary which
returns based on argv[0] - so it can't be called by other name.

Create an empty executable instead.

@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
testHeaders copies the 'true' binary to a file named testHeaders relying on the
fact that GNU's true always exits 0. The 'true' implementation in
rust-coreutils is a multicall binary which returns based on argv[0] - o it
can't be called by other name. This commit changes that behavior, creating an
empty executable instead.

@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 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
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.

@yadij yadij Jun 12, 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.

athos-ribeiro:

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

Unfortunately anything under /dev is not guaranteed to be a file we can copy. It may be a socket, pipe, or kernel device. Best we could do along that approach is, e.g. use install to duplicate a local script that calls true - which is just extra complication.

While it is a bit obscure the : > $@ command is sufficient and works portably. The part holding review is whether we can drop the chmod entirely. If we can, then a simple and clear touch $@ would be better logic.

@renanrodrigo renanrodrigo Jun 12, 2026

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

FWIW If the : approach is too shady, a comment on why could be useful?

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.

IMO the only thing "shady" about it is that it is a symbol instead of a word self-documenting what it does/means. Once one finds the right part of shell documentation it checks out as fine.

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.

FWIW If the : approach is too shady, a comment on why could be useful?

This change request is not about the arguably problematic choice of executable creation code (i.e. redirecting :). It is about the alleged need to create an executable here (by any means). This change request remains unaddressed. I will come back to that in a separate comment later -- it is difficult for me to type long responses right now. Carefully rereading (and answering) my request followup may speed things up.

However, I would be curious to know the answer to the why question, even though it is outside this change request scope: How would you justify using : instead of doing something more ordinary/well-understood/etc.? This answer may help with the other change in this PR.

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

@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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-to-v7 maintainer has approved these changes for v7 backporting S-waiting-for-author author action is expected (and usually required)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants