diff options
author | Edward O'Callaghan <quasisec@google.com> | 2023-01-15 14:50:25 +1100 |
---|---|---|
committer | Anastasia Klimchuk <aklm@chromium.org> | 2023-01-22 05:56:12 +0000 |
commit | dd41980f1784c91dd8b30a9074a260621d366c2e (patch) | |
tree | a9a006d60a296cc3a92f4826348185aeff5b30ec /tests/chip.c | |
parent | 46856234b3b6dea93e38c499eecbb432cb1e455e (diff) | |
download | flashrom-dd41980f1784c91dd8b30a9074a260621d366c2e.tar.gz flashrom-dd41980f1784c91dd8b30a9074a260621d366c2e.tar.bz2 flashrom-dd41980f1784c91dd8b30a9074a260621d366c2e.zip |
tests/: Assert on NULL heap allocations in tests
Change-Id: Id2adcfe859fb25d2a7f0734655c6b9a58c0890b6
Signed-off-by: Edward O'Callaghan <quasisec@google.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/71919
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
Diffstat (limited to 'tests/chip.c')
-rw-r--r-- | tests/chip.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/tests/chip.c b/tests/chip.c index dc2ca11b..ad0d7701 100644 --- a/tests/chip.c +++ b/tests/chip.c @@ -279,6 +279,7 @@ void read_chip_test_success(void **state) const char *const filename = "read_chip.test"; unsigned long size = mock_chip.total_size * 1024; unsigned char *buf = calloc(size, sizeof(unsigned char)); + assert_non_null(buf); printf("Read chip operation started.\n"); assert_int_equal(0, flashrom_image_read(&flashctx, buf, size)); @@ -316,6 +317,7 @@ void read_chip_with_dummyflasher_test_success(void **state) const char *const filename = "read_chip.test"; unsigned long size = mock_chip.total_size * 1024; unsigned char *buf = calloc(size, sizeof(unsigned char)); + assert_non_null(buf); printf("Read chip operation started.\n"); assert_int_equal(0, flashrom_image_read(&flashctx, buf, size)); @@ -365,6 +367,7 @@ void write_chip_test_success(void **state) const char *const filename = "-"; unsigned long size = mock_chip.total_size * 1024; uint8_t *const newcontents = malloc(size); + assert_non_null(newcontents); printf("Write chip operation started.\n"); assert_int_equal(0, read_buf_from_file(newcontents, size, filename)); @@ -403,6 +406,7 @@ void write_chip_with_dummyflasher_test_success(void **state) const char *const filename = "-"; unsigned long size = mock_chip.total_size * 1024; uint8_t *const newcontents = malloc(size); + assert_non_null(newcontents); printf("Write chip operation started.\n"); assert_int_equal(0, read_buf_from_file(newcontents, size, filename)); @@ -542,6 +546,7 @@ void verify_chip_test_success(void **state) const char *const filename = "-"; unsigned long size = mock_chip.total_size * 1024; uint8_t *const newcontents = malloc(size); + assert_non_null(newcontents); printf("Verify chip operation started.\n"); assert_int_equal(0, read_buf_from_file(newcontents, size, filename)); @@ -581,6 +586,7 @@ void verify_chip_with_dummyflasher_test_success(void **state) const char *const filename = "-"; unsigned long size = mock_chip.total_size * 1024; uint8_t *const newcontents = malloc(size); + assert_non_null(newcontents); /* * Dummyflasher controls chip state and fully emulates reads and writes, |