improve xkvmgr and testsuite for scheduler
This commit is contained in:
parent
2ee87d4ee6
commit
598d381379
10 changed files with 327 additions and 64 deletions
|
|
@ -3,6 +3,7 @@
|
|||
#define _SCHEDULER_H_ 1
|
||||
|
||||
#include <pthread.h>
|
||||
#include <rtti.h>
|
||||
#include <stdint.h>
|
||||
#include <time.h>
|
||||
|
||||
|
|
|
|||
|
|
@ -31,3 +31,5 @@ scheduler = executable('xce_scheduler',
|
|||
dependencies: scheduler_deps,
|
||||
link_args: wrap_link_args,
|
||||
install: true)
|
||||
|
||||
subdir('testsuite')
|
||||
|
|
|
|||
13
src/scheduler/testsuite/meson.build
Normal file
13
src/scheduler/testsuite/meson.build
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
scheduler_test_src = [
|
||||
'test.c'
|
||||
]
|
||||
|
||||
scheduler_test_deps = [libxce_deps, librtti_dep, unity_dep]
|
||||
|
||||
incdir = include_directories('../include', '../../include', '.')
|
||||
|
||||
scheduler_test = executable('sched_test',
|
||||
scheduler_test_src,
|
||||
include_directories:[incdir],
|
||||
dependencies: [scheduler_test_deps],
|
||||
install: false)
|
||||
82
src/scheduler/testsuite/test.c
Normal file
82
src/scheduler/testsuite/test.c
Normal file
|
|
@ -0,0 +1,82 @@
|
|||
#include <argp.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unity/unity.h>
|
||||
|
||||
void setUp() { return; }
|
||||
|
||||
void tearDown(void)
|
||||
{
|
||||
printf("\n-----------------------------------------------------\n");
|
||||
return;
|
||||
}
|
||||
|
||||
static char doc[] = "sched_test";
|
||||
static char args_doc[] = "";
|
||||
|
||||
#define MAX_TESTS (256)
|
||||
|
||||
struct arguments {
|
||||
int ntests;
|
||||
char* tests[MAX_TESTS];
|
||||
};
|
||||
|
||||
static struct argp_option options[] = {
|
||||
{ "run", 't', "STR", 0, "run test" },
|
||||
{ 0 }
|
||||
};
|
||||
|
||||
static error_t parse_opt(int key, char* arg, struct argp_state* state)
|
||||
{
|
||||
struct arguments* arguments = state->input;
|
||||
|
||||
switch (key) {
|
||||
case 't':
|
||||
if (arguments->ntests >= MAX_TESTS) {
|
||||
fprintf(stderr, "Too many tests\n");
|
||||
exit(-1);
|
||||
}
|
||||
arguments->tests[arguments->ntests] = arg;
|
||||
arguments->ntests++;
|
||||
break;
|
||||
default:
|
||||
return ARGP_ERR_UNKNOWN;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct argp argp = { options, parse_opt, args_doc, doc };
|
||||
struct arguments arguments;
|
||||
|
||||
static int check_test(struct arguments* args, char* x)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (args->ntests == 0) {
|
||||
return 1;
|
||||
}
|
||||
for (i = 0; i < args->ntests; i++) {
|
||||
if (strcmp(x, args->tests[i]) == 0) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define TEST(x) \
|
||||
do { \
|
||||
if (check_test(&arguments, #x)) { \
|
||||
x(); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
argp_parse(&argp, argc, argv, 0, 0, &arguments);
|
||||
|
||||
UNITY_BEGIN();
|
||||
|
||||
return UNITY_END();
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue