Skip to content

Commit b16af2a

Browse files
committed
Merged PR 5136889: Fix issue of checking registry
Related work items: #28937105
1 parent 0405106 commit b16af2a

File tree

1 file changed

+32
-31
lines changed

1 file changed

+32
-31
lines changed

ProtocolTestManager/Kernel/TestSuiteIntro/TestSuiteFamilies.cs

Lines changed: 32 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -122,33 +122,6 @@ public static TestSuiteFamilies Load(string filename, string customizedConfig =
122122
}
123123
}
124124

125-
// Find Test suite Information from Registry
126-
RegistryKey HKLM = Registry.LocalMachine;
127-
RegistryKey[] testSuitesRegPathList;
128-
if (Environment.Is64BitProcess)
129-
{
130-
// 32-bit and 64-bit
131-
testSuitesRegPathList = new RegistryKey[]
132-
{
133-
HKLM.OpenSubKey(family.RegistryPath),
134-
HKLM.OpenSubKey(family.RegistryPath64)
135-
};
136-
}
137-
else
138-
{
139-
// 32-bit only
140-
testSuitesRegPathList = new RegistryKey[]
141-
{
142-
HKLM.OpenSubKey(family.RegistryPath)
143-
};
144-
}
145-
146-
// Check if all registry paths do not exist
147-
testSuitesRegPathList = testSuitesRegPathList.Where(Entry => Entry != null).ToArray();
148-
if (testSuitesRegPathList.Length == 0)
149-
{
150-
return family;
151-
}
152125

153126
//Check if the test suite is installed.
154127
foreach (TestSuiteFamily f in family)
@@ -177,7 +150,7 @@ public static TestSuiteFamilies Load(string filename, string customizedConfig =
177150
{
178151
// Find the registry key of the test suite.
179152

180-
testsuite.IsInstalled = FindTestSuiteInformationInRegistry(testSuitesRegPathList, testsuite);
153+
testsuite.IsInstalled = FindTestSuiteInformationInRegistry(family, testsuite);
181154

182155
if (!testsuite.IsInstalled)
183156
{
@@ -244,16 +217,44 @@ public static TestSuiteFamilies Reload(string filename, string customizedConfig,
244217
/// <summary>
245218
/// Find test suite related information in registry.
246219
/// </summary>
247-
/// <param name="registryList">registry root path for test suite.</param>
220+
/// <param name="family">Test suite families.</param>
248221
/// <param name="testSuite">Test suite name.</param>
249222
/// <returns>True if found, otherwise false.</returns>
250-
private static bool FindTestSuiteInformationInRegistry(RegistryKey[] registryList, TestSuiteInfo testSuite)
223+
private static bool FindTestSuiteInformationInRegistry(TestSuiteFamilies family, TestSuiteInfo testSuite)
251224
{
225+
// Find Test suite Information from Registry
226+
RegistryKey HKLM = Registry.LocalMachine;
227+
RegistryKey[] testSuitesRegPathList;
228+
if (Environment.Is64BitProcess)
229+
{
230+
// 32-bit and 64-bit
231+
testSuitesRegPathList = new RegistryKey[]
232+
{
233+
HKLM.OpenSubKey(family.RegistryPath),
234+
HKLM.OpenSubKey(family.RegistryPath64)
235+
};
236+
}
237+
else
238+
{
239+
// 32-bit only
240+
testSuitesRegPathList = new RegistryKey[]
241+
{
242+
HKLM.OpenSubKey(family.RegistryPath)
243+
};
244+
}
245+
246+
// Check if all registry paths do not exist
247+
testSuitesRegPathList = testSuitesRegPathList.Where(Entry => Entry != null).ToArray();
248+
if (testSuitesRegPathList.Length == 0)
249+
{
250+
return false;
251+
}
252+
252253
string latestTestSuiteVersionString = null;
253254
Version latestTestSuiteVersion = null;
254255
string latestTestSuiteEndPoint = null;
255256

256-
foreach (var registryPath in registryList)
257+
foreach (var registryPath in testSuitesRegPathList)
257258
{
258259
var registryKeyNames = registryPath.GetSubKeyNames()
259260
.Where(s => s.Contains(testSuite.TestSuiteName));

0 commit comments

Comments
 (0)