Ansel 0.0
A darktable fork - bloat + design vision
Loading...
Searching...
No Matches
test_pipe_cache_flush.c File Reference
#include "caches/pixelpipe_cache.h"
#include "system/atomic.h"
#include <stdarg.h>
#include <stddef.h>
#include <setjmp.h>
#include <stdint.h>
#include <cmocka.h>
#include "win/main_wrapper.h"
+ Include dependency graph for test_pipe_cache_flush.c:

Go to the source code of this file.

Macros

#define LINE_BYTES   (256 * 1024)
 
#define HASH_A   0x0A0A0A0A0A0A0A0Aull
 

Functions

static int _setup (void **state __attribute__((unused)))
 
static int _teardown (void **state __attribute__((unused)))
 
static dt_pixel_cache_entry_t * _create_held (void)
 
static void _held_line_survives_the_flush (void **state __attribute__((unused)))
 
static void _released_line_goes_with_the_flush (void **state __attribute__((unused)))
 
int main (int argc, char *argv[])
 

Macro Definition Documentation

◆ HASH_A

#define HASH_A   0x0A0A0A0A0A0A0A0Aull

Definition at line 44 of file test_pipe_cache_flush.c.

◆ LINE_BYTES

#define LINE_BYTES   (256 * 1024)

A flush frees nothing somebody holds.

A backbuffer keepalive, or a module keeping its preview across runs, holds a reference and no lock. The flush used to spare locked lines only: it freed a held one, and the holder's release then decremented freed memory (issue #1546).

These tests drive the cache alone, without a pipe: the contract is the cache's.

Definition at line 43 of file test_pipe_cache_flush.c.

Function Documentation

◆ _create_held()

◆ _held_line_survives_the_flush()

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

Held through the flush: the line stays, with its reference, and its holder releases it safely.

Definition at line 70 of file test_pipe_cache_flush.c.

References _create_held(), dt_atomic_get_int(), dt_dev_pixelpipe_cache_flush(), dt_dev_pixelpipe_cache_get_entry(), dt_dev_pixelpipe_cache_unref_entry(), HASH_A, and dt_pixel_cache_entry_t::refcount.

Referenced by main().

◆ _released_line_goes_with_the_flush()

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

Released, the same line goes with the next flush: the guard spares holders, not lines.

Definition at line 82 of file test_pipe_cache_flush.c.

References _create_held(), dt_dev_pixelpipe_cache_flush(), dt_dev_pixelpipe_cache_get_entry(), dt_dev_pixelpipe_cache_unref_entry(), and HASH_A.

Referenced by main().

◆ _setup()

static int _setup ( void **state   __attribute__(unused))
static

Definition at line 46 of file test_pipe_cache_flush.c.

References dt_dev_pixelpipe_cache_init(), and FALSE.

Referenced by main().

◆ _teardown()

static int _teardown ( void **state   __attribute__(unused))
static

Definition at line 51 of file test_pipe_cache_flush.c.

References dt_dev_pixelpipe_cache_cleanup().

Referenced by main().

◆ 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 91 of file test_pipe_cache_flush.c.

References _held_line_survives_the_flush(), _released_line_goes_with_the_flush(), _setup(), and _teardown().