20 #include <winpr/crt.h>
21 #include <winpr/error.h>
23 static BOOL test_co_errors(
void)
25 const LONG should[] = {
26 (LONG)0x80004006l, (LONG)0x80004007l, (LONG)0x80004008l, (LONG)0x80004009l,
27 (LONG)0x8000400Al, (LONG)0x8000400Bl, (LONG)0x8000400Cl, (LONG)0x8000400Dl,
28 (LONG)0x8000400El, (LONG)0x8000400Fl, (LONG)0x80004010l, (LONG)0x80004011l,
29 (LONG)0x80004012l, (LONG)0x80004013l, (LONG)0x80004014l, (LONG)0x80004015l,
30 (LONG)0x80004016l, (LONG)0x80004017l, (LONG)0x80004018l, (LONG)0x80004019l,
31 (LONG)0x8000401Al, (LONG)0x8000401Bl, (LONG)0x8000401Cl, (LONG)0x8000401Dl,
32 (LONG)0x8000401El, (LONG)0x8000401Fl, (LONG)0x80004020l, (LONG)0x80004021l,
33 (LONG)0x80004022l, (LONG)0x80004023l, (LONG)0x80004024l, (LONG)0x80004025l,
34 (LONG)0x80004026l, (LONG)0x80004027l, (LONG)0x80004028l, (LONG)0x80004029l,
35 (LONG)0x8000402Al, (LONG)0x8000402Bl, (LONG)0x80004030l, (LONG)0x80004031l,
36 (LONG)0x80004032l, (LONG)0x80004033l, (LONG)0x8000FFFFL, (LONG)0x80070005L,
37 (LONG)0x80070006L, (LONG)0x8007000EL, (LONG)0x80070057L, (LONG)0x80004001L,
38 (LONG)0x80004002L, (LONG)0x80004003L, (LONG)0x80004004L, (LONG)0x80004005L
40 const LONG are[] = { CO_E_INIT_TLS,
41 CO_E_INIT_SHARED_ALLOCATOR,
42 CO_E_INIT_MEMORY_ALLOCATOR,
43 CO_E_INIT_CLASS_CACHE,
44 CO_E_INIT_RPC_CHANNEL,
45 CO_E_INIT_TLS_SET_CHANNEL_CONTROL,
46 CO_E_INIT_TLS_CHANNEL_CONTROL,
47 CO_E_INIT_UNACCEPTED_USER_ALLOCATOR,
48 CO_E_INIT_SCM_MUTEX_EXISTS,
49 CO_E_INIT_SCM_FILE_MAPPING_EXISTS,
50 CO_E_INIT_SCM_MAP_VIEW_OF_FILE,
51 CO_E_INIT_SCM_EXEC_FAILURE,
52 CO_E_INIT_ONLY_SINGLE_THREADED,
55 CO_E_WRONG_SERVER_IDENTITY,
56 CO_E_OLE1DDE_DISABLED,
58 CO_E_CREATEPROCESS_FAILURE,
59 CO_E_RUNAS_CREATEPROCESS_FAILURE,
60 CO_E_RUNAS_LOGON_FAILURE,
61 CO_E_LAUNCH_PERMSSION_DENIED,
62 CO_E_START_SERVICE_FAILURE,
63 CO_E_REMOTE_COMMUNICATION_FAILURE,
64 CO_E_SERVER_START_TIMEOUT,
65 CO_E_CLSREG_INCONSISTENT,
66 CO_E_IIDREG_INCONSISTENT,
70 CO_E_ATTEMPT_TO_CREATE_OUTSIDE_CLIENT_CONTEXT,
72 CO_E_SERVER_NOT_PAUSED,
75 CO_E_ASYNC_WORK_REJECTED,
76 CO_E_SERVER_INIT_TIMEOUT,
77 CO_E_NO_SECCTX_IN_ACTIVATE,
79 CO_E_THREADPOOL_CONFIG,
93 if (ARRAYSIZE(should) != ARRAYSIZE(are))
95 const size_t a = ARRAYSIZE(should);
96 const size_t b = ARRAYSIZE(are);
97 printf(
"mismatch: %" PRIuz
" vs %" PRIuz
"\n", a, b);
100 for (
size_t x = 0; x < ARRAYSIZE(are); x++)
102 const LONG a = are[x];
103 const LONG b = should[x];
106 printf(
"mismatch[%" PRIuz
"]: %08" PRIx32
" vs %08" PRIx32
"\n", x, a, b);
113 static BOOL TestSucceededFailedMacros(HRESULT hr,
char* sym, BOOL isSuccess)
117 if (SUCCEEDED(hr) && !isSuccess)
119 printf(
"Error: SUCCEEDED with \"%s\" must be false\n", sym);
122 if (!SUCCEEDED(hr) && isSuccess)
124 printf(
"Error: SUCCEEDED with \"%s\" must be true\n", sym);
127 if (!FAILED(hr) && !isSuccess)
129 printf(
"Error: FAILED with \"%s\" must be true\n", sym);
132 if (FAILED(hr) && isSuccess)
134 printf(
"Error: FAILED with \"%s\" must be false\n", sym);
141 int TestTypes(
int argc,
char* argv[])
149 if (!test_co_errors())
154 printf(
"Error: S_OK should be 0\n");
159 printf(
"Error: S_FALSE should be 1\n");
164 ok &= TestSucceededFailedMacros(S_OK,
"S_OK", TRUE);
165 ok &= TestSucceededFailedMacros(S_FALSE,
"S_FALSE", TRUE);
168 ok &= TestSucceededFailedMacros(E_NOTIMPL,
"E_NOTIMPL", FALSE);
169 ok &= TestSucceededFailedMacros(E_OUTOFMEMORY,
"E_OUTOFMEMORY", FALSE);
170 ok &= TestSucceededFailedMacros(E_INVALIDARG,
"E_INVALIDARG", FALSE);
171 ok &= TestSucceededFailedMacros(E_FAIL,
"E_FAIL", FALSE);
172 ok &= TestSucceededFailedMacros(E_ABORT,
"E_ABORT", FALSE);
175 hr = HRESULT_FROM_WIN32(ERROR_SUCCESS);
176 ok &= TestSucceededFailedMacros(hr,
"HRESULT_FROM_WIN32(ERROR_SUCCESS)", TRUE);
178 hr = HRESULT_FROM_WIN32(ERROR_INVALID_FUNCTION);
179 ok &= TestSucceededFailedMacros(hr,
"HRESULT_FROM_WIN32(ERROR_INVALID_FUNCTION)", FALSE);
181 hr = HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED);
182 ok &= TestSucceededFailedMacros(hr,
"HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED)", FALSE);
184 hr = HRESULT_FROM_WIN32(ERROR_NOACCESS);
185 ok &= TestSucceededFailedMacros(hr,
"HRESULT_FROM_WIN32(ERROR_NOACCESS)", FALSE);
187 hr = HRESULT_FROM_WIN32(ERROR_NOT_FOUND);
188 ok &= TestSucceededFailedMacros(hr,
"HRESULT_FROM_WIN32(ERROR_NOT_FOUND)", FALSE);
190 hr = HRESULT_FROM_WIN32(ERROR_TIMEOUT);
191 ok &= TestSucceededFailedMacros(hr,
"HRESULT_FROM_WIN32(ERROR_TIMEOUT)", FALSE);
193 hr = HRESULT_FROM_WIN32(RPC_S_ZERO_DIVIDE);
194 ok &= TestSucceededFailedMacros(hr,
"HRESULT_FROM_WIN32(RPC_S_ZERO_DIVIDE)", FALSE);
196 hr = HRESULT_FROM_WIN32(ERROR_STATIC_INIT);
197 ok &= TestSucceededFailedMacros(hr,
"HRESULT_FROM_WIN32(ERROR_STATIC_INIT)", FALSE);
199 hr = HRESULT_FROM_WIN32(ERROR_ENCRYPTION_FAILED);
200 ok &= TestSucceededFailedMacros(hr,
"HRESULT_FROM_WIN32(ERROR_ENCRYPTION_FAILED)", FALSE);
202 hr = HRESULT_FROM_WIN32(WSAECANCELLED);
203 ok &= TestSucceededFailedMacros(hr,
"HRESULT_FROM_WIN32(WSAECANCELLED)", FALSE);
207 printf(
"Test completed successfully\n");
212 printf(
"Error: Test failed\n");