test: cover configured fsync save path
CI / lint (pull_request) Successful in 11s
CI / sanitizers (address) (pull_request) Successful in 37s
CI / sanitizers (undefined) (pull_request) Successful in 37s
CI / fuzz-build (pull_request) Successful in 14s
CI / coverage (pull_request) Successful in 31s
CI / build-and-test (pull_request) Successful in 1m15s
CI / valgrind (pull_request) Successful in 33s
CI / lint (pull_request) Successful in 11s
CI / sanitizers (address) (pull_request) Successful in 37s
CI / sanitizers (undefined) (pull_request) Successful in 37s
CI / fuzz-build (pull_request) Successful in 14s
CI / coverage (pull_request) Successful in 31s
CI / build-and-test (pull_request) Successful in 1m15s
CI / valgrind (pull_request) Successful in 33s
This commit is contained in:
@@ -465,7 +465,7 @@ defaults to the current directory. |
|
|||||||
|
|
||||||
## Protocol and Security
|
## Protocol and Security
|
||||||
|
|
||||||
FastSync protocol version `2.2.0` is shared by the client and server. The
|
FastSync protocol version `2.3.0` is shared by the client and server. The
|
||||||
current protocol is sender-driven and includes configuration negotiation,
|
current protocol is sender-driven and includes configuration negotiation,
|
||||||
incremental checks, checksums, manifests, keep-alives, abort handling, and
|
incremental checks, checksums, manifests, keep-alives, abort handling, and
|
||||||
FastSync-native delta messages. Client and server versions must currently
|
FastSync-native delta messages. Client and server versions must currently
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#include "test_file.h"
|
#include "test_file.h"
|
||||||
#include "file.h"
|
#include "file.h"
|
||||||
#include "data.h"
|
#include "data.h"
|
||||||
|
#include "config.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
#include "protocol.h"
|
#include "protocol.h"
|
||||||
#include "test_utils.h"
|
#include "test_utils.h"
|
||||||
@@ -88,6 +89,30 @@ static void test_file_save_to_disk() {
|
|||||||
rmdir("test_save_tmp");
|
rmdir("test_save_tmp");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void test_file_save_to_disk_with_fsync_config() {
|
||||||
|
File* f = file_create("saved_file_fsync.txt");
|
||||||
|
EXPECT_NOT_NULL(f);
|
||||||
|
const char* content = "Save to disk with fsync";
|
||||||
|
f->data->data = malloc(strlen(content));
|
||||||
|
EXPECT_NOT_NULL(f->data->data);
|
||||||
|
memcpy(f->data->data, content, strlen(content));
|
||||||
|
f->data->size = strlen(content);
|
||||||
|
|
||||||
|
Config* config = config_create();
|
||||||
|
EXPECT_NOT_NULL(config);
|
||||||
|
config->use_fsync = true;
|
||||||
|
EXPECT_TRUE(file_save_to_disk("test_save_fsync_tmp", f, config));
|
||||||
|
|
||||||
|
struct stat st;
|
||||||
|
EXPECT_EQ_INT(stat("test_save_fsync_tmp/saved_file_fsync.txt", &st), 0);
|
||||||
|
EXPECT_EQ_INT((int)st.st_size, (int)strlen(content));
|
||||||
|
|
||||||
|
file_destroy(f);
|
||||||
|
config_delete(config);
|
||||||
|
unlink("test_save_fsync_tmp/saved_file_fsync.txt");
|
||||||
|
rmdir("test_save_fsync_tmp");
|
||||||
|
}
|
||||||
|
|
||||||
static void test_file_write_to_disk_basic() {
|
static void test_file_write_to_disk_basic() {
|
||||||
const char* content = "Basic file_write_to_disk test";
|
const char* content = "Basic file_write_to_disk test";
|
||||||
EXPECT_TRUE(file_write_to_disk("test_file_write_to_disk_basic.txt", content, strlen(content),
|
EXPECT_TRUE(file_write_to_disk("test_file_write_to_disk_basic.txt", content, strlen(content),
|
||||||
@@ -469,6 +494,7 @@ void test_file() {
|
|||||||
test_file_load_data();
|
test_file_load_data();
|
||||||
test_file_load_data_missing_file();
|
test_file_load_data_missing_file();
|
||||||
test_file_save_to_disk();
|
test_file_save_to_disk();
|
||||||
|
test_file_save_to_disk_with_fsync_config();
|
||||||
test_file_write_to_disk_basic();
|
test_file_write_to_disk_basic();
|
||||||
test_file_write_to_disk_with_fsync();
|
test_file_write_to_disk_with_fsync();
|
||||||
test_file_write_to_disk_creates_dirs();
|
test_file_write_to_disk_creates_dirs();
|
||||||
|
|||||||
Reference in New Issue
Block a user