Ansel 0.0
A darktable fork - bloat + design vision
Loading...
Searching...
No Matches
test_pipe_cache_alloc_refusals.c File Reference
#include "caches/pixelpipe_cache.h"
#include "system/macros.h"
#include <glib.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_alloc_refusals.c:

Go to the source code of this file.

Macros

#define MIB   ((size_t)1024 * 1024)
 
#define CACHE_BYTES   (64 * MIB)
 
#define HASH_HELD   0x0A0A0A0A0A0A0A0Aull
 

Functions

static int _setup (void **state __attribute__((unused)))
 
static int _teardown (void **state __attribute__((unused)))
 
static void _granted_allocation_is_not_counted (void **state __attribute__((unused)))
 
static void _request_larger_than_the_cache_is_counted_once (void **state __attribute__((unused)))
 
static void _budget_spent_by_a_line_in_use_is_counted_once (void **state __attribute__((unused)))
 
static gpointer _refuse_on_this_thread (gpointer unused __attribute__((unused)))
 
static void _refusal_on_another_thread_is_not_counted_here (void **state __attribute__((unused)))
 
int main (int argc, char *argv[])
 

Macro Definition Documentation

◆ CACHE_BYTES

#define CACHE_BYTES   (64 * MIB)

Definition at line 46 of file test_pipe_cache_alloc_refusals.c.

◆ HASH_HELD

#define HASH_HELD   0x0A0A0A0A0A0A0A0Aull

Definition at line 47 of file test_pipe_cache_alloc_refusals.c.

◆ MIB

#define MIB   ((size_t)1024 * 1024)

The cache counts what it refuses for lack of memory, per thread.

A pixelpipe run that fails returns the same error whether a module failed or the cache refused it a buffer. An export reads dt_pixelpipe_cache_get_alloc_refusals() around the run to tell the two apart, and shows "Out of RAM" on the thumbnail instead of "Processing error". That holds only if every refusal is counted once, nothing else is, and a refusal on another thread is not.

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

Definition at line 45 of file test_pipe_cache_alloc_refusals.c.

Function Documentation

◆ _budget_spent_by_a_line_in_use_is_counted_once()

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

◆ _granted_allocation_is_not_counted()

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

A buffer the cache can give is not a refusal.

Definition at line 61 of file test_pipe_cache_alloc_refusals.c.

References dt_pixelpipe_cache_alloc_align_cache_impl(), dt_pixelpipe_cache_free_align_cache(), dt_pixelpipe_cache_get_alloc_refusals(), and MIB.

Referenced by main().

◆ _refusal_on_another_thread_is_not_counted_here()

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

A refusal is counted on the thread it was refused to, and read there only: an export reading its own run must not see another pipe's.

Definition at line 110 of file test_pipe_cache_alloc_refusals.c.

References _refuse_on_this_thread(), and dt_pixelpipe_cache_get_alloc_refusals().

Referenced by main().

◆ _refuse_on_this_thread()

static gpointer _refuse_on_this_thread ( gpointer unused   __attribute__(unused))
static

◆ _request_larger_than_the_cache_is_counted_once()

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

More than the whole cache: the arena has no run that long.

Definition at line 73 of file test_pipe_cache_alloc_refusals.c.

References CACHE_BYTES, dt_pixelpipe_cache_alloc_align_cache_impl(), and dt_pixelpipe_cache_get_alloc_refusals().

Referenced by main().

◆ _setup()

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

Definition at line 49 of file test_pipe_cache_alloc_refusals.c.

References CACHE_BYTES, dt_dev_pixelpipe_cache_init(), and FALSE.

Referenced by main().

◆ _teardown()

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

Definition at line 54 of file test_pipe_cache_alloc_refusals.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 121 of file test_pipe_cache_alloc_refusals.c.

References _budget_spent_by_a_line_in_use_is_counted_once(), _granted_allocation_is_not_counted(), _refusal_on_another_thread_is_not_counted_here(), _request_larger_than_the_cache_is_counted_once(), _setup(), and _teardown().