winetest: Add an option that shuts Windows down once the tests have completed.

This commit is contained in:
Francois Gouget 2007-10-28 02:48:59 +02:00 committed by Alexandre Julliard
parent bbf17b0a86
commit e88af468fe
2 changed files with 23 additions and 1 deletions

View File

@ -4,7 +4,7 @@ SRCDIR = @srcdir@
VPATH = @srcdir@
MODULE = winetest.exe
APPMODE = -mconsole
IMPORTS = comctl32 version user32 gdi32 wsock32 kernel32
IMPORTS = comctl32 version user32 gdi32 advapi32 wsock32 kernel32
C_SRCS = \
gui.c \

View File

@ -612,6 +612,7 @@ usage (void)
" -c console mode, no GUI\n"
" -e preserve the environment\n"
" -h print this message and exit\n"
" -p shutdown when the tests are done\n"
" -q quiet mode, no output at all\n"
" -o FILE put report into FILE, do not submit\n"
" -s FILE submit FILE, do not run tests\n"
@ -624,6 +625,7 @@ int WINAPI WinMain (HINSTANCE hInst, HINSTANCE hPrevInst,
char *logname = NULL;
const char *cp, *submit = NULL;
int reset_env = 1;
int poweroff = 0;
int interactive = 1;
/* initialize the revision information first */
@ -645,8 +647,12 @@ int WINAPI WinMain (HINSTANCE hInst, HINSTANCE hPrevInst,
reset_env = 0;
break;
case 'h':
case '?':
usage ();
exit (0);
case 'p':
poweroff = 1;
break;
case 'q':
report (R_QUIET);
interactive = 0;
@ -718,5 +724,21 @@ int WINAPI WinMain (HINSTANCE hInst, HINSTANCE hPrevInst,
} else run_tests (logname);
report (R_STATUS, "Finished");
}
if (poweroff)
{
HANDLE hToken;
TOKEN_PRIVILEGES npr;
/* enable the shutdown privilege for the current process */
if (OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES, &hToken))
{
LookupPrivilegeValueA(0, SE_SHUTDOWN_NAME, &npr.Privileges[0].Luid);
npr.PrivilegeCount = 1;
npr.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
AdjustTokenPrivileges(hToken, FALSE, &npr, 0, 0, 0);
CloseHandle(hToken);
}
ExitWindowsEx(EWX_SHUTDOWN | EWX_POWEROFF | EWX_FORCEIFHUNG, SHTDN_REASON_MAJOR_OTHER | SHTDN_REASON_MINOR_OTHER);
}
exit (0);
}