[COMMIT osv master] tst-realloc: test malloc_usable_size() only when running with OSv libc

2 views
Skip to first unread message

Commit Bot

unread,
Dec 14, 2023, 11:32:51 PM12/14/23
to osv...@googlegroups.com, Waldemar Kozaczuk
From: Waldemar Kozaczuk <jwkoz...@gmail.com>
Committer: Waldemar Kozaczuk <jwkoz...@gmail.com>
Branch: master

tst-realloc: test malloc_usable_size() only when running with OSv libc

The results returned malloc_usable_size() are very much dependant
on the malloc() implementation. Let us disable this part of the
tst-realloc.c when built with glibc.

As of this commit, most of the unit tests should pass when running on OSv
with Linux dynamic linker:

scripts/test.py --linux_ld -m modules/tests-with-linux-ld/usr.manifest \
-d tst-futimesat \
-d tst-kill \
-d tst-mmap \
-d tst-pthread-clock \
-d tst-reloc \
-d tst-shm \
-d tst-sigaction \
-d tst-sigwait \
-d tst-stdio-rofs \
-d tst-symlink \
-d tst-symlink-rofs \
-d tst-time \
-d tst-truncate \
-d tst-utimensat \
-d tst-utimes \
-d tst-wctype

Signed-off-by: Waldemar Kozaczuk <jwkoz...@gmail.com>

---
diff --git a/tests/tst-realloc.cc b/tests/tst-realloc.cc
--- a/tests/tst-realloc.cc
+++ b/tests/tst-realloc.cc
@@ -38,6 +38,7 @@ static void test_realloc(size_t original_size, size_t new_size)
std::cerr << "PASSED realloc() for original_size: " << original_size << ", new_size: " << new_size << std::endl;
}

+#ifdef __OSV__
static void test_usable_size(size_t size, size_t expected_usable_size)
{
void* ptr = malloc(size);
@@ -46,6 +47,7 @@ static void test_usable_size(size_t size, size_t expected_usable_size)

std::cerr << "PASSED malloc_usable_size() for size: " << size << std::endl;
}
+#endif

int main()
{
@@ -82,13 +84,15 @@ int main()
buf = malloc(16);
assert(!realloc(buf, 0));

+#ifdef __OSV__
test_usable_size(1, 8);
test_usable_size(8, 8);
test_usable_size(67, 128);
test_usable_size(0x4010, 0x4FC0);
test_usable_size(0x100000, 0x100FC0);
test_usable_size(0x200000, 0x200FC0);
+#endif

std::cerr << "PASSED\n";
return 0;
-}
\ No newline at end of file
+}
Reply all
Reply to author
Forward
0 new messages