![]() |
Ansel 0.0
A darktable fork - bloat + design vision
|
#include "common/conf.h"#include "darktable.h"#include "system/macros.h"#include <glib.h>#include <glib/gstdio.h>#include <stdarg.h>#include <stddef.h>#include <stdio.h>#include <stdlib.h>#include <string.h>#include <setjmp.h>#include <stdint.h>#include <cmocka.h>#include "win/main_wrapper.h"
Include dependency graph for test_conf_save.c:Go to the source code of this file.
Macros | |
| #define | TEST_KEY "plugins/test/conf_save" |
Functions | |
| static int | _count_entries (const char *dir) |
| static int | _setup (void **state __attribute__((unused))) |
| static int | _teardown (void **state __attribute__((unused))) |
| static void | _flush_writes_what_was_set (void **state __attribute__((unused))) |
| static void | _flush_replaces_the_file_rather_than_rewriting_it (void **state __attribute__((unused))) |
| static void | _a_failed_flush_returns_1_and_writes_nothing (void **state __attribute__((unused))) |
| int | main (int argc, char *argv[]) |
Variables | |
| static char * | _dir = NULL |
| static char * | _rcfile = NULL |
| #define TEST_KEY "plugins/test/conf_save" |
What dt_conf_flush() leaves on disk.
The settings file is replaced, not rewritten in place: a process that dies during a save must leave the previous file whole. The observable, without killing anything, is a handle opened on the old file before the save: a replacement leaves it reading the old content, a rewrite in place ("wb") truncates it under the reader.
The tests share a directory of their own, so that what is left beside the settings file – the temporary file of the replacement – can be counted.
Checked against the defect: with the save put back to g_fopen(filename, "wb"), _flush_replaces_the_file_rather_than_rewriting_it() fails on old_intact, the old handle reading the rewritten file. The other two pass either way: they pin what is written and what a failure returns, not how the file is replaced. A key with no confgen declaration, so nothing clamps or sanitises what we store.
Definition at line 57 of file test_conf_save.c.
|
static |
A flush that cannot write returns 1 and leaves nothing behind. The settings file is pointed below a regular file, which no platform and no user, root included, can create a file in.
Definition at line 165 of file test_conf_save.c.
References _count_entries(), _dir, darktable_t::conf, darktable, dt_conf_flush(), dt_conf_set_string(), entries, dt_conf_t::filename, and TEST_KEY.
Referenced by main().
|
static |
Definition at line 62 of file test_conf_save.c.
References d.
Referenced by _a_failed_flush_returns_1_and_writes_nothing(), and _flush_writes_what_was_set().
|
static |
A handle opened on the old file still reads the old content after the flush: the file was replaced. A rewrite in place would have truncated it under the reader.
Definition at line 130 of file test_conf_save.c.
References _rcfile, dt_conf_flush(), dt_conf_set_string(), IS_NULL_PTR, n, TEST_KEY, and TRUE.
Referenced by main().
A value set in memory is in the file once the flush returns, and the temporary file the replacement went through is gone.
Definition at line 114 of file test_conf_save.c.
References _count_entries(), _dir, _rcfile, dt_conf_flush(), dt_conf_set_string(), IS_NULL_PTR, and TEST_KEY.
Referenced by main().
Definition at line 72 of file test_conf_save.c.
References _dir, _rcfile, darktable_t::conf, darktable, dt_conf_init(), and IS_NULL_PTR.
Referenced by main().
Definition at line 84 of file test_conf_save.c.
References _dir, _rcfile, darktable_t::conf, d, darktable, dt_conf_cleanup(), IS_NULL_PTR, and name.
Referenced by main().
| int main | ( | int | argc, |
| char * | argv[] | ||
| ) |
Definition at line 193 of file test_conf_save.c.
References _a_failed_flush_returns_1_and_writes_nothing(), _flush_replaces_the_file_rather_than_rewriting_it(), _flush_writes_what_was_set(), _setup(), and _teardown().
|
static |
Definition at line 59 of file test_conf_save.c.
Referenced by _a_failed_flush_returns_1_and_writes_nothing(), _flush_writes_what_was_set(), _setup(), and _teardown().
|
static |
Definition at line 60 of file test_conf_save.c.
Referenced by _flush_replaces_the_file_rather_than_rewriting_it(), _flush_writes_what_was_set(), _setup(), and _teardown().