Implement pipe() mock

This commit is contained in:
2026-01-27 22:57:45 +01:00
parent 10053d3567
commit 3bb30dcd09
7 changed files with 90 additions and 23 deletions
+4 -2
View File
@@ -36,8 +36,8 @@ typedef pthread_mutex_t Mutex;
#define PARALLEL_LIMIT 5
//#define CLIENT_TRACE(fmt, ...) {}
#define CLIENT_TRACE(fmt, ...) fprintf(stderr, "CLIENT: " fmt "\n", ##__VA_ARGS__);
#define CLIENT_TRACE(fmt, ...) {}
//#define CLIENT_TRACE(fmt, ...) fprintf(stderr, "CLIENT: " fmt "\n", ##__VA_ARGS__);
typedef struct {
SHA256 hash;
@@ -1555,6 +1555,8 @@ static void process_event_for_write(ToastyFS *toasty,
int next_server_lid = 0;
toasty->operations[opidx].num_uploads = 0;
// This loop is for chunks that already exist in the file
for (uint32_t i = 0; i < num_hashes; i++) {
char *src = full_ptr + relative_off;
+3 -2
View File
@@ -9,8 +9,8 @@
#include "message.h"
#include "metadata_server.h"
//#define MS_TRACE(fmt, ...) {}
#define MS_TRACE(fmt, ...) fprintf(stderr, "MS: " fmt "\n", ##__VA_ARGS__);
#define MS_TRACE(fmt, ...) {}
//#define MS_TRACE(fmt, ...) fprintf(stderr, "MS: " fmt "\n", ##__VA_ARGS__);
static void chunk_server_peer_init(ChunkServerPeer *chunk_server, Time current_time)
{
@@ -1226,6 +1226,7 @@ int metadata_server_tick(void *state_, void **ctxs,
MS_TRACE("Message from client");
ret = process_client_message(state, conn_idx, msg_type, msg);
} else {
MS_TRACE("Message from CS (conn_idx=%d)", conn_idx);
state->chunk_servers[tag].last_response_time = current_time;
ret = process_chunk_server_message(state, conn_idx, msg_type, msg);
}
+13 -7
View File
@@ -52,10 +52,11 @@ int test_client_init(void *state_, int argc, char **argv,
return -1;
client->state = TEST_CLIENT_STATE_0;
client->tick = 0;
printf("Client set up (remote=%s:%d)\n", addr, port);
*timeout = 0;
*timeout = -1;
if (pcap < TCP_POLL_CAPACITY)
return -1;
*pnum = toasty_process_events(client->toasty, ctxs, pdata, *pnum);
@@ -94,11 +95,16 @@ int test_client_tick(void *state_, void **ctxs,
int ret;
ToastyResult result;
case TEST_CLIENT_STATE_0:
if (client->tick < 10) {
*timeout = 0;
client->tick++;
return 0;
}
client->handle = toasty_begin_create_file(client->toasty, file_path, 128);
if (client->handle == TOASTY_INVALID) {
assert(0); // TODO
}
printf(">>> Create started <<<<<<<<<<<<\n");
printf("Create started\n");
client->state = TEST_CLIENT_STATE_1;
break;
case TEST_CLIENT_STATE_1:
@@ -109,7 +115,7 @@ int test_client_tick(void *state_, void **ctxs,
if (ret == 1) {
break;
}
printf(">>> Create completed <<<<<<<<<<<<\n");
printf("Create completed\n");
assert(ret == 0);
if (result.type != TOASTY_RESULT_CREATE_SUCCESS) {
assert(0); // TODO
@@ -118,7 +124,7 @@ int test_client_tick(void *state_, void **ctxs,
if (client->handle == TOASTY_INVALID) {
assert(0); // TODO
}
printf(">>> Write started <<<<<<<<<<<<\n");
printf("Write started\n");
client->state = TEST_CLIENT_STATE_2;
break;
case TEST_CLIENT_STATE_2:
@@ -129,7 +135,7 @@ int test_client_tick(void *state_, void **ctxs,
if (ret == 1) {
break;
}
printf(">>> Write completed <<<<<<<<<<<<\n");
printf("Write completed\n");
assert(ret == 0);
if (result.type != TOASTY_RESULT_WRITE_SUCCESS) {
assert(0); // TODO
@@ -138,7 +144,7 @@ int test_client_tick(void *state_, void **ctxs,
if (client->handle == TOASTY_INVALID) {
assert(0); // TODO
}
printf(">>> Read started <<<<<<<<<<<<\n");
printf("Read started\n");
client->state = TEST_CLIENT_STATE_3;
break;
case TEST_CLIENT_STATE_3:
@@ -149,7 +155,7 @@ int test_client_tick(void *state_, void **ctxs,
if (ret == 1) {
break;
}
printf(">>> Read completed <<<<<<<<<<<<\n");
printf("Read completed\n");
assert(ret == 0);
if (result.type != TOASTY_RESULT_READ_SUCCESS) {
assert(0); // TODO
+1
View File
@@ -14,6 +14,7 @@ typedef struct {
ToastyFS* toasty;
ToastyHandle handle;
TestClientState state;
int tick;
char buf[1<<10];
} TestClient;