Loading...
--- libmalloc/libmalloc-646.40.3/tests/stress_test.c
+++ libmalloc/libmalloc-166.200.60/tests/stress_test.c
@@ -30,30 +30,11 @@
 #include <string.h>
 #include <time.h>
 #include <errno.h>
-
-#include "../src/platform.h"
-
-#if !MALLOC_TARGET_EXCLAVES
 #include <err.h>
-#endif // !MALLOC_TARGET_EXCLAVES
 
 #if DARWINTEST
 #include <darwintest.h>
-T_GLOBAL_META(T_META_RUN_CONCURRENTLY(true), T_META_TAG_XZONE, T_META_TAG_VM_NOT_PREFERRED);
-#endif
-
-static time_t time_seconds(void) {
-#if !MALLOC_TARGET_EXCLAVES
-	return time(0);
-#else
-	struct timespec t;
-	int rc = clock_gettime(CLOCK_MONOTONIC_RAW, &t);
-	if (rc) {
-		return -1;
-	}
-	return t.tv_sec;
-#endif // !MALLOC_TARGET_EXCLAVES
-}
+#endif
 
 /* globals */
 int rseed;	 /* initial random seed value */
@@ -87,7 +68,6 @@
 /* Generate a random percentage (1-100) */
 #define D100 (1 + (rand() % 100))
 
-#if !MALLOC_TARGET_EXCLAVES
 int signal_happened = 0; /* gets set to signal# if one happens */
 
 void
@@ -111,7 +91,6 @@
 		};
 	}
 }
-#endif // !MALLOC_TARGET_EXCLAVES
 
 /* Display a brief usage message and exit with status 99 */
 void
@@ -174,7 +153,6 @@
 	for (mx = 0; mx < malloc_calls_made; mx++) {
 		if (!(minfo_array[mx].this_buffer_freed)) {
 			free(minfo_array[mx].buf_ptr);
-#if !MALLOC_TARGET_EXCLAVES
 			if (signal_happened) {
 #if DARWINTEST
 				T_FAIL("Signal %d occurred during free(0x%llx)", signal_happened, (unsigned long long)(minfo_array[mx].buf_ptr));
@@ -184,7 +162,6 @@
 				exit(1);
 #endif
 			}
-#endif // !MALLOC_TARGET_EXCLAVES
 		}
 	}
 	return;
@@ -235,7 +212,7 @@
 	mem_allocated = 0;
 
 	/* Set defaults */
-	rseed = (int)time_seconds();
+	rseed = (int)time(0);
 	min_bytes = 1;
 	max_bytes = (1024 * 1024);			/* 1mb */
 	max_mem = 0;						/* Continue until malloc() returns NULL */
@@ -357,15 +334,10 @@
 void
 do_test(void)
 {
-	time_t start_time = time_seconds();
-#if DARWINTEST
-	T_ASSERT_NE(start_time, -1, "Failed to get start time");
-#endif // DARWINTEST
-
-#if !MALLOC_TARGET_EXCLAVES
+	time_t start_time = time(0);
+
 	/* Trap all signals that are possible to trap */
 	trap_signals();
-#endif // !MALLOC_TARGET_EXCLAVES
 
 	/*
 	 * Loop until we have some reason to quit.
@@ -378,7 +350,7 @@
 		int save_errno;
 
 		/* Have we exceeded our execution time limit? */
-		if (time_limit > 0 && (time_seconds() - start_time >= time_limit)) {
+		if (time_limit > 0 && (time(0) - start_time >= time_limit)) {
 #if DARWINTEST
 			cleanup();
 			T_PASS("Ran until time limit without incident.");
@@ -402,7 +374,6 @@
 				random_buf = rand() % malloc_calls_made;
 				if (!(minfo_array[random_buf].this_buffer_freed)) {
 					free(minfo_array[random_buf].buf_ptr);
-#if !MALLOC_TARGET_EXCLAVES
 					/* If a signal happened, Fail */
 					if (signal_happened) {
 #if DARWINTEST
@@ -416,7 +387,6 @@
 						exit(1);
 #endif
 					}
-#endif // !MALLOC_TARGET_EXCLAVES
 
 					minfo_array[random_buf].this_buffer_freed = 1;
 					malloc_bufs--; /* decrease the count of allocated bufs */
@@ -438,7 +408,6 @@
 		malloc_buf = malloc(buf_size);
 		save_errno = errno;
 
-#if !MALLOC_TARGET_EXCLAVES
 		/* If a signal was caught, summarize and FAIL */
 		if (signal_happened) {
 #if DARWINTEST
@@ -451,7 +420,6 @@
 			exit(1);
 #endif
 		}
-#endif // !MALLOC_TARGET_EXCLAVES
 
 		if (debug_dump) {
 			printf("INFO: Allocated buffer (%d bytes) at address 0x%llx\n", buf_size, (unsigned long long)malloc_buf);
@@ -512,7 +480,6 @@
 			char byte;
 			*((volatile char *)&byte) = *((volatile char *)malloc_buf + bx);
 
-#if !MALLOC_TARGET_EXCLAVES
 			if (signal_happened) {
 #if DARWINTEST
 				T_FAIL("Signal %d caught reading buffer!", signal_happened);
@@ -523,7 +490,6 @@
 				exit(1);
 #endif
 			}
-#endif // !MALLOC_TARGET_EXCLAVES
 		}
 
 		/*
@@ -562,7 +528,6 @@
 			*((long double *)malloc_buf) = 7.2;
 		}
 
-#if !MALLOC_TARGET_EXCLAVES
 		if (signal_happened) {
 #if DARWINTEST
 			T_FAIL("Signal %d occurred storing numeric types at address 0x%llx (%d bytes)", signal_happened,
@@ -575,12 +540,10 @@
 			exit(1);
 #endif
 		}
-#endif // !MALLOC_TARGET_EXCLAVES
 
 		/* Pick a random byte value to set the bytes of the buffer to */
 		set_buf_val = rand() & 0xFF;
 		memset(malloc_buf, set_buf_val, buf_size);
-#if !MALLOC_TARGET_EXCLAVES
 		if (signal_happened) {
 #if DARWINTEST
 			T_FAIL("Signal %d caught initializing buffer to byte value %d!", signal_happened, set_buf_val);
@@ -591,7 +554,6 @@
 			exit(1);
 #endif
 		}
-#endif // !MALLOC_TARGET_EXCLAVES
 
 		/* Save the new malloc info */
 
@@ -660,7 +622,6 @@
 				}
 			}
 
-#if !MALLOC_TARGET_EXCLAVES
 			/* If any signal occurred, that's a FAIL too. */
 			if (signal_happened) {
 #if DARWINTEST
@@ -672,7 +633,6 @@
 				exit(1);
 #endif
 			}
-#endif // !MALLOC_TARGET_EXCLAVES
 
 		} /* end then malloc succeeded */
 
@@ -695,9 +655,7 @@
 	time_limit = 15;
 	
 	debug_dump = 0;
-
-	malloc_calls_made = 0;
-
+	
 	do_test();
 }
 
@@ -706,31 +664,25 @@
 	setup_and_test();
 }
 
-T_DECL(malloc_stress_nano, "Stress the heck out of malloc() with nano",
-		T_META_ENVVAR("MallocNanoZone=1"), T_META_TAG_NANO_ON_XZONE)
+T_DECL(malloc_stress_msl_full, "Stress the heck out of malloc() - enable malloc stack logging, full mode", T_META_ENVVAR("MallocStackLogging=1"))
 {
 	setup_and_test();
 }
 
-T_DECL(malloc_stress_msl_full, "Stress the heck out of malloc() - enable malloc stack logging, full mode", T_META_ENVVAR("MallocStackLogging=1"))
+T_DECL(malloc_stress_msl_malloc, "Stress the heck out of malloc() - enable malloc stack logging, malloc mode", T_META_ENVVAR("MallocStackLogging=malloc"))
 {
 	setup_and_test();
 }
 
-T_DECL(malloc_stress_msl_malloc, "Stress the heck out of malloc() - enable malloc stack logging, malloc mode", T_META_ENVVAR("MallocStackLogging=malloc"))
+T_DECL(malloc_stress_msl_vm, "Stress the heck out of malloc() - enable malloc stack logging, vm mode", T_META_ENVVAR("MallocStackLogging=vm"))
 {
 	setup_and_test();
 }
 
-T_DECL(malloc_stress_msl_vm, "Stress the heck out of malloc() - enable malloc stack logging, vm mode", T_META_ENVVAR("MallocStackLogging=vm"))
+T_DECL(malloc_stress_msl_lite, "Stress the heck out of malloc() - enable malloc stack logging, lite mode", T_META_ENVVAR("MallocStackLogging=lite"))
 {
 	setup_and_test();
 }
 
-T_DECL(malloc_stress_msl_lite, "Stress the heck out of malloc() - enable malloc stack logging, lite mode", T_META_ENVVAR("MallocStackLogging=lite"))
-{
-	setup_and_test();
-}
-
-
-#endif
+
+#endif