update for HEAD-2003021201
[reactos.git] / apps / testsets / msvcrt / fileio / main.c
1 /*
2  *  ReactOS test program - 
3  *
4  *  main.c
5  *
6  *  Copyright (C) 2002  Robert Dickenson <robd@reactos.org>
7  *
8  *  This program is free software; you can redistribute it and/or modify
9  *  it under the terms of the GNU General Public License as published by
10  *  the Free Software Foundation; either version 2 of the License, or
11  *  (at your option) any later version.
12  *
13  *  This program is distributed in the hope that it will be useful,
14  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  *  GNU General Public License for more details.
17  *
18  *  You should have received a copy of the GNU General Public License
19  *  along with this program; if not, write to the Free Software
20  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21  */
22
23 #define WIN32_LEAN_AND_MEAN
24 #include <windows.h>
25 #include <tchar.h>
26 #include <wchar.h>
27 #include <stdio.h>
28 #include <stdlib.h>
29
30 #include "main.h"
31
32
33 #define VERSION 1
34
35 #ifdef UNICODE
36 #define TARGET  "UNICODE"
37 #else
38 #define TARGET  "MBCS"
39 #endif
40
41 BOOL verbose_flagged = 0;
42 BOOL status_flagged = 0;
43
44 int usage(char* argv0)
45 {
46     printf("USAGE: %s test_id [unicode]|[ansi] [clean]|[status][verbose]\n", argv0);
47     printf("\tWhere test_id is one of:\n");
48     printf("\t0 - (default) regression mode, run tests 1-4 displaying failures only\n");
49     printf("\t1 - Write DOS style eol data to file in text mode (text.dos)\n");
50     printf("\t2 - Write NIX style eol data to file in binary mode (binary.dos)\n");
51     printf("\t3 - Write DOS style eol data to file in text mode (text.nix)\n");
52     printf("\t4 - Write NIX style eol data to file in binary mode (binary.nix)\n");
53     printf("\t5 - Echo console line input\n");
54     printf("\t6 - Dump console line input in hex format\n");
55     printf("\t7 - The source code is your friend\n");
56     printf("\t[unicode] - perform tests using UNICODE versions of library functions\n");
57     printf("\t[ansi] - perform tests using ANSI versions of library functions\n");
58     printf("\t    If neither unicode or ansi is specified build default is used\n");
59     printf("\t[clean] - delete all temporary test output files\n");
60     printf("\t[status] - enable extra status display while running\n");
61     printf("\t[verbose] - enable verbose output when running\n");
62     return 0;
63 }
64
65 int __cdecl main(int argc, char* argv[])
66 {
67     int test_num = 0;
68     int version = 0;
69     int result = 0;
70     int i = 0;
71
72     printf("%s test application - build %03d (default: %s)\n", argv[0], VERSION, TARGET);
73     if (argc < 2) {
74         return usage(argv[0]);
75     }
76     for (i = 1; i < argc; i++) {
77         if (strstr(argv[i], "ansi") || strstr(argv[i], "ANSI")) {
78             version = 1;
79         } else if (strstr(argv[i], "unicode") || strstr(argv[i], "UNICODE")) {
80             version = 2;
81         } else if (strstr(argv[i], "clean") || strstr(argv[i], "CLEAN")) {
82             test_num = -1;
83         } else if (strstr(argv[i], "verbose") || strstr(argv[i], "VERBOSE")) {
84             verbose_flagged = 1;
85         } else if (strstr(argv[i], "status") || strstr(argv[i], "STATUS")) {
86             status_flagged = 1;
87         } else {
88             test_num = atoi(argv[1]);
89             //if (test_num < 0
90         }
91     }
92     for (i = test_num; i <= test_num; i++) {
93         if (!test_num) {
94             test_num = 4;
95             i = 1;
96         }
97         switch (version) {
98         case 1:
99             result = run_ansi_tests(i);
100             break;
101         case 2:
102             result = run_unicode_tests(i);
103             break;
104         default:
105             result = run_ansi_tests(i);
106             result = run_unicode_tests(i);
107             break;
108         }
109     }
110     printf("finished\n");
111     return result;
112 }
113
114 #ifndef __GNUC__
115
116 char* args[] = { "fileio.exe", "0", "unicode", "verbose"};
117
118 int __cdecl mainCRTStartup(void)
119 {
120     main(2, args);
121     return 0;
122 }
123
124 #endif /*__GNUC__*/