diff options
| author | dkf <donal.k.fellows@manchester.ac.uk> | 2025-06-17 10:17:49 (GMT) |
|---|---|---|
| committer | dkf <donal.k.fellows@manchester.ac.uk> | 2025-06-17 10:17:49 (GMT) |
| commit | c0d2a628a7aae16cba02725ff7ecf832dfc11332 (patch) | |
| tree | 9fa4d0bb92d4c229edf14db531b30e3bced7af5b /generic/tclTest.c | |
| parent | 477358dd87a8ab7890be0d2172a097b1de4828de (diff) | |
| parent | 5df8c22f6d572f4a169b24195b9a5aef31b598cc (diff) | |
| download | tcl-core-arith-series-bytecode.zip tcl-core-arith-series-bytecode.tar.gz tcl-core-arith-series-bytecode.tar.bz2 | |
merge trunkcore-arith-series-bytecode
Diffstat (limited to 'generic/tclTest.c')
| -rw-r--r-- | generic/tclTest.c | 92 |
1 files changed, 92 insertions, 0 deletions
diff --git a/generic/tclTest.c b/generic/tclTest.c index 1747006..2e578dd 100644 --- a/generic/tclTest.c +++ b/generic/tclTest.c @@ -334,6 +334,10 @@ static Tcl_ObjCmdProc TestInterpResolverCmd; static Tcl_ObjCmdProc TestcpuidCmd; #endif static Tcl_ObjCmdProc TestApplyLambdaCmd; +#ifdef _WIN32 +static Tcl_ObjCmdProc TestHandleCountCmd; +static Tcl_ObjCmdProc TestAppVerifierPresentCmd; +#endif static const Tcl_Filesystem testReportingFilesystem = { "reporting", @@ -725,6 +729,12 @@ Tcltest_Init( NULL, NULL); Tcl_CreateObjCommand(interp, "testlutil", TestLutilCmd, NULL, NULL); +#if defined(_WIN32) + Tcl_CreateObjCommand(interp, "testhandlecount", TestHandleCountCmd, + NULL, NULL); + Tcl_CreateObjCommand(interp, "testappverifierpresent", + TestAppVerifierPresentCmd, NULL, NULL); +#endif if (TclObjTest_Init(interp) != TCL_OK) { return TCL_ERROR; @@ -8824,6 +8834,88 @@ vamoose: return ret; } +#ifdef _WIN32 +/* + *---------------------------------------------------------------------- + * + * TestHandleCountCmd -- + * + * This procedure implements the "testhandlecount" command. It returns + * the number of open handles in the process. + * + * Results: + * A standard Tcl result. + * + * Side effects: + * None. + * + *---------------------------------------------------------------------- + */ +static int +TestHandleCountCmd( + TCL_UNUSED(void *), + Tcl_Interp *interp, /* Current interpreter. */ + int objc, /* Number of arguments. */ + Tcl_Obj *const objv[]) /* Arguments. */ +{ + DWORD count; + if (objc != 1) { + Tcl_WrongNumArgs(interp, 1, objv, ""); + return TCL_ERROR; + } + if (GetProcessHandleCount(GetCurrentProcess(), &count)) { + Tcl_SetObjResult(interp, Tcl_NewWideIntObj(count)); + return TCL_OK; + } + Tcl_SetObjResult(interp, Tcl_NewStringObj( + "GetProcessHandleCount failed", -1)); + return TCL_ERROR; +} + +/* + *---------------------------------------------------------------------- + * + * TestAppVerifierPresentCmd -- + * + * This procedure implements the "testappverifierpresent" command. + * Result is 1 if the process is running under the Application Verifier, + * 0 otherwise. + * + * Results: + * A standard Tcl result. + * + * Side effects: + * None. + * + *---------------------------------------------------------------------- + */ +static int +TestAppVerifierPresentCmd( + TCL_UNUSED(void *), + Tcl_Interp *interp, /* Current interpreter. */ + int objc, /* Number of arguments. */ + Tcl_Obj *const objv[]) /* Arguments. */ +{ + if (objc != 1) { + Tcl_WrongNumArgs(interp, 1, objv, ""); + return TCL_ERROR; + } + const char *dlls[] = { + "verifier.dll", "vfbasics.dll", "vfcompat.dll", "vfnet.dll", NULL + }; + const char **dll; + for (dll = dlls; dll; ++dll) { + if (GetModuleHandleA(*dll) != NULL) { + break; + } + } + Tcl_SetObjResult(interp, Tcl_NewBooleanObj(*dll != NULL)); + return TCL_OK; +} + + +#endif /* _WIN32 */ + /* * Local Variables: * mode: c |
