Hi,
I want to verify that the "if (!protected) ..." are correct.
That is, on non-Win2000 platforms, we can't verify LastError ==
ERROR_SUCCESS, so I have removed those as per Juan's request. However,
there are two places where Win2000 is returning a different error
code.
So the question is, is this the correct way to do this (and because I
have changed the condition for the first test that I have changed I
want to verify it stll works on Win2000).
Thanks,
- Reece
diff --git a/dlls/crypt32/tests/protectdata.c b/dlls/crypt32/tests/protectdata.c
index b77b81b..df890e0 100644
--- a/dlls/crypt32/tests/protectdata.c
+++ b/dlls/crypt32/tests/protectdata.c
@@ -82,10 +82,13 @@ static void test_cryptprotectdata(void)
SetLastError(0xDEADBEEF);
protected =
pCryptProtectData(&plain,desc,&entropy,NULL,NULL,0,&cipher_entropy);
ok(protected, "Encrypting with entropy.\n");
- r = GetLastError();
- ok(r == ERROR_SUCCESS ||
- r == ERROR_IO_PENDING, /* win2k */
- "Expected ERROR_SUCCESS or ERROR_IO_PENDING, got %d\n",r);
+ /* Vista does not set last error on success, but earlier versions do, so
we can't test this. */
+ if (!protected)
+ {
+ /* fails in win2k */
+ ok(GetLastError() == ERROR_IO_PENDING,
+ "Expected ERROR_IO_PENDING, got %d\n", GetLastError());
+ }
cipher_no_desc.pbData=NULL;
cipher_no_desc.cbData=0;
@@ -95,16 +98,12 @@ static void test_cryptprotectdata(void)
plain.cbData=strlen(secret2)+1;
SetLastError(0xDEADBEEF);
protected =
pCryptProtectData(&plain,NULL,&entropy,NULL,NULL,0,&cipher_no_desc);
- r = GetLastError();
- if (protected)
- {
- ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
- }
- else
+ /* Vista does not set last error on success, but earlier versions do, so
we can't test this. */
+ if (!protected)
{
/* fails in win2k */
- ok(r == ERROR_INVALID_PARAMETER,
- "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
+ ok(GetLastError() == ERROR_INVALID_PARAMETER,
+ "Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
}
}
@@ -158,8 +157,7 @@ static void test_cryptunprotectdata(void)
SetLastError(0xDEADBEEF);
okay = pCryptUnprotectData(&cipher,&data_desc,NULL,NULL,NULL,0,&plain);
ok(okay,"Decrypting without entropy\n");
- r = GetLastError();
- ok(r == ERROR_SUCCESS, "Wrong (%u) GetLastError seen\n",r);
+ /* Vista does not set last error on success, but earlier versions do, so
we can't test this. */
ok(plain.pbData!=NULL,"Plain DATA_BLOB missing data\n");
ok(plain.cbData==strlen(secret)+1,"Plain DATA_BLOB wrong length\n");
@@ -185,8 +183,7 @@ static void test_cryptunprotectdata(void)
SetLastError(0xDEADBEEF);
okay =
pCryptUnprotectData(&cipher_entropy,&data_desc,&entropy,NULL,NULL,0,&plain);
ok(okay,"Decrypting with entropy\n");
- r = GetLastError();
- ok(r == ERROR_SUCCESS, "Wrong (%u) GetLastError seen\n",r);
+ /* Vista does not set last error on success, but earlier versions do, so
we can't test this. */
ok(plain.pbData!=NULL,"Plain DATA_BLOB missing data\n");
ok(plain.cbData==strlen(secret)+1,"Plain DATA_BLOB wrong length\n");
@@ -205,8 +202,7 @@ static void test_cryptunprotectdata(void)
SetLastError(0xDEADBEEF);
okay =
pCryptUnprotectData(&cipher_no_desc,&data_desc,&entropy,NULL,NULL,0,&plain);
ok(okay,"Decrypting with entropy and no description\n");
- r = GetLastError();
- ok(r == ERROR_SUCCESS, "Wrong (%u) GetLastError seen\n",r);
+ /* Vista does not set last error on success, but earlier versions do, so
we can't test this. */
ok(plain.pbData!=NULL,"Plain DATA_BLOB missing data\n");
ok(plain.cbData==strlen(secret2)+1,"Plain DATA_BLOB wrong length\n");