diff options
Diffstat (limited to 'src/pal/tests/palsuite/exception_handling/pal_except')
22 files changed, 1063 insertions, 0 deletions
diff --git a/src/pal/tests/palsuite/exception_handling/pal_except/CMakeLists.txt b/src/pal/tests/palsuite/exception_handling/pal_except/CMakeLists.txt new file mode 100644 index 0000000000..19ee487a6a --- /dev/null +++ b/src/pal/tests/palsuite/exception_handling/pal_except/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 2.8.12.2) + +add_subdirectory(test1) +add_subdirectory(test2) +add_subdirectory(test3) +add_subdirectory(test4) +add_subdirectory(test5) +add_subdirectory(test6) +add_subdirectory(test7) + diff --git a/src/pal/tests/palsuite/exception_handling/pal_except/test1/CMakeLists.txt b/src/pal/tests/palsuite/exception_handling/pal_except/test1/CMakeLists.txt new file mode 100644 index 0000000000..635e35d635 --- /dev/null +++ b/src/pal/tests/palsuite/exception_handling/pal_except/test1/CMakeLists.txt @@ -0,0 +1,19 @@ +cmake_minimum_required(VERSION 2.8.12.2) + +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +set(SOURCES + test1.c +) + +add_executable(paltest_pal_except_test1 + ${SOURCES} +) + +add_dependencies(paltest_pal_except_test1 coreclrpal) + +target_link_libraries(paltest_pal_except_test1 + pthread + m + coreclrpal +) diff --git a/src/pal/tests/palsuite/exception_handling/pal_except/test1/test1.c b/src/pal/tests/palsuite/exception_handling/pal_except/test1/test1.c new file mode 100644 index 0000000000..0fe48e7fc3 --- /dev/null +++ b/src/pal/tests/palsuite/exception_handling/pal_except/test1/test1.c @@ -0,0 +1,67 @@ +// 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: test1.c (exception_handling\pal_except\test1) +** +** Purpose: Test to make sure the PAL_EXCEPT block is executed +** after an exception occurs in the PAL_TRY block +** +** +**===================================================================*/ +#include <palsuite.h> + +/* Execution flags */ +BOOL bTry = FALSE; +BOOL bExcept = FALSE; + +int __cdecl main(int argc, char *argv[]) +{ + if (0 != PAL_Initialize(argc, argv)) + { + return FAIL; + } + + PAL_TRY + { + int* p = 0x00000000; /* NULL pointer */ + + bTry = TRUE; /* indicate we hit the PAL_TRY block */ + *p = 13; /* causes an access violation exception */ + + Fail("ERROR: code was executed after the access violation.\n"); + } + PAL_EXCEPT(EXCEPTION_EXECUTE_HANDLER) + { + if (!bTry) + { + Fail("ERROR: PAL_EXCEPT was hit without PAL_TRY being hit.\n"); + } + + bExcept = TRUE; /* indicate we hit the PAL_EXCEPT block */ + } + PAL_ENDTRY; + + if (!bTry) + { + Trace("ERROR: the code in the PAL_TRY block was not executed.\n"); + } + + if (!bExcept) + { + Trace("ERROR: the code in the PAL_EXCEPT block was not executed.\n"); + } + + /* did we hit all the code blocks? */ + if(!bTry || !bExcept) + { + Fail(""); + } + + + PAL_Terminate(); + return PASS; + +} diff --git a/src/pal/tests/palsuite/exception_handling/pal_except/test1/testinfo.dat b/src/pal/tests/palsuite/exception_handling/pal_except/test1/testinfo.dat new file mode 100644 index 0000000000..246553a9cb --- /dev/null +++ b/src/pal/tests/palsuite/exception_handling/pal_except/test1/testinfo.dat @@ -0,0 +1,23 @@ +# 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 = exception_handling + +Function = PAL_TRY and PAL_EXCEPT + +Name = Test for PAL_TRY and PAL_EXCEPT + +Type = DEFAULT + +EXE1 = test1 + +LANG = cpp + +Description + += Test to make sure the PAL_EXCEPT block is executed + += after an exception occurs in the PAL_TRY block diff --git a/src/pal/tests/palsuite/exception_handling/pal_except/test2/CMakeLists.txt b/src/pal/tests/palsuite/exception_handling/pal_except/test2/CMakeLists.txt new file mode 100644 index 0000000000..813b0e66a1 --- /dev/null +++ b/src/pal/tests/palsuite/exception_handling/pal_except/test2/CMakeLists.txt @@ -0,0 +1,19 @@ +cmake_minimum_required(VERSION 2.8.12.2) + +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +set(SOURCES + test2.c +) + +add_executable(paltest_pal_except_test2 + ${SOURCES} +) + +add_dependencies(paltest_pal_except_test2 coreclrpal) + +target_link_libraries(paltest_pal_except_test2 + pthread + m + coreclrpal +) diff --git a/src/pal/tests/palsuite/exception_handling/pal_except/test2/test2.c b/src/pal/tests/palsuite/exception_handling/pal_except/test2/test2.c new file mode 100644 index 0000000000..bc0d4e300a --- /dev/null +++ b/src/pal/tests/palsuite/exception_handling/pal_except/test2/test2.c @@ -0,0 +1,111 @@ +// 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: test2.c (exception_handling\pal_except\test2) +** +** Purpose: Test to make sure the PAL_EXCEPT block is executed +** after an exception occurs in the PAL_TRY block +** that contains another PAL_TRY-PAL_EXCEPT block +** +** +**===================================================================*/ +#include <palsuite.h> + +/* Execution flags */ +BOOL bTry = FALSE; +BOOL bExcept = FALSE; +BOOL bTry_nested = FALSE; +BOOL bExcept_nested = FALSE; + +int __cdecl main(int argc, char *argv[]) +{ + if (0 != PAL_Initialize(argc, argv)) + { + return FAIL; + } + + PAL_TRY + { + int* p = 0x00000000; /* NULL pointer */ + + bTry = TRUE; /* indicate we hit the PAL_TRY block */ + + + /* Nested PAL_TRY */ + PAL_TRY + { + bTry_nested = TRUE; + + *p = 13; /* causes an access violation exception */ + + Fail("ERROR: code was executed after the nested access violation.\n"); + + } + PAL_EXCEPT(EXCEPTION_EXECUTE_HANDLER) + { + if (!bTry) + { + Fail("ERROR: Nested PAL_EXCEPT was hit without " + "nested PAL_TRY being hit.\n"); + } + bExcept_nested = TRUE; + } + PAL_ENDTRY; + + *p = 13; /* causes an access violation exception */ + + Fail("ERROR: code was executed after the access violation.\n"); + } + PAL_EXCEPT(EXCEPTION_EXECUTE_HANDLER) + { + if (!bTry) + { + Fail("ERROR: PAL_EXCEPT was hit without PAL_TRY being hit.\n"); + } + if (!bExcept_nested) + { + Fail("ERROR: PAL_EXCEPT was hit without " + "nested PAL_EXCEPT being hit.\n"); + } + + bExcept = TRUE; /* indicate we hit the PAL_EXCEPT block */ + } + PAL_ENDTRY; + + if (!bTry) + { + Trace("ERROR: the code in the PAL_TRY block was not executed.\n"); + } + + if (!bExcept) + { + Trace("ERROR: the code in the PAL_EXCEPT block was not executed.\n"); + } + + if (!bTry_nested) + { + Trace("ERROR: the code in the " + "nested PAL_TRY block was not executed.\n"); + } + + if (!bExcept_nested) + { + Trace("ERROR: the code in the " + "nested PAL_EXCEPT block was not executed.\n"); + } + + /* did we hit all the code blocks? */ + if(!bTry || !bExcept || + !bTry_nested || !bExcept_nested) + { + Fail(""); + } + + + PAL_Terminate(); + return PASS; + +} diff --git a/src/pal/tests/palsuite/exception_handling/pal_except/test2/testinfo.dat b/src/pal/tests/palsuite/exception_handling/pal_except/test2/testinfo.dat new file mode 100644 index 0000000000..39a628b16c --- /dev/null +++ b/src/pal/tests/palsuite/exception_handling/pal_except/test2/testinfo.dat @@ -0,0 +1,25 @@ +# 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 = exception_handling + +Function = PAL_TRY and PAL_EXCEPT_EX + +Name = Test for PAL_TRY and PAL_EXCEPT_EX + +Type = DEFAULT + +EXE1 = test2 + +LANG = cpp + +Description + += Test to make sure the PAL_EXCEPT_EX block is executed + += after an exception occurs in the PAL_TRY block + += that contains another PAL_TRY-PAL_EXCEPT_EX block diff --git a/src/pal/tests/palsuite/exception_handling/pal_except/test3/CMakeLists.txt b/src/pal/tests/palsuite/exception_handling/pal_except/test3/CMakeLists.txt new file mode 100644 index 0000000000..5fc3b096af --- /dev/null +++ b/src/pal/tests/palsuite/exception_handling/pal_except/test3/CMakeLists.txt @@ -0,0 +1,19 @@ +cmake_minimum_required(VERSION 2.8.12.2) + +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +set(SOURCES + test3.c +) + +add_executable(paltest_pal_except_test3 + ${SOURCES} +) + +add_dependencies(paltest_pal_except_test3 coreclrpal) + +target_link_libraries(paltest_pal_except_test3 + pthread + m + coreclrpal +) diff --git a/src/pal/tests/palsuite/exception_handling/pal_except/test3/test3.c b/src/pal/tests/palsuite/exception_handling/pal_except/test3/test3.c new file mode 100644 index 0000000000..0137697774 --- /dev/null +++ b/src/pal/tests/palsuite/exception_handling/pal_except/test3/test3.c @@ -0,0 +1,120 @@ +// 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: test3.c (exception_handling\pal_except\test3) +** +** Purpose: Test to make sure the PAL_EXCEPT block is executed +** after an exception occurs in the PAL_TRY block +** that calls a function that contains +** another PAL_TRY-PAL_EXCEPT block +** +** +**===================================================================*/ +#include <palsuite.h> + +/* Execution flags */ +BOOL bTry = FALSE; +BOOL bExcept = FALSE; +BOOL bTry_function = FALSE; +BOOL bExcept_function = FALSE; + +/* + * Helper function that contains a PAL_TRY-PAL_EXCEPT block + */ +void Helper() +{ + /* Nested PAL_TRY */ + PAL_TRY + { + int *lp = 0x00000000; + + bTry_function = TRUE; + + *lp = 13; /* causes an access violation exception */ + + Fail("ERROR: code was executed after the function's access violation.\n"); + + } + PAL_EXCEPT(EXCEPTION_EXECUTE_HANDLER) + { + if (!bTry) + { + Fail("ERROR: Nested PAL_EXCEPT was hit without " + "the function's PAL_TRY being hit.\n"); + } + bExcept_function = TRUE; + } + PAL_ENDTRY; +} + +int __cdecl main(int argc, char *argv[]) +{ + if (0 != PAL_Initialize(argc, argv)) + { + return FAIL; + } + + PAL_TRY + { + int* p = 0x00000000; /* NULL pointer */ + + bTry = TRUE; /* indicate we hit the PAL_TRY block */ + + Helper(); + + *p = 13; /* causes an access violation exception */ + + Fail("ERROR: code was executed after the access violation.\n"); + } + PAL_EXCEPT(EXCEPTION_EXECUTE_HANDLER) + { + if (!bTry) + { + Fail("ERROR: PAL_EXCEPT was hit without PAL_TRY being hit.\n"); + } + if (!bExcept_function) + { + Fail("ERROR: PAL_EXCEPT was hit without " + "function's PAL_EXCEPT being hit.\n"); + } + + bExcept = TRUE; /* indicate we hit the PAL_EXCEPT block */ + } + PAL_ENDTRY; + + if (!bTry) + { + Trace("ERROR: the code in the PAL_TRY block was not executed.\n"); + } + + if (!bExcept) + { + Trace("ERROR: the code in the PAL_EXCEPT block was not executed.\n"); + } + + if (!bTry_function) + { + Trace("ERROR: the code in the " + "function's PAL_TRY block was not executed.\n"); + } + + if (!bExcept_function) + { + Trace("ERROR: the code in the " + "function's PAL_EXCEPT block was not executed.\n"); + } + + /* did we hit all the code blocks? */ + if(!bTry || !bExcept || + !bTry_function || !bExcept_function) + { + Fail(""); + } + + PAL_Terminate(); + return PASS; + +} diff --git a/src/pal/tests/palsuite/exception_handling/pal_except/test3/testinfo.dat b/src/pal/tests/palsuite/exception_handling/pal_except/test3/testinfo.dat new file mode 100644 index 0000000000..07da444a5a --- /dev/null +++ b/src/pal/tests/palsuite/exception_handling/pal_except/test3/testinfo.dat @@ -0,0 +1,27 @@ +# 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 = exception_handling + +Function = PAL_TRY and PAL_EXCEPT + +Name = Test for PAL_TRY and PAL_EXCEPT + +Type = DEFAULT + +EXE1 = test3 + +LANG = cpp + +Description + += Test to make sure the PAL_EXCEPT block is executed + += after an exception occurs in the PAL_TRY block + += that calls a function that contains + += another PAL_TRY-PAL_EXCEPT block diff --git a/src/pal/tests/palsuite/exception_handling/pal_except/test4/CMakeLists.txt b/src/pal/tests/palsuite/exception_handling/pal_except/test4/CMakeLists.txt new file mode 100644 index 0000000000..cc054d15dd --- /dev/null +++ b/src/pal/tests/palsuite/exception_handling/pal_except/test4/CMakeLists.txt @@ -0,0 +1,19 @@ +cmake_minimum_required(VERSION 2.8.12.2) + +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +set(SOURCES + test4.c +) + +add_executable(paltest_pal_except_test4 + ${SOURCES} +) + +add_dependencies(paltest_pal_except_test4 coreclrpal) + +target_link_libraries(paltest_pal_except_test4 + pthread + m + coreclrpal +) diff --git a/src/pal/tests/palsuite/exception_handling/pal_except/test4/test4.c b/src/pal/tests/palsuite/exception_handling/pal_except/test4/test4.c new file mode 100644 index 0000000000..87844973b0 --- /dev/null +++ b/src/pal/tests/palsuite/exception_handling/pal_except/test4/test4.c @@ -0,0 +1,105 @@ +// 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: test4.c (exception_handling\pal_except\test4) +** +** Purpose: Test to make sure the PAL_EXCEPT block is executed +** after an exception occurs in the PAL_TRY block +** if the PAL_EXCEPT block contains a nested +** PAL_TRY-PAL_EXCEPT block +** +** +**===================================================================*/ +#include <palsuite.h> + +/* Execution flags */ +BOOL bTry = FALSE; +BOOL bExcept = FALSE; +BOOL bTry_nested = FALSE; +BOOL bExcept_nested = FALSE; + +int __cdecl main(int argc, char *argv[]) +{ + if (0 != PAL_Initialize(argc, argv)) + { + return FAIL; + } + + PAL_TRY + { + int* p = 0x00000000; /* NULL pointer */ + + bTry = TRUE; /* indicate we hit the PAL_TRY block */ + *p = 13; /* causes an access violation exception */ + + Fail("ERROR: code was executed after the access violation.\n"); + } + PAL_EXCEPT(EXCEPTION_EXECUTE_HANDLER) + { + if (!bTry) + { + Fail("ERROR: PAL_EXCEPT was hit without PAL_TRY being hit.\n"); + } + + PAL_TRY + { + int *lp = 0x00000000; + + bTry_nested = TRUE; + *lp = 13; /* causes an access violation exception */ + + Fail("ERROR: code was executed after the " + "nested access violation.\n"); + } + PAL_EXCEPT(EXCEPTION_EXECUTE_HANDLER) + { + if (!bTry_nested) + { + Fail("ERROR: PAL_EXCEPT was hit without PAL_TRY being hit " + "in the nested block.\n"); + } + bExcept_nested = TRUE; + } + PAL_ENDTRY; + + bExcept = TRUE; /* indicate we hit the PAL_EXCEPT block */ + } + PAL_ENDTRY; + + if (!bTry) + { + Trace("ERROR: the code in the PAL_TRY block was not executed.\n"); + } + + if (!bExcept) + { + Trace("ERROR: the code in the PAL_EXCEPT block was not executed.\n"); + } + + if (!bTry_nested) + { + Trace("ERROR: the code in the nested " + "PAL_TRY block was not executed.\n"); + } + + if (!bExcept_nested) + { + Trace("ERROR: the code in the nested " + "PAL_EXCEPT block was not executed.\n"); + } + + /* did we hit all the code blocks? */ + if(!bTry || !bExcept || + !bTry_nested || !bExcept_nested) + { + Fail(""); + } + + + PAL_Terminate(); + return PASS; + +} diff --git a/src/pal/tests/palsuite/exception_handling/pal_except/test4/testinfo.dat b/src/pal/tests/palsuite/exception_handling/pal_except/test4/testinfo.dat new file mode 100644 index 0000000000..d658cc85fa --- /dev/null +++ b/src/pal/tests/palsuite/exception_handling/pal_except/test4/testinfo.dat @@ -0,0 +1,27 @@ +# 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 = exception_handling + +Function = PAL_TRY and PAL_EXCEPT + +Name = Test for PAL_TRY and PAL_EXCEPT + +Type = DEFAULT + +EXE1 = test4 + +LANG = cpp + +Description + += Test to make sure the PAL_EXCEPT block is executed + += after an exception occurs in the PAL_TRY block + += if the PAL_EXCEPT block contains a nested + += PAL_TRY-PAL_EXCEPT block diff --git a/src/pal/tests/palsuite/exception_handling/pal_except/test5/CMakeLists.txt b/src/pal/tests/palsuite/exception_handling/pal_except/test5/CMakeLists.txt new file mode 100644 index 0000000000..7b8f1d0361 --- /dev/null +++ b/src/pal/tests/palsuite/exception_handling/pal_except/test5/CMakeLists.txt @@ -0,0 +1,19 @@ +cmake_minimum_required(VERSION 2.8.12.2) + +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +set(SOURCES + test5.c +) + +add_executable(paltest_pal_except_test5 + ${SOURCES} +) + +add_dependencies(paltest_pal_except_test5 coreclrpal) + +target_link_libraries(paltest_pal_except_test5 + pthread + m + coreclrpal +) diff --git a/src/pal/tests/palsuite/exception_handling/pal_except/test5/test5.c b/src/pal/tests/palsuite/exception_handling/pal_except/test5/test5.c new file mode 100644 index 0000000000..f9faf4440e --- /dev/null +++ b/src/pal/tests/palsuite/exception_handling/pal_except/test5/test5.c @@ -0,0 +1,112 @@ +// 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: test5.c (exception_handling\pal_except\test5) +** +** Purpose: Test to make sure the PAL_EXCEPT block is executed +** after an exception occurs in the PAL_TRY block +** if the PAL_EXCEPT block calls a function that contains +** another PAL_TRY-PAL_EXCEPT block +** +** +**===================================================================*/ +#include <palsuite.h> + +/* Execution flags */ +BOOL bTry = FALSE; +BOOL bExcept = FALSE; +BOOL bTry_nested = FALSE; +BOOL bExcept_nested = FALSE; + +int __cdecl main(int argc, char *argv[]) +{ + if (0 != PAL_Initialize(argc, argv)) + { + return FAIL; + } + + PAL_TRY + { + int* p = 0x00000000; /* NULL pointer */ + + bTry = TRUE; /* indicate we hit the PAL_TRY block */ + + + /* Nested PAL_TRY */ + PAL_TRY + { + bTry_nested = TRUE; + + *p = 13; /* causes an access violation exception */ + + Fail("ERROR: code was executed after the nested access violation.\n"); + + } + PAL_EXCEPT(EXCEPTION_EXECUTE_HANDLER) + { + if (!bTry) + { + Fail("ERROR: Nested PAL_EXCEPT was hit without " + "nested PAL_TRY being hit.\n"); + } + bExcept_nested = TRUE; + } + PAL_ENDTRY; + + *p = 13; /* causes an access violation exception */ + + Fail("ERROR: code was executed after the access violation.\n"); + } + PAL_EXCEPT(EXCEPTION_EXECUTE_HANDLER) + { + if (!bTry) + { + Fail("ERROR: PAL_EXCEPT was hit without PAL_TRY being hit.\n"); + } + if (!bExcept_nested) + { + Fail("ERROR: PAL_EXCEPT was hit without " + "nested PAL_EXCEPT being hit.\n"); + } + + bExcept = TRUE; /* indicate we hit the PAL_EXCEPT block */ + } + PAL_ENDTRY; + + if (!bTry) + { + Trace("ERROR: the code in the PAL_TRY block was not executed.\n"); + } + + if (!bExcept) + { + Trace("ERROR: the code in the PAL_EXCEPT block was not executed.\n"); + } + + if (!bTry_nested) + { + Trace("ERROR: the code in the " + "nested PAL_TRY block was not executed.\n"); + } + + if (!bExcept_nested) + { + Trace("ERROR: the code in the " + "nested PAL_EXCEPT block was not executed.\n"); + } + + /* did we hit all the code blocks? */ + if(!bTry || !bExcept || + !bTry_nested || !bExcept_nested) + { + Fail(""); + } + + + PAL_Terminate(); + return PASS; + +} diff --git a/src/pal/tests/palsuite/exception_handling/pal_except/test5/testinfo.dat b/src/pal/tests/palsuite/exception_handling/pal_except/test5/testinfo.dat new file mode 100644 index 0000000000..2e12d0c64b --- /dev/null +++ b/src/pal/tests/palsuite/exception_handling/pal_except/test5/testinfo.dat @@ -0,0 +1,27 @@ +# 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 = exception_handling + +Function = PAL_TRY and PAL_EXCEPT + +Name = Test for PAL_TRY and PAL_EXCEPT + +Type = DEFAULT + +EXE1 = test5 + +LANG = cpp + +Description + += Test to make sure the PAL_EXCEPT block is executed + += after an exception occurs in the PAL_TRY block + += if the PAL_EXCEPT block calls a function that contains + += another PAL_TRY-PAL_EXCEPT block diff --git a/src/pal/tests/palsuite/exception_handling/pal_except/test6/CMakeLists.txt b/src/pal/tests/palsuite/exception_handling/pal_except/test6/CMakeLists.txt new file mode 100644 index 0000000000..7f943bf126 --- /dev/null +++ b/src/pal/tests/palsuite/exception_handling/pal_except/test6/CMakeLists.txt @@ -0,0 +1,19 @@ +cmake_minimum_required(VERSION 2.8.12.2) + +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +set(SOURCES + test6.c +) + +add_executable(paltest_pal_except_test6 + ${SOURCES} +) + +add_dependencies(paltest_pal_except_test6 coreclrpal) + +target_link_libraries(paltest_pal_except_test6 + pthread + m + coreclrpal +) diff --git a/src/pal/tests/palsuite/exception_handling/pal_except/test6/test6.c b/src/pal/tests/palsuite/exception_handling/pal_except/test6/test6.c new file mode 100644 index 0000000000..44b0ba1bc9 --- /dev/null +++ b/src/pal/tests/palsuite/exception_handling/pal_except/test6/test6.c @@ -0,0 +1,160 @@ +// 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: test6.c (exception_handling\pal_except\test6) +** +** Purpose: Test to make sure the PAL_EXCEPT block is executed +** after an exception occurs in the PAL_TRY block +** that contains multiple PAL_TRY-PAL_EXCEPT blocks +** +** +**===================================================================*/ +#include <palsuite.h> + +/* Execution flags */ +BOOL bTry = FALSE; +BOOL bExcept = FALSE; +BOOL bTry_nested = FALSE; +BOOL bExcept_nested = FALSE; +BOOL bTry_nested2 = FALSE; +BOOL bExcept_nested2 = FALSE; + + +int __cdecl main(int argc, char *argv[]) +{ + if (0 != PAL_Initialize(argc, argv)) + { + return FAIL; + } + + /* First block */ + PAL_TRY + { + int* p = 0x00000000; /* NULL pointer */ + + bTry = TRUE; /* indicate we hit the PAL_TRY block */ + + /* Second PAL_TRY block */ + PAL_TRY + { + bTry_nested = TRUE; + + /* Third PAL_TRY block*/ + PAL_TRY + { + bTry_nested2 = TRUE; + + *p = 13; /* causes an access violation exception */ + + Fail("ERROR: code was executed after the nested access violation.\n"); + + } + PAL_EXCEPT(EXCEPTION_EXECUTE_HANDLER) + { + if (!bTry_nested2) + { + Fail("ERROR: Third PAL_EXCEPT was hit without " + "third PAL_TRY being hit.\n"); + } + bExcept_nested2 = TRUE; + } + PAL_ENDTRY; + + *p = 13; /* causes an access violation exception */ + + Fail("ERROR: code was executed after the nested access violation.\n"); + + } + PAL_EXCEPT(EXCEPTION_EXECUTE_HANDLER) + { + if (!bTry_nested) + { + Fail("ERROR: Second PAL_EXCEPT was hit without " + "second PAL_TRY being hit.\n"); + } + if (!bExcept_nested2) + { + Fail("ERROR: second PAL_EXCEPT was hit without " + "third PAL_EXCEPT being hit.\n"); + } + bExcept_nested = TRUE; + } + PAL_ENDTRY; + + *p = 13; /* causes an access violation exception */ + + Fail("ERROR: code was executed after the access violation.\n"); + } + PAL_EXCEPT(EXCEPTION_EXECUTE_HANDLER) + { + if (!bTry) + { + Fail("ERROR: PAL_EXCEPT was hit without PAL_TRY being hit.\n"); + } + if (!bExcept_nested) + { + Fail("ERROR: first PAL_EXCEPT was hit without " + "second PAL_EXCEPT being hit.\n"); + } + if (!bExcept_nested2) + { + Fail("ERROR: first PAL_EXCEPT was hit without " + "third PAL_EXCEPT being hit.\n"); + } + + bExcept = TRUE; /* indicate we hit the PAL_EXCEPT block */ + } + PAL_ENDTRY; + + if (!bTry) + { + Trace("ERROR: the code in the " + "first PAL_TRY block was not executed.\n"); + } + + if (!bExcept) + { + Trace("ERROR: the code in the " + "first PAL_EXCEPT block was not executed.\n"); + } + + if (!bTry_nested) + { + Trace("ERROR: the code in the " + "second PAL_TRY block was not executed.\n"); + } + + if (!bExcept_nested) + { + Trace("ERROR: the code in the " + "second PAL_EXCEPT block was not executed.\n"); + } + + if (!bTry_nested2) + { + Trace("ERROR: the code in the " + "third PAL_TRY block was not executed.\n"); + } + + if (!bExcept_nested2) + { + Trace("ERROR: the code in the " + "third PAL_EXCEPT block was not executed.\n"); + } + + /* did we hit all the code blocks? */ + if(!bTry || !bExcept || + !bTry_nested || !bExcept_nested || + !bTry_nested2 || !bExcept_nested2) + { + Fail(""); + } + + + PAL_Terminate(); + return PASS; + +} diff --git a/src/pal/tests/palsuite/exception_handling/pal_except/test6/testinfo.dat b/src/pal/tests/palsuite/exception_handling/pal_except/test6/testinfo.dat new file mode 100644 index 0000000000..f8901a7f50 --- /dev/null +++ b/src/pal/tests/palsuite/exception_handling/pal_except/test6/testinfo.dat @@ -0,0 +1,25 @@ +# 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 = exception_handling + +Function = PAL_TRY and PAL_EXCEPT_EX + +Name = Test for PAL_TRY and PAL_EXCEPT_EX + +Type = DEFAULT + +EXE1 = test6 + +LANG = cpp + +Description + += Test to make sure the PAL_EXCEPT_EX block is executed + += after an exception occurs in the PAL_TRY block + += that contains multiple PAL_TRY-PAL_EXCEPT_EX blocks diff --git a/src/pal/tests/palsuite/exception_handling/pal_except/test7/CMakeLists.txt b/src/pal/tests/palsuite/exception_handling/pal_except/test7/CMakeLists.txt new file mode 100644 index 0000000000..09399c8f6b --- /dev/null +++ b/src/pal/tests/palsuite/exception_handling/pal_except/test7/CMakeLists.txt @@ -0,0 +1,19 @@ +cmake_minimum_required(VERSION 2.8.12.2) + +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +set(SOURCES + test7.c +) + +add_executable(paltest_pal_except_test7 + ${SOURCES} +) + +add_dependencies(paltest_pal_except_test7 coreclrpal) + +target_link_libraries(paltest_pal_except_test7 + pthread + m + coreclrpal +) diff --git a/src/pal/tests/palsuite/exception_handling/pal_except/test7/test7.c b/src/pal/tests/palsuite/exception_handling/pal_except/test7/test7.c new file mode 100644 index 0000000000..a8dc8331c2 --- /dev/null +++ b/src/pal/tests/palsuite/exception_handling/pal_except/test7/test7.c @@ -0,0 +1,67 @@ +// 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: test7.c (exception_handling\pal_except\test7) +** +** Purpose: Tests the PAL implementation of the PAL_TRY and +** PAL_EXCEPT functions. Tests that the EXCEPTION block +** is missed if no exceptions happen +** +** +**===================================================================*/ + + + +#include <palsuite.h> + + +int __cdecl main(int argc, char *argv[]) +{ + BOOL bTry = FALSE; + BOOL bExcept = FALSE; + + if (0 != PAL_Initialize(argc, argv)) + { + return FAIL; + } + + /* + ** Test to make sure we skip the exception block. + */ + + PAL_TRY + { + bTry = TRUE; /* indicate we hit the PAL_TRY block */ + } + PAL_EXCEPT(EXCEPTION_EXECUTE_HANDLER) + { + bExcept = TRUE; /* indicate we hit the PAL_EXCEPT block */ + } + PAL_ENDTRY; + + if (!bTry) + { + Trace("PAL_TRY_EXCEPT: ERROR -> It appears the code in the PAL_TRY" + " block was not executed.\n"); + } + + if (bExcept) + { + Trace("PAL_TRY_EXCEPT: ERROR -> It appears the code in the PAL_EXCEPT" + " block was executed even though no exception was supposed to" + " happen.\n"); + } + + /* did we hit the correct code blocks? */ + if(!bTry || bExcept) + { + Fail(""); + } + + PAL_Terminate(); + return PASS; + +} diff --git a/src/pal/tests/palsuite/exception_handling/pal_except/test7/testinfo.dat b/src/pal/tests/palsuite/exception_handling/pal_except/test7/testinfo.dat new file mode 100644 index 0000000000..546d64cdec --- /dev/null +++ b/src/pal/tests/palsuite/exception_handling/pal_except/test7/testinfo.dat @@ -0,0 +1,24 @@ +# 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 = exception_handling + +Function = PAL_TRY and PAL_EXCEPT + +Name = Test for PAL_TRY and PAL_EXCEPT + +Type = DEFAULT + +EXE1 = test7 + +LANG = cpp + +Description + += In this test, no exceptions are forced to ensure the EXCEPTION block + += isn't hit. + |