Go to the documentation of this file.
12 printf(
"hello world");
17 if (handler == NULL) {
18 printf(
"failed to malloc comand_handler\n");
22 handler->
name =
"hello-world";
26 #pragma GCC diagnostic ignored "-Wunused-parameter"
27 #pragma GCC diagnostic ignored "-Wunused-variable"
32 char *argv[1] = {
"test_arg"};
34 assert(cmdobj == NULL);
37 assert(cmdobj != NULL);
38 assert(cmdobj->
argc == 1);
39 assert(strcmp(cmdobj->
argv[0],
"test_arg") == 0);
43 #pragma GCC diagnostic ignored "-Wunused-parameter"
45 #pragma GCC diagnostic ignored "-Wunused-but-set-variable"
50 assert(cmdobj != NULL);
53 assert(response == 0);
58 assert(response == -1);
62 #pragma GCC diagnostic ignored "-Wunused-parameter"
64 #pragma GCC diagnostic ignored "-Wunused-but-set-variable"
69 assert(cmdobj != NULL);
72 assert(response == 0);
73 response =
execute(cmdobj,
"hello-world");
74 assert(response == 0);
75 response =
execute(cmdobj,
"not-a-command");
76 assert(response == -1);
81 const struct CMUnitTest tests[] = {
86 return cmocka_run_group_tests(tests, NULL, NULL);
void free_command_object(command_object *self)
frees memory allocated for the command_object and sets pointer to null for some reason this is causin...
void test_load_command(void **state)
int load_command(command_object *self, command_handler *command)
loads command handler and makes it executable
void test_execute(void **state)
int execute(command_object *self, char *run)
checks to see if we have a command named according to run and executes it
void test_new_command_object(void **state)
command_handler_callback callback
command_object * new_command_object(int argc, char *argv[])
intializes a new command_object to have commands loaded into
command_handler * new_test_command()