mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 22:13:06 +00:00
[KERNEL32_APITEST] Improve SetComputerNameExW test a bit (#1580)
Addendum to 8aeb6a9
. ROSTESTS-227
This commit is contained in:
parent
a0be8d2c2d
commit
de2b20d240
1 changed files with 10 additions and 8 deletions
|
@ -39,24 +39,26 @@ static HKEY OpenComputerNameKey(void)
|
||||||
|
|
||||||
START_TEST(SetComputerNameExW)
|
START_TEST(SetComputerNameExW)
|
||||||
{
|
{
|
||||||
|
static const WCHAR szNewName[] = L"SRVROSTEST";
|
||||||
LONG Error;
|
LONG Error;
|
||||||
BOOL ret;
|
BOOL ret;
|
||||||
HKEY hKeyHN, hKeyCN;
|
HKEY hKeyHN, hKeyCN;
|
||||||
DWORD cbData;
|
DWORD cbData;
|
||||||
WCHAR szHostNameOld[MAX_PATH], szHostNameNew[MAX_PATH];
|
WCHAR szHostNameOld[MAX_PATH], szHostNameNew[MAX_PATH];
|
||||||
WCHAR szComputerNameOld[MAX_PATH], szComputerNameNew[MAX_PATH];
|
WCHAR szComputerNameOld[MAX_PATH], szComputerNameNew[MAX_PATH];
|
||||||
static const WCHAR szNewName[] = L"SRVROSTEST";
|
|
||||||
|
|
||||||
/* Open keys */
|
/* Open keys */
|
||||||
hKeyHN = OpenHostNameKey();
|
hKeyHN = OpenHostNameKey();
|
||||||
|
ok(hKeyHN, "hKeyHN is NULL\n");
|
||||||
hKeyCN = OpenComputerNameKey();
|
hKeyCN = OpenComputerNameKey();
|
||||||
|
ok(hKeyCN, "hKeyCN is NULL\n");
|
||||||
if (!hKeyHN || !hKeyCN)
|
if (!hKeyHN || !hKeyCN)
|
||||||
{
|
{
|
||||||
if (hKeyHN)
|
if (hKeyHN)
|
||||||
RegCloseKey(hKeyHN);
|
RegCloseKey(hKeyHN);
|
||||||
if (hKeyCN)
|
if (hKeyCN)
|
||||||
RegCloseKey(hKeyCN);
|
RegCloseKey(hKeyCN);
|
||||||
skip("Unable to open keys (%p, %p).\n", hKeyHN, hKeyCN);
|
skip("Unable to open keys. Missing Admin rights?\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,14 +67,14 @@ START_TEST(SetComputerNameExW)
|
||||||
cbData = sizeof(szHostNameOld);
|
cbData = sizeof(szHostNameOld);
|
||||||
Error = RegQueryValueExW(hKeyHN, L"Hostname", NULL, NULL, (LPBYTE)szHostNameOld, &cbData);
|
Error = RegQueryValueExW(hKeyHN, L"Hostname", NULL, NULL, (LPBYTE)szHostNameOld, &cbData);
|
||||||
ok_long(Error, ERROR_SUCCESS);
|
ok_long(Error, ERROR_SUCCESS);
|
||||||
ok(szHostNameOld[0], "szHostNameOld is %S", szHostNameOld);
|
ok(szHostNameOld[0], "szHostNameOld is empty\n");
|
||||||
|
|
||||||
/* Get Old Computer Name */
|
/* Get Old Computer Name */
|
||||||
szComputerNameOld[0] = UNICODE_NULL;
|
szComputerNameOld[0] = UNICODE_NULL;
|
||||||
cbData = sizeof(szComputerNameOld);
|
cbData = sizeof(szComputerNameOld);
|
||||||
Error = RegQueryValueExW(hKeyCN, L"ComputerName", NULL, NULL, (LPBYTE)szComputerNameOld, &cbData);
|
Error = RegQueryValueExW(hKeyCN, L"ComputerName", NULL, NULL, (LPBYTE)szComputerNameOld, &cbData);
|
||||||
ok_long(Error, ERROR_SUCCESS);
|
ok_long(Error, ERROR_SUCCESS);
|
||||||
ok(szComputerNameOld[0], "szHostNameOld is %S", szComputerNameOld);
|
ok(szComputerNameOld[0], "szComputerNameOld is empty\n");
|
||||||
|
|
||||||
/* Change the value */
|
/* Change the value */
|
||||||
ret = SetComputerNameExW(ComputerNamePhysicalDnsHostname, szNewName);
|
ret = SetComputerNameExW(ComputerNamePhysicalDnsHostname, szNewName);
|
||||||
|
@ -83,18 +85,18 @@ START_TEST(SetComputerNameExW)
|
||||||
cbData = sizeof(szHostNameNew);
|
cbData = sizeof(szHostNameNew);
|
||||||
Error = RegQueryValueExW(hKeyHN, L"Hostname", NULL, NULL, (LPBYTE)szHostNameNew, &cbData);
|
Error = RegQueryValueExW(hKeyHN, L"Hostname", NULL, NULL, (LPBYTE)szHostNameNew, &cbData);
|
||||||
ok_long(Error, ERROR_SUCCESS);
|
ok_long(Error, ERROR_SUCCESS);
|
||||||
ok(szHostNameNew[0], "szHostNameNew was empty.\n");
|
ok(szHostNameNew[0], "szHostNameNew is empty\n");
|
||||||
ok(lstrcmpW(szHostNameNew, szHostNameOld) == 0,
|
ok(lstrcmpW(szHostNameNew, szHostNameOld) == 0,
|
||||||
"szHostNameNew '%S' should be szHostNameOld '%S'.\n", szHostNameNew, szHostNameOld);
|
"szHostNameNew '%S' should be szHostNameOld '%S'\n", szHostNameNew, szHostNameOld);
|
||||||
|
|
||||||
/* Get New Computer Name */
|
/* Get New Computer Name */
|
||||||
szComputerNameNew[0] = UNICODE_NULL;
|
szComputerNameNew[0] = UNICODE_NULL;
|
||||||
cbData = sizeof(szComputerNameNew);
|
cbData = sizeof(szComputerNameNew);
|
||||||
Error = RegQueryValueExW(hKeyCN, L"ComputerName", NULL, NULL, (LPBYTE)szComputerNameNew, &cbData);
|
Error = RegQueryValueExW(hKeyCN, L"ComputerName", NULL, NULL, (LPBYTE)szComputerNameNew, &cbData);
|
||||||
ok_long(Error, ERROR_SUCCESS);
|
ok_long(Error, ERROR_SUCCESS);
|
||||||
ok(szComputerNameNew[0], "szComputerNameNew was empty.\n");
|
ok(szComputerNameNew[0], "szComputerNameNew is empty\n");
|
||||||
ok(lstrcmpW(szComputerNameNew, szNewName) == 0,
|
ok(lstrcmpW(szComputerNameNew, szNewName) == 0,
|
||||||
"szComputerNameNew '%S' should be szNewName '%S'.\n", szComputerNameNew, szNewName);
|
"szComputerNameNew '%S' should be szNewName '%S'\n", szComputerNameNew, szNewName);
|
||||||
|
|
||||||
/* Restore the registry values */
|
/* Restore the registry values */
|
||||||
cbData = (lstrlenW(szHostNameOld) + 1) * sizeof(WCHAR);
|
cbData = (lstrlenW(szHostNameOld) + 1) * sizeof(WCHAR);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue