# gVisor FUSE Test Suite This is an integration test suite for fuse(4) filesystem. It runs under gVisor sandbox container with VFS2 and FUSE function enabled. This document describes the framework of FUSE integration test, how to use it, and the guidelines that should be followed when adding new testing features. ## Integration Test Framework By inheriting the `FuseTest` class defined in `linux/fuse_base.h`, every test fixture can run in an environment with `mount_point_` mounted by a fake FUSE server. It creates a `socketpair(2)` to send and receive control commands and data between the client and the server. Because the FUSE server runs in the background thread, gTest cannot catch its assertion failure immediately. Thus, `TearDown()` function sends command to the FUSE server to check if all gTest assertion in the server are successful and all requests and preset responses are consumed. ## Communication Diagram Diagram below describes how a testing thread communicates with the FUSE server to achieve integration test. For the following diagram, `>` means entering the function, `<` is leaving the function, and `=` indicates sequentially entering and leaving. Not necessarily follow exactly the below diagram due to the nature of a multi-threaded system, however, it is still helpful to know when the client waits for the server to complete a command and when the server awaits the next instruction. ``` | Client (Testing Thread) | Server (FUSE Server Thread) | | | >TEST_F() | | >SetUp() | | =MountFuse() | | >SetUpFuseServer() | | [create communication socket]| | =fork() | =fork() | [wait server complete] | | | =ServerConsumeFuseInit() | | =ServerCompleteWith() | ServerFuseLoop() | | [poll on socket and fd] | >SetServerResponse() | | [write data to socket] | | [wait server complete] | | | [socket event occurs] | | >ServerHandleCommand() | | >ServerReceiveResponse() | | [read data from socket] | | [save data to memory] | | [Do fs operation] | | [wait for fs response] | | | [fd event occurs] | | >ServerProcessFuseRequest() | | =[read fs request] | | =[save fs request to memory] | | =[write fs response] | <[Do fs operation] | | | GetServerActualRequest() | | [write data to socket] | | [wait data from server] | | | [socket event occurs] | | >ServerHandleCommand() | | >ServerSendReceivedRequest() | | [write data to socket] | [read data from socket] | | [wait server complete] | | | TearDown() | | =UnmountFuse() | |