blob: 32e8487d07c1a9d42700ba69b76efbfb69bc0145 (
plain)
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
|
// 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: pal_errno.c
**
** Purpose: Positive test the PAL_errno API.
** call PAL_errno to retrieve the pointer to
** the per-thread errno value.
**
**
**============================================================*/
#include <palsuite.h>
int __cdecl main(int argc, char *argv[])
{
int err;
FILE *pFile = NULL;
/*Initialize the PAL environment*/
err = PAL_Initialize(argc, argv);
if( 0 != err)
{
return FAIL;
}
/*Try to open a not-exist file to read to generate an error*/
pFile = fopen( "no_exist_file_name", "r" );
if( NULL != pFile )
{
Trace("\nFailed to call fopen to open a not exist for reading, "
"an error is expected, but no error occurred\n");
if( EOF == fclose( pFile ) )
{
Trace("\nFailed to call fclose to close a file stream\n");
}
Fail( "Test failed! fopen() Should not have worked!" );
}
/*retrieve the per-thread error value pointer*/
if( 2 != errno )
{
Fail("\nFailed to call PAL_errno API, this value is not correct."
" The correct value is ENOENT[2] ( No such file or directory.).\n");
}
PAL_Terminate();
return PASS;
}
|