diff options
Diffstat (limited to 'src/burn/test/BurnUnitTest/ElevationTest.cpp')
| -rw-r--r-- | src/burn/test/BurnUnitTest/ElevationTest.cpp | 27 |
1 files changed, 11 insertions, 16 deletions
diff --git a/src/burn/test/BurnUnitTest/ElevationTest.cpp b/src/burn/test/BurnUnitTest/ElevationTest.cpp index 3d144128..97d76b7d 100644 --- a/src/burn/test/BurnUnitTest/ElevationTest.cpp +++ b/src/burn/test/BurnUnitTest/ElevationTest.cpp | |||
| @@ -52,38 +52,33 @@ namespace Bootstrapper | |||
| 52 | void ElevateTest() | 52 | void ElevateTest() |
| 53 | { | 53 | { |
| 54 | HRESULT hr = S_OK; | 54 | HRESULT hr = S_OK; |
| 55 | BURN_PIPE_CONNECTION connection = { }; | 55 | BURN_ENGINE_STATE engineState = { }; |
| 56 | BURN_PIPE_CONNECTION* pConnection = &engineState.companionConnection; | ||
| 56 | HANDLE hEvent = NULL; | 57 | HANDLE hEvent = NULL; |
| 57 | DWORD dwResult = S_OK; | 58 | DWORD dwResult = S_OK; |
| 59 | |||
| 60 | engineState.sczBundleEngineWorkingPath = L"tests\\ignore\\this\\path\\to\\burn.exe"; | ||
| 61 | |||
| 58 | try | 62 | try |
| 59 | { | 63 | { |
| 60 | ShelFunctionOverride(ElevateTest_ShellExecuteExW); | 64 | ShelFunctionOverride(ElevateTest_ShellExecuteExW); |
| 61 | 65 | ||
| 62 | PipeConnectionInitialize(&connection); | 66 | PipeConnectionInitialize(pConnection); |
| 63 | 67 | ||
| 64 | // | 68 | // |
| 65 | // per-user side setup | 69 | // per-user side setup |
| 66 | // | 70 | // |
| 67 | hr = PipeCreateNameAndSecret(&connection.sczName, &connection.sczSecret); | 71 | hr = ElevationElevate(&engineState, NULL); |
| 68 | TestThrowOnFailure(hr, L"Failed to create connection name and secret."); | 72 | TestThrowOnFailure(hr, L"Failed to elevate."); |
| 69 | |||
| 70 | hr = PipeCreatePipes(&connection, TRUE, &hEvent); | ||
| 71 | TestThrowOnFailure(hr, L"Failed to create pipes."); | ||
| 72 | |||
| 73 | hr = PipeLaunchChildProcess(L"tests\\ignore\\this\\path\\to\\burn.exe", &connection, TRUE, NULL); | ||
| 74 | TestThrowOnFailure(hr, L"Failed to create elevated process."); | ||
| 75 | |||
| 76 | hr = PipeWaitForChildConnect(&connection); | ||
| 77 | TestThrowOnFailure(hr, L"Failed to wait for child process to connect."); | ||
| 78 | 73 | ||
| 79 | // post execute message | 74 | // post execute message |
| 80 | hr = PipeSendMessage(connection.hPipe, TEST_PARENT_SENT_MESSAGE_ID, NULL, 0, ProcessParentMessages, NULL, &dwResult); | 75 | hr = PipeSendMessage(pConnection->hPipe, TEST_PARENT_SENT_MESSAGE_ID, NULL, 0, ProcessParentMessages, NULL, &dwResult); |
| 81 | TestThrowOnFailure(hr, "Failed to post execute message to per-machine process."); | 76 | TestThrowOnFailure(hr, "Failed to post execute message to per-machine process."); |
| 82 | 77 | ||
| 83 | // | 78 | // |
| 84 | // initiate termination | 79 | // initiate termination |
| 85 | // | 80 | // |
| 86 | hr = PipeTerminateChildProcess(&connection, 666, FALSE); | 81 | hr = PipeTerminateChildProcess(pConnection, 666, FALSE); |
| 87 | TestThrowOnFailure(hr, L"Failed to terminate elevated process."); | 82 | TestThrowOnFailure(hr, L"Failed to terminate elevated process."); |
| 88 | 83 | ||
| 89 | // check flags | 84 | // check flags |
| @@ -91,7 +86,7 @@ namespace Bootstrapper | |||
| 91 | } | 86 | } |
| 92 | finally | 87 | finally |
| 93 | { | 88 | { |
| 94 | PipeConnectionUninitialize(&connection); | 89 | PipeConnectionUninitialize(pConnection); |
| 95 | ReleaseHandle(hEvent); | 90 | ReleaseHandle(hEvent); |
| 96 | } | 91 | } |
| 97 | } | 92 | } |
