-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Test harness #57
Test harness #57
Conversation
28c780a
to
762c78b
Compare
tools/src/bin/run-fap.rs
Outdated
// Run the FAP. | ||
cli.send_and_wait_eol(&format!("loader open Applications {}\r", dest_file))?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently it is not possible to provide arguments to external FAPs. I've opened flipperdevices/flipperzero-firmware#2505 upstream requesting this. In the meantime, this just means that test filtering won't work.
328ca23
to
3b9e596
Compare
// Upload the FAP to a temporary directory. | ||
let dest_dir = | ||
storage::FlipperPath::from(format!("/ext/tmp-{:08x}", thread_rng().gen::<u32>())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't yet figured out if any of the Flipper Zero SDKs let a running external FAP learn where it was loaded from. Without that knowledge, it's gonna be tricky to reliably redirect stdout to a file that both won't collide with an existing file on the Flipper Zero, and that this tool can find.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I ended up just using a common fixed path of /ext/flipperzero-rs-stdout
, on the assumption that external FAPs cannot run concurrently, so only one app at a time will ever be running, and as long as we immediately read the file and then remove it we're probably fine. This will do until the Flipper Zero SDK supports RPC usage.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You may try addressing the issues in Flipperzero Telegram group, i.e. Development (SW&HW)
channel.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
flipperdevices/flipperzero-firmware#2505 (comment) indicated that an improved host-device communication protocol is planned for external FAPs, so that is likely what will be used instead when available.
512b0cc
to
f8def9a
Compare
Okay, I have this working on Linux and macOS! Current output:
|
And if I manually cause some tests to fail:
Currently the test failures are printed in-line, to avoid requiring |
a62620e
to
2b92a66
Compare
I've adjusted the test harness so it now also works for integration tests, and to allow the manifest arguments to be set (in particular, while adding more tests in subsequent local changes I need to bump the stack size). There are probably more usability tweaks that could be made, but I think we'll discover those as the test harness is used, so I'm not planning to make any more changes to this PR other than in response to review. |
@@ -1,6 +1,7 @@ | |||
//! High-level bindings for the Flipper Zero. | |||
|
|||
#![no_std] | |||
#![cfg_attr(test, no_main)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we just apply #[no_main]
unconditionally? I'm not sure if there's much of an impact on lib
crates, but FAP applications are unlikely to support a standard main function.
Rebased on |
Looks like
In this case, maybe we just go with the shell script and make this work for Windows in a future PR. |
os.fspath(args.binary), | ||
] + args.arguments, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For something as simple as this script, we could probably even get away with just + sys.argv
.
I've now found rust-lang/cargo#8347 which indicates we just need to set the runner to |
I think what's going on here is that CI was configured to run all tests, but nothing had tests enabled so it did nothing. Now that we enable tests, CI tries to run them, but because the |
The tests can be run with `cargo test` from within the `crates/` directory.
Force-pushed to add missing package to CI, and hopefully fix |
Okay, confirmed that CI fails now because it can't find a Flipper Zero. I'll adjust CI to expect that failure, so we're still compiling everything and checking the runner. |
Looks like I hit python/cpython#99185 (Windows does not provide a PEP-397 tries to resolve this situation by introducing a Not sure if there's an easy fix. There doesn't seem to be a |
Hmm. Now that I know we can have arguments inside |
I cannot figure out how to work around the latter inside |
Sadly However, I've figured out another solution: aliases! We remove the |
Thanks for sticking with this! Honestly I'm fine with just setting it to
It worries me a little not setting a A couple of thoughts:
|
This is why I added the target detection code, so that
That is exactly what the current aliases do (it's
AFAICT no; the
Then let's just do this. A Windows user can copy I've edited the last commit to remove the alias changes (but left the target detection code since that is independently useful). |
Hi @str4d. Apologies for the wait. Yes, I'm happy to merge this. Over the weekend I got to see how a few other projects tackle this. Ferrus Systems has a tool called I should make |
Yeah, those were what made me realize we could run tests and apps in this way. But we can't use any of the existing ones because they flash firmware, and I wanted this to be as easy to use as possible, so no need to install anything ideally. Didn't quite get there on all platforms, and if we end up having an installable FAP runner then I don't mind. |
The other thing is that an installable FAP runner will be much nicer once upstream has implement proper RPC support for FAPs, so we don't have to do the hacky "write stdout to a file and then copy it off afterwards" that really is only suitable for one-shot FAPs. |
I'm very much looking forward to that. It's bit awful what you have to do when trying to use a serial CLI as a file transfer layer. |
Closes #53.