Files
ray/src/common/test/test_common.h
T
Stephanie Wang 9d1e750e8f Merge task table and task log into a single table (#30)
* Merge task table and task log

* Fix test in db tests

* Address Robert's comments and some better error checking

* Add a LOG_FATAL that exits the program
2016-11-10 18:13:26 -08:00

41 lines
1.1 KiB
C

#ifndef TEST_COMMON_H
#define TEST_COMMON_H
#include "hiredis/hiredis.h"
#include "task.h"
task_spec *example_task_spec(void) {
task_id parent_task_id = globally_unique_id();
function_id func_id = globally_unique_id();
task_spec *task =
start_construct_task_spec(parent_task_id, 0, func_id, 2, 1, 0);
task_args_add_ref(task, globally_unique_id());
task_args_add_ref(task, globally_unique_id());
finish_construct_task_spec(task);
return task;
}
task *example_task(void) {
task_spec *spec = example_task_spec();
task *instance = alloc_task(spec, TASK_STATUS_WAITING, NIL_ID);
free_task_spec(spec);
return instance;
}
/* Flush redis. */
void flushall_redis() {
redisContext *context = redisConnect("127.0.0.1", 6379);
freeReplyObject(redisCommand(context, "FLUSHALL"));
redisFree(context);
}
/* Cleanup method for running tests with the greatest library.
* Runs the test, then clears the Redis database. */
#define RUN_REDIS_TEST(test) \
flushall_redis(); \
RUN_TEST(test); \
flushall_redis();
#endif /* TEST_COMMON */