mirror of https://github.com/FreeRDP/FreeRDP
winpr: fix some tests
TestNtCreateFile, TestPipeCreateNamedPipeOverlapped - These tests are currently only expected to succeed on _WIN32 - Also reflect the reverse meaning of this fact in the return values TestSynchWaitableTimer, TestSynchWaitableTimerAPC: - These tests are currently expected to fail on __APPLE__ - Also reflect the reverse meaning of this fact in the return values This logic makes sure that we don't forget to fix the tests if the corresponding WinPR implementations are fixed. TestLibrary: - TestLibraryA and TestLibraryB must always get built as shared libraries
This commit is contained in:
parent
0abb285c3d
commit
f2c825bb76
|
@ -24,7 +24,7 @@ if(MSVC)
|
|||
set(${MODULE_PREFIX}_SRCS ${${MODULE_PREFIX}_SRCS})
|
||||
endif()
|
||||
|
||||
add_library(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS})
|
||||
add_library(${MODULE_NAME} SHARED ${${MODULE_PREFIX}_SRCS})
|
||||
|
||||
set_target_properties(${MODULE_NAME} PROPERTIES PREFIX "")
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ if(MSVC)
|
|||
set(${MODULE_PREFIX}_SRCS ${${MODULE_PREFIX}_SRCS})
|
||||
endif()
|
||||
|
||||
add_library(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS})
|
||||
add_library(${MODULE_NAME} SHARED ${${MODULE_PREFIX}_SRCS})
|
||||
|
||||
set_target_properties(${MODULE_NAME} PROPERTIES PREFIX "")
|
||||
|
||||
|
|
|
@ -20,14 +20,7 @@ int TestNtCreateFile(int argc, char* argv[])
|
|||
ACCESS_MASK DesiredAccess = 0;
|
||||
OBJECT_ATTRIBUTES attributes;
|
||||
IO_STATUS_BLOCK ioStatusBlock;
|
||||
|
||||
int eFailure = -1;
|
||||
int eSuccess = 0;
|
||||
|
||||
#ifndef _WIN32
|
||||
printf("Note: %s result may currently only be trusted on Win32\n", __FUNCTION__);
|
||||
eFailure = eSuccess;
|
||||
#endif
|
||||
int result = -1;
|
||||
|
||||
_RtlInitAnsiString(&aString, TESTFILE);
|
||||
|
||||
|
@ -35,7 +28,7 @@ int TestNtCreateFile(int argc, char* argv[])
|
|||
if (ntstatus != STATUS_SUCCESS)
|
||||
{
|
||||
printf("_RtlAnsiStringToUnicodeString failure: 0x%08X\n", ntstatus);
|
||||
return eFailure;
|
||||
goto out;
|
||||
}
|
||||
|
||||
handle = NULL;
|
||||
|
@ -53,7 +46,7 @@ int TestNtCreateFile(int argc, char* argv[])
|
|||
if (ntstatus != STATUS_SUCCESS)
|
||||
{
|
||||
printf("_NtCreateFile failure: 0x%08X\n", ntstatus);
|
||||
return eFailure;
|
||||
goto out;
|
||||
}
|
||||
|
||||
_RtlFreeUnicodeString(&uString);
|
||||
|
@ -63,8 +56,27 @@ int TestNtCreateFile(int argc, char* argv[])
|
|||
if (ntstatus != STATUS_SUCCESS)
|
||||
{
|
||||
printf("_NtClose failure: 0x%08X\n", ntstatus);
|
||||
return eFailure;
|
||||
goto out;
|
||||
}
|
||||
|
||||
return eSuccess;
|
||||
result = 0;
|
||||
|
||||
out:
|
||||
|
||||
#ifndef _WIN32
|
||||
if (result == 0)
|
||||
{
|
||||
printf("%s: Error, this test is currently expected not to succeed on this platform.\n",
|
||||
__FUNCTION__);
|
||||
result = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("%s: This test is currently expected to fail on this platform.\n",
|
||||
__FUNCTION__);
|
||||
result = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -338,13 +338,7 @@ int TestPipeCreateNamedPipeOverlapped(int argc, char* argv[])
|
|||
{
|
||||
HANDLE ClientThread;
|
||||
HANDLE ServerThread;
|
||||
int eFailure = -1;
|
||||
int eSuccess = 0;
|
||||
|
||||
#ifndef _WIN32
|
||||
printf("Note: %s result may currently only be trusted on Win32\n", __FUNCTION__);
|
||||
eFailure = eSuccess;
|
||||
#endif
|
||||
int result = -1;
|
||||
|
||||
FillMemory(SERVER_MESSAGE, PIPE_BUFFER_SIZE, 0xAA);
|
||||
FillMemory(CLIENT_MESSAGE, PIPE_BUFFER_SIZE, 0xBB);
|
||||
|
@ -352,24 +346,51 @@ int TestPipeCreateNamedPipeOverlapped(int argc, char* argv[])
|
|||
if (!(serverReadyEvent = CreateEvent(NULL, TRUE, FALSE, NULL)))
|
||||
{
|
||||
printf("CreateEvent failed: %d\n", GetLastError());
|
||||
return eFailure;
|
||||
goto out;
|
||||
}
|
||||
if (!(ClientThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE) named_pipe_client_thread, NULL, 0, NULL)))
|
||||
{
|
||||
printf("CreateThread (client) failed: %d\n", GetLastError());
|
||||
return eFailure;
|
||||
goto out;
|
||||
}
|
||||
if (!(ServerThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE) named_pipe_server_thread, NULL, 0, NULL)))
|
||||
{
|
||||
printf("CreateThread (server) failed: %d\n", GetLastError());
|
||||
return eFailure;
|
||||
goto out;
|
||||
}
|
||||
|
||||
WaitForSingleObject(ClientThread, INFINITE);
|
||||
WaitForSingleObject(ServerThread, INFINITE);
|
||||
if (WAIT_OBJECT_0 != WaitForSingleObject(ClientThread, INFINITE))
|
||||
{
|
||||
printf("%s: Failed to wait for client thread: %u\n",
|
||||
__FUNCTION__, GetLastError());
|
||||
goto out;
|
||||
}
|
||||
if (WAIT_OBJECT_0 != WaitForSingleObject(ServerThread, INFINITE))
|
||||
{
|
||||
printf("%s: Failed to wait for server thread: %u\n",
|
||||
__FUNCTION__, GetLastError());
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (bClientSuccess && bServerSuccess)
|
||||
return eSuccess;
|
||||
result = 0;
|
||||
|
||||
return eFailure;
|
||||
out:
|
||||
|
||||
#ifndef _WIN32
|
||||
if (result == 0)
|
||||
{
|
||||
printf("%s: Error, this test is currently expected not to succeed on this platform.\n",
|
||||
__FUNCTION__);
|
||||
result = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("%s: This test is currently expected to fail on this platform.\n",
|
||||
__FUNCTION__);
|
||||
result = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -8,13 +8,14 @@ int TestSynchWaitableTimer(int argc, char* argv[])
|
|||
HANDLE timer;
|
||||
LONG period;
|
||||
LARGE_INTEGER due;
|
||||
int result = -1;
|
||||
|
||||
timer = CreateWaitableTimer(NULL, FALSE, NULL);
|
||||
|
||||
if (!timer)
|
||||
{
|
||||
printf("CreateWaitableTimer failure\n");
|
||||
return -1;
|
||||
goto out;
|
||||
}
|
||||
|
||||
due.QuadPart = -15000000LL; /* 1.5 seconds */
|
||||
|
@ -22,7 +23,7 @@ int TestSynchWaitableTimer(int argc, char* argv[])
|
|||
if (!SetWaitableTimer(timer, &due, 0, NULL, NULL, 0))
|
||||
{
|
||||
printf("SetWaitableTimer failure\n");
|
||||
return -1;
|
||||
goto out;
|
||||
}
|
||||
|
||||
status = WaitForSingleObject(timer, INFINITE);
|
||||
|
@ -30,7 +31,7 @@ int TestSynchWaitableTimer(int argc, char* argv[])
|
|||
if (status != WAIT_OBJECT_0)
|
||||
{
|
||||
printf("WaitForSingleObject(timer, INFINITE) failure\n");
|
||||
return -1;
|
||||
goto out;
|
||||
}
|
||||
|
||||
printf("Timer Signaled\n");
|
||||
|
@ -40,7 +41,7 @@ int TestSynchWaitableTimer(int argc, char* argv[])
|
|||
if (status != WAIT_TIMEOUT)
|
||||
{
|
||||
printf("WaitForSingleObject(timer, 2000) failure: Actual: 0x%04X, Expected: 0x%04X\n", status, WAIT_TIMEOUT);
|
||||
return -1;
|
||||
goto out;
|
||||
}
|
||||
|
||||
due.QuadPart = 0;
|
||||
|
@ -50,13 +51,13 @@ int TestSynchWaitableTimer(int argc, char* argv[])
|
|||
if (!SetWaitableTimer(timer, &due, period, NULL, NULL, 0))
|
||||
{
|
||||
printf("SetWaitableTimer failure\n");
|
||||
return -1;
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (WaitForSingleObject(timer, INFINITE) != WAIT_OBJECT_0)
|
||||
{
|
||||
printf("WaitForSingleObject(timer, INFINITE) failure\n");
|
||||
return -1;
|
||||
goto out;
|
||||
}
|
||||
|
||||
printf("Timer Signaled\n");
|
||||
|
@ -64,13 +65,32 @@ int TestSynchWaitableTimer(int argc, char* argv[])
|
|||
if (WaitForMultipleObjects(1, &timer, FALSE, INFINITE) != WAIT_OBJECT_0)
|
||||
{
|
||||
printf("WaitForMultipleObjects(timer, INFINITE) failure\n");
|
||||
return -1;
|
||||
goto out;
|
||||
}
|
||||
|
||||
printf("Timer Signaled\n");
|
||||
|
||||
result = 0;
|
||||
|
||||
out:
|
||||
CloseHandle(timer);
|
||||
|
||||
return 0;
|
||||
|
||||
#ifdef __APPLE__
|
||||
if (result == 0)
|
||||
{
|
||||
printf("%s: Error, this test is currently expected not to succeed on this platform.\n",
|
||||
__FUNCTION__);
|
||||
result = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("%s: This test is currently expected to fail on this platform.\n",
|
||||
__FUNCTION__);
|
||||
result = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -108,6 +108,20 @@ cleanup:
|
|||
CloseHandle(g_Event);
|
||||
free(apcData);
|
||||
|
||||
#ifdef __APPLE__
|
||||
if (status == 0)
|
||||
{
|
||||
printf("%s: Error, this test is currently expected not to succeed on this platform.\n",
|
||||
__FUNCTION__);
|
||||
status = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("%s: This test is currently expected to fail on this platform.\n",
|
||||
__FUNCTION__);
|
||||
status = 0;
|
||||
}
|
||||
#endif
|
||||
return status;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue