summaryrefslogtreecommitdiff
path: root/src/pal/tests/palsuite/miscellaneous/FlushInstructionCache/test1/test1.c
diff options
context:
space:
mode:
authorJiyoung Yun <jy910.yun@samsung.com>2016-11-23 19:09:09 +0900
committerJiyoung Yun <jy910.yun@samsung.com>2016-11-23 19:09:09 +0900
commit4b4aad7217d3292650e77eec2cf4c198ea9c3b4b (patch)
tree98110734c91668dfdbb126fcc0e15ddbd93738ca /src/pal/tests/palsuite/miscellaneous/FlushInstructionCache/test1/test1.c
parentfa45f57ed55137c75ac870356a1b8f76c84b229c (diff)
downloadcoreclr-4b4aad7217d3292650e77eec2cf4c198ea9c3b4b.tar.gz
coreclr-4b4aad7217d3292650e77eec2cf4c198ea9c3b4b.tar.bz2
coreclr-4b4aad7217d3292650e77eec2cf4c198ea9c3b4b.zip
Imported Upstream version 1.1.0upstream/1.1.0
Diffstat (limited to 'src/pal/tests/palsuite/miscellaneous/FlushInstructionCache/test1/test1.c')
-rw-r--r--src/pal/tests/palsuite/miscellaneous/FlushInstructionCache/test1/test1.c66
1 files changed, 66 insertions, 0 deletions
diff --git a/src/pal/tests/palsuite/miscellaneous/FlushInstructionCache/test1/test1.c b/src/pal/tests/palsuite/miscellaneous/FlushInstructionCache/test1/test1.c
new file mode 100644
index 0000000000..cdbefd01cc
--- /dev/null
+++ b/src/pal/tests/palsuite/miscellaneous/FlushInstructionCache/test1/test1.c
@@ -0,0 +1,66 @@
+// 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
+**
+** Purpose: Tests that FlushInstructionCache returns the correct value for a
+** number of different inputs.
+**
+**
+** Note :
+** For this function, what constitutes "invalid parameters" will depend entirely
+** on the platform; because of this we can't simply test values on Windows and
+** then ask for the same results everywhere. Because of this, this test can
+** ensure that the function succeeds for some "obviously" valid values, but
+** can't make sure that it fails for invalid values.
+**
+**=========================================================*/
+
+#include <palsuite.h>
+
+void DoTest(void *Buffer, int Size, int Expected)
+{
+ int ret;
+
+ SetLastError(0);
+ ret = FlushInstructionCache(GetCurrentProcess(), Buffer, Size);
+ if (!ret && Expected)
+ {
+ Fail("Expected FlushInstructionCache to return non-zero, got zero!\n"
+ "region: %p, size: %d, GetLastError: %d\n", Buffer, Size,
+ GetLastError());
+ }
+ else if (ret && !Expected)
+ {
+ Fail("Expected FlushInstructionCache to return zero, got non-zero!\n"
+ "region: %p, size: %d, GetLastError: %d\n", Buffer, Size,
+ GetLastError());
+ }
+
+ if (!Expected && ERROR_NOACCESS != GetLastError())
+ {
+ Fail("FlushInstructionCache failed to set the last error to "
+ "ERROR_NOACCESS!\n");
+ }
+
+}
+
+int __cdecl main(int argc,char *argv[])
+{
+ char ValidPtr[256];
+
+ if(PAL_Initialize(argc, argv))
+ {
+ return FAIL;
+ }
+
+ /* with valid pointer, zero-size and valid size must succeed */
+ DoTest(ValidPtr, 0, 1);
+ DoTest(ValidPtr, 42, 1);
+
+ PAL_Terminate();
+ return PASS;
+}