[PATCH v2] testsuite,clang: fix malloc04 and malloctest for on clang

Daniel Hellstrom daniel at gaisler.com
Fri Oct 5 07:57:25 UTC 2018


malloc04 and malloctest tests from the rtems test-suite fails
when checking the return value of malloc(). The check is
optimized away and always fails.
---
 testsuites/libtests/malloc04/init.c   | 6 ++++++
 testsuites/libtests/malloctest/init.c | 1 +
 2 files changed, 7 insertions(+)

diff --git a/testsuites/libtests/malloc04/init.c b/testsuites/libtests/malloc04/init.c
index 632ea28..e3fb3b8 100644
--- a/testsuites/libtests/malloc04/init.c
+++ b/testsuites/libtests/malloc04/init.c
@@ -99,6 +99,7 @@ rtems_task Init(
 
   errno = 0;
   p = malloc( 256 );
+  RTEMS_OBFUSCATE_VARIABLE( p );
   rtems_test_assert( p == NULL );
   rtems_test_assert( errno == ENOMEM );
   rtems_test_assert( sbrk_count == 0 );
@@ -118,6 +119,7 @@ rtems_task Init(
   rtems_test_assert( sbrk_count == 0 );
 
   p = malloc(257);
+  RTEMS_OBFUSCATE_VARIABLE( p );
   rtems_test_assert( p != NULL );
   rtems_test_assert( sbrk_count == 1 );
 
@@ -131,6 +133,7 @@ rtems_task Init(
 
   errno = 0;
   p = malloc( sizeof( Malloc_Heap ) );
+  RTEMS_OBFUSCATE_VARIABLE( p );
   rtems_test_assert( p == NULL );
   rtems_test_assert( errno == ENOMEM );
   rtems_test_assert( sbrk_count == 1 );
@@ -144,10 +147,12 @@ rtems_task Init(
   RTEMS_Malloc_Initialize( &area, 1, NULL );
 
   p = malloc( 128 );
+  RTEMS_OBFUSCATE_VARIABLE( p );
   rtems_test_assert( p != NULL );
   rtems_test_assert( sbrk_count == 0 );
 
   p = malloc( 128 );
+  RTEMS_OBFUSCATE_VARIABLE( p );
   rtems_test_assert( p != NULL );
   rtems_test_assert( sbrk_count == 1 );
 
@@ -161,6 +166,7 @@ rtems_task Init(
 
   errno = 0;
   p = malloc( 256 );
+  RTEMS_OBFUSCATE_VARIABLE( p );
   rtems_test_assert( p == NULL );
   rtems_test_assert( errno == ENOMEM );
   rtems_test_assert( sbrk_count == 2 );
diff --git a/testsuites/libtests/malloctest/init.c b/testsuites/libtests/malloctest/init.c
index 577f557..89b56f8 100644
--- a/testsuites/libtests/malloctest/init.c
+++ b/testsuites/libtests/malloctest/init.c
@@ -1400,6 +1400,7 @@ static void test_early_malloc( void )
   rtems_test_assert( r == q );
 
   s = malloc( 1 );
+  RTEMS_OBFUSCATE_VARIABLE( s );
   rtems_test_assert( s != NULL );
 
   free( s );
-- 
2.7.4



More information about the devel mailing list