Author: fireball
Date: Wed Aug 9 23:42:50 2006
New Revision: 23536
URL:
http://svn.reactos.org/svn/reactos?rev=23536&view=rev
Log:
Dmitriy Philippov (shedon(a)mail.ru): Add test application for move file after reboot
function of smss.exe / kernel32.dll
Added:
trunk/reactos/base/applications/testsets/smss/
trunk/reactos/base/applications/testsets/smss/movefile/
trunk/reactos/base/applications/testsets/smss/movefile/movefile.cpp
trunk/reactos/base/applications/testsets/smss/movefile/movefile.rbuild
trunk/reactos/base/applications/testsets/smss/movefile/movefile.rc
trunk/reactos/base/applications/testsets/smss/smss.rbuild
Modified:
trunk/reactos/base/applications/testsets/testsets.rbuild
Added: trunk/reactos/base/applications/testsets/smss/movefile/movefile.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/testsets…
==============================================================================
--- trunk/reactos/base/applications/testsets/smss/movefile/movefile.cpp (added)
+++ trunk/reactos/base/applications/testsets/smss/movefile/movefile.cpp Wed Aug 9
23:42:50 2006
@@ -1,0 +1,193 @@
+/*
+ * PROJECT: ReactOS Test applications
+ * LICENSE: GPL - See COPYING in the top level directory
+ * FILE: base/applications/testsets/smss/movefile.cpp
+ * PURPOSE: Provides testing for the "move file after reboot"
+ * function of smss.exe/kernel32.dll
+ * PROGRAMMERS: Dmitriy Philippov (shedon(a)mail.ru)
+ */
+
+
+#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
+#include "windows.h"
+#include <stdio.h>
+#include <tchar.h>
+#include "stdlib.h"
+#include "string.h"
+
+
+void Usage()
+{
+ printf(" Usage: smssTest.exe -g|c|s|d \n \
+ g - generate test files \n \
+ c - check files after reboot \n \
+ s - show registry entry \n \
+ d - delete registry value \n");
+}
+
+int ShowRegValue()
+{
+ BYTE lpBuff[255];
+ memset(lpBuff, 0, sizeof(lpBuff));
+
+ DWORD lSize = sizeof(lpBuff);
+ HKEY hKey;
+ LONG retValue;
+ // test registry entry
+ retValue = RegOpenKeyEx(HKEY_LOCAL_MACHINE,
"SYSTEM\\CurrentControlSet\\Control\\Session Manager", 0, KEY_QUERY_VALUE,
&hKey);
+ if( ERROR_SUCCESS != retValue ) {
+ printf("RegOpenKeyEx err=%ld \n", retValue);
+ return 1;
+ }
+
+ retValue = RegQueryValueEx(hKey, "PendingFileRenameOperations", NULL, NULL,
lpBuff, &lSize);
+ if( ERROR_SUCCESS != retValue ) {
+ printf("RegQueryValueEx err=%ld \n", retValue);
+ lSize = 0;
+ }
+
+ printf("reg data: \n");
+ for(UINT i=0; i<lSize; i++) {
+ printf("%c", lpBuff[i]);
+ }
+ printf("\n");
+
+ RegCloseKey(hKey);
+
+ return 0;
+}
+
+int DeleteValue()
+{
+ HKEY hKey;
+ LONG retValue;
+ // test registry entry
+ retValue = RegOpenKeyEx(HKEY_LOCAL_MACHINE,
"SYSTEM\\CurrentControlSet\\Control\\Session Manager", 0, KEY_SET_VALUE,
&hKey);
+ if( ERROR_SUCCESS != retValue ) {
+ printf("RegOpenKeyEx err=%ld \n", retValue);
+ return 1;
+ }
+
+ retValue = RegDeleteValue(hKey, "PendingFileRenameOperations");
+ if( ERROR_SUCCESS != retValue ) {
+ printf("RegDeleteValue err=%ld \n", retValue);
+ }
+
+ RegCloseKey(hKey);
+
+ return 0;
+}
+
+int Generate()
+{
+ char sBuf[255];
+ DWORD dwSize;
+ HANDLE hFile = NULL;
+
+ char *szxMovedFile = "c:\\testFileShouldBeMoved";
+ char *szxNewMovedFile = "c:\\testFileIsMoved";
+
+ char *szxDeletedFile = "c:\\testFileShouldBeDeleted";
+
+ memset(sBuf, 0xaa, sizeof(sBuf));
+
+ // create the first file for moving
+ hFile = CreateFile(
+ szxMovedFile,
+ FILE_ALL_ACCESS,
+ 0,
+ NULL,
+ CREATE_ALWAYS,
+ FILE_ATTRIBUTE_NORMAL,
+ NULL);
+ if(NULL == hFile) {
+ printf("Can't create the %s file, err=%ld \n", szxMovedFile,
GetLastError());
+ return 1;
+ }
+ WriteFile(hFile, sBuf, sizeof(sBuf), &dwSize, NULL);
+ CloseHandle(hFile);
+
+ // create the second file for removing
+ hFile = CreateFile(
+ szxDeletedFile,
+ FILE_ALL_ACCESS,
+ 0,
+ NULL,
+ CREATE_ALWAYS,
+ FILE_ATTRIBUTE_NORMAL,
+ NULL);
+ if(NULL == hFile) {
+ printf("Can't create the %s file, err=%ld \n", szxDeletedFile,
GetLastError());
+ return 1;
+ }
+ WriteFile(hFile, sBuf, sizeof(sBuf), &dwSize, NULL);
+ CloseHandle(hFile);
+
+
+ BOOL fReturnValue;
+
+ fReturnValue = MoveFileEx(
+ szxDeletedFile,
+ NULL,
+ MOVEFILE_DELAY_UNTIL_REBOOT);
+ if( !fReturnValue ) {
+ printf("Can't move the %s file, err=%ld \n", szxMovedFile,
GetLastError());
+ return 1;
+ }
+
+ ShowRegValue();
+
+ fReturnValue = MoveFileEx(
+ szxMovedFile,
+ szxNewMovedFile,
+ MOVEFILE_DELAY_UNTIL_REBOOT);
+ if( !fReturnValue ) {
+ printf("Can't move the %s file, err=%ld \n", szxMovedFile,
GetLastError());
+ return 1;
+ }
+
+ ShowRegValue();
+
+ return 0;
+}
+
+int Check()
+{
+ return 0;
+}
+
+int _tmain(int argc, _TCHAR* argv[])
+{
+ if( argc<2 ) {
+ Usage();
+ return 1;
+ }
+
+ if( 0 == strncmp(argv[1], "-g", 2) )
+ {
+ // generate test files and registry values
+ return Generate();
+ }
+ else if( 0 == strncmp(argv[1], "-c", 2) )
+ {
+ // check generated files
+ return Check();
+ }
+ else if( 0 == strncmp(argv[1], "-s", 2) )
+ {
+ //
+ return ShowRegValue();
+ }
+ else if( 0 == strncmp(argv[1], "-d", 2) )
+ {
+ return DeleteValue();
+ }
+ else
+ {
+ Usage();
+ return 1;
+ }
+
+ return 0;
+}
+
Added: trunk/reactos/base/applications/testsets/smss/movefile/movefile.rbuild
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/testsets…
==============================================================================
--- trunk/reactos/base/applications/testsets/smss/movefile/movefile.rbuild (added)
+++ trunk/reactos/base/applications/testsets/smss/movefile/movefile.rbuild Wed Aug 9
23:42:50 2006
@@ -1,0 +1,11 @@
+<module name="movefile" type="win32cui"
installbase="system32" installname="movefiletest.exe">
+ <include base="movefile">.</include>
+ <define name="__USE_W32API" />
+ <define name="_WIN32_IE">0x0500</define>
+ <define name="_WIN32_WINNT">0x0600</define>
+ <define name="WINVER">0x0600</define>
+ <library>kernel32</library>
+ <library>user32</library>
+ <file>movefile.cpp</file>
+ <file>movefile.rc</file>
+</module>
Added: trunk/reactos/base/applications/testsets/smss/movefile/movefile.rc
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/testsets…
==============================================================================
--- trunk/reactos/base/applications/testsets/smss/movefile/movefile.rc (added)
+++ trunk/reactos/base/applications/testsets/smss/movefile/movefile.rc Wed Aug 9 23:42:50
2006
@@ -1,0 +1,9 @@
+#include <windows.h>
+#include "resource.h"
+
+#define REACTOS_STR_FILE_DESCRIPTION "ReactOS Move File after reboot test\0"
+#define REACTOS_STR_INTERNAL_NAME "movefiletest\0"
+#define REACTOS_STR_ORIGINAL_FILENAME "movefiletest.exe\0"
+#include <reactos/version.rc>
+
+
Added: trunk/reactos/base/applications/testsets/smss/smss.rbuild
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/testsets…
==============================================================================
--- trunk/reactos/base/applications/testsets/smss/smss.rbuild (added)
+++ trunk/reactos/base/applications/testsets/smss/smss.rbuild Wed Aug 9 23:42:50 2006
@@ -1,0 +1,7 @@
+<?xml version="1.0"?>
+<!DOCTYPE project SYSTEM "tools/rbuild/project.dtd">
+<group>
+<directory name="movefile">
+ <xi:include href="movefile/movefile.rbuild" />
+</directory>
+</group>
Modified: trunk/reactos/base/applications/testsets/testsets.rbuild
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/testsets…
==============================================================================
--- trunk/reactos/base/applications/testsets/testsets.rbuild (original)
+++ trunk/reactos/base/applications/testsets/testsets.rbuild Wed Aug 9 23:42:50 2006
@@ -1,6 +1,9 @@
<?xml version="1.0"?>
<!DOCTYPE project SYSTEM "tools/rbuild/project.dtd">
<group>
+<directory name="smss">
+ <xi:include href="smss/smss.rbuild" />
+</directory>
<directory name="user32">
<xi:include href="user32/user32.rbuild" />
</directory>