nsprpub/pr/tests/op_nofil.c

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     2 /* This Source Code Form is subject to the terms of the Mozilla Public
     3  * License, v. 2.0. If a copy of the MPL was not distributed with this
     4  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     6 /***********************************************************************
     7 **
     8 ** Name: op_nofil.c
     9 **
    10 ** Description: Test Program to verify the PR_FILE_NOT_FOUND_ERROR
    11 **
    12 ** Modification History:
    13 ** 03-June-97 AGarcia- Initial version
    14 ***********************************************************************/
    16 /***********************************************************************
    17 ** Includes
    18 ***********************************************************************/
    19 /* Used to get the command line option */
    20 #include "prinit.h"
    21 #include "prmem.h"
    22 #include "prio.h"
    23 #include "prerror.h"
    24 #include <stdio.h>
    25 #include "plgetopt.h"
    27 /*
    28  * A file name that cannot exist
    29  */
    30 #define NO_SUCH_FILE "/no/such/file.tmp"
    32 static PRFileDesc *t1;
    34 int main(int argc, char **argv)
    35 {
    36     PR_STDIO_INIT();
    37 	t1 = PR_Open(NO_SUCH_FILE,  PR_RDONLY, 0666);
    38 	if (t1 == NULL) {
    39 		if (PR_GetError() == PR_FILE_NOT_FOUND_ERROR) {
    40 			printf ("error code is PR_FILE_NOT_FOUND_ERROR, as expected\n");
    41 			printf ("PASS\n");
    42 			return 0;
    43 		} else {
    44 			printf ("error code is %d \n", PR_GetError());
    45 			printf ("FAIL\n");
    46 			return 1;
    47 		}
    48 	}
    49 	printf ("File %s exists on this machine!?\n", NO_SUCH_FILE);
    50 	if (PR_Close(t1) == PR_FAILURE) {
    51 		printf ("cannot close file\n");
    52 		printf ("error code is %d \n", PR_GetError());
    53 	}
    54 	printf ("FAIL\n");
    55 	return 1;
    56 }			

mercurial