diff options
Diffstat (limited to 'tests/realtimeGC')
-rw-r--r-- | tests/realtimeGC/cmain.c | 67 | ||||
-rw-r--r-- | tests/realtimeGC/main.nim.cfg | 6 | ||||
-rw-r--r-- | tests/realtimeGC/nmain.nim | 46 | ||||
-rw-r--r-- | tests/realtimeGC/readme.txt | 21 | ||||
-rw-r--r-- | tests/realtimeGC/shared.nim | 5 | ||||
-rw-r--r-- | tests/realtimeGC/shared.nim.cfg | 5 | ||||
-rw-r--r-- | tests/realtimeGC/tmain.nim | 62 |
7 files changed, 62 insertions, 150 deletions
diff --git a/tests/realtimeGC/cmain.c b/tests/realtimeGC/cmain.c deleted file mode 100644 index 0d4bb096a..000000000 --- a/tests/realtimeGC/cmain.c +++ /dev/null @@ -1,67 +0,0 @@ -#ifdef WIN -#include <windows.h> -#else -#include <dlfcn.h> -#include <unistd.h> /* for sleep(3) */ -#endif -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <assert.h> -#include <time.h> - -#define RUNTIME (15*60) - - -typedef void (*pFunc)(void); - -int main(int argc, char* argv[]) -{ - int i; - void* hndl; - pFunc status; - pFunc count; - pFunc checkOccupiedMem; - -#ifdef WIN - hndl = (void*) LoadLibrary((char const*)"./tests/realtimeGC/shared.dll"); - status = (pFunc)GetProcAddress((HMODULE) hndl, (char const*)"status"); - count = (pFunc)GetProcAddress((HMODULE) hndl, (char const*)"count"); - checkOccupiedMem = (pFunc)GetProcAddress((HMODULE) hndl, (char const*)"checkOccupiedMem"); -#else /* OSX || NIX */ - hndl = (void*) dlopen((char const*)"./tests/realtimeGC/libshared.so", RTLD_LAZY); - status = (pFunc) dlsym(hndl, (char const*)"status"); - count = (pFunc) dlsym(hndl, (char const*)"count"); - checkOccupiedMem = (pFunc) dlsym(hndl, (char const*)"checkOccupiedMem"); -#endif - - assert(hndl); - assert(status); - assert(count); - assert(checkOccupiedMem); - - time_t startTime = time((time_t*)0); - time_t runTime = (time_t)(RUNTIME); - time_t accumTime = 0; - while (accumTime < runTime) { - for (i = 0; i < 10; i++) - count(); - /* printf("1. sleeping...\n"); */ - sleep(1); - for (i = 0; i < 10; i++) - status(); - /* printf("2. sleeping...\n"); */ - sleep(1); - checkOccupiedMem(); - accumTime = time((time_t*)0) - startTime; - /* printf("--- Minutes left to run: %d\n", (int)(runTime-accumTime)/60); */ - } - printf("Cleaning up the shared object pointer...\n"); -#ifdef WIN - FreeLibrary((HMODULE)hndl); -#else /* OSX || NIX */ - dlclose(hndl); -#endif - printf("Done\n"); - return 0; -} diff --git a/tests/realtimeGC/main.nim.cfg b/tests/realtimeGC/main.nim.cfg deleted file mode 100644 index fed4fa471..000000000 --- a/tests/realtimeGC/main.nim.cfg +++ /dev/null @@ -1,6 +0,0 @@ - ---app:console ---threads:on - --d:release --d:useRealtimeGC diff --git a/tests/realtimeGC/nmain.nim b/tests/realtimeGC/nmain.nim deleted file mode 100644 index c9f558dbc..000000000 --- a/tests/realtimeGC/nmain.nim +++ /dev/null @@ -1,46 +0,0 @@ -discard """ - cmd: "nim $target --debuginfo $options $file" - output: "Done" -""" - -import times, os, threadpool - -const RUNTIME = 15 * 60 # 15 minutes - -when defined(windows): - const dllname = "./tests/realtimeGC/shared.dll" -elif defined(macosx): - const dllname = "./tests/realtimeGC/libshared.dylib" -else: - const dllname = "./tests/realtimeGC/libshared.so" - -proc status() {.importc: "status", dynlib: dllname.} -proc count() {.importc: "count", dynlib: dllname.} -proc checkOccupiedMem() {.importc: "checkOccupiedMem", dynlib: dllname.} - -proc process() = - let startTime = getTime() - let runTime = cast[Time](RUNTIME) # - var accumTime: Time - while accumTime < runTime: - for i in 0..10: - count() - # echo("1. sleeping... ") - sleep(500) - for i in 0..10: - status() - # echo("2. sleeping... ") - sleep(500) - checkOccupiedMem() - accumTime = cast[Time]((getTime() - startTime)) - # echo("--- Minutes left to run: ", int(int(runTime-accumTime)/60)) - -proc main() = - process() - # parallel: - # for i in 0..0: - # spawn process() - # sync() - echo("Done") - -main() diff --git a/tests/realtimeGC/readme.txt b/tests/realtimeGC/readme.txt deleted file mode 100644 index b2e37a1f0..000000000 --- a/tests/realtimeGC/readme.txt +++ /dev/null @@ -1,21 +0,0 @@ -Test the realtime GC without linking nimrtl.dll/so. - -Note, this is a long running test, default is 35 minutes. To change the -the run time see RUNTIME in nmain.nim and cmain.c. - -You can build shared.nim, nmain.nim, and cmain.c by running make (nix systems) -or make.bat (Windows systems). They both assume GCC and that it's in your -path. Output: shared.(dll/so), cmain(.exe), nmain(.exe). - -To run the test: execute either nmain or cmain in a shell window. - -To build by hand: - - - build the shared object (shared.nim): - - $ nim c tests/realtimeGC/shared.nim - - - build the client executables: - - $ nim c --threads:on tests/realtimeGC/nmain.nim - $ gcc -o tests/realtimeGC/cmain tests/realtimeGC/cmain.c -ldl diff --git a/tests/realtimeGC/shared.nim b/tests/realtimeGC/shared.nim index 1abe42089..8b5c05e47 100644 --- a/tests/realtimeGC/shared.nim +++ b/tests/realtimeGC/shared.nim @@ -1,8 +1,3 @@ -discard """ -cmd: "nim $target --debuginfo --hints:on --app:lib $options $file" -action: compile -""" - import strutils # Global state, accessing with threads, no locks. Don't do this at diff --git a/tests/realtimeGC/shared.nim.cfg b/tests/realtimeGC/shared.nim.cfg deleted file mode 100644 index e153b26fa..000000000 --- a/tests/realtimeGC/shared.nim.cfg +++ /dev/null @@ -1,5 +0,0 @@ ---app:lib ---threads:on - --d:release --d:useRealtimeGC diff --git a/tests/realtimeGC/tmain.nim b/tests/realtimeGC/tmain.nim new file mode 100644 index 000000000..ca0177e3d --- /dev/null +++ b/tests/realtimeGC/tmain.nim @@ -0,0 +1,62 @@ +discard """ + cmd: "nim $target --threads:on -d:release -d:useRealtimeGC $options $file" + joinable:false +""" + +#[ +was: cmd: "nim $target --debuginfo $options $file" +these dont' seem needed --debuginfo +nor these from the previous main.nim.cfg: --app:console +]# + +#[ +Test the realtime GC without linking nimrtl.dll/so. + +To build by hand and run the test for 35 minutes: +`nim r --threads:on -d:runtimeSecs:2100 tests/realtimeGC/tmain.nim` +]# + +import times, os, strformat, strutils +from stdtest/specialpaths import buildDir +# import threadpool + +const runtimeSecs {.intdefine.} = 5 + +const file = "shared.nim" +const dllname = buildDir / (DynlibFormat % "shared_D20210524T180506") + +static: + # D20210524T180826:here we compile the dependency on the fly + let nim = getCurrentCompilerExe() + let (output, exitCode) = gorgeEx(fmt"{nim} c -o:{dllname} --debuginfo --app:lib --threads:on -d:release -d:useRealtimeGC {file}") + doAssert exitCode == 0, output + +proc status() {.importc: "status", dynlib: dllname.} +proc count() {.importc: "count", dynlib: dllname.} +proc checkOccupiedMem() {.importc: "checkOccupiedMem", dynlib: dllname.} + +proc process() = + let startTime = getTime() + let runTime = cast[Time](runtimeSecs) + var accumTime: Time + while accumTime < runTime: + for i in 0..10: + count() + # echo("1. sleeping... ") + sleep(500) + for i in 0..10: + status() + # echo("2. sleeping... ") + sleep(500) + checkOccupiedMem() + accumTime = cast[Time]((getTime() - startTime)) + # echo("--- Minutes left to run: ", int(int(runTime-accumTime)/60)) + +proc main() = + process() + # parallel: + # for i in 0..0: + # spawn process() + # sync() + +main() |