diff --git a/test/cmocka/unit_test_cntlr.c b/test/cmocka/unit_test_cntlr.c index ced0be1038375a14e053644f0d227f4cf4a593e8..189054c1a79869ece7113dc026aef41a8fb93baf 100644 --- a/test/cmocka/unit_test_cntlr.c +++ b/test/cmocka/unit_test_cntlr.c @@ -37,37 +37,26 @@ struct test_ctx { static int group_setup(void **state) { - struct test_ctx *ctx;// = malloc(sizeof(struct test_ctx)); + struct test_ctx *ctx; ctx = calloc(1, sizeof(*ctx)); - printf("%s %d\n", __func__, __LINE__); - start_test_logging(); + if (!ctx) + return -1; + + remove(CNTLR_FILE); + remove(AGENT_FILE); + memset(&ctx->bb, 0, sizeof(struct blob_buf)); -// if (!ctx) -// return -1; -// -// printf("%s %d\n", __func__, __LINE__); -// -// remove(CNTLR_FILE); -// remove(AGENT_FILE); -// -// printf("%s %d\n", __func__, __LINE__); -// -// memset(&ctx->bb, 0, sizeof(struct blob_buf)); -// -// printf("%s %d\n", __func__, __LINE__); -// -// *state = ctx; + *state = ctx; return 0; } static int setup(void **state) { - printf("%s %d\n", __func__, __LINE__); return 0; } @@ -75,7 +64,6 @@ static int teardown(void **state) { stop_test_logging(); - printf("%s %d\n", __func__, __LINE__); return 0; } @@ -90,34 +78,27 @@ static int group_teardown(void **state) { // struct test_ctx *ctx = (struct test_ctx *) *state; - printf("%s %d\n", __func__, __LINE__); - -// blob_buf_free(&ctx->bb); + blob_buf_free(&ctx->bb); // free(ctx); -// remove(CNTLR_FILE); -// remove(AGENT_FILE); + remove(CNTLR_FILE); + remove(AGENT_FILE); return 0; } static void test_cmdu_comm(void **state) { - //struct test_ctx *ctx = (struct test_ctx *) *state; - //struct blob_buf *bb = &ctx->bb; - //struct json_object *jobj, *tmp; int rv; struct blob_buf bb = {0}; struct controller c; + // TODO: place in group setup c.ubus_ctx = ubus_connect(NULL); blob_buf_init(&bb, 0); - printf("%s %d\n", __func__, __LINE__); rv = cntlr_ap_caps(NULL, &c.obj, NULL, NULL, bb.head); - dbg("test\n"); -printf("%s %d\n", __func__, __LINE__); assert_int_equal(rv, 0); -printf("%s %d\n", __func__, __LINE__); + assert_true(!compare_files(CNTLR_FILE, AGENT_FILE)); }