compare with negative integers to check signals

pull/107/head
Daniel Micay 2020-04-11 15:26:24 -04:00
parent d757835d90
commit c75dcb9d9c
1 changed files with 22 additions and 22 deletions

View File

@ -18,33 +18,33 @@ class TestSimpleMemoryCorruption(unittest.TestCase):
def test_delete_type_size_mismatch(self): def test_delete_type_size_mismatch(self):
_stdout, stderr, returncode = self.run_test( _stdout, stderr, returncode = self.run_test(
"delete_type_size_mismatch") "delete_type_size_mismatch")
self.assertEqual(abs(returncode), 6) self.assertEqual(returncode, -6)
self.assertEqual(stderr.decode( self.assertEqual(stderr.decode(
"utf-8"), "fatal allocator error: sized deallocation mismatch (small)\n") "utf-8"), "fatal allocator error: sized deallocation mismatch (small)\n")
def test_double_free_large_delayed(self): def test_double_free_large_delayed(self):
_stdout, stderr, returncode = self.run_test( _stdout, stderr, returncode = self.run_test(
"double_free_large_delayed") "double_free_large_delayed")
self.assertEqual(abs(returncode), 6) self.assertEqual(returncode, -6)
self.assertEqual(stderr.decode("utf-8"), self.assertEqual(stderr.decode("utf-8"),
"fatal allocator error: invalid free\n") "fatal allocator error: invalid free\n")
def test_double_free_large(self): def test_double_free_large(self):
_stdout, stderr, returncode = self.run_test("double_free_large") _stdout, stderr, returncode = self.run_test("double_free_large")
self.assertEqual(abs(returncode), 6) self.assertEqual(returncode, -6)
self.assertEqual(stderr.decode("utf-8"), self.assertEqual(stderr.decode("utf-8"),
"fatal allocator error: invalid free\n") "fatal allocator error: invalid free\n")
def test_double_free_small_delayed(self): def test_double_free_small_delayed(self):
_stdout, stderr, returncode = self.run_test( _stdout, stderr, returncode = self.run_test(
"double_free_small_delayed") "double_free_small_delayed")
self.assertEqual(abs(returncode), 6) self.assertEqual(returncode, -6)
self.assertEqual(stderr.decode("utf-8"), self.assertEqual(stderr.decode("utf-8"),
"fatal allocator error: double free (quarantine)\n") "fatal allocator error: double free (quarantine)\n")
def test_double_free_small(self): def test_double_free_small(self):
_stdout, stderr, returncode = self.run_test("double_free_small") _stdout, stderr, returncode = self.run_test("double_free_small")
self.assertEqual(abs(returncode), 6) self.assertEqual(returncode, -6)
self.assertEqual(stderr.decode("utf-8"), self.assertEqual(stderr.decode("utf-8"),
"fatal allocator error: double free (quarantine)\n") "fatal allocator error: double free (quarantine)\n")
@ -56,39 +56,39 @@ class TestSimpleMemoryCorruption(unittest.TestCase):
def test_eight_byte_overflow_small(self): def test_eight_byte_overflow_small(self):
_stdout, stderr, returncode = self.run_test( _stdout, stderr, returncode = self.run_test(
"eight_byte_overflow_small") "eight_byte_overflow_small")
self.assertEqual(abs(returncode), 6) self.assertEqual(returncode, -6)
self.assertEqual(stderr.decode("utf-8"), self.assertEqual(stderr.decode("utf-8"),
"fatal allocator error: canary corrupted\n") "fatal allocator error: canary corrupted\n")
def test_invalid_free_protected(self): def test_invalid_free_protected(self):
_stdout, stderr, returncode = self.run_test("invalid_free_protected") _stdout, stderr, returncode = self.run_test("invalid_free_protected")
self.assertEqual(abs(returncode), 6) self.assertEqual(returncode, -6)
self.assertEqual(stderr.decode("utf-8"), self.assertEqual(stderr.decode("utf-8"),
"fatal allocator error: invalid free\n") "fatal allocator error: invalid free\n")
def test_invalid_free_small_region_far(self): def test_invalid_free_small_region_far(self):
_stdout, stderr, returncode = self.run_test( _stdout, stderr, returncode = self.run_test(
"invalid_free_small_region_far") "invalid_free_small_region_far")
self.assertEqual(abs(returncode), 6) self.assertEqual(returncode, -6)
self.assertEqual(stderr.decode( self.assertEqual(stderr.decode(
"utf-8"), "fatal allocator error: invalid free within a slab yet to be used\n") "utf-8"), "fatal allocator error: invalid free within a slab yet to be used\n")
def test_invalid_free_small_region(self): def test_invalid_free_small_region(self):
_stdout, stderr, returncode = self.run_test( _stdout, stderr, returncode = self.run_test(
"invalid_free_small_region") "invalid_free_small_region")
self.assertEqual(abs(returncode), 6) self.assertEqual(returncode, -6)
self.assertEqual(stderr.decode("utf-8"), self.assertEqual(stderr.decode("utf-8"),
"fatal allocator error: double free\n") "fatal allocator error: double free\n")
def test_invalid_free_unprotected(self): def test_invalid_free_unprotected(self):
_stdout, stderr, returncode = self.run_test("invalid_free_unprotected") _stdout, stderr, returncode = self.run_test("invalid_free_unprotected")
self.assertEqual(abs(returncode), 6) self.assertEqual(returncode, -6)
self.assertEqual(stderr.decode("utf-8"), self.assertEqual(stderr.decode("utf-8"),
"fatal allocator error: invalid free\n") "fatal allocator error: invalid free\n")
def test_read_after_free_large(self): def test_read_after_free_large(self):
_stdout, _stderr, returncode = self.run_test("read_after_free_large") _stdout, _stderr, returncode = self.run_test("read_after_free_large")
self.assertEqual(abs(returncode), 11) self.assertEqual(returncode, -11)
def test_read_after_free_small(self): def test_read_after_free_small(self):
stdout, _stderr, returncode = self.run_test("read_after_free_small") stdout, _stderr, returncode = self.run_test("read_after_free_small")
@ -98,7 +98,7 @@ class TestSimpleMemoryCorruption(unittest.TestCase):
def test_read_zero_size(self): def test_read_zero_size(self):
_stdout, _stderr, returncode = self.run_test("read_zero_size") _stdout, _stderr, returncode = self.run_test("read_zero_size")
self.assertEqual(abs(returncode), 11) self.assertEqual(returncode, -11)
def test_string_overflow(self): def test_string_overflow(self):
stdout, _stderr, returncode = self.run_test("string_overflow") stdout, _stderr, returncode = self.run_test("string_overflow")
@ -107,58 +107,58 @@ class TestSimpleMemoryCorruption(unittest.TestCase):
def test_unaligned_free_large(self): def test_unaligned_free_large(self):
_stdout, stderr, returncode = self.run_test("unaligned_free_large") _stdout, stderr, returncode = self.run_test("unaligned_free_large")
self.assertEqual(abs(returncode), 6) self.assertEqual(returncode, -6)
self.assertEqual(stderr.decode("utf-8"), self.assertEqual(stderr.decode("utf-8"),
"fatal allocator error: invalid free\n") "fatal allocator error: invalid free\n")
def test_unaligned_free_small(self): def test_unaligned_free_small(self):
_stdout, stderr, returncode = self.run_test("unaligned_free_small") _stdout, stderr, returncode = self.run_test("unaligned_free_small")
self.assertEqual(abs(returncode), 6) self.assertEqual(returncode, -6)
self.assertEqual(stderr.decode("utf-8"), self.assertEqual(stderr.decode("utf-8"),
"fatal allocator error: invalid unaligned free\n") "fatal allocator error: invalid unaligned free\n")
def test_uninitialized_free(self): def test_uninitialized_free(self):
_stdout, stderr, returncode = self.run_test("uninitialized_free") _stdout, stderr, returncode = self.run_test("uninitialized_free")
self.assertEqual(abs(returncode), 6) self.assertEqual(returncode, -6)
self.assertEqual(stderr.decode("utf-8"), self.assertEqual(stderr.decode("utf-8"),
"fatal allocator error: invalid free\n") "fatal allocator error: invalid free\n")
def test_uninitialized_malloc_usable_size(self): def test_uninitialized_malloc_usable_size(self):
_stdout, _stderr, returncode = self.run_test( _stdout, _stderr, returncode = self.run_test(
"uninitialized_malloc_usable_size") "uninitialized_malloc_usable_size")
self.assertEqual(abs(returncode), 11) self.assertEqual(returncode, -11)
def test_uninitialized_realloc(self): def test_uninitialized_realloc(self):
_stdout, stderr, returncode = self.run_test("uninitialized_realloc") _stdout, stderr, returncode = self.run_test("uninitialized_realloc")
self.assertEqual(abs(returncode), 6) self.assertEqual(returncode, -6)
self.assertEqual(stderr.decode("utf-8"), self.assertEqual(stderr.decode("utf-8"),
"fatal allocator error: invalid realloc\n") "fatal allocator error: invalid realloc\n")
def test_write_after_free_large_reuse(self): def test_write_after_free_large_reuse(self):
_stdout, _stderr, returncode = self.run_test( _stdout, _stderr, returncode = self.run_test(
"write_after_free_large_reuse") "write_after_free_large_reuse")
self.assertEqual(abs(returncode), 11) self.assertEqual(returncode, -11)
def test_write_after_free_large(self): def test_write_after_free_large(self):
_stdout, _stderr, returncode = self.run_test("write_after_free_large") _stdout, _stderr, returncode = self.run_test("write_after_free_large")
self.assertEqual(abs(returncode), 11) self.assertEqual(returncode, -11)
def test_write_after_free_small_reuse(self): def test_write_after_free_small_reuse(self):
_stdout, stderr, returncode = self.run_test( _stdout, stderr, returncode = self.run_test(
"write_after_free_small_reuse") "write_after_free_small_reuse")
self.assertEqual(abs(returncode), 6) self.assertEqual(returncode, -6)
self.assertEqual(stderr.decode("utf-8"), self.assertEqual(stderr.decode("utf-8"),
"fatal allocator error: detected write after free\n") "fatal allocator error: detected write after free\n")
def test_write_after_free_small(self): def test_write_after_free_small(self):
_stdout, stderr, returncode = self.run_test("write_after_free_small") _stdout, stderr, returncode = self.run_test("write_after_free_small")
self.assertEqual(abs(returncode), 6) self.assertEqual(returncode, -6)
self.assertEqual(stderr.decode("utf-8"), self.assertEqual(stderr.decode("utf-8"),
"fatal allocator error: detected write after free\n") "fatal allocator error: detected write after free\n")
def test_write_zero_size(self): def test_write_zero_size(self):
_stdout, _stderr, returncode = self.run_test("write_zero_size") _stdout, _stderr, returncode = self.run_test("write_zero_size")
self.assertEqual(abs(returncode), 11) self.assertEqual(returncode, -11)
if __name__ == '__main__': if __name__ == '__main__':