diff options
| author | Rob Mensching <rob@firegiant.com> | 2025-02-11 13:53:50 -0800 |
|---|---|---|
| committer | Rob Mensching <rob@firegiant.com> | 2025-02-11 15:49:33 -0800 |
| commit | 040e50ec2859c1de70cd8e9f957474321774f293 (patch) | |
| tree | cebfe14eccdb3884d5eefc443b285917b6b4a38b /src/test/burn/TestData/PrereqBaTests/ReplaceConfig/ReplaceConfig.cpp | |
| parent | ccfed95b510f7cd1b205379d0cec50de69c2d850 (diff) | |
| download | wix-040e50ec2859c1de70cd8e9f957474321774f293.tar.gz wix-040e50ec2859c1de70cd8e9f957474321774f293.tar.bz2 wix-040e50ec2859c1de70cd8e9f957474321774f293.zip | |
Rewrite Prereq tests after hardening and bypassing .NET GUI errors
Diffstat (limited to 'src/test/burn/TestData/PrereqBaTests/ReplaceConfig/ReplaceConfig.cpp')
| -rw-r--r-- | src/test/burn/TestData/PrereqBaTests/ReplaceConfig/ReplaceConfig.cpp | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/src/test/burn/TestData/PrereqBaTests/ReplaceConfig/ReplaceConfig.cpp b/src/test/burn/TestData/PrereqBaTests/ReplaceConfig/ReplaceConfig.cpp index 1fa71bc2..b8172e6b 100644 --- a/src/test/burn/TestData/PrereqBaTests/ReplaceConfig/ReplaceConfig.cpp +++ b/src/test/burn/TestData/PrereqBaTests/ReplaceConfig/ReplaceConfig.cpp | |||
| @@ -7,27 +7,31 @@ int __cdecl wmain( | |||
| 7 | __in LPWSTR argv[] | 7 | __in LPWSTR argv[] |
| 8 | ) | 8 | ) |
| 9 | { | 9 | { |
| 10 | DWORD er = ERROR_SUCCESS; | ||
| 10 | HRESULT hr = S_OK; | 11 | HRESULT hr = S_OK; |
| 11 | DWORD dwExitCode = 0; | ||
| 12 | LPCWSTR wzDestinationFile = argc > 1 ? argv[1] : NULL; | 12 | LPCWSTR wzDestinationFile = argc > 1 ? argv[1] : NULL; |
| 13 | LPCWSTR wzGoodFile = argc > 2 ? argv[2] : NULL; | 13 | LPCWSTR wzGoodFile = argc > 2 ? argv[2] : NULL; |
| 14 | LPCWSTR wzBadFile = argc > 3 ? argv[3] : NULL; | 14 | LPCWSTR wzBackupFile = argc > 3 ? argv[3] : NULL; |
| 15 | 15 | ||
| 16 | if (argc != 4) | 16 | if (!wzDestinationFile || !*wzDestinationFile || !wzGoodFile || !*wzGoodFile) |
| 17 | { | 17 | { |
| 18 | ExitWithRootFailure(hr, E_INVALIDARG, "Invalid args"); | 18 | ExitWithRootFailure(hr, E_INVALIDARG, "Invalid args"); |
| 19 | } | 19 | } |
| 20 | 20 | ||
| 21 | if (!::MoveFileW(wzDestinationFile, wzBadFile)) | 21 | if (wzBackupFile && *wzBackupFile && !::CopyFileW(wzDestinationFile, wzBackupFile, FALSE)) |
| 22 | { | 22 | { |
| 23 | ExitWithLastError(hr, "Failed to move bad file"); | 23 | er = ::GetLastError(); |
| 24 | if (ERROR_PATH_NOT_FOUND != er && ERROR_FILE_NOT_FOUND != er) | ||
| 25 | { | ||
| 26 | ExitOnWin32Error(er, hr, "Failed to copy to backup file"); | ||
| 27 | } | ||
| 24 | } | 28 | } |
| 25 | 29 | ||
| 26 | if (!::MoveFileW(wzGoodFile, wzDestinationFile)) | 30 | if (!::CopyFileW(wzGoodFile, wzDestinationFile, FALSE)) |
| 27 | { | 31 | { |
| 28 | ExitWithLastError(hr, "Failed to move good file"); | 32 | ExitWithLastError(hr, "Failed to copy in good file"); |
| 29 | } | 33 | } |
| 30 | 34 | ||
| 31 | LExit: | 35 | LExit: |
| 32 | return FAILED(hr) ? (int)hr : (int)dwExitCode; | 36 | return FAILED(hr) ? (int)hr : (int)0; |
| 33 | } | 37 | } |
