111 int id1, id2, id3, wait;
115 info->name =
"sched_test_order";
116 info->category =
"/main/sched/";
117 info->summary =
"Test ordering of events in the scheduler API";
119 "This test ensures that events are properly ordered by the " 120 "time they are scheduled to execute in the scheduler API.";
128 "Test failed - could not create scheduler context\n");
137 "ast_sched_wait() should have returned -1, returned '%d'\n",
149 "ast_sched_wait() should have returned <= 100000, returned '%d'\n",
161 "ast_sched_wait() should have returned <= 10000, returned '%d'\n",
173 "ast_sched_wait() should have returned <= 1000, returned '%d'\n",
185 "ast_sched_wait() should have returned > 1000, returned '%d'\n",
197 "ast_sched_wait() should have returned > 10000, returned '%d'\n",
209 "ast_sched_wait() should have returned -1, returned '%d'\n",
219 #define DELAYED_SAME_EXPIRE 300 252 "ast_sched_wait() should have returned -1, returned '%d'\n",
268 struct timeval start;
270 int *sched_ids =
NULL;
274 e->
command =
"sched benchmark";
276 "Usage: sched benchmark <num>\n" 287 if (sscanf(a->
argv[e->
args],
"%u", &num) != 1) {
292 ast_cli(a->
fd,
"Test failed - could not create scheduler context\n");
296 if (!(sched_ids =
ast_malloc(
sizeof(*sched_ids) * num))) {
297 ast_cli(a->
fd,
"Test failed - memory allocation failure\n");
301 ast_cli(a->
fd,
"Testing ast_sched_add() performance - timing how long it takes " 302 "to add %u entries at random time intervals from 0 to 60 seconds\n", num);
306 for (i = 0; i < num; i++) {
309 ast_cli(a->
fd,
"Test failed - sched_add returned -1\n");
316 ast_cli(a->
fd,
"Testing ast_sched_del() performance - timing how long it takes " 317 "to delete %u entries with random time intervals from 0 to 60 seconds\n", num);
321 for (i = 0; i < num; i++) {
323 ast_cli(a->
fd,
"Test failed - sched_del returned -1\n");
static char * handle_cli_sched_bench(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
#define AST_CLI_DEFINE(fn, txt,...)
#define AST_MODULE_INFO_STANDARD(keystr, desc)
Asterisk main include file. File version handling, generic pbx functions.
static int load_module(void)
int ast_sched_runq(struct ast_sched_context *con)
Runs the queue.
int ast_cli_unregister_multiple(struct ast_cli_entry *e, int len)
Unregister multiple commands.
descriptor for a cli entry.
static int sched_order_2_cb(const void *data)
AST_TEST_DEFINE(sched_test_order)
#define AST_TEST_REGISTER(cb)
#define ast_cli_register_multiple(e, len)
Register multiple commands.
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
static int sched_order_7_cb(const void *data)
void ast_cli(int fd, const char *fmt,...)
#define DELAYED_SAME_EXPIRE
int args
This gets set in ast_cli_register()
static int sched_order_5_cb(const void *data)
#define ast_test_status_update(a, b, c...)
Scheduler Routines (derived from cheops)
long int ast_random(void)
static int sched_order_4_cb(const void *data)
#define ast_malloc(len)
A wrapper for malloc()
static int sched_order_1_cb(const void *data)
static int sched_cb(const void *data)
struct ast_sched_context * ast_sched_context_create(void)
Create a scheduler context.
static struct ast_cli_entry cli_sched[]
static int unload_module(void)
static int order_check_failed
#define AST_TEST_UNREGISTER(cb)
int ast_sched_del(struct ast_sched_context *con, int id) attribute_warn_unused_result
Deletes a scheduled event.
int ast_sched_add(struct ast_sched_context *con, int when, ast_sched_cb callback, const void *data) attribute_warn_unused_result
Adds a scheduled event.
static int sched_order_8_cb(const void *data)
Standard Command Line Interface.
int ast_sched_wait(struct ast_sched_context *con) attribute_warn_unused_result
Determines number of seconds until the next outstanding event to take place.
int64_t ast_tvdiff_us(struct timeval end, struct timeval start)
Computes the difference (in microseconds) between two struct timeval instances.
#define ASTERISK_GPL_KEY
The text the key() function should return.
Asterisk module definitions.
void ast_sched_context_destroy(struct ast_sched_context *c)
destroys a schedule context
static void sched_order_check(struct ast_test *test, int order)
static int sched_order_6_cb(const void *data)
static int sched_order_3_cb(const void *data)