Skip to content

Commit 1f34ec9

Browse files
thomasbuildsthestinger
authored andcommitted
fix stale zero size allocation tests and missing test coverage
1 parent ff431a4 commit 1f34ec9

4 files changed

Lines changed: 25 additions & 2 deletions

File tree

test/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ invalid_malloc_usable_size_small
3131
invalid_malloc_usable_size_small_quarantine
3232
malloc_object_size
3333
malloc_object_size_offset
34+
malloc_object_size_zero
3435
invalid_malloc_object_size_small
3536
invalid_malloc_object_size_small_quarantine
3637
impossibly_large_malloc
@@ -41,4 +42,6 @@ overflow_small_8_byte
4142
uninitialized_read_large
4243
uninitialized_read_small
4344
realloc_init
45+
malloc_zero_different
46+
malloc_noreuse
4447
__pycache__/

test/malloc_object_size_zero.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ size_t malloc_object_size(void *ptr);
88
OPTNONE int main(void) {
99
char *p = malloc(0);
1010
size_t size = malloc_object_size(p);
11-
return size == 0;
11+
return size != 0;
1212
}

test/malloc_zero_different.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@
66
OPTNONE int main(void) {
77
char *p = malloc(0);
88
char *q = malloc(0);
9-
return p != q;
9+
return p == q;
1010
}

test/test_smc.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,5 +238,25 @@ def test_realloc_init(self):
238238
"realloc_init")
239239
self.assertEqual(returncode, 0)
240240

241+
def test_large_array_growth(self):
242+
_stdout, _stderr, returncode = self.run_test(
243+
"large_array_growth")
244+
self.assertEqual(returncode, 0)
245+
246+
def test_malloc_object_size_zero(self):
247+
_stdout, _stderr, returncode = self.run_test(
248+
"malloc_object_size_zero")
249+
self.assertEqual(returncode, 0)
250+
251+
def test_malloc_zero_different(self):
252+
_stdout, _stderr, returncode = self.run_test(
253+
"malloc_zero_different")
254+
self.assertEqual(returncode, 0)
255+
256+
def test_malloc_noreuse(self):
257+
_stdout, _stderr, returncode = self.run_test(
258+
"malloc_noreuse")
259+
self.assertEqual(returncode, 0)
260+
241261
if __name__ == '__main__':
242262
unittest.main()

0 commit comments

Comments
 (0)