Test assumptions we make about the platform
Things that are not guaranteed by the standard but should be true of all
platforms of interest to us:
- 8-bit chars
- NULL pointers represented by all-bits-zero
diff --git a/tests/suites/main_test.function b/tests/suites/main_test.function
index ecd5182..f1ef917 100644
--- a/tests/suites/main_test.function
+++ b/tests/suites/main_test.function
@@ -216,6 +216,7 @@
FILE *file;
char buf[5000];
char *params[50];
+ void *pointer;
#if defined(MBEDTLS_MEMORY_BUFFER_ALLOC_C) && \
!defined(TEST_SUITE_MEMORY_BUFFER_ALLOC)
@@ -223,6 +224,18 @@
mbedtls_memory_buffer_alloc_init( alloc_buf, sizeof(alloc_buf) );
#endif
+ /*
+ * The C standard doesn't guarantee that all-bits-0 is the representation
+ * of a NULL pointer. We do however use that in our code for initializing
+ * structures, which should work on every modern platform. Let's be sure.
+ */
+ memset( &pointer, 0, sizeof( void * ) );
+ if( pointer != NULL )
+ {
+ mbedtls_fprintf( stderr, "all-bits-zero is not a NULL pointer\n" );
+ return( 1 );
+ }
+
file = fopen( filename, "r" );
if( file == NULL )
{