Commit Graph

59 Commits

Author SHA1 Message Date
Xphalnos
5f918ef28d [Misc] Replaced const with constexpr where possible 2025-03-25 19:50:37 +01:00
Gliniak
7437c020d6 [Misc] Fixed some issues during compilation process on Linux 2025-01-07 22:54:16 +01:00
Gliniak
c3586bc165 [C++] Uplift version to C++20 2024-12-26 23:42:31 +01:00
Gliniak
ec267c348a [LINT] Fixed lint issues after clang-format update 2024-06-13 20:56:56 +02:00
Triang3l
f964290ea8 [Base] Relax the system clock difference allowance in the test
Hopefully should reduce the CI failure rate, although this testing
approach is fundamentally flawed as it depends on OS scheduling.
2024-05-12 17:44:52 +03:00
Joel Linn
3b4dc7da3b [Base] Use disruptorplus spin wait
- Attempt to fix deadlocks when using valgrind on CI
2022-04-26 13:56:11 -05:00
Joel Linn
e59a0e1206 [Base] Relax some timing constraints.
- Because setting the timer is scheduled by us but the wait on POSIX is
  currently scheduled by pthreads, this solves issues on overprovisioned
  CIs
2022-04-26 13:56:11 -05:00
Joel Linn
15950eec37 [Base] Use chrono APIs for Timers 2022-04-26 13:56:11 -05:00
Joel Linn
1478be14c7 [Base] Add chrono tests 2022-04-26 13:56:11 -05:00
Joel Linn
a85fc25040 [Base] Add more tests for HighResolutionTimer 2022-04-26 13:56:11 -05:00
Joel Linn
e0f34b97fb [Base] Check for correct thread in HResTimer tests 2022-03-08 12:17:57 -06:00
Joel Linn
986dcf4f65 [Base] Check success of sync primitive creation
- Mainly use `assert`s, since failure is very rare
- Forward failure of `CreateSemaphore` to guests because it is more easy
  to trigger with invalid initial parameters.
2022-03-08 12:17:57 -06:00
Joel Linn
4ea6e45e0c [Base] Remove Sleeps from more test cases
Timing dependencies in this tests were causing spurious test failures:
- Create and Run Thread
- Test Thread QueueUserCallback

They have been largely replaced by spin waits.
2022-03-08 12:17:57 -06:00
Joel Linn
ca6296089e [Base] Remove timing dependency from test
- Use atomics and spin waits to synchronize threads for tests
- Improves test stability on CI
2022-03-08 12:17:57 -06:00
Joel Linn
49efbeaca8 [Base] Add spin wait helper to threading test 2022-03-08 12:17:57 -06:00
Joel Linn
dbbf401205 [Base] Align test memory 2022-01-25 12:55:10 -06:00
Joel Linn
0316d1a054 [Base] Tests for copy_and_swap_16_in_32_aligned 2022-01-22 16:18:54 +03:00
Joel Linn
bfaad055a2 [Base] Add easier to debug copy_and_swap tests 2022-01-22 16:18:54 +03:00
Wunkolo
1a8068b151 [Base] Add user-literals for several memory sizes
Rather than using `n * 1024 * 1024`, this adds a convenient `_MiB`/`_KiB` user-literal to the new `literals.h` header to concisely describe units of memory in a much more readable way. Any other useful literals can be added to this header. These literals exist in the `xe::literals` namespace so they are opt-in, similar to `std::chrono` literals, and require a `using namespace xe::literals` statement to utilize it within the current scope.

I've done a pass through the codebase to replace trivial instances of `1024 * 1024 * ...` expressions being used but avoided anything that added additional casting complexity from `size_t` to `uint32_t` and such to keep this commit concise.
2022-01-02 11:51:31 -06:00
Gliniak
1cc0c1c985 Added more UTF-8 path tests (fnfp & fbnfp).
Added more UTF-8 path tests (find_name_from_path &
find_base_name_from_path).
2021-06-25 23:35:56 -05:00
Rick Gibbed
0d3ef65dcd Add more UTF-8 path tests.
Add more UTF-8 path tests to catch newly discovered issues.
2021-06-25 23:07:57 -05:00
Joel Linn
ceb382f8ec Update Catch2 test framework
- Use their main() method to fix command line options. Fix CLion testing
- Change to correct tag syntax.
2021-06-02 22:28:43 -05:00
Joel Linn
0e019f96b4 [Base, Linux] Make thread exit non returning
- Use pthread_exit() instead of pthread_cancel() if current thread
- Modify tests to ensure Exit does not return
2021-06-02 22:28:43 -05:00
Joel Linn
4d0d3f3ad4 [Base] Fix semaphore test
- Was using `Sleep()`
- Replaced with atomic value and bool flag
2021-06-02 22:28:43 -05:00
Joel Linn
2d9462f02b [Base] Fix unitialized variable in threading test 2021-06-02 22:28:43 -05:00
Joel Linn
4daa3f5a52 [Base] Add FourCC tests 2021-06-02 22:28:43 -05:00
gibbed
a18f9c9dc1 Add UTF-8 path tests for trailing separator. 2021-05-02 09:36:32 -05:00
gibbed
9185c36b41 Add more UTF-8 path edge cases.
- Add macro for automatically testing both / and \ of all path
  input/outputs.
- Add more UTF-8 path edge cases.
2021-05-02 08:18:22 -05:00
gibbed
653931ec8f Add and improve UTF8 tests. 2021-05-01 15:16:37 -05:00
Triang3l
aca23c08cf [Memory] Fix kFileMappingHandleInvalid typos in tests 2020-11-22 18:49:47 +03:00
Triang3l
86ae42919d [Memory] Close shared memory FD and properly handle its invalid value 2020-11-22 14:17:37 +03:00
Sandy Carter
49e194009b [memory linux] Properly unlink shared memory
shm_unlink(name) is the proper way to close a shared memory in linux.
Prior to this, xenia was creating and not cleaning up shared memory handle
which would accumulate in /dev/shm. shm_unlink is the proper way of doing
this.
Add filename to CloseFileMappingHandle signature.
Add simple test to open and close.
2020-11-22 13:54:00 +03:00
Sandy Carter
2c7009ca80 [memory] Move "Local\\" prefix to win impl
CreateFileMappingHandle now takes shared memory name without a prefix.
The doc of shm_open recommends not using slashes and prefixing with "/".
The prefixing has been moved to the os implementation layer.
Invocations of CreateFileMappingHandle were all using "Local\\" so these
prefixes were removed.
2020-11-22 13:54:00 +03:00
Sandy Carter
22ef265057 [memory] Add Memory mapping view tests
Add test for mapping and for mapping with access.
2020-11-22 13:54:00 +03:00
Sandy Carter
aa332dcc8e threading_posix: Increase stack size in test
16 KB is not enough for the linux thread to be spawned so bump up to 16MB
2020-11-21 22:30:43 -06:00
Sandy
36466231d0 threading test: zero initialize counter
The high performance test atomic counters need to be set to zero to have reliable results.
2020-11-16 00:13:14 -06:00
Joel Linn
68cf47e245 [threading] Fix Fence for multiple waiting threads 2020-11-15 11:12:05 -06:00
Sandy Carter
e945a13957 [threading linux] Implement suspend count
Add suspend count to thread implementation.
Increment suspend count on suspend and decrement on resume.
Wait on suspend count to be decremented to 0.
Return suspend count on suspend and on resume before incr/decr.
Fix naming of resume suspend count to make clear that suspend count is
before incr/decr.
Add test.
2020-11-15 11:12:05 -06:00
Sandy Carter
e11fa0372d [threading linux] Implement Signal and Wait
Add Signal abstract function to handles.
Test SignalAndWait.
2020-11-15 11:12:05 -06:00
Sandy Carter
cb905fb195 [threading] Add complex wait on multiple test 2020-11-15 11:12:05 -06:00
Sandy Carter
e9e269622b [threading linux] Implement TLS
Implement TLSHandle with pthread_key_t.

Test Alloc, Free, Get and Set.
2020-11-15 11:12:05 -06:00
Sandy Carter
634f87f63b [threading linux] Implement Callback Queuing
Add thread local bool for alertable state.
Use real-time event interrupt to run callback.
Fix sleep duration from miliseconds (microseconds / 1000) to seconds in sleep
command.
Add note for future implementation.

Ignore real-time event 37 in .gdbinit which is used to signal callback.

Test AlertableSleep
Test Thread QueueUserCallback.
TODO: Test alerted wait result when using IO functions.
2020-11-15 11:12:05 -06:00
Sandy Carter
4397f25325 [threading linux] Implement suspendable pthreads
Use real-time event interrupt to communicate suspend in timely manner.
Use conditional_variable to implement suspend wait and resume trigger.

Ignore real-time event 36 in .gdbinit which is used to signal suspend.

Test suspending threads.
2020-11-15 11:12:05 -06:00
Sandy Carter
b91203a0b5 [threading linux] Implement basic Thread function
Add Basic Tests on Threads
2020-11-15 11:12:05 -06:00
Sandy Carter
c2de074d5c [threading linux] Implement Timer
Test Manual Reset and Synchronization timers single threaded.
Test Cancelling timers.
Test WaitMultiple.
Ignore real-time event 35 in .gdbinit which is used to signal timer.

Callbacks don't seem to be called so testing them is difficult.
2020-11-15 11:12:05 -06:00
Sandy Carter
331bb0ea9a [threading linux] Implement Mutant
Keep track of recursive locks with owner and count of locks.
Only allow recursive locks from same thread and increment count.
Only allow first locks from when count is zero.

Test acquiring and releasing mutant on same and on different threads.
Test Release return values.
Test WaitAll and WaitAny.
2020-11-15 11:12:05 -06:00
Sandy Carter
5d0efedaf4 [threading linux] Implement Semaphore
Test acquiring and releasing semaphores on same and on different threads.
Test previous_count values.
Test WaitAll and WaitAny.

Add tests for invalid semaphore creation parameters but disactivated as
they do not pass on any platform. These should be enabled and the
implementations fixed to match documentation.
2020-11-15 11:12:05 -06:00
Sandy Carter
6e13a38cad [threading linux] Implement WaitMultiple
Make conditional_variable and mutex static and create generalisation of
Wait for vector of handles.
Use std::any for waitany and std::all for waitall
2020-11-15 11:12:05 -06:00
Sandy Carter
4ce9eddfb9 [threading] Test WaitAll and WaitAny with Events 2020-11-15 11:12:05 -06:00
Sandy Carter
9d20adfa77 [threading linux] Implement Events
Remove file-descriptor specific wait implementation to PosixFdHandle class
which breaks on waits of non-fd handles.
Replace with PosixConditionHandle and extend to support auto reset and
initial values.
Simplify mutex and conditional variable use with stdlib versions which
wrap these primitives but provide better C++ interface.
Test Event and Reset
2020-11-15 11:12:05 -06:00