40#include <glib/gstdio.h>
57#define TEST_KEY "plugins/test/conf_save"
64 GDir *
d = g_dir_open(dir, 0, NULL);
67 while(g_dir_read_name(
d)) count++;
74 _dir = g_dir_make_tmp(
"ansel_test_conf_save_XXXXXX", NULL);
92 GDir *
d = g_dir_open(
_dir, 0, NULL);
95 const char *
name = NULL;
96 while((
name = g_dir_read_name(
d)))
98 char *path = g_build_filename(
_dir,
name, NULL);
119 char *contents = NULL;
120 assert_true(g_file_get_contents(
_rcfile, &contents, NULL, NULL));
123 assert_true(written);
140 FILE *old = g_fopen(
_rcfile,
"rb");
141 assert_non_null(old);
147 GString *seen = g_string_new(NULL);
150 while((
n = fread(buffer, 1,
sizeof(buffer), old)) > 0) g_string_append_len(seen, buffer,
n);
153 g_string_free(seen,
TRUE);
154 assert_true(old_intact);
156 char *contents = NULL;
157 assert_true(g_file_get_contents(
_rcfile, &contents, NULL, NULL));
160 assert_true(new_written);
167 char *blocker = g_build_filename(
_dir,
"not-a-directory", NULL);
168 assert_true(g_file_set_contents(blocker,
"x", 1, NULL));
169 char *unwritable = g_build_filename(blocker,
"anselrc", NULL);
182 char *contents = NULL;
183 assert_true(g_file_get_contents(blocker, &contents, NULL, NULL));
184 const gboolean blocker_intact = !g_strcmp0(contents,
"x");
188 assert_int_equal(result, 1);
189 assert_true(blocker_intact);
193int main(
int argc,
char *argv[])
195 const struct CMUnitTest tests[] = {
void dt_conf_cleanup(dt_conf_t *cf)
Free everything cf owns. No dt_conf_*() call is valid afterwards.
int dt_conf_flush(void)
Write the settings to their file now. Overridden keys keep their stored value.
void dt_conf_init(dt_conf_t *cf, const char *filename, GSList *override_entries)
Populate cf from filename and from the generated defaults.
void dt_conf_set_string(const char *name, const char *val)
#define IS_NULL_PTR(p)
C is way too permissive with !=, == and if(var) checks, which can mean too many things depending on w...
float dt_aligned_pixel_simd_t __attribute__((vector_size(16), aligned(16)))
Apply one channel's tone curve to each of the three colour channels, or pass the channel through unto...
const float uint32_t state[4]
The whole configuration state. One instance lives at darktable.conf.
char filename[DT_PATH_MAX]
static void _flush_writes_what_was_set(void **state __attribute__((unused)))
static void _a_failed_flush_returns_1_and_writes_nothing(void **state __attribute__((unused)))
static int _teardown(void **state __attribute__((unused)))
static void _flush_replaces_the_file_rather_than_rewriting_it(void **state __attribute__((unused)))
static int _setup(void **state __attribute__((unused)))
static int _count_entries(const char *dir)