diff options
Diffstat (limited to 'tools/testing/memblock/tests/common.h')
| -rw-r--r-- | tools/testing/memblock/tests/common.h | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/tools/testing/memblock/tests/common.h b/tools/testing/memblock/tests/common.h index c53f9c365714..78128e109a95 100644 --- a/tools/testing/memblock/tests/common.h +++ b/tools/testing/memblock/tests/common.h @@ -12,6 +12,13 @@ #define MEM_SIZE SZ_16K +enum test_flags { + /* No special request. */ + TEST_F_NONE = 0x0, + /* Perform raw allocations (no zeroing of memory). */ + TEST_F_RAW = 0x1, +}; + /** * ASSERT_EQ(): * Check the condition @@ -63,6 +70,18 @@ } \ } while (0) +/** + * ASSERT_MEM_NE(): + * Check that none of the first @_size bytes of @_seen are equal to @_expected. + * If false, print failed test message (if running with --verbose) and then + * assert. + */ +#define ASSERT_MEM_NE(_seen, _expected, _size) do { \ + for (int _i = 0; _i < (_size); _i++) { \ + ASSERT_NE(((char *)_seen)[_i], (_expected)); \ + } \ +} while (0) + #define PREFIX_PUSH() prefix_push(__func__) /* @@ -116,4 +135,12 @@ static inline void run_bottom_up(int (*func)()) prefix_pop(); } +static inline void assert_mem_content(void *mem, int size, int flags) +{ + if (flags & TEST_F_RAW) + ASSERT_MEM_NE(mem, 0, size); + else + ASSERT_MEM_EQ(mem, 0, size); +} + #endif |
