зеркало из https://github.com/nextcloud/desktop.git
Respect return values in tests.
This commit is contained in:
Родитель
804e5adee6
Коммит
9a440d4501
|
@ -8,15 +8,15 @@
|
|||
CSYNC *csync;
|
||||
|
||||
static void setup(void) {
|
||||
system("mkdir -p /tmp/csync1");
|
||||
system("mkdir -p /tmp/csync2");
|
||||
csync_create(&csync, "/tmp/csync1", "/tmp/csync2");
|
||||
fail_if(system("mkdir -p /tmp/csync1") < 0, "Setup failed");
|
||||
fail_if(system("mkdir -p /tmp/csync2") < 0, "Setup failed");
|
||||
fail_if(csync_create(&csync, "/tmp/csync1", "/tmp/csync2") < 0, "Setup failed");
|
||||
}
|
||||
|
||||
static void teardown(void) {
|
||||
csync_destroy(csync);
|
||||
system("rm -rf /tmp/csync1");
|
||||
system("rm -rf /tmp/csync2");
|
||||
fail_if(csync_destroy(csync) < 0, "Teardown failed");
|
||||
fail_if(system("rm -rf /tmp/csync1") < 0, "Teardown failed");
|
||||
fail_if(system("rm -rf /tmp/csync2") < 0, "Teardown failed");
|
||||
}
|
||||
|
||||
START_TEST (check_csync_destroy_null)
|
||||
|
|
|
@ -11,15 +11,15 @@ CSYNC *csync;
|
|||
const char *testconf = "/tmp/check_csync1/csync.conf";
|
||||
|
||||
static void setup(void) {
|
||||
system("mkdir -p /tmp/check_csync1");
|
||||
csync_create(&csync, "/tmp/check_csync1", "/tmp/check_csync2");
|
||||
fail_if(system("mkdir -p /tmp/check_csync1") < 0, "Setup failed");
|
||||
fail_if(csync_create(&csync, "/tmp/check_csync1", "/tmp/check_csync2") < 0, "Setup failed");
|
||||
SAFE_FREE(csync->options.config_dir);
|
||||
csync->options.config_dir = c_strdup("/tmp/check_csync1/");
|
||||
}
|
||||
|
||||
static void teardown(void) {
|
||||
csync_destroy(csync);
|
||||
system("rm -rf /tmp/check_csync");
|
||||
fail_if(csync_destroy(csync) < 0, "Teardown failed");
|
||||
fail_if(system("rm -rf /tmp/check_csync") < 0, "Teardown failed");
|
||||
}
|
||||
|
||||
START_TEST (check_csync_config_copy_default)
|
||||
|
|
|
@ -10,21 +10,21 @@
|
|||
CSYNC *csync;
|
||||
|
||||
static void setup(void) {
|
||||
csync_create(&csync, "/tmp/check_csync1", "/tmp/check_csync2");
|
||||
fail_if(csync_create(&csync, "/tmp/check_csync1", "/tmp/check_csync2") < 0, "Setup failed");
|
||||
SAFE_FREE(csync->options.config_dir);
|
||||
csync->options.config_dir = c_strdup("/tmp/check_csync1/");
|
||||
}
|
||||
|
||||
static void setup_init(void) {
|
||||
csync_create(&csync, "/tmp/check_csync1", "/tmp/check_csync2");
|
||||
fail_if(csync_create(&csync, "/tmp/check_csync1", "/tmp/check_csync2") < 0, "Setup failed");
|
||||
SAFE_FREE(csync->options.config_dir);
|
||||
csync->options.config_dir = c_strdup("/tmp/check_csync1");
|
||||
csync_exclude_load(csync, BINARYDIR "/config/" CSYNC_EXCLUDE_FILE);
|
||||
fail_if(csync_exclude_load(csync, BINARYDIR "/config/" CSYNC_EXCLUDE_FILE) < 0, "Setup failed");
|
||||
}
|
||||
|
||||
static void teardown(void) {
|
||||
csync_destroy(csync);
|
||||
system("rm -rf /tmp/check_csync1");
|
||||
fail_if(csync_destroy(csync) < 0, "Teardown failed");
|
||||
fail_if (system("rm -rf /tmp/check_csync1") < 0, "Teardown failed");
|
||||
}
|
||||
|
||||
START_TEST (check_csync_exclude_add)
|
||||
|
|
|
@ -11,44 +11,45 @@ const char *testdb = (char *) "/tmp/check_csync1/test.db";
|
|||
const char *testtmpdb = (char *) "/tmp/check_csync1/test.db.ctmp";
|
||||
|
||||
static void setup(void) {
|
||||
system("rm -rf /tmp/check_csync1");
|
||||
system("mkdir -p /tmp/check_csync1");
|
||||
csync_create(&csync, "/tmp/check_csync1", "/tmp/check_csync2");
|
||||
fail_if(system("rm -rf /tmp/check_csync1") < 0, "Setup failed");
|
||||
fail_if(system("mkdir -p /tmp/check_csync1") < 0, "Setup failed");
|
||||
fail_if(csync_create(&csync, "/tmp/check_csync1", "/tmp/check_csync2") < 0, "Setup failed");
|
||||
SAFE_FREE(csync->options.config_dir);
|
||||
csync->options.config_dir = c_strdup("/tmp/check_csync1/");
|
||||
}
|
||||
|
||||
static void setup_init(void) {
|
||||
system("rm -rf /tmp/check_csync1");
|
||||
csync_create(&csync, "/tmp/check_csync1", "/tmp/check_csync2");
|
||||
fail_if(system("rm -rf /tmp/check_csync1") < 0, "Setup failed");
|
||||
fail_if (system("mkdir -p /tmp/check_csync1") < 0, "Setup failed");
|
||||
fail_if (csync_create(&csync, "/tmp/check_csync1", "/tmp/check_csync2") < 0, "Setup failed");
|
||||
SAFE_FREE(csync->options.config_dir);
|
||||
csync->options.config_dir = c_strdup("/tmp/check_csync1/");
|
||||
csync_init(csync);
|
||||
}
|
||||
|
||||
static void teardown(void) {
|
||||
csync_destroy(csync);
|
||||
system("rm -rf /tmp/check_csync1");
|
||||
fail_if(csync_destroy(csync) < 0, "Teardown failed");
|
||||
fail_if(system("rm -rf /tmp/check_csync1") < 0, "Teardown failed");
|
||||
}
|
||||
|
||||
START_TEST (check_csync_journal_check)
|
||||
{
|
||||
system("mkdir -p /tmp/check_csync1");
|
||||
fail_if(system("mkdir -p /tmp/check_csync1") < 0, NULL);
|
||||
|
||||
/* old db */
|
||||
system("echo \"SQLite format 2\" > /tmp/check_csync1/test.db");
|
||||
fail_if(system("echo \"SQLite format 2\" > /tmp/check_csync1/test.db") < 0, NULL);
|
||||
fail_unless(csync_journal_check(testdb) == 0);
|
||||
|
||||
/* db already exists */
|
||||
fail_unless(csync_journal_check(testdb) == 0);
|
||||
|
||||
/* no db exists */
|
||||
system("rm -f /tmp/check_csync1/test.db");
|
||||
fail_if(system("rm -f /tmp/check_csync1/test.db") < 0, NULL);
|
||||
fail_unless(csync_journal_check(testdb) == 0);
|
||||
|
||||
fail_unless(csync_journal_check((char *) "/tmp/check_csync1/") < 0);
|
||||
|
||||
system("rm -rf /tmp/check_csync1");
|
||||
fail_if(system("rm -rf /tmp/check_csync1") < 0, NULL);
|
||||
}
|
||||
END_TEST
|
||||
|
||||
|
|
|
@ -15,11 +15,11 @@
|
|||
#define TEST_LOCK "/tmp/check_csync/test"
|
||||
|
||||
static void setup(void) {
|
||||
system("mkdir -p /tmp/check_csync");
|
||||
fail_if(system("mkdir -p /tmp/check_csync") < 0, "Setup failed");
|
||||
}
|
||||
|
||||
static void teardown(void) {
|
||||
system("rm -rf /tmp/check_csync");
|
||||
fail_if(system("rm -rf /tmp/check_csync") < 0, "Teardown failed");
|
||||
}
|
||||
|
||||
START_TEST (check_csync_lock)
|
||||
|
|
|
@ -12,12 +12,12 @@ const char *check_dir = "/tmp/check/c_mkdirs//with/check//";
|
|||
const char *check_file = "/tmp/check/c_mkdirs/with/check/foobar.txt";
|
||||
|
||||
static void setup(void) {
|
||||
c_mkdirs(check_dir, 0755);
|
||||
system("touch /tmp/check/c_mkdirs/with/check/foobar.txt");
|
||||
fail_if(c_mkdirs(check_dir, 0755) < 0, "Setup failed");
|
||||
fail_if(system("touch /tmp/check/c_mkdirs/with/check/foobar.txt") < 0, "Setup failed");
|
||||
}
|
||||
|
||||
static void teardown(void) {
|
||||
system("rm -rf /tmp/check");
|
||||
fail_if(system("rm -rf /tmp/check") < 0, "Teardown failed");
|
||||
}
|
||||
|
||||
static int test_dir(const char *path, mode_t mode) {
|
||||
|
@ -42,7 +42,7 @@ START_TEST (check_c_mkdirs_new)
|
|||
{
|
||||
fail_unless(c_mkdirs(check_dir, 0755) == 0, NULL);
|
||||
fail_unless(test_dir(check_dir, 0755) == 0, NULL);
|
||||
system("rm -rf /tmp/check");
|
||||
fail_if(system("rm -rf /tmp/check") < 0, NULL);
|
||||
}
|
||||
END_TEST
|
||||
|
||||
|
@ -50,7 +50,7 @@ START_TEST (check_c_mkdirs_mode)
|
|||
{
|
||||
fail_unless(c_mkdirs(check_dir, 0700) == 0, NULL);
|
||||
fail_unless(test_dir(check_dir, 0700) == 0, NULL);
|
||||
system("rm -rf /tmp/check");
|
||||
fail_if(system("rm -rf /tmp/check") < 0, NULL);
|
||||
}
|
||||
END_TEST
|
||||
|
||||
|
|
|
@ -30,12 +30,12 @@ static int test_file(const char *path, mode_t mode) {
|
|||
}
|
||||
|
||||
static void setup(void) {
|
||||
system("mkdir -p /tmp/check");
|
||||
system("echo 42 > /tmp/check/foo.txt");
|
||||
fail_if(system("mkdir -p /tmp/check") < 0, "Setup failed");
|
||||
fail_if(system("echo 42 > /tmp/check/foo.txt") < 0, "Setup failed");
|
||||
}
|
||||
|
||||
static void teardown(void) {
|
||||
system("rm -rf /tmp/check");
|
||||
fail_if(system("rm -rf /tmp/check") < 0, "Teardown failed");
|
||||
}
|
||||
|
||||
START_TEST (check_c_copy)
|
||||
|
|
|
@ -65,13 +65,13 @@ static void destructor(void *data) {
|
|||
}
|
||||
|
||||
static void setup(void) {
|
||||
c_rbtree_create(&tree, key_cmp, data_cmp);
|
||||
fail_if(c_rbtree_create(&tree, key_cmp, data_cmp) < 0, "Setup failed");
|
||||
}
|
||||
|
||||
static void setup_complete_tree(void) {
|
||||
int i = 0;
|
||||
|
||||
c_rbtree_create(&tree, key_cmp, data_cmp);
|
||||
fail_if(c_rbtree_create(&tree, key_cmp, data_cmp) < 0, "Setup failed");
|
||||
for (i = 0; i < 100; i++) {
|
||||
test_t *testdata = NULL;
|
||||
|
||||
|
@ -80,7 +80,7 @@ static void setup_complete_tree(void) {
|
|||
|
||||
testdata->key = i;
|
||||
|
||||
c_rbtree_insert(tree, (void *) testdata);
|
||||
fail_if(c_rbtree_insert(tree, (void *) testdata) < 0, "Setup failed");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -17,34 +17,34 @@
|
|||
CSYNC *csync;
|
||||
|
||||
static void setup(void) {
|
||||
system("rm -rf /tmp/csync/");
|
||||
csync_create(&csync, "/tmp/csync1", "/tmp/csync2");
|
||||
fail_if(system("rm -rf /tmp/csync/") < 0, "Setup failed");
|
||||
fail_if(csync_create(&csync, "/tmp/csync1", "/tmp/csync2") < 0, "Setup failed");
|
||||
csync->replica = LOCAL_REPLICA;
|
||||
}
|
||||
|
||||
static void setup_dir(void) {
|
||||
system("rm -rf /tmp/csync/");
|
||||
mkdir(CSYNC_TEST_DIR, 0755);
|
||||
csync_create(&csync, "/tmp/csync1", "/tmp/csync2");
|
||||
fail_if(system("rm -rf /tmp/csync/") < 0, "Setup failed");
|
||||
fail_if(mkdir(CSYNC_TEST_DIR, 0755) < 0, "Setup failed");
|
||||
fail_if(csync_create(&csync, "/tmp/csync1", "/tmp/csync2") < 0, "Setup failed");
|
||||
csync->replica = LOCAL_REPLICA;
|
||||
}
|
||||
|
||||
static void setup_file(void) {
|
||||
system("rm -rf /tmp/csync/");
|
||||
mkdir(CSYNC_TEST_DIR, 0755);
|
||||
system("echo \"This is a test\" > /tmp/csync/file.txt");
|
||||
csync_create(&csync, "/tmp/csync1", "/tmp/csync2");
|
||||
fail_if(system("rm -rf /tmp/csync/") < 0, "Setup failed");
|
||||
fail_if(mkdir(CSYNC_TEST_DIR, 0755) < 0, "Setup failed");
|
||||
fail_if(system("echo \"This is a test\" > /tmp/csync/file.txt") < 0, "Setup failed");
|
||||
fail_if(csync_create(&csync, "/tmp/csync1", "/tmp/csync2") < 0, "Setup failed");
|
||||
csync->replica = LOCAL_REPLICA;
|
||||
}
|
||||
|
||||
static void teardown(void) {
|
||||
csync_destroy(csync);
|
||||
system("rm -rf /tmp/csync/");
|
||||
fail_if(csync_destroy(csync) < 0, "Teardown failed");
|
||||
fail_if(system("rm -rf /tmp/csync/") < 0, "Teardown failed");
|
||||
}
|
||||
|
||||
static void teardown_dir(void) {
|
||||
csync_destroy(csync);
|
||||
system("rm -rf /tmp/csync/");
|
||||
fail_if(csync_destroy(csync) < 0, "Teardown failed");
|
||||
fail_if(system("rm -rf /tmp/csync/") < 0, "Teardown failed");
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -17,22 +17,22 @@
|
|||
CSYNC *csync;
|
||||
|
||||
static void setup(void) {
|
||||
system("rm -rf /tmp/csync/");
|
||||
fail_if(system("rm -rf /tmp/csync/") < 0, "Setup failed");
|
||||
}
|
||||
|
||||
static void setup_dir(void) {
|
||||
system("rm -rf /tmp/csync/");
|
||||
mkdir(CSYNC_TEST_DIR, 0755);
|
||||
fail_if(system("rm -rf /tmp/csync/") < 0, "Setup failed");
|
||||
fail_if(mkdir(CSYNC_TEST_DIR, 0755) < 0, "Setup failed");
|
||||
}
|
||||
|
||||
static void setup_file(void) {
|
||||
system("rm -rf /tmp/csync/");
|
||||
mkdir(CSYNC_TEST_DIR, 0755);
|
||||
system("echo \"This is a test\" > /tmp/csync/file.txt");
|
||||
fail_if(system("rm -rf /tmp/csync/") < 0, "Setup failed");
|
||||
fail_if(mkdir(CSYNC_TEST_DIR, 0755) < 0, "Setup failed");
|
||||
fail_if(system("echo \"This is a test\" > /tmp/csync/file.txt") < 0, "Setup failed");
|
||||
}
|
||||
|
||||
static void teardown_dir(void) {
|
||||
system("rm -rf /tmp/csync/");
|
||||
fail_if(system("rm -rf /tmp/csync/") < 0, "Teardown failed");
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
Загрузка…
Ссылка в новой задаче