int TestVersion(int argc, char* argv[])
{
- const char *version;
- const char *git;
- const char *build;
+ const char* version;
+ const char* git;
+ const char* build;
int major = 0, minor = 0, revision = 0;
-
+ WINPR_UNUSED(argc);
+ WINPR_UNUSED(argv);
freerdp_get_version(&major, &minor, &revision);
+
if (major != FREERDP_VERSION_MAJOR)
return -1;
return -1;
version = freerdp_get_version_string();
+
if (!version)
return -1;
git = freerdp_get_build_revision();
+
if (!git)
return -1;
return -1;
build = freerdp_get_build_date();
+
if (!build)
return -1;
build = freerdp_get_build_config();
+
if (!build)
return -1;
}
rc = WaitForSingleObject(mutex, INFINITE);
+
if (rc != WAIT_OBJECT_0)
{
printf("%s: WaitForSingleObject on mutex failed with %"PRIu32"\n", __FUNCTION__, rc);
printf("%s: CloseHandle on mutex failed\n", __FUNCTION__);
return FALSE;
}
+
return TRUE;
}
for (i = 0; i < cnt; i++)
{
rc = WaitForSingleObject(mutex, INFINITE);
+
if (rc != WAIT_OBJECT_0)
{
printf("%s: WaitForSingleObject #%"PRIu32" on mutex failed with %"PRIu32"\n", __FUNCTION__, i, rc);
printf("%s: CloseHandle on mutex failed\n", __FUNCTION__);
return FALSE;
}
+
return TRUE;
}
-
static HANDLE thread1_mutex1 = NULL;
static HANDLE thread1_mutex2 = NULL;
static BOOL thread1_failed = TRUE;
{
HANDLE hStartEvent = (HANDLE)lpParam;
DWORD rc = 0;
+
if (WaitForSingleObject(hStartEvent, INFINITE) != WAIT_OBJECT_0)
{
fprintf(stderr, "%s: failed to wait for start event\n", __FUNCTION__);
return 0;
}
-
+
/**
* at this point:
* thread1_mutex1 is expected to be locked
* try to lock thread1_mutex1 (expected to fail)
* lock and unlock thread1_mutex2 (expected to work)
*/
-
rc = WaitForSingleObject(thread1_mutex1, 10);
+
if (rc != WAIT_TIMEOUT)
{
- fprintf(stderr, "%s: WaitForSingleObject on thread1_mutex1 unexpectedly returned %"PRIu32" instead of WAIT_TIMEOUT (%u)\n",
- __FUNCTION__, rc, WAIT_TIMEOUT);
+ fprintf(stderr,
+ "%s: WaitForSingleObject on thread1_mutex1 unexpectedly returned %"PRIu32" instead of WAIT_TIMEOUT (%u)\n",
+ __FUNCTION__, rc, WAIT_TIMEOUT);
return 0;
}
rc = WaitForSingleObject(thread1_mutex2, 10);
+
if (rc != WAIT_OBJECT_0)
{
- fprintf(stderr, "%s: WaitForSingleObject on thread1_mutex2 unexpectedly returned %"PRIu32" instead of WAIT_OBJECT_0\n",
- __FUNCTION__, rc);
+ fprintf(stderr,
+ "%s: WaitForSingleObject on thread1_mutex2 unexpectedly returned %"PRIu32" instead of WAIT_OBJECT_0\n",
+ __FUNCTION__, rc);
return 0;
}
- if (!ReleaseMutex(thread1_mutex2)) {
+ if (!ReleaseMutex(thread1_mutex2))
+ {
fprintf(stderr, "%s: ReleaseMutex failed on thread1_mutex2\n", __FUNCTION__);
return 0;
}
thread1_failed = FALSE;
-
return 0;
}
{
printf("%s: ReleaseMutex unexpectedly succeeded on thread1_mutex2\n", __FUNCTION__);
goto fail;
- }
+ }
CloseHandle(hThread);
CloseHandle(hStartEvent);
CloseHandle(thread1_mutex1);
CloseHandle(thread1_mutex2);
-
- return TRUE;
-
+ return TRUE;
fail:
ReleaseMutex(thread1_mutex1);
ReleaseMutex(thread1_mutex2);
int TestSynchMutex(int argc, char* argv[])
{
+ int rc = 0;
+ WINPR_UNUSED(argc);
+ WINPR_UNUSED(argv);
+
if (!test_mutex_basic())
- return 1;
+ rc += 1;
if (!test_mutex_recursive())
- return 2;
+ rc += 2;
if (!test_mutex_threading())
- return 3;
+ rc += 4;
- printf("TestSynchMutex succeeded\n");
- return 0;
+ printf("TestSynchMutex result %d\n", rc);
+ return rc;
}
{
APC_DATA* apcData;
UINT32 CurrentTime = GetTickCount();
+ WINPR_UNUSED(dwTimerLowValue);
+ WINPR_UNUSED(dwTimerHighValue);
if (!lpArg)
return;
apcData = (APC_DATA*) lpArg;
-
printf("TimerAPCProc: time: %"PRIu32"\n", CurrentTime - apcData->StartTime);
-
g_Count++;
if (g_Count >= 5)
HANDLE hTimer = NULL;
BOOL bSuccess;
LARGE_INTEGER due;
- APC_DATA* apcData = NULL;
-
- apcData = (APC_DATA*) malloc(sizeof(APC_DATA));
- if (!apcData)
- {
- printf("Memory allocation failed\n");
- goto cleanup;
- }
-
+ APC_DATA apcData = { 0 };
+ WINPR_UNUSED(argc);
+ WINPR_UNUSED(argv);
g_Event = CreateEvent(NULL, TRUE, FALSE, NULL);
+
if (!g_Event)
{
printf("Failed to create event\n");
goto cleanup;
due.QuadPart = -15000000LL; /* 1.5 seconds */
-
- apcData->StartTime = GetTickCount();
- bSuccess = SetWaitableTimer(hTimer, &due, 2000, TimerAPCProc, apcData, FALSE);
+ apcData.StartTime = GetTickCount();
+ bSuccess = SetWaitableTimer(hTimer, &due, 2000, TimerAPCProc, &apcData, FALSE);
if (!bSuccess)
goto cleanup;
* using SetWaitableTimer. However, the thread must be in an ALERTABLE state.
*/
-
/**
* Note: On WIN32 we need to use WaitForSingleObjectEx with parameter bAlertable = TRUE
* However, WinPR currently (May 2016) does not have a working WaitForSingleObjectEx implementation
* timer implementations.
**/
- for(;;)
+ for (;;)
{
DWORD rc;
#ifdef _WIN32
#else
rc = WaitForSingleObject(g_Event, INFINITE);
#endif
+
if (rc == WAIT_OBJECT_0)
break;
}
status = 0;
-
cleanup:
+
if (hTimer)
CloseHandle(hTimer);
+
if (g_Event)
CloseHandle(g_Event);
- free(apcData);
return status;
}
int TestVersion(int argc, char* argv[])
{
- const char *version;
- const char *git;
- const char *build;
+ const char* version;
+ const char* git;
+ const char* build;
int major = 0, minor = 0, revision = 0;
-
+ WINPR_UNUSED(argc);
+ WINPR_UNUSED(argv);
winpr_get_version(&major, &minor, &revision);
+
if (major != WINPR_VERSION_MAJOR)
return -1;
return -1;
version = winpr_get_version_string();
+
if (!version)
return -1;
git = winpr_get_build_revision();
+
if (!git)
return -1;
return -1;
build = winpr_get_build_date();
+
if (!build)
return -1;
build = winpr_get_build_config();
+
if (!build)
return -1;