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

Alexandre Julliard julliard at winehq.org
Mon Oct 29 08:34:48 CDT 2007


Module: wine
Branch: master
Commit: e88af468fe6112f9c4435647ffd719856d7b2bf9
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=e88af468fe6112f9c4435647ffd719856d7b2bf9

Author: Francois Gouget <fgouget at free.fr>
Date:   Sun Oct 28 02:48:59 2007 +0200

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

---

 programs/winetest/Makefile.in |    2 +-
 programs/winetest/main.c      |   22 ++++++++++++++++++++++
 2 files changed, 23 insertions(+), 1 deletions(-)

diff --git a/programs/winetest/Makefile.in b/programs/winetest/Makefile.in
index d640848..2d4b12b 100644
--- a/programs/winetest/Makefile.in
+++ b/programs/winetest/Makefile.in
@@ -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 \
diff --git a/programs/winetest/main.c b/programs/winetest/main.c
index 54574b1..41879b4 100644
--- a/programs/winetest/main.c
+++ b/programs/winetest/main.c
@@ -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);
 }




More information about the wine-cvs mailing list