Asterisk - The Open Source Telephony Project  21.4.1
Data Structures | Macros | Functions | Variables
test_sorcery_memory_cache_thrash.c File Reference

Sorcery Unit Tests. More...

#include "asterisk.h"
#include "asterisk/test.h"
#include "asterisk/module.h"
#include "asterisk/sorcery.h"
#include "asterisk/logger.h"
#include "asterisk/vector.h"
#include "asterisk/cli.h"

Go to the source code of this file.

Data Structures

struct  sorcery_memory_cache_thrash
 Structure for memory cache thrashing. More...
 
struct  sorcery_memory_cache_thrash_thread
 Structure for a memory cache thras thread. More...
 
struct  test_data
 Sorcery object created based on backend data. More...
 

Macros

#define TEST_THRASH_RETRIEVERS   25
 The number of threads to use for retrieving for applicable tests.
 
#define TEST_THRASH_TIME   3
 The default amount of time (in seconds) that thrash unit tests execute for.
 
#define TEST_THRASH_UPDATERS   25
 The number of threads to use for updating for applicable tests.
 

Functions

static void __reg_module (void)
 
static void __unreg_module (void)
 
struct ast_moduleAST_MODULE_SELF_SYM (void)
 
 AST_TEST_DEFINE (low_unique_object_count_immediately_stale)
 
 AST_TEST_DEFINE (low_unique_object_count_immediately_expire)
 
 AST_TEST_DEFINE (low_unique_object_count_high_concurrent_updates)
 
 AST_TEST_DEFINE (unique_objects_exceeding_maximum)
 
 AST_TEST_DEFINE (unique_objects_exceeding_maximum_with_expire_and_stale)
 
 AST_TEST_DEFINE (conflicting_expire_and_stale)
 
 AST_TEST_DEFINE (high_object_count_without_expiration)
 
static int load_module (void)
 
static void * mock_retrieve_id (const struct ast_sorcery *sorcery, void *data, const char *type, const char *id)
 Callback for retrieving sorcery object by ID. More...
 
static int mock_update (const struct ast_sorcery *sorcery, void *data, void *object)
 Callback for updating a sorcery object. More...
 
static enum ast_test_result_state nominal_thrash (struct ast_test *test, const char *cache_configuration, unsigned int thrash_time, unsigned int unique_objects, unsigned int retrieve_threads, unsigned int update_threads)
 
static char * sorcery_memory_cache_cli_thrash (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 
static struct sorcery_memory_cache_thrashsorcery_memory_cache_thrash_create (const char *cache_configuration, unsigned int update_threads, unsigned int retrieve_threads, unsigned int unique_objects)
 
static void sorcery_memory_cache_thrash_destroy (void *obj)
 
static void * sorcery_memory_cache_thrash_retrieve (void *data)
 
static int sorcery_memory_cache_thrash_start (struct sorcery_memory_cache_thrash *thrash)
 
static void sorcery_memory_cache_thrash_stop (struct sorcery_memory_cache_thrash *thrash)
 
static void * sorcery_memory_cache_thrash_update (void *data)
 
static void * test_data_alloc (const char *id)
 Allocation callback for test_data sorcery object.
 
static int unload_module (void)
 

Variables

static struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "Sorcery Cache Thrasing test module" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = AST_BUILDOPT_SUM, .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_DEFAULT, .support_level = AST_MODULE_SUPPORT_CORE, }
 
static const struct ast_module_infoast_module_info = &__mod_info
 
static struct ast_cli_entry cli_memory_cache_thrash []
 
static struct ast_sorcery_wizard mock_wizard
 A mock sorcery wizard used for the stale test. More...
 

Detailed Description

Sorcery Unit Tests.

Author
Joshua Colp jcolp.nosp@m.@dig.nosp@m.ium.c.nosp@m.om

Definition in file test_sorcery_memory_cache_thrash.c.

Function Documentation

static void* mock_retrieve_id ( const struct ast_sorcery sorcery,
void *  data,
const char *  type,
const char *  id 
)
static

Callback for retrieving sorcery object by ID.

Parameters
sorceryThe sorcery instance
dataUnused
typeThe object type. Will always be "test".
idThe object id. Will always be "test".
Return values
NULLBackend data successfully allocated
non-NULLBackend data could not be successfully allocated

Definition at line 106 of file test_sorcery_memory_cache_thrash.c.

References ast_sorcery_alloc().

108 {
109  return ast_sorcery_alloc(sorcery, type, id);
110 }
void * ast_sorcery_alloc(const struct ast_sorcery *sorcery, const char *type, const char *id)
Allocate an object.
Definition: sorcery.c:1744
static int mock_update ( const struct ast_sorcery sorcery,
void *  data,
void *  object 
)
static

Callback for updating a sorcery object.

Parameters
sorceryThe sorcery instance
dataUnused
objectThe object to update.

Definition at line 120 of file test_sorcery_memory_cache_thrash.c.

122 {
123  return 0;
124 }

Variable Documentation

struct ast_cli_entry cli_memory_cache_thrash[]
static
Initial value:
= {
{ .handler = sorcery_memory_cache_cli_thrash , .summary = "Thrash a sorcery memory cache" ,},
}

Definition at line 429 of file test_sorcery_memory_cache_thrash.c.

struct ast_sorcery_wizard mock_wizard
static
Initial value:
= {
.name = "mock",
.retrieve_id = mock_retrieve_id,
.update = mock_update,
}
static int mock_update(const struct ast_sorcery *sorcery, void *data, void *object)
Callback for updating a sorcery object.
static void * mock_retrieve_id(const struct ast_sorcery *sorcery, void *data, const char *type, const char *id)
Callback for retrieving sorcery object by ID.

A mock sorcery wizard used for the stale test.

Definition at line 129 of file test_sorcery_memory_cache_thrash.c.