summaryrefslogtreecommitdiff
path: root/src/burn/test/BurnUnitTest/CacheTest.cpp
diff options
context:
space:
mode:
authorRob Mensching <rob@firegiant.com>2021-04-22 17:06:54 -0700
committerRob Mensching <rob@firegiant.com>2021-04-29 16:36:06 -0700
commitaf10c45d7b3a44af0b461a557847fe03263dcc10 (patch)
tree6a5c1532304782c36ffe4200b38f3afb76789a43 /src/burn/test/BurnUnitTest/CacheTest.cpp
parent9c2aed97299fb96aeee3f1471ce40225437aaecf (diff)
downloadwix-af10c45d7b3a44af0b461a557847fe03263dcc10.tar.gz
wix-af10c45d7b3a44af0b461a557847fe03263dcc10.tar.bz2
wix-af10c45d7b3a44af0b461a557847fe03263dcc10.zip
Move burn into burn
Diffstat (limited to 'src/burn/test/BurnUnitTest/CacheTest.cpp')
-rw-r--r--src/burn/test/BurnUnitTest/CacheTest.cpp119
1 files changed, 119 insertions, 0 deletions
diff --git a/src/burn/test/BurnUnitTest/CacheTest.cpp b/src/burn/test/BurnUnitTest/CacheTest.cpp
new file mode 100644
index 00000000..d0cc237f
--- /dev/null
+++ b/src/burn/test/BurnUnitTest/CacheTest.cpp
@@ -0,0 +1,119 @@
1// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
2
3#include "precomp.h"
4
5static HRESULT CALLBACK CacheTestEventRoutine(
6 __in BURN_CACHE_MESSAGE* pMessage,
7 __in LPVOID pvContext
8 );
9
10static DWORD CALLBACK CacheTestProgressRoutine(
11 __in LARGE_INTEGER TotalFileSize,
12 __in LARGE_INTEGER TotalBytesTransferred,
13 __in LARGE_INTEGER StreamSize,
14 __in LARGE_INTEGER StreamBytesTransferred,
15 __in DWORD dwStreamNumber,
16 __in DWORD dwCallbackReason,
17 __in HANDLE hSourceFile,
18 __in HANDLE hDestinationFile,
19 __in_opt LPVOID lpData
20 );
21
22typedef struct _CACHE_TEST_CONTEXT
23{
24} CACHE_TEST_CONTEXT;
25
26namespace Microsoft
27{
28namespace Tools
29{
30namespace WindowsInstallerXml
31{
32namespace Test
33{
34namespace Bootstrapper
35{
36 using namespace System;
37 using namespace System::IO;
38 using namespace Xunit;
39
40 public ref class CacheTest : BurnUnitTest
41 {
42 public:
43 CacheTest(BurnTestFixture^ fixture) : BurnUnitTest(fixture)
44 {
45 }
46
47 [Fact]
48 void CacheSignatureTest()
49 {
50 HRESULT hr = S_OK;
51 BURN_PACKAGE package = { };
52 BURN_PAYLOAD payload = { };
53 LPWSTR sczPayloadPath = NULL;
54 BYTE* pb = NULL;
55 DWORD cb = NULL;
56 CACHE_TEST_CONTEXT context = { };
57
58 try
59 {
60 pin_ptr<const wchar_t> dataDirectory = PtrToStringChars(this->TestContext->TestDirectory);
61 hr = PathConcat(dataDirectory, L"TestData\\CacheTest\\CacheSignatureTest.File", &sczPayloadPath);
62 Assert::True(S_OK == hr, "Failed to get path to test file.");
63 Assert::True(FileExistsEx(sczPayloadPath, NULL), "Test file does not exist.");
64
65 hr = StrAllocHexDecode(L"25e61cd83485062b70713aebddd3fe4992826cb121466fddc8de3eacb1e42f39d4bdd8455d95eec8c9529ced4c0296ab861931fe2c86df2f2b4e8d259a6d9223", &pb, &cb);
66 Assert::Equal(S_OK, hr);
67
68 package.fPerMachine = FALSE;
69 package.sczCacheId = L"Bootstrapper.CacheTest.CacheSignatureTest";
70 payload.sczKey = L"CacheSignatureTest.PayloadKey";
71 payload.sczFilePath = L"CacheSignatureTest.File";
72 payload.pbHash = pb;
73 payload.cbHash = cb;
74
75 hr = CacheCompletePayload(package.fPerMachine, &payload, package.sczCacheId, sczPayloadPath, FALSE, CacheTestEventRoutine, CacheTestProgressRoutine, &context);
76 Assert::Equal(S_OK, hr);
77 }
78 finally
79 {
80 ReleaseMem(pb);
81 ReleaseStr(sczPayloadPath);
82
83 String^ filePath = Path::Combine(Environment::GetFolderPath(Environment::SpecialFolder::LocalApplicationData), "Package Cache\\Bootstrapper.CacheTest.CacheSignatureTest\\CacheSignatureTest.File");
84 if (File::Exists(filePath))
85 {
86 File::SetAttributes(filePath, FileAttributes::Normal);
87 File::Delete(filePath);
88 }
89 }
90 }
91 };
92}
93}
94}
95}
96}
97
98static HRESULT CALLBACK CacheTestEventRoutine(
99 __in BURN_CACHE_MESSAGE* /*pMessage*/,
100 __in LPVOID /*pvContext*/
101 )
102{
103 return S_OK;
104}
105
106static DWORD CALLBACK CacheTestProgressRoutine(
107 __in LARGE_INTEGER /*TotalFileSize*/,
108 __in LARGE_INTEGER /*TotalBytesTransferred*/,
109 __in LARGE_INTEGER /*StreamSize*/,
110 __in LARGE_INTEGER /*StreamBytesTransferred*/,
111 __in DWORD /*dwStreamNumber*/,
112 __in DWORD /*dwCallbackReason*/,
113 __in HANDLE /*hSourceFile*/,
114 __in HANDLE /*hDestinationFile*/,
115 __in_opt LPVOID /*lpData*/
116 )
117{
118 return PROGRESS_QUIET;
119}