summaryrefslogtreecommitdiffhomepage
path: root/test/fuse/linux/fuse_base.h
diff options
context:
space:
mode:
authorCraig Chi <craigchi@google.com>2020-08-14 09:54:35 -0700
committerAndrei Vagin <avagin@gmail.com>2020-09-16 12:19:30 -0700
commita289c3862653cded271408b31a9e704be615503a (patch)
tree6a8e93dd076ecd1ac59bdbb621ae310c27b114bf /test/fuse/linux/fuse_base.h
parent15ff2893d9bf896cc33e880983cb800cd71c946b (diff)
Add functions in FUSE integration test to get metrics from FUSE server
This commit adds 3 utility functions to ensure all received requests and preset responses are consumed. 1. Get number of unconsumed requests (received by the FUSE server but not consumed by the testing thread). 2. Get number of unsent responses (set by the testing thread but not processed by the FUSE server). 3. Get total bytes of the received requests (to ensure some operations don't trigger FUSE requests). Fixes #3607
Diffstat (limited to 'test/fuse/linux/fuse_base.h')
-rw-r--r--test/fuse/linux/fuse_base.h24
1 files changed, 24 insertions, 0 deletions
diff --git a/test/fuse/linux/fuse_base.h b/test/fuse/linux/fuse_base.h
index b610d0f54..3f2522977 100644
--- a/test/fuse/linux/fuse_base.h
+++ b/test/fuse/linux/fuse_base.h
@@ -36,6 +36,9 @@ constexpr char kMountOpts[] = "rootmode=755,user_id=0,group_id=0";
enum class FuseTestCmd {
kSetResponse = 0,
kGetRequest,
+ kGetNumUnconsumedRequests,
+ kGetNumUnsentResponses,
+ kGetTotalReceivedBytes,
};
// Holds the information of a memory block in a serial buffer.
@@ -124,6 +127,21 @@ class FuseTest : public ::testing::Test {
// data from server.
void GetServerActualRequest(std::vector<struct iovec>& iovecs);
+ // Called by the testing thread to query the number of unconsumed requests in
+ // the requests_ serial buffer of the FUSE server. TearDown() ensures all
+ // FUSE requests received by the FUSE server were consumed by the testing
+ // thread.
+ uint32_t GetServerNumUnconsumedRequests();
+
+ // Called by the testing thread to query the number of unsent responses in
+ // the responses_ serial buffer of the FUSE server. TearDown() ensures all
+ // preset FUSE responses were sent out by the FUSE server.
+ uint32_t GetServerNumUnsentResponses();
+
+ // Called by the testing thread to ask the FUSE server for its total received
+ // bytes from /dev/fuse.
+ uint32_t GetServerTotalReceivedBytes();
+
protected:
TempPath mount_point_;
@@ -137,6 +155,9 @@ class FuseTest : public ::testing::Test {
// Creates a socketpair for communication and forks FUSE server.
void SetUpFuseServer();
+ // Sends a FuseTestCmd and gets a uint32_t data from the FUSE server.
+ inline uint32_t GetServerData(uint32_t cmd);
+
// Waits for FUSE server to complete its processing. Complains if the FUSE
// server responds any failure during tests.
void WaitServerComplete();
@@ -166,6 +187,9 @@ class FuseTest : public ::testing::Test {
// the cursor.
void ServerSendReceivedRequest();
+ // Sends a uint32_t data via socket.
+ inline void ServerSendData(uint32_t data);
+
// Handles FUSE request sent to /dev/fuse by its saved responses.
void ServerProcessFuseRequest();