Ansel 0.0
A darktable fork - bloat + design vision
Loading...
Searching...
No Matches
test_image_cache_flags_writeback.c File Reference
#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
 

Macro Definition Documentation

◆ CRAWL_BIT_A

#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.

◆ CRAWL_BIT_B

#define CRAWL_BIT_B   (1 << 5)

Definition at line 45 of file test_image_cache_flags_writeback.c.

◆ CRAWL_MASK

#define CRAWL_MASK   (CRAWL_BIT_A | CRAWL_BIT_B)

Definition at line 46 of file test_image_cache_flags_writeback.c.

◆ USER_BIT

#define USER_BIT   2048

Definition at line 48 of file test_image_cache_flags_writeback.c.

Typedef Documentation

◆ _crawl_dir_t

typedef struct _crawl_dir_t _crawl_dir_t

◆ _holder_t

typedef struct _holder_t _holder_t

Function Documentation

◆ _crawl_dir_free()

◆ _crawl_dir_new()

◆ _hold_entry()

◆ _image_with_flags()

static int32_t _image_with_flags ( const char *  folder,
const char *  name,
const int  flags 
)
static

◆ _row_has()

◆ cache_setup()

static int cache_setup ( void **  state)
static

◆ cache_teardown()

static int cache_teardown ( void **  state)
static

◆ main()

◆ 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()

static void test_crawl_reads_a_miscased_name_as_the_filesystem_does ( void **  state)
static

◆ test_crawl_waits_for_a_held_entry()

◆ test_editing_the_entry_survives_the_next_rating()

◆ test_testget_does_not_create_an_entry()

static void test_testget_does_not_create_an_entry ( void **  state)
static

Variable Documentation

◆ _rcfile

char* _rcfile = NULL
static

Definition at line 50 of file test_image_cache_flags_writeback.c.

Referenced by cache_setup(), and cache_teardown().