X-Git-Url: http://git.silcnet.org/gitweb/?p=runtime.git;a=blobdiff_plain;f=lib%2Fsilcutil%2Ftests%2Ftest_silcstack.c;h=00d65b1506a5482882bf81fc6dfd34d4b30903ad;hp=34b6fc3fead140a024985a44912668bea998d2cd;hb=a788ad407a51e84cfd41fedc6c053e62283ea2d7;hpb=72c2de619079457f7a68100eb13385275a424a23 diff --git a/lib/silcutil/tests/test_silcstack.c b/lib/silcutil/tests/test_silcstack.c index 34b6fc3f..00d65b15 100644 --- a/lib/silcutil/tests/test_silcstack.c +++ b/lib/silcutil/tests/test_silcstack.c @@ -1,6 +1,6 @@ /* SilcStack tests */ -#include "silc.h" +#include "silcruntime.h" #define NUM_ALLS 300 @@ -22,13 +22,17 @@ int main(int argc, char **argv) stack = silc_stack_alloc(0, NULL); if (!stack) goto err; +#ifdef SILC_DIST_INPLACE silc_stack_stats(stack); +#endif /* SILC_DIST_INPLACE */ SILC_LOG_DEBUG(("Allocating 2048 bytes from stack")); ptr = silc_smalloc(stack, 2048); if (!ptr) goto err; +#ifdef SILC_DIST_INPLACE silc_stack_stats(stack); +#endif /* SILC_DIST_INPLACE */ SILC_LOG_DEBUG(("Freeing the stack")); silc_stack_free(stack); @@ -37,7 +41,9 @@ int main(int argc, char **argv) stack = silc_stack_alloc(0, NULL); if (!stack) goto err; +#ifdef SILC_DIST_INPLACE silc_stack_stats(stack); +#endif /* SILC_DIST_INPLACE */ SILC_LOG_DEBUG(("Pushing and allocating %d times", NUM_ALLS)); if (!silc_stack_push(stack, NULL)) @@ -47,10 +53,14 @@ int main(int argc, char **argv) if (!ptr2) goto err; } +#ifdef SILC_DIST_INPLACE silc_stack_stats(stack); +#endif /* SILC_DIST_INPLACE */ silc_stack_pop(stack); SILC_LOG_DEBUG(("Popping")); +#ifdef SILC_DIST_INPLACE silc_stack_stats(stack); +#endif /* SILC_DIST_INPLACE */ SILC_LOG_DEBUG(("Pushing and allocating %d times", NUM_ALLS)); if (!silc_stack_push(stack, NULL)) @@ -60,10 +70,14 @@ int main(int argc, char **argv) if (!ptr2) goto err; } +#ifdef SILC_DIST_INPLACE silc_stack_stats(stack); +#endif /* SILC_DIST_INPLACE */ silc_stack_pop(stack); SILC_LOG_DEBUG(("Popping")); +#ifdef SILC_DIST_INPLACE silc_stack_stats(stack); +#endif /* SILC_DIST_INPLACE */ SILC_LOG_DEBUG(("Pushing %d times", NUM_ALLS / 2)); for (i = 0; i < NUM_ALLS / 2; i++) { @@ -73,11 +87,15 @@ int main(int argc, char **argv) if (!ptr2) goto err; } +#ifdef SILC_DIST_INPLACE silc_stack_stats(stack); +#endif /* SILC_DIST_INPLACE */ SILC_LOG_DEBUG(("Popping %d times", NUM_ALLS / 2)); for (i = 0; i < NUM_ALLS / 2; i++) silc_stack_pop(stack); +#ifdef SILC_DIST_INPLACE silc_stack_stats(stack); +#endif /* SILC_DIST_INPLACE */ SILC_LOG_DEBUG(("Pushing and reallocating %d times", NUM_ALLS / 10)); ptr2 = NULL; @@ -88,10 +106,14 @@ int main(int argc, char **argv) if (!ptr2) goto err; } +#ifdef SILC_DIST_INPLACE silc_stack_stats(stack); +#endif /* SILC_DIST_INPLACE */ silc_stack_pop(stack); SILC_LOG_DEBUG(("Popping")); +#ifdef SILC_DIST_INPLACE silc_stack_stats(stack); +#endif /* SILC_DIST_INPLACE */ SILC_LOG_DEBUG(("Creating child stack")); child = silc_stack_alloc(8190, stack); @@ -105,11 +127,15 @@ int main(int argc, char **argv) if (!ptr2) goto err; } +#ifdef SILC_DIST_INPLACE silc_stack_stats(child); +#endif /* SILC_DIST_INPLACE */ SILC_LOG_DEBUG(("Popping %d times", NUM_ALLS / 2)); for (i = 0; i < NUM_ALLS / 2; i++) silc_stack_pop(child); +#ifdef SILC_DIST_INPLACE silc_stack_stats(child); +#endif /* SILC_DIST_INPLACE */ SILC_LOG_DEBUG(("Pushing and reallocating %d times", NUM_ALLS / 10)); ptr2 = NULL; @@ -121,13 +147,21 @@ int main(int argc, char **argv) goto err; } ptr = silc_smalloc(child, 100000); +#ifdef SILC_DIST_INPLACE silc_stack_stats(child); +#endif /* SILC_DIST_INPLACE */ silc_stack_pop(child); SILC_LOG_DEBUG(("Popping")); +#ifdef SILC_DIST_INPLACE silc_stack_stats(child); +#endif /* SILC_DIST_INPLACE */ +#ifdef SILC_DIST_INPLACE silc_stack_stats(stack); +#endif /* SILC_DIST_INPLACE */ silc_stack_free(child); +#ifdef SILC_DIST_INPLACE silc_stack_stats(stack); +#endif /* SILC_DIST_INPLACE */ SILC_LOG_DEBUG(("Creating child stack")); child = silc_stack_alloc(8192, stack); @@ -141,11 +175,15 @@ int main(int argc, char **argv) if (!ptr2) goto err; } +#ifdef SILC_DIST_INPLACE silc_stack_stats(child); +#endif /* SILC_DIST_INPLACE */ SILC_LOG_DEBUG(("Popping %d times", NUM_ALLS / 10)); for (i = 0; i < NUM_ALLS / 10; i++) silc_stack_pop(child); +#ifdef SILC_DIST_INPLACE silc_stack_stats(child); +#endif /* SILC_DIST_INPLACE */ SILC_LOG_DEBUG(("Pushing and reallocating %d times", NUM_ALLS / 10)); ptr2 = NULL; @@ -159,19 +197,31 @@ int main(int argc, char **argv) SILC_LOG_DEBUG(("Allocate child from child")); child2 = silc_stack_alloc(0, child); ptr = silc_smalloc(child2, 500000); +#ifdef SILC_DIST_INPLACE silc_stack_stats(child2); +#endif /* SILC_DIST_INPLACE */ silc_stack_free(child2); - silc_stack_stats(child); +#ifdef SILC_DIST_INPLACE + silc_stack_stats(child2); +#endif /* SILC_DIST_INPLACE */ silc_stack_pop(child); SILC_LOG_DEBUG(("Popping")); +#ifdef SILC_DIST_INPLACE silc_stack_stats(child); +#endif /* SILC_DIST_INPLACE */ +#ifdef SILC_DIST_INPLACE silc_stack_stats(stack); +#endif /* SILC_DIST_INPLACE */ silc_stack_free(child); +#ifdef SILC_DIST_INPLACE silc_stack_stats(stack); +#endif /* SILC_DIST_INPLACE */ SILC_LOG_DEBUG(("Purge stack")); silc_stack_purge(stack); +#ifdef SILC_DIST_INPLACE silc_stack_stats(stack); +#endif /* SILC_DIST_INPLACE */ SILC_LOG_DEBUG(("Current alignment: %d", silc_stack_get_alignment(stack))); SILC_LOG_DEBUG(("Set alignemtn to 16")); @@ -203,5 +253,5 @@ int main(int argc, char **argv) SILC_LOG_DEBUG(("Testing was %s", success ? "SUCCESS" : "FAILURE")); fprintf(stderr, "Testing was %s\n", success ? "SUCCESS" : "FAILURE"); - return success; + return !success; }