Commit Graph

75 Commits

Author SHA1 Message Date
Armin Novak
6bdd36c83d [winpr,test] fix testsynchmultiplethreads 2023-08-01 07:44:48 +02:00
Armin Novak
e61880d077 [standard] replace __FUNCTION__ with __func__ 2023-07-27 20:02:43 +02:00
David Fort
da10710cf9
winpr: complement thread tests and fix some asserts (#8105) 2022-08-02 11:40:55 +02:00
David Fort
77413f49b2 winpr: rework alignment functions
_align_XXX functions aren't widely available depending on the C runtime. That causes
problems with mingw where we can easily have some runtime mixes (which lead to mysterious
segfaults most of the time). This patch introduce winpr_aligned_XXX functions that will
either use the function available, or use an emulation layer.
2022-05-12 11:36:01 +02:00
Armin Novak
1947629b8e Fixed possible leaks in TestSynchMultipleThreads 2022-02-14 08:36:55 +00:00
Armin Novak
5eea7fc12d WINPR_UNUSED argc, argv for unit tests 2021-08-24 10:45:57 +02:00
Armin Novak
610396e197 Fixed compilation warnings
Try to get the number of warnings down
2021-08-02 10:28:06 +02:00
Armin Novak
1af7ef2f1b Fixed compilation warnings and typos 2021-06-16 15:21:56 +02:00
Armin Novak
210b9f58b7 Increased time in TestSynchMultipleThreads 2021-06-09 11:03:37 +02:00
Armin Novak
c5fded2d83 Improved runtime of unit tests 2021-06-08 08:21:47 +02:00
Armin Novak
37c7d5d0f0 Increased TestSynchCritical timeout 2021-06-01 14:18:01 +02:00
Armin Novak
a2930c04c3 Fixed random sleep time for test_synch_barrier_thread 2021-05-31 12:29:16 +02:00
Armin Novak
d4b3267860 Make TestSynchBarrier verbose 2021-05-31 12:26:30 +02:00
akallabeth
997ea7e09d Increased thread test run time to fix failing mac tests 2021-05-25 08:54:09 +02:00
akallabeth
d4ebf8546f Cleaned up crypto API 2021-05-11 08:00:18 +02:00
Armin Novak
18ceebb774 Simplified sync test 2021-04-27 11:48:39 +02:00
David Fort
aeba30a505 winpr: correctly implement APC
This patch implements APC functions and fixes waitable timers with completions.
2021-04-07 08:15:16 +02:00
David Fort
dfbbf3b618 winpr: cleanup polling code
Externalize all the polling logic in a pollset component. This patch prepares the
support of APC and alertable state.
2021-04-07 08:15:16 +02:00
Armin Novak
72ca88f49c Reformatted to new style 2019-11-07 10:53:54 +01:00
Armin Novak
c7b7d527f3 Fixed unused argument warnings for tests. 2019-04-05 09:14:35 +02:00
Armin Novak
6e655189c3 Fixed sign-compare warnings 2019-04-05 09:14:34 +02:00
Armin Novak
9033df501e Fixed compiler warnings for TRIO_CONST and limited data type. 2019-01-29 17:51:44 +01:00
Kyle Evans
8073a7850e Pull in the libepoll-shim includes for libwinpr's synch/test
This allows FreeBSD to successfully build with BUILD_TESTING enabled. Currently,
only 3/184 tests fail:

	 13 - TestLibraryLoadLibrary (Failed)
	 14 - TestLibraryGetProcAddress (Failed)
	 15 - TestLibraryGetModuleFileName (Failed)

These failures are probably due to a lack of GetModuleFileNameA implementation
on FreeBSD.
2018-05-02 23:19:44 -05:00
Armin Novak
9bd13c25c9 Added WaitableTimer implementation for mac OS. 2018-03-12 13:39:21 +01:00
Armin Novak
44eebbb6e0 Fixed compiler warnings. 2018-03-07 14:47:06 +01:00
Armin Novak
2517755d25 Fixed thread function return and parameters. 2018-03-07 14:36:55 +01:00
Norbert Federa
36b8f54c5e Fixed a few compiler warnings 2017-07-10 17:52:05 +02:00
Armin Novak
09d43a66f4 Fixed tests and dead store warnings. 2017-03-28 16:49:56 +02:00
Norbert Federa
f71b6b46e8 fix string format specifiers
- fixed invalid, missing or additional arguments
- removed all type casts from arguments
- added missing (void*) typecasts for %p arguments
- use inttypes defines where appropriate
2016-12-16 13:48:43 +01:00
Armin Novak
50c509eee2 Fixed barrier test. 2016-10-06 13:43:10 +02:00
Armin Novak
1454400236 Fixed windows defines for *LIST* 2016-10-06 13:43:10 +02:00
Armin Novak
64c5d78b3f Fixed clang warnings. 2016-10-06 13:43:09 +02:00
Norbert Federa
f2c825bb76 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
2016-06-07 17:20:56 +02:00
Norbert Federa
131ffaa89b winpr/synch: improve barrier test
The SYNCHRONIZATION_BARRIER_FLAGS_SPIN_ONLY flag caused this test
to run extremely long if the system has very few processors.
Although this is expected (thread starvation) this will cause a
intolerably long execution time for automated tests.
Changed the number of threads to be calculated dyamically based
on the number of processors.
Also do proper cleanup to prevent memory leaks.
2016-06-06 15:41:05 +02:00
Norbert Federa
2dba082587 winpr/synch/barrier: fix return value and test
- According to the msdn docs DeleteSynchronizationBarrier always returns TRUE
- Added additional error checks to the barrier test
2016-06-04 13:40:01 +02:00
Norbert Federa
85f44262de winpr/synch: add spinning support to barrier
Implemented the SYNCHRONIZATION_BARRIER_FLAGS_BLOCK_ONLY and
SYNCHRONIZATION_BARRIER_FLAGS_SPIN_ONLY flags.
2016-06-04 00:55:27 +02:00
Norbert Federa
341eed138f winpr/synch: rewrite barrier implementation & test
The synchronization barrier test as well as the actual WinPR
implementation were completely broken.
2016-06-03 18:56:36 +02:00
Norbert Federa
e718fb324b fix race conditions, tests and some invalid return values
Since the current winpr implementation for overlapped operations is
incomplete and buggy, all affected functions will now fail if they are
called with a set FILE_FLAG_OVERLAPPED flag or a non-null pointer to
a OVERLAPPED structure.

winpr/nt:
- use proper one-time initialization on win32
- fix TestNtCreateFile
- fix broken/incomplete _RtlAnsiStringToUnicodeString
- unimplemented functions return appropriate error codes

winpr/pipe:
- improved TestPipeCreateNamedPipe
- rewrite the completely broken TestPipeCreateNamedPipeOverlapped test

rdtk:
- improve test and don't blindly return success

winpr/synch:
- fix race condition in TestSynchTimerQueue

winpr/ssspi:
- fix TestEnumerateSecurityPackages printf output
- fix TestQuerySecurityPackageInfo printf output

winpr/environment:
- fix GetEnvironmentStrings printf output

winpr/comm:
- unimplemented functions return appropriate error codes

winpr/io:
- unimplemented functions return appropriate error codes

winpr/thread:
- implement SwitchToThread() via sched_yield()
2016-06-01 16:26:26 +02:00
Norbert Federa
aded51f38f winpr/synch: fix tests
TestSynchTimerQueue:
- fixed race condition

TestSynchWaitableTimerAPC:
- Use WaitForSingleObjectEx since the thread must be in an alterable state

TestSynch is now expected to succeed on WIN32
2016-05-24 22:33:27 +02:00
Norbert Federa
386d290015 winpr/synch: fix mutex implementation
- Mutex is recursive on Windows; as a consequence we have to use
  the pthread PTHREAD_MUTEX_RECURSIVE type
- Adapt MutexCloseHandle accordingly
- ReleaseMutex returned TRUE even if pthread_mutex_unlock failed
- Fixed and improved the TestSynchMutex ctest
2016-05-24 15:10:57 +02:00
Marc-André Moreau
093aaa4dc0 Merge pull request #2636 from xhaakon/master
Fix crashes in shadow server
2015-06-22 09:15:37 -04:00
Norbert Federa
f503f4cf0b winpr/synch: fix ResetEvent & improve CTest
Unless there is an invalid parameter or internal error, ResetEvent
must return TRUE, even if the object is in nonsignaled state.

Also fixed and improved the CTest TestSynchEvent to test for the
expected/correct SetEvent and ResetEvent return values.
2015-06-17 14:13:28 +02:00
Jakub Adam
73888a57c2 Ensure threads have finished using a barrier before releasing it
MSDN documentation says it is ensured that all threads in the barrier
have finished using it before allowing the barrier to be released in
DeleteSynchronizationBarrier(). The winpr re-implementation wasn't
keeping to that requirement, which was causing occasional crashes
when shadow client tried to access already freed barrier structure.

The crash was occuring in winpr_Handle_cleanup() after finished
waiting on a barrier's event.
2015-05-22 13:36:15 +02:00
Norbert Federa
1eff1a345e free can handle NULL perfectly fine 2015-05-11 09:07:39 +02:00
Norbert Federa
25fc866a58 Fix unchecked CreateThread calls and misc fixes 2015-05-05 13:55:48 +02:00
Norbert Federa
ef1fd12b15 Fix unchecked CreateEvent calls and misc fixes
1)
Added missing checks for CreateEvent which also required the
following related changes:

- changed freerdp_context_new API to BOOL
- changed freerdp_peer_context_new API to BOOL
- changed pRdpClientNew callback to BOOL
- changed pContextNew callback to BOOL
- changed psPeerAccepted callback to BOOL
- changed psPeerContextNew callback to BOOL

2)
Fixed lots of missing alloc and error checks in the
changed code's neighbourhood.

3)
Check freerdp_client_codecs_prepare result to avoid segfaults
caused by using non-initialized codecs.

4)
Fixed deadlocks in x11 caused by missing xf_unlock_x11() calls
in some error handlers

5)
Some fixes in thread pool:
- DEFAULT_POOL assignment did not match TP_POOL definition
- don't free the pool pointer if it points to the static DEFAULT_POOL
- added error handling and cleanup in InitializeThreadpool
2015-04-29 18:18:39 +02:00
Bernhard Miklautz
850de59b55 winpr: add checks for *alloc
Add missing checks if memory allocation was successful. Also adapt
caller(s) when possible.
2015-04-08 11:34:37 +02:00
Marc-André Moreau
ccf144e10f libwinpr-synch: fix test build on Win32 2015-02-17 18:44:09 -05:00
Armin Novak
51cc567dc6 Fixed typo. 2014-11-16 23:52:22 +01:00
Armin Novak
a1761d8a7b Fixed memory leaks. 2014-11-16 23:10:33 +01:00