error instead of echo when testament category is empty; fix realtimeGC (#16162)

This commit is contained in:
Timothee Cour 2020-12-01 11:34:53 -08:00 • committed by GitHub
commit fd98705680
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 32 additions and 47 deletions

View file

@ -748,7 +748,9 @@ proc processCategory(r: var TResults, cat: Category,
testSpec r, test testSpec r, test
inc testsRun inc testsRun
if testsRun == 0: if testsRun == 0:
echo "[Warning] - Invalid category specified \"", cat.string, "\", no tests were run" const whiteListedDirs = ["deps"]
doAssert cat.string in whiteListedDirs,
"Invalid category specified: '$#' not in whilelist: $#" % [cat.string, $whiteListedDirs]
proc processPattern(r: var TResults, pattern, options: string; simulate: bool) = proc processPattern(r: var TResults, pattern, options: string; simulate: bool) =
var testsRun = 0 var testsRun = 0

View file

@ -1,3 +1,5 @@
/* xxx consider removing, this seems redundant with tmain.nim */
#ifdef WIN #ifdef WIN
#include <windows.h> #include <windows.h>
#else #else
@ -28,7 +30,7 @@ int main(int argc, char* argv[])
status = (pFunc)GetProcAddress((HMODULE) hndl, (char const*)"status"); status = (pFunc)GetProcAddress((HMODULE) hndl, (char const*)"status");
count = (pFunc)GetProcAddress((HMODULE) hndl, (char const*)"count"); count = (pFunc)GetProcAddress((HMODULE) hndl, (char const*)"count");
checkOccupiedMem = (pFunc)GetProcAddress((HMODULE) hndl, (char const*)"checkOccupiedMem"); checkOccupiedMem = (pFunc)GetProcAddress((HMODULE) hndl, (char const*)"checkOccupiedMem");
#else /* OSX || NIX */ #else /* OSX || NIX xxx: OSX assumes dylib*/
hndl = (void*) dlopen((char const*)"./tests/realtimeGC/libshared.so", RTLD_LAZY); hndl = (void*) dlopen((char const*)"./tests/realtimeGC/libshared.so", RTLD_LAZY);
status = (pFunc) dlsym(hndl, (char const*)"status"); status = (pFunc) dlsym(hndl, (char const*)"status");
count = (pFunc) dlsym(hndl, (char const*)"count"); count = (pFunc) dlsym(hndl, (char const*)"count");

View file

@ -1,6 +0,0 @@
--app:console
--threads:on
-d:release
-d:useRealtimeGC

View file

@ -1,21 +1,10 @@
Test the realtime GC without linking nimrtl.dll/so. Test the realtime GC without linking nimrtl.dll/so.
Note, this is a long running test, default is 35 minutes. To change the To build by hand and run the test for 35 minutes:
the run time see RUNTIME in nmain.nim and cmain.c. $ nim r --threads:on -d:runtimeSecs:2100 tests/realtimeGC/nmain.nim
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 xxx do we still need tests/realtimeGC/cmain.c?
path. Output: shared.(dll/so), cmain(.exe), nmain(.exe). if so, tests/realtimeGC/cmain.c needs to updated and factorized with nmain.nim to avoid duplication (even if it's a C file)
```
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 $ gcc -o tests/realtimeGC/cmain tests/realtimeGC/cmain.c -ldl

View file

@ -1,8 +1,3 @@
discard """
cmd: "nim $target --debuginfo --hints:on --app:lib $options $file"
action: compile
"""
import strutils import strutils
# Global state, accessing with threads, no locks. Don't do this at # Global state, accessing with threads, no locks. Don't do this at

View file

@ -1,5 +0,0 @@
--app:lib
--threads:on
-d:release
-d:useRealtimeGC

View file

@ -1,18 +1,27 @@
discard """ discard """
cmd: "nim $target --debuginfo $options $file" cmd: "nim $target --threads:on -d:release -d:useRealtimeGC $options $file"
output: "Done" joinable:false
""" """
import times, os, threadpool #[
was: cmd: "nim $target --debuginfo $options $file"
these dont' seem needed --debuginfo
nor these from the previous main.nim.cfg: --app:console
]#
const RUNTIME = 15 * 60 # 15 minutes import times, os, strformat, strutils
from stdtest/specialpaths import buildDir
# import threadpool
when defined(windows): const runtimeSecs {.intdefine.} = 5
const dllname = "./tests/realtimeGC/shared.dll"
elif defined(macosx): const file = "shared.nim"
const dllname = "./tests/realtimeGC/libshared.dylib" const dllname = buildDir / (DynlibFormat % file)
else:
const dllname = "./tests/realtimeGC/libshared.so" static:
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 status() {.importc: "status", dynlib: dllname.}
proc count() {.importc: "count", dynlib: dllname.} proc count() {.importc: "count", dynlib: dllname.}
@ -20,7 +29,7 @@ proc checkOccupiedMem() {.importc: "checkOccupiedMem", dynlib: dllname.}
proc process() = proc process() =
let startTime = getTime() let startTime = getTime()
let runTime = cast[Time](RUNTIME) # let runTime = cast[Time](runtimeSecs)
var accumTime: Time var accumTime: Time
while accumTime < runTime: while accumTime < runTime:
for i in 0..10: for i in 0..10:
@ -41,6 +50,5 @@ proc main() =
# for i in 0..0: # for i in 0..0:
# spawn process() # spawn process()
# sync() # sync()
echo("Done")
main() main()