nsprpub/pr/tests/op_2long.c

Fri, 16 Jan 2015 04:50:19 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Fri, 16 Jan 2015 04:50:19 +0100
branch
TOR_BUG_9701
changeset 13
44a2da4a2ab2
permissions
-rw-r--r--

Replace accessor implementation with direct member state manipulation, by
request https://trac.torproject.org/projects/tor/ticket/9701#comment:32

     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_2long.c
     9 **
    10 ** Description: Test Program to verify the PR_NAME_TOO_LONG_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 "plerror.h"
    26 #include "plgetopt.h"
    28 static PRFileDesc *t1;
    29 PRIntn error_code;
    31 /*
    32  * should exceed any system's maximum file name length
    33  * Note: was set at 4096. This is legal on some unix (Linux 2.1+) platforms.
    34  * 
    35  */
    36 #define TOO_LONG 5000
    38 int main(int argc, char **argv)
    39 {
    40 	char nameTooLong[TOO_LONG];
    41 	int i;
    43 	/* Generate a really long pathname */
    44 	for (i = 0; i < TOO_LONG - 1; i++) {
    45 		if (i % 10 == 0) {
    46 			nameTooLong[i] = '/';
    47 		} else {
    48 			nameTooLong[i] = 'a';
    49 		}
    50 	}
    51 	nameTooLong[TOO_LONG - 1] = 0;
    53     PR_STDIO_INIT();
    54 	t1 = PR_Open(nameTooLong, PR_RDWR, 0666);
    55 	if (t1 == NULL) {
    56 		if (PR_GetError() == PR_NAME_TOO_LONG_ERROR) {
    57             PL_PrintError("error code is");
    58 			printf ("PASS\n");
    59 			return 0;
    60 		}
    61 		else {
    62             PL_PrintError("error code is");
    63 			printf ("FAIL\n");
    64 			return 1;
    65 		}
    66 	}
    68 		else {
    69 			printf ("Test passed\n");
    70 			return 0;
    71 		}
    75 }			

mercurial