Ansel 0.0
A darktable fork - bloat + design vision
Loading...
Searching...
No Matches
test_image_cache_unreadable.c File Reference
#include "testdb.h"
#include "caches/image_cache.h"
#include "common/conf.h"
#include "common/grouping.h"
#include "common/image.h"
#include "darktable.h"
#include <glib/gstdio.h>
#include <math.h>
#include <stdlib.h>
#include "win/main_wrapper.h"
+ Include dependency graph for test_image_cache_unreadable.c:

Go to the source code of this file.

Functions

static int _setup (void **state __attribute__((unused)))
 
static void _remove_tree (const gchar *dir)
 
static int _teardown (void **state)
 
static void _make_unreadable (const int32_t imgid)
 
static gboolean _group_is (const int32_t group_id, const int32_t *members, const int count)
 
static void _group_of_three (const char *folder, int32_t *a, int32_t *b, int32_t *c)
 
static void test_change_representative_moves_an_unreadable_member (void **state __attribute__((unused)))
 
static void test_remove_from_group_names_the_group_after_a_readable_member (void **state __attribute__((unused)))
 
static void test_setters_leave_an_unreadable_image_alone (void **state __attribute__((unused)))
 
static void test_rename_leaves_an_unreadable_duplicate_behind (void **state __attribute__((unused)))
 
int main (int argc, char *argv[])
 

Variables

static gchar * _dir = NULL
 
static gchar * _library = NULL
 
static gchar * _rcfile = NULL
 

Function Documentation

◆ _group_is()

static gboolean _group_is ( const int32_t  group_id,
const int32_t *  members,
const int  count 
)
static

◆ _group_of_three()

static void _group_of_three ( const char *  folder,
int32_t *  a,
int32_t *  b,
int32_t *  c 
)
static

◆ _make_unreadable()

static void _make_unreadable ( const int32_t  imgid)
static

Ask for imgid while another connection holds the library: the read fails, and the cache keeps answering NULL for it once the lock is gone. Call it before anything else of the test reads an image.

Definition at line 113 of file test_image_cache_unreadable.c.

References _library, and dt_image_cache_get().

Referenced by _group_of_three(), test_rename_leaves_an_unreadable_duplicate_behind(), and test_setters_leave_an_unreadable_image_alone().

◆ _remove_tree()

static void _remove_tree ( const gchar *  dir)
static

Definition at line 76 of file test_image_cache_unreadable.c.

References _remove_tree(), d, dt_free, IS_NULL_PTR, and name.

Referenced by _remove_tree(), and _teardown().

◆ _setup()

◆ _teardown()

static int _teardown ( void **  state)
static

◆ main()

int main ( int  argc,
char *  argv[] 
)
Todo:
: test if file with replaced ext exists
Todo:
: add a callback to set the bpp without going through the config
Todo:
: have a parameter in command line to get the export presets

Definition at line 250 of file test_image_cache_unreadable.c.

References _setup(), _teardown(), test_change_representative_moves_an_unreadable_member(), test_remove_from_group_names_the_group_after_a_readable_member(), test_rename_leaves_an_unreadable_duplicate_behind(), and test_setters_leave_an_unreadable_image_alone().

◆ test_change_representative_moves_an_unreadable_member()

static void test_change_representative_moves_an_unreadable_member ( void **state   __attribute__(unused))
static

Definition at line 154 of file test_image_cache_unreadable.c.

References _group_is(), _group_of_three(), and dt_grouping_change_representative().

Referenced by main().

◆ test_remove_from_group_names_the_group_after_a_readable_member()

static void test_remove_from_group_names_the_group_after_a_readable_member ( void **state   __attribute__(unused))
static

Definition at line 173 of file test_image_cache_unreadable.c.

References _group_is(), _group_of_three(), and dt_grouping_remove_from_group().

Referenced by main().

◆ test_rename_leaves_an_unreadable_duplicate_behind()

static void test_rename_leaves_an_unreadable_duplicate_behind ( void **state   __attribute__(unused))
static

◆ test_setters_leave_an_unreadable_image_alone()

Variable Documentation

◆ _dir

gchar* _dir = NULL
static

What the callers of dt_image_cache_get() do with an image they cannot read.

The cache answers NULL for an image whose first database read failed, for as long as the entry stays cached, although the row is there and other queries list it: group members, duplicates. That is the state these tests put one image in, the way another program does – a second connection holds the library's EXCLUSIVE lock while the image is asked for. Each caller below dereferenced that NULL.

Definition at line 44 of file test_image_cache_unreadable.c.

Referenced by _setup(), _teardown(), and test_rename_leaves_an_unreadable_duplicate_behind().

◆ _library

gchar* _library = NULL
static

Definition at line 45 of file test_image_cache_unreadable.c.

Referenced by _make_unreadable(), _setup(), and _teardown().

◆ _rcfile

gchar* _rcfile = NULL
static

Definition at line 46 of file test_image_cache_unreadable.c.

Referenced by _setup(), and _teardown().