Add another test for mroe coverage
This commit is contained in:
@@ -102,6 +102,28 @@ START_TEST (test_read_file_devnull)
|
||||
|
||||
END_TEST
|
||||
|
||||
START_TEST (test_read_file_too_big)
|
||||
char *content;
|
||||
const char *filename = "test_read_file_simple";
|
||||
size_t len;
|
||||
ssize_t rc;
|
||||
|
||||
int fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC, 0664);
|
||||
fail_if(fd == -1);
|
||||
|
||||
rc = write(fd, "hello", 5);
|
||||
fail_if(rc != 5, "rc was %ld", (long)rc);
|
||||
|
||||
close(fd);
|
||||
|
||||
content = uc_read_file(filename, &len, 4);
|
||||
|
||||
fail_if(errno != EMSGSIZE);
|
||||
fail_if(content != NULL);
|
||||
|
||||
unlink(filename);
|
||||
END_TEST
|
||||
|
||||
Suite *read_file_suite(void)
|
||||
{
|
||||
Suite *s = suite_create("read_file");
|
||||
@@ -111,6 +133,7 @@ Suite *read_file_suite(void)
|
||||
tcase_add_test(tc, test_read_file_greater_than_max);
|
||||
tcase_add_test(tc, test_read_file_boundary);
|
||||
tcase_add_test(tc, test_read_file_devnull);
|
||||
tcase_add_test(tc, test_read_file_too_big);
|
||||
|
||||
|
||||
suite_add_tcase(s, tc);
|
||||
|
||||
Reference in New Issue
Block a user