1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
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;
}
|