Skip to content

Commit

Permalink
Add unit test for fwpkg_read_*()
Browse files Browse the repository at this point in the history
  • Loading branch information
matwey committed May 8, 2017
1 parent ab1a38b commit 53e069d
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions test/fwpkg.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include <check.h>
#include <stdlib.h>

#include <fwpkg.h>

Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down

0 comments on commit 53e069d

Please sign in to comment.