diff options
author | Jon Bratseth <bratseth@yahoo-inc.com> | 2016-06-15 23:09:44 +0200 |
---|---|---|
committer | Jon Bratseth <bratseth@yahoo-inc.com> | 2016-06-15 23:09:44 +0200 |
commit | 72231250ed81e10d66bfe70701e64fa5fe50f712 (patch) | |
tree | 2728bba1131a6f6e5bdf95afec7d7ff9358dac50 /vespamalloc/src/tests/test.cpp |
Publish
Diffstat (limited to 'vespamalloc/src/tests/test.cpp')
-rw-r--r-- | vespamalloc/src/tests/test.cpp | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/vespamalloc/src/tests/test.cpp b/vespamalloc/src/tests/test.cpp new file mode 100644 index 00000000000..24acb3368d8 --- /dev/null +++ b/vespamalloc/src/tests/test.cpp @@ -0,0 +1,62 @@ +// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +#include <stdio.h> +#include <stdlib.h> +#include <vespa/fastos/fastos.h> + +namespace vespamalloc { +void info(); +} + +void testbigblocks(size_t count, size_t sz) +{ + for (size_t i=0; i < count; i++) { + char * a = new char[sz]; + delete [] a; + a = new char [sz-1]; + delete [] a; + } +} + +void testdd() +{ + char * a = (char *)malloc(0x1003); + free(a); +} + +class Thread : public FastOS_Runnable +{ +private: + void Run(FastOS_ThreadInterface * ti, void * arg); +}; + +int main(int, char *[]) +{ + FastOS_ThreadPool threadPool(512*1024); + printf("Main stack(%p)\n", &threadPool); + Thread context; + + FastOS_ThreadInterface * th[4]; + for (size_t i=0; i<sizeof(th)/sizeof(th[0]); i++) { + th[i] = threadPool.NewThread(&context); + } + for (size_t i=0; i<sizeof(th)/sizeof(th[0]); i++) { + th[i]->Join(); + delete th[i]; + } + + return 0; +} + +void Thread::Run(FastOS_ThreadInterface *, void *) +{ + char * a = new char [100]; + delete [] a; + char * b; + + testbigblocks(1, 0x800003); + testbigblocks(64000, 0x200003); + for (size_t i=0; i<100;i++) a = new char[400]; + testdd(); + b = new char[200]; + (void)b; +} |