![]() |
Ansel 0.0
A darktable fork - bloat + design vision
|
#include "testdb.h"#include "caches/image_cache.h"#include "common/conf.h"#include "common/image.h"#include "control/crawler.h"#include "darktable.h"#include <glib/gstdio.h>#include <stdlib.h>
Include dependency graph for test_image_cache_flags_writeback.c:Go to the source code of this file.
Data Structures | |
| struct | _crawl_dir_t |
| struct | _holder_t |
Macros | |
| #define | CRAWL_BIT_A (1 << 4) |
| #define | CRAWL_BIT_B (1 << 5) |
| #define | CRAWL_MASK (CRAWL_BIT_A | CRAWL_BIT_B) |
| #define | USER_BIT 2048 |
Typedefs | |
| typedef struct _crawl_dir_t | _crawl_dir_t |
| typedef struct _holder_t | _holder_t |
Functions | |
| static int | cache_setup (void **state) |
| static int | cache_teardown (void **state) |
| static int32_t | _image_with_flags (const char *folder, const char *name, const int flags) |
| static gboolean | _row_has (const int32_t imgid, const int flag) |
| static void | test_cached_entry_overwrites_a_row_written_behind_it (void **state) |
| static void | test_editing_the_entry_survives_the_next_rating (void **state) |
| static void | test_testget_does_not_create_an_entry (void **state) |
| static void | test_crawl_keeps_a_cached_entry_in_step (void **state) |
| static _crawl_dir_t | _crawl_dir_new (const char *db_name) |
| static void | _crawl_dir_free (_crawl_dir_t *d) |
| static void | test_crawl_corrects_an_entry_the_row_already_agrees_with (void **state) |
| static gpointer | _hold_entry (gpointer data) |
| static void | test_crawl_waits_for_a_held_entry (void **state) |
| static void | test_crawl_reads_a_miscased_name_as_the_filesystem_does (void **state) |
| int | main (void) |
Variables | |
| static char * | _rcfile = NULL |
| #define CRAWL_BIT_A (1 << 4) |
Why anything writing main.images.flags behind the image cache has to keep the cache in step.
A cache entry holds its own dt_image_t, and releasing it writes that WHOLE struct back – which is how a rating reaches the database (metadata/ratings.c). So a row updated straight through the repository while a stale entry sits in the cache is not durable: the next release of that entry overwrites it, at a moment nothing connects to the update.
The XMP crawler is the caller this was found on (control/crawler.c). It takes the entry and edits it when there is one, and writes the row only when there is not; these tests pin both halves of that reasoning – the hazard, and the sequence that avoids it.
Definition at line 44 of file test_image_cache_flags_writeback.c.
| #define CRAWL_BIT_B (1 << 5) |
Definition at line 45 of file test_image_cache_flags_writeback.c.
| #define CRAWL_MASK (CRAWL_BIT_A | CRAWL_BIT_B) |
Definition at line 46 of file test_image_cache_flags_writeback.c.
| #define USER_BIT 2048 |
Definition at line 48 of file test_image_cache_flags_writeback.c.
| typedef struct _crawl_dir_t _crawl_dir_t |
|
static |
Definition at line 267 of file test_image_cache_flags_writeback.c.
References d.
Referenced by test_crawl_corrects_an_entry_the_row_already_agrees_with(), test_crawl_reads_a_miscased_name_as_the_filesystem_does(), and test_crawl_waits_for_a_held_entry().
|
static |
Definition at line 250 of file test_image_cache_flags_writeback.c.
References _image_with_flags(), d, _crawl_dir_t::dir, dt_image_repository_set_write_timestamp(), and USER_BIT.
Referenced by test_crawl_corrects_an_entry_the_row_already_agrees_with(), test_crawl_reads_a_miscased_name_as_the_filesystem_does(), and test_crawl_waits_for_a_held_entry().
|
static |
Definition at line 319 of file test_image_cache_flags_writeback.c.
References _holder_t::cond, dt_image_cache_get(), DT_IMAGE_CACHE_RELAXED, dt_image_cache_write_release(), dt_image_t::flags, _holder_t::holding, _holder_t::img, _holder_t::lock, and TRUE.
Referenced by test_crawl_waits_for_a_held_entry().
|
static |
Make an image whose row carries flags, and leave nothing of it in the cache.
Definition at line 85 of file test_image_cache_flags_writeback.c.
References dt_image_repository_set_flags(), dt_image_repository_set_group(), flags, folder, name, testdb_make_film(), and testdb_make_image().
Referenced by _crawl_dir_new(), test_cached_entry_overwrites_a_row_written_behind_it(), test_crawl_keeps_a_cached_entry_in_step(), test_editing_the_entry_survives_the_next_rating(), and test_testget_does_not_create_an_entry().
|
static |
Definition at line 99 of file test_image_cache_flags_writeback.c.
References dt_image_repository_get_ids_with_flag_among(), and flag.
Referenced by test_cached_entry_overwrites_a_row_written_behind_it(), test_crawl_corrects_an_entry_the_row_already_agrees_with(), test_crawl_keeps_a_cached_entry_in_step(), test_crawl_reads_a_miscased_name_as_the_filesystem_does(), test_crawl_waits_for_a_held_entry(), test_editing_the_entry_survives_the_next_rating(), and test_testget_does_not_create_an_entry().
|
static |
Definition at line 52 of file test_image_cache_flags_writeback.c.
References _rcfile, darktable_t::conf, darktable, dt_conf_init(), dt_image_cache_init(), FALSE, state, and testdb_setup().
Referenced by main().
|
static |
Definition at line 70 of file test_image_cache_flags_writeback.c.
References _rcfile, darktable_t::conf, darktable, dt_conf_cleanup(), dt_image_cache_cleanup(), state, and testdb_teardown().
Referenced by main().
| int main | ( | void | ) |
Definition at line 399 of file test_image_cache_flags_writeback.c.
References cache_setup(), cache_teardown(), test_cached_entry_overwrites_a_row_written_behind_it(), test_crawl_corrects_an_entry_the_row_already_agrees_with(), test_crawl_keeps_a_cached_entry_in_step(), test_crawl_reads_a_miscased_name_as_the_filesystem_does(), test_crawl_waits_for_a_held_entry(), test_editing_the_entry_survives_the_next_rating(), and test_testget_does_not_create_an_entry().
Definition at line 112 of file test_image_cache_flags_writeback.c.
References _image_with_flags(), _row_has(), CRAWL_BIT_A, CRAWL_MASK, dt_image_cache_get(), dt_image_cache_read_release(), DT_IMAGE_CACHE_RELAXED, dt_image_cache_write_release(), dt_image_repository_set_flags_masked(), dt_image_t::flags, state, USER_BIT, and void().
Referenced by main().
Definition at line 282 of file test_image_cache_flags_writeback.c.
References _crawl_dir_free(), _crawl_dir_new(), _row_has(), d, dt_control_crawler_run(), dt_image_cache_get(), dt_image_cache_read_release(), DT_IMAGE_CACHE_RELAXED, dt_image_cache_write_release(), DT_IMAGE_HAS_TXT, dt_image_repository_set_flags_masked(), dt_image_t::flags, state, and void().
Referenced by main().
Definition at line 186 of file test_image_cache_flags_writeback.c.
References _image_with_flags(), _row_has(), dt_control_crawler_run(), dt_image_cache_get(), dt_image_cache_read_release(), DT_IMAGE_CACHE_RELAXED, dt_image_cache_write_release(), DT_IMAGE_HAS_TXT, dt_image_repository_set_write_timestamp(), dt_image_t::flags, state, USER_BIT, and void().
Referenced by main().
Definition at line 373 of file test_image_cache_flags_writeback.c.
References _crawl_dir_free(), _crawl_dir_new(), _row_has(), d, dt_control_crawler_run(), DT_IMAGE_HAS_TXT, state, and void().
Referenced by main().
Definition at line 338 of file test_image_cache_flags_writeback.c.
References _crawl_dir_free(), _crawl_dir_new(), _hold_entry(), _row_has(), _holder_t::cond, d, dt_control_crawler_run(), dt_image_cache_get(), dt_image_cache_read_release(), DT_IMAGE_HAS_TXT, FALSE, _holder_t::holding, _holder_t::img, _holder_t::lock, state, and void().
Referenced by main().
Definition at line 139 of file test_image_cache_flags_writeback.c.
References _image_with_flags(), _row_has(), CRAWL_BIT_A, dt_image_cache_get(), dt_image_cache_read_release(), DT_IMAGE_CACHE_RELAXED, dt_image_cache_testget(), dt_image_cache_write_release(), dt_image_t::flags, state, USER_BIT, and void().
Referenced by main().
Definition at line 168 of file test_image_cache_flags_writeback.c.
References _image_with_flags(), _row_has(), CRAWL_BIT_B, CRAWL_MASK, dt_image_cache_testget(), dt_image_repository_set_flags_masked(), state, USER_BIT, and void().
Referenced by main().
|
static |
Definition at line 50 of file test_image_cache_flags_writeback.c.
Referenced by cache_setup(), and cache_teardown().