source: trunk/testcase/1023-maxfilehandles.c@ 1361

Last change on this file since 1361 was 1361, checked in by bird, 21 years ago

..

  • Property cvs2svn:cvs-rev set to 1.2
  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 2.4 KB
Line 
1/** @file
2 *
3 * Testcase for bug #1023 autoincrement of file handles.
4 *
5 * InnoTek Systemberatung GmbH confidential
6 *
7 * Copyright (c) 2004 InnoTek Systemberatung GmbH
8 * Author: knut st. osmundsen <bird-srcspam@anduin.net>
9 *
10 * All Rights Reserved
11 *
12 */
13
14/*******************************************************************************
15* Header Files *
16*******************************************************************************/
17#define INCL_DOS
18#define INCL_DOSINFOSEG
19#ifdef __IBMC__
20#include "../src/emx/include/os2emx.h"
21#else
22#include <os2.h>
23#endif
24#include <stdio.h>
25#include <string.h>
26
27
28
29int main(int argc, const char **argv)
30{
31 int i,j;
32 LONG lFHDelta = 0;
33 ULONG cFHs = 0;
34 ULONG cFHLast;
35 unsigned msLastInc;
36 unsigned msEnd;
37 unsigned msStart;
38 PGINFOSEG pGIS = GETGINFOSEG();
39#define MAX_FHS 0x11000
40 static FILE *apFiles[MAX_FHS];
41
42 DosSetRelMaxFH(&lFHDelta, &cFHs);
43 printf("cFHs=%d\n", cFHs);
44
45 cFHLast = cFHs;
46 msLastInc = pGIS->msecs;
47 for (i = 0; i < MAX_FHS; i++)
48 {
49 msStart = pGIS->msecs;
50 apFiles[i] = fopen(argv[argc - 1], "rb");
51 msEnd = pGIS->msecs;
52 if (apFiles[i] == NULL)
53 {
54 printf("error %d!\n", i + 1);
55 break;
56 }
57
58 lFHDelta = cFHs = 0;
59 DosSetRelMaxFH(&lFHDelta, &cFHs);
60 lFHDelta = cFHs = 0;
61 DosSetRelMaxFH(&lFHDelta, &cFHs);
62 if (cFHs != cFHLast)
63 {
64 printf("Max FH change %i (fh=%d): %d -> %d (inc: %d ms since last: %d ms)\n", i + 1, fileno(apFiles[i]), cFHLast, cFHs,
65 msEnd - msStart, msStart - msLastInc);
66 msLastInc = msEnd;
67 }
68 cFHLast = cFHs;
69 }
70
71 lFHDelta = cFHs = 0;
72 DosSetRelMaxFH(&lFHDelta, &cFHs);
73 printf("cFHs=%d\n", cFHs);
74
75 /*
76 * Free the files.
77 */
78 msStart = pGIS->msecs;
79 for (j = 0; j < i; j++)
80 fclose(apFiles[j]);
81 msEnd = pGIS->msecs;
82 printf("close of %j files took %d ms\n", j, msEnd - msStart);
83
84 /*
85 * Report the result.
86 */
87 if (i < 9900)
88 {
89 printf("1023-maxfilehandles: failed, could only open %d handles, expected > 9900\n", i);
90 return 1;
91 }
92
93 printf("1023-maxfilehandles: succeeded opening %d handles.\n", i);
94 return 0;
95}
Note: See TracBrowser for help on using the repository browser.