zargony / fuse-rs

Rust library for filesystems in userspace (FUSE)
MIT License
1.07k stars 130 forks source link

Public constructors for `Request` and `Reply` types #116

Open asomers opened 5 years ago

asomers commented 5 years ago

It would be nice to be able to unit test my filesystem's FUSE interface. Right now the only way to test it is to mount an actual filesystem and use the command line. But if rust-fuse did the following, then I would be able to write tests that hook into my filesystem's rust-fuse interface and exercise the whole API. This would require:

chisa0a commented 5 years ago

So much this.

Trying to use rust-fuse as a library crate is all but impossible atm. Would this be a better suited task for implementing a high-level API?

New to the library, and to Rust, and would really love to use rust-fuse in a project. Happy to contribute where I can.

Many thanks in advance.

zargony commented 5 years ago

Back then when rust-fuse was created, we intentionally chose to have no public constructors to ensure that implementations comply with what the kernel protocol requires. Nowadays the interface on the Rust side still works the same but looks a bit unusual. There's ongoing effort (e.g. in #90 and the modernize branch) to make rust-fuse more idiomatic and especially add async and testing capability. I suppose that request and reply types will completely change so that this issue won't apply anymore. But afaik there is no issue specific to testability yet, so if you edit this issue to be more generic towards the new implementation, we could use it for collecting ideas and tracking progress of making fuse implementation testing easier.

asomers commented 5 years ago

I've been working on a new approach to testing crates that use rust-fuse. I'm using mockall to create mock versions of each Request and Reply type. Then I have to redefine FileSystem to take these mock types instead of the real ones. It's a lot of boilerplate, but it seems to work.