1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/nsprpub/pr/tests/op_2long.c Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,75 @@ 1.4 +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +/*********************************************************************** 1.10 +** 1.11 +** Name: op_2long.c 1.12 +** 1.13 +** Description: Test Program to verify the PR_NAME_TOO_LONG_ERROR 1.14 +** 1.15 +** Modification History: 1.16 +** 03-June-97 AGarcia- Initial version 1.17 +***********************************************************************/ 1.18 + 1.19 +/*********************************************************************** 1.20 +** Includes 1.21 +***********************************************************************/ 1.22 +/* Used to get the command line option */ 1.23 +#include "prinit.h" 1.24 +#include "prmem.h" 1.25 +#include "prio.h" 1.26 +#include "prerror.h" 1.27 +#include <stdio.h> 1.28 +#include "plerror.h" 1.29 +#include "plgetopt.h" 1.30 + 1.31 +static PRFileDesc *t1; 1.32 +PRIntn error_code; 1.33 + 1.34 +/* 1.35 + * should exceed any system's maximum file name length 1.36 + * Note: was set at 4096. This is legal on some unix (Linux 2.1+) platforms. 1.37 + * 1.38 + */ 1.39 +#define TOO_LONG 5000 1.40 + 1.41 +int main(int argc, char **argv) 1.42 +{ 1.43 + char nameTooLong[TOO_LONG]; 1.44 + int i; 1.45 + 1.46 + /* Generate a really long pathname */ 1.47 + for (i = 0; i < TOO_LONG - 1; i++) { 1.48 + if (i % 10 == 0) { 1.49 + nameTooLong[i] = '/'; 1.50 + } else { 1.51 + nameTooLong[i] = 'a'; 1.52 + } 1.53 + } 1.54 + nameTooLong[TOO_LONG - 1] = 0; 1.55 + 1.56 + PR_STDIO_INIT(); 1.57 + t1 = PR_Open(nameTooLong, PR_RDWR, 0666); 1.58 + if (t1 == NULL) { 1.59 + if (PR_GetError() == PR_NAME_TOO_LONG_ERROR) { 1.60 + PL_PrintError("error code is"); 1.61 + printf ("PASS\n"); 1.62 + return 0; 1.63 + } 1.64 + else { 1.65 + PL_PrintError("error code is"); 1.66 + printf ("FAIL\n"); 1.67 + return 1; 1.68 + } 1.69 + } 1.70 + 1.71 + else { 1.72 + printf ("Test passed\n"); 1.73 + return 0; 1.74 + } 1.75 + 1.76 + 1.77 + 1.78 +}