From 53e069da84b1d22fdffbe81f16915eac5407c37e Mon Sep 17 00:00:00 2001 From: "Matwey V. Kornilov" Date: Mon, 8 May 2017 17:45:41 +0300 Subject: [PATCH] Add unit test for fwpkg_read_*() --- test/fwpkg.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/test/fwpkg.c b/test/fwpkg.c index 45c0423..8f147fb 100644 --- a/test/fwpkg.c +++ b/test/fwpkg.c @@ -1,4 +1,5 @@ #include +#include #include @@ -28,6 +29,38 @@ START_TEST (test_fwpkg_size1) { fwpkg_free(fwpkg); } END_TEST +START_TEST (test_fwpkg_read1) { + char* buf; + size_t size; + struct fwpkg* fwpkg = fwpkg_new(); + int ret; + ck_assert_ptr_ne(fwpkg, NULL); + ret = fwpkg_from_file(fwpkg, PROJECT_ROOT "/ov3.fwpkg"); + ck_assert_int_eq(ret, 0); + size = fwpkg_map_size(fwpkg); + buf = malloc(size); + ck_assert_int_eq(fwpkg_read_map(fwpkg, buf, &size), 0); + ck_assert_uint_eq(size, fwpkg_map_size(fwpkg)); + free(buf); + fwpkg_free(fwpkg); +} +END_TEST +START_TEST (test_fwpkg_read2) { + char* buf; + size_t size; + struct fwpkg* fwpkg = fwpkg_new(); + int ret; + ck_assert_ptr_ne(fwpkg, NULL); + ret = fwpkg_from_file(fwpkg, PROJECT_ROOT "/ov3.fwpkg"); + ck_assert_int_eq(ret, 0); + size = fwpkg_bitstream_size(fwpkg); + buf = malloc(size); + ck_assert_int_eq(fwpkg_read_bitstream(fwpkg, buf, &size), 0); + ck_assert_uint_eq(size, fwpkg_bitstream_size(fwpkg)); + free(buf); + fwpkg_free(fwpkg); +} +END_TEST Suite* range_suite(void) { Suite *s; @@ -40,6 +73,8 @@ Suite* range_suite(void) { tcase_add_test(tc_core, test_fwpkg_new1); tcase_add_test(tc_core, test_fwpkg_load1); tcase_add_test(tc_core, test_fwpkg_size1); + tcase_add_test(tc_core, test_fwpkg_read1); + tcase_add_test(tc_core, test_fwpkg_read2); suite_add_tcase(s, tc_core); return s;