diff options
Diffstat (limited to 'src/pal/tests/palsuite/miscellaneous/InterlockedExchangePointer')
4 files changed, 99 insertions, 0 deletions
diff --git a/src/pal/tests/palsuite/miscellaneous/InterlockedExchangePointer/CMakeLists.txt b/src/pal/tests/palsuite/miscellaneous/InterlockedExchangePointer/CMakeLists.txt new file mode 100644 index 0000000000..f6aa0cb2d9 --- /dev/null +++ b/src/pal/tests/palsuite/miscellaneous/InterlockedExchangePointer/CMakeLists.txt @@ -0,0 +1,4 @@ +cmake_minimum_required(VERSION 2.8.12.2) + +add_subdirectory(test1) + diff --git a/src/pal/tests/palsuite/miscellaneous/InterlockedExchangePointer/test1/CMakeLists.txt b/src/pal/tests/palsuite/miscellaneous/InterlockedExchangePointer/test1/CMakeLists.txt new file mode 100644 index 0000000000..b0858963a0 --- /dev/null +++ b/src/pal/tests/palsuite/miscellaneous/InterlockedExchangePointer/test1/CMakeLists.txt @@ -0,0 +1,19 @@ +cmake_minimum_required(VERSION 2.8.12.2) + +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +set(SOURCES + InterlockedExchangePointer.cpp +) + +add_executable(paltest_interlockedexchangepointer_test1 + ${SOURCES} +) + +add_dependencies(paltest_interlockedexchangepointer_test1 coreclrpal) + +target_link_libraries(paltest_interlockedexchangepointer_test1 + pthread + m + coreclrpal +) diff --git a/src/pal/tests/palsuite/miscellaneous/InterlockedExchangePointer/test1/InterlockedExchangePointer.cpp b/src/pal/tests/palsuite/miscellaneous/InterlockedExchangePointer/test1/InterlockedExchangePointer.cpp new file mode 100644 index 0000000000..d36c96724f --- /dev/null +++ b/src/pal/tests/palsuite/miscellaneous/InterlockedExchangePointer/test1/InterlockedExchangePointer.cpp @@ -0,0 +1,64 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +/*============================================================= +** +** Source: InterlockedExchangePointer +** +** Purpose: Positive test the InterlockedExchangePointer API. +** Call InterlockedExchangePointer to exchange a pair of +** value +** +** +** +**============================================================*/ +#include <palsuite.h> + +int __cdecl main(int argc, char *argv[]) +{ + int err; + int i1 = 10; + int i2 = 20; + int *pOldValue = &i1; + int *pNewValue = &i2; + PVOID pReturnValue; + + /*Initialize the PAL environment*/ + err = PAL_Initialize(argc, argv); + if(0 != err) + { + return FAIL; + } + + + + /* + Testing + ======= + */ + + pReturnValue = InterlockedExchangePointer((PVOID)&pOldValue, + (PVOID)pNewValue); + /*check the returned value*/ + if(*(int *)pReturnValue != i1) + { + Fail("\nFailed to call InterlockedExchangePointer API, " + "return pointer does not point to the origional value\n"); + } + + /*check the exchanged value*/ + if(*pOldValue != *pNewValue) + { + Fail("\nFailed to call InterlockedExchangePointer API, " + "exchanged value is not right\n"); + } + + + + /* + Clean Up + */ + PAL_Terminate(); + return PASS; +} diff --git a/src/pal/tests/palsuite/miscellaneous/InterlockedExchangePointer/test1/testinfo.dat b/src/pal/tests/palsuite/miscellaneous/InterlockedExchangePointer/test1/testinfo.dat new file mode 100644 index 0000000000..5e0a36627a --- /dev/null +++ b/src/pal/tests/palsuite/miscellaneous/InterlockedExchangePointer/test1/testinfo.dat @@ -0,0 +1,12 @@ +# Licensed to the .NET Foundation under one or more agreements. +# The .NET Foundation licenses this file to you under the MIT license. +# See the LICENSE file in the project root for more information. + +Version = 1.0 +Section = miscellaneous +Function = InterlockedExchangePointer +Name = Pos test for InterlockedExchangePointer API to excnage a pair of value +TYPE = DEFAULT +EXE1 = interlockedexchangepointer +Description +=Test the InterlockedExchangePointer to exchange a pair of value |