From 539937336d6d0c6a9704b74dbd39ebb9e79bbb90 Mon Sep 17 00:00:00 2001 From: Robert Norton Date: Mon, 7 Feb 2022 16:36:51 +0000 Subject: [PATCH] Extend malloc test to check CHERI capability length. --- src/test/func/malloc/malloc.cc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/test/func/malloc/malloc.cc b/src/test/func/malloc/malloc.cc index 6aa8ae9..9fa1aef 100644 --- a/src/test/func/malloc/malloc.cc +++ b/src/test/func/malloc/malloc.cc @@ -44,6 +44,15 @@ void check_result(size_t size, size_t align, void* p, int err, bool null) const auto exact_size = false; #else const auto exact_size = align == 1; +#endif +#ifdef __CHERI_PURE_CAPABILITY__ + const auto cheri_size = __builtin_cheri_length_get(p); + if (cheri_size != alloc_size && (size != 0)) + { + printf( + "Cheri size is %zu, but required to be %zu.\n", cheri_size, alloc_size); + failed = true; + } #endif if (exact_size && (alloc_size != expected_size) && (size != 0)) {