42 #define CATEGORY "/main/media_cache/" 45 #define VALID_RESOURCE "httptest://localhost:8088/test_media_cache/monkeys.wav" 48 #define INVALID_RESOURCE "httptest://localhost:8088/test_media_cache/bad.wav" 51 #define INVALID_SCHEME "foo://localhost:8088/test_media_cache/monkeys.wav" 54 #define NO_SCHEME "localhost:8088/test_media_cache/monkeys.wav" 89 void *data,
const char *
type,
const char *
id)
140 info->name = __func__;
142 info->summary =
"Test nominal existance of resources in the cache";
144 "This test verifies that if a known resource is in the cache, " 145 "calling ast_media_cache_exists will return logical True. If " 146 "a resource does not exist, the same function call will return " 154 ast_test_validate(
test, res == 0);
157 ast_test_validate(
test, res == 1);
168 info->name = __func__;
170 info->summary =
"Test off nominal existance of resources in the cache";
172 "This test verifies that checking for bad resources (NULL, bad " 173 "scheme, etc.) does not result in false positivies.";
180 ast_test_validate(
test, res != 1);
183 ast_test_validate(
test, res != 1);
186 ast_test_validate(
test, res != 1);
189 ast_test_validate(
test, res != 1);
198 char tmp_path_one[
PATH_MAX] =
"/tmp/test-media-cache-XXXXXX";
199 char tmp_path_two[
PATH_MAX] =
"/tmp/test-media-cache-XXXXXX";
204 info->name = __func__;
206 info->summary =
"Test nominal creation/updating of a resource";
208 "This test creates a resource and associates it with a file. " 209 "It then updates the resource with a new file. In both cases, " 210 "the test verifies that the resource is associated with the " 218 fd = mkstemp(tmp_path_one);
227 fd = mkstemp(tmp_path_two);
237 ast_test_validate(
test, res == 0);
241 ast_test_validate(
test, res == 0);
242 ast_test_validate(
test, strcmp(file_path, tmp_path_one) == 0);
246 ast_test_validate(
test, res == 0);
250 ast_test_validate(
test, res == 0);
251 ast_test_validate(
test, strcmp(file_path, tmp_path_two) == 0);
253 unlink(tmp_path_one);
254 unlink(tmp_path_two);
262 char tmp_path[
PATH_MAX] =
"/tmp/test-media-cache-XXXXXX";
267 info->name = __func__;
269 info->summary =
"Test off nominal creation/updating of a resource";
271 "Test creation/updating of a resource with a variety of invalid\n" 279 fd = mkstemp(tmp_path);
289 ast_test_validate(
test, res != 0);
292 ast_test_validate(
test, res != 0);
295 ast_test_validate(
test, res != 0);
298 ast_test_validate(
test, res != 0);
301 ast_test_validate(
test, res != 0);
304 ast_test_validate(
test, res != 0);
314 char tmp_path[
PATH_MAX] =
"/tmp/test-media-cache-XXXXXX";
316 char actual_metadata[32];
323 info->name = __func__;
325 info->summary =
"Test nominal creation/updating of a resource";
327 "This test creates a resource and associates it with a file. " 328 "It then updates the resource with a new file. In both cases, " 329 "the test verifies that the resource is associated with the " 337 fd = mkstemp(tmp_path);
361 ast_test_validate(
test, res == 0);
365 ast_test_validate(
test, res == 0);
366 ast_test_validate(
test, strcmp(file_path, tmp_path) == 0);
369 actual_metadata,
sizeof(actual_metadata));
370 ast_test_validate(
test, res == 0);
371 ast_test_validate(
test, strcmp(actual_metadata,
"value1") == 0);
374 actual_metadata,
sizeof(actual_metadata));
375 ast_test_validate(
test, res == 0);
376 ast_test_validate(
test, strcmp(actual_metadata,
"value2") == 0);
398 &bucket_file_test_wizard,
NULL,
NULL)) {
399 ast_log(
LOG_ERROR,
"Failed to register Bucket HTTP test wizard scheme implementation\n");
#define AST_MODULE_INFO_STANDARD(keystr, desc)
Asterisk main include file. File version handling, generic pbx functions.
Structure for variables, used for configurations and for channel variables.
#define AST_TEST_REGISTER(cb)
Full structure for sorcery.
struct ast_bucket_file * ast_bucket_file_alloc(const char *uri)
Allocate a new bucket file.
const char * name
Name of the wizard.
void(* close)(void *data)
Callback for closing a wizard.
#define ast_test_status_update(a, b, c...)
const char * ast_sorcery_object_get_id(const void *object)
Get the unique identifier of a sorcery object.
Bucket file structure, contains reference to file and information about it.
#define ast_variable_new(name, value, filename)
#define AST_TEST_UNREGISTER(cb)
Module has failed to load, may be in an inconsistent state.
int ast_bucket_file_temporary_create(struct ast_bucket_file *file)
Common file snapshot creation callback for creating a temporary file.
Interface for a sorcery wizard.
static struct ast_sorcery * sorcery
#define ast_bucket_scheme_register(name, bucket, file, create_cb, destroy_cb)
Register support for a specific scheme.
#define ASTERISK_GPL_KEY
The text the key() function should return.
Asterisk module definitions.
#define ast_variable_list_append(head, new_var)