Skip to content

Conversation

@sp1ritCS
Copy link
Contributor

No description provided.

@sp1ritCS sp1ritCS requested a review from jpakkane as a code owner November 12, 2025 20:02
@sp1ritCS sp1ritCS force-pushed the android-ci branch 3 times, most recently from 13dc846 to 36ab8f6 Compare November 12, 2025 20:15
@sp1ritCS sp1ritCS changed the title ci: Run tests against Android NDK wip: ci: Run tests against Android NDK Nov 12, 2025
@jpakkane
Copy link
Member

Instead of having a custom cross file, it would be better to create it with meson env2mfile. It would also test that functionality at the same time.

@sp1ritCS
Copy link
Contributor Author

sp1ritCS commented Nov 13, 2025

Maybe. The bigger issue I have is coercing the container build.py into being able to re-use the same built container for multiple test runs.

@sp1ritCS sp1ritCS force-pushed the android-ci branch 5 times, most recently from 1870927 to 5a2fabf Compare November 13, 2025 10:28
@dcbaker
Copy link
Member

dcbaker commented Nov 13, 2025

@thesamesam and @eli-schwartz Are the two that understand the CI system the best

@sp1ritCS
Copy link
Contributor Author

I think the way I added the functionality was unnecessary actually. It seems like run_cross_tests actually supports that internally when passing multiple --cross arguments. I just figured that'd behave like meson itself does in merging the cross definitions.

This then obv. means I can't have split cross definitions like I had intended. Wouldn't be an issue with the env2mfile, but that has the issue of a) requiring meson during install and b) it generates a few dozen cross files but I don't want to run run_cross_tests a few dozen times.

Copy link
Member

@eli-schwartz eli-schwartz left a comment

Choose a reason for hiding this comment

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

Preliminary overview.

Comment on lines 81 to 83
SDKMANAGER="sdkmanager --sdk_root=${ANDROID_HOME}" #ANDROID_HOME may not contain a space :(
${SDKMANAGER} \
"ndk;${ANDROID_NDKVER}"
Copy link
Member

Choose a reason for hiding this comment

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

What is the purpose of this horribly unsafe variable indirection? Run the command properly?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I assume this was done in an attempt to get the google sdkmanager (which I guess has a handwritten arg parser) to accept a sdk root containing spaces. Wasn't possible tho.

But I guess, given that we moved from the google sdkmanager to the fdroid python reimplemetnation, which just uses argparse this should actually just work when removing the =.

Copy link
Member

Choose a reason for hiding this comment

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

To clarify my previous comment, these two lines are an incorrect and unsafe attempt to execute a command.

Removing the variable assignment and running the command properly will have the same semantic effect as the two lines which are there right now. The effect on sdkmanager is not strictly tied to that.

(Supporting spaces won't work either way, the variable isn't being quoted at the point of execution -- the second line -- which is a significantly greater problem and also incidentally a reason to stop incorrectly and unsafely storing a command with arguments inside a simple variable, as you cannot execute a variable as a command and sensibly quote one of the arguments stuffed inside the variable. Do not use shell variables to hold commands-with-arguments. Ever.)

Copy link
Member

Choose a reason for hiding this comment

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

In general it is very difficult to write a program on Unix (but very easy to write one on windows) that actually breaks on spaces in command line arguments. There are ways to break because of spaces, but they happen long after arguments are parsed.

The arg parser should never be related to the issue. Arguments are safely split up before the argument parser gets involved.

... Except on Windows, for Microsoft reasons. It is broadly speaking impossible to design software within the constraints of the Windows API and calling convention, that robustly and reliably parses arguments with spaces or special characters.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, I fully understood what you meant. Already moved it into one line. The fact that it was done with the variable was just the remains of some experimentation from my side when I wrote that initially.

But assuming you know that the whole variable only contains trusted input, whats the issue with running an unquoted variable as command with args?

Copy link
Contributor Author

@sp1ritCS sp1ritCS Nov 14, 2025

Choose a reason for hiding this comment

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

In general it is very difficult to write a program on Unix [...] that actually breaks on spaces in command line arguments.

never underestimate the power of a multi-trillion dollar mega corporation that first shoves all arguments encoded as a single argument to java and then uses substring to take the part of the argument after = as value.

Copy link
Member

Choose a reason for hiding this comment

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

But assuming you know that the whole variable only contains trusted input, whats the issue with running an unquoted variable as command with args?

It has nothing whatsoever to do with trusted or untrusted input. Untrusted input is unsafe to eval. Mangling it in the invoked command's argv array is an application bug leading to unintended effects -- from a trust perspective it is no different from accepting different arguments equal to what the original arguments were misparsed as.

The actual issue is: It becomes difficult to read during code review.

  • the logical flow is obscured
  • the reviewer has to reason about when word splitting does and doesn't occur, and try to figure out if the word splitting was intended in all those places

It has no advantages and only confuses the reader. In the event that you actually need to save commands-with-arguments and "replay" them later, use an array!

Copy link
Member

Choose a reason for hiding this comment

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

never underestimate the power of a multi-trillion dollar mega corporation that first shoves all arguments encoded as a single argument to java and then uses substring to take the part of the argument after = as value.

I would argue that that's not an argument parser at all. :D

@sp1ritCS sp1ritCS force-pushed the android-ci branch 8 times, most recently from 660eed4 to 91bd25f Compare November 14, 2025 11:21
This is required that the debugger can find the library loaded by the
remote device in the local filesystem.
@sp1ritCS sp1ritCS force-pushed the android-ci branch 2 times, most recently from c661986 to 0fa9c08 Compare November 14, 2025 11:46
@thesamesam
Copy link
Member

(Fixed the Gentoo builder in #15248.)

@sp1ritCS sp1ritCS force-pushed the android-ci branch 2 times, most recently from 0456661 to e2d4a72 Compare November 16, 2025 11:33
@sp1ritCS sp1ritCS force-pushed the android-ci branch 3 times, most recently from 61a49d0 to 09a4ae0 Compare November 16, 2025 12:04
sp1ritCS and others added 3 commits November 16, 2025 14:05
The error message that gets emmited changed with 183e4b8, but the tests
did not get adjusted.
Meson does not use options passed via native-file when cross-building,
resulting in tests failing/98 and failing/99 suceeding when cross
building, even tho they shouldn't.

This patch introduces the concept of an optionsfile to the testsuite,
which will, depending on the build configuration, be passed as cross or
native file.
@sp1ritCS
Copy link
Contributor Author

Does somebody know what causes the following: here the platform-android test cases succeed, where as they don't in my fork directly. I would expect them to fail, as I haven't yet rebased to include #15241. Does GHA somehow do an automatic auto-rebase on PRs?

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.

5 participants