File: fortest.c

package info (click to toggle)
libhdf4 4.3.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 30,384 kB
  • sloc: ansic: 128,700; sh: 15,015; fortran: 12,444; java: 5,863; xml: 1,205; makefile: 794; yacc: 678; pascal: 418; perl: 360; javascript: 203; lex: 163; csh: 41
file content (208 lines) | stat: -rw-r--r-- 8,156 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 * Copyright by The HDF Group.                                               *
 * Copyright by the Board of Trustees of the University of Illinois.         *
 * All rights reserved.                                                      *
 *                                                                           *
 * This file is part of HDF.  The full HDF copyright notice, including       *
 * terms governing use, modification, and redistribution, is contained in    *
 * the COPYING file, which can be found at the root of the source code       *
 * distribution tree, or in https://support.hdfgroup.org/ftp/HDF/releases/.  *
 * If you do not have access to either file, you may request a copy from     *
 * help@hdfgroup.org.                                                        *
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

#define TESTMASTER

#include "hdf.h"
#include "tutils.h"
#include "fortest.h"
#define NUMOFTESTS 20

static int InitTest(const char *TheName, const char *TheCall, const char *TheDescr);

struct TestStruct {
    int  NumErrors;
    char Description[64];
    int  SkipFlag;
    char Name[16];
    char Call[20];
} Test[NUMOFTESTS];

static int
InitTest(const char *TheName, const char *TheCall, const char *TheDescr)
{
    static int Index = 0;

    if (Index >= NUMOFTESTS) {
        printf("*** Too many tests.  Need to increase NUMOFTESTS (%d).\n", NUMOFTESTS);
        printf("\tRequest (%s) ignored.\n", TheName);
    }
    else {
        strcpy(Test[Index].Description, TheDescr);
        strcpy(Test[Index].Name, TheName);
        strcpy(Test[Index].Call, TheCall);
        Test[Index].NumErrors = -1;
        Test[Index].SkipFlag  = 0;
        Index++;
    }
    return Index;
}

int
main(int argc, char *argv[])
{
    int         CLLoop; /* Command Line Loop */
    int         Loop, Loop1;
    int         Summary   = 0;
    int         CleanUp   = 1;
    int         num_tests = 0;
    FILE       *cmdfile;
    const char *cmdfilename = "fortest.arg";

    printf(" ===========================================\n");
    printf(" HDF Library Fortran Interface Tests Setup\n");
    printf(" ===========================================\n");

    num_tests = InitTest("slab", "slabwf", "");
    num_tests = InitTest("r24", "t24f", "");
    num_tests = InitTest("an", "tanf", "");
    num_tests = InitTest("anfile", "tanfilef", "");
    num_tests = InitTest("manf", "manf", "");
    num_tests = InitTest("mgrf", "mgrf", "");
    num_tests = InitTest("p", "tpf", "");
    num_tests = InitTest("r8", "tr8f", "");
    num_tests = InitTest("sdmms", "tsdmmsf", "");
    num_tests = InitTest("sdnmms", "tsdnmmsf", "");
    num_tests = InitTest("sdnnt", "tsdnntf", "");
    num_tests = InitTest("sdnt", "tsdntf", "");
    num_tests = InitTest("sdstr", "tsdstrf", "");
    num_tests = InitTest("vsetf", "tvsetf", "");
    num_tests = InitTest("vsetblock", "tvsetblock", "");
    num_tests = InitTest("vgroups", "tvgroups", "");
    num_tests = InitTest("vattrf", "tvattrf", "");
/* The test is skipped when size of fortran integer is smaller than
   the size of C pointer; this happens on all 64-bit platforms.
   We need a better fix; see HDFFR-191.
*/
#if defined(_WIN64) || defined(H4_HAVE_LP64)
    printf("   Skipping stubs\n");
#else
    num_tests = InitTest("stubs", "tstubsf", "");
#endif

    if ((cmdfile = fopen(cmdfilename, "w")) == NULL) {
        printf("***Can't write to cmdfile(%s)***\n", cmdfilename);
        return -1;
    }

    /* Default setting */
    Verbosity = 3; /* Default Verbosity is Low */
    /* setup Cleanup Command */
    fprintf(cmdfile, "%s %s\n", CLEAN_STR, CLEAN_CMD);

    for (CLLoop = 1; CLLoop < argc; CLLoop++) {
        if ((argc > CLLoop + 1) &&
            ((strcmp(argv[CLLoop], "-verbose") == 0) || (strcmp(argv[CLLoop], "-v") == 0))) {
            if (argv[CLLoop + 1][0] == 'l')
                Verbosity = 5;
            else if (argv[CLLoop + 1][0] == 'm')
                Verbosity = 7;
            else if (argv[CLLoop + 1][0] == 'h')
                Verbosity = 9;
            else
                Verbosity = atoi(argv[CLLoop + 1]);
            fprintf(cmdfile, "%s %d\n", VERBOSITY_STR, Verbosity);
        }
        if ((argc > CLLoop) &&
            ((strcmp(argv[CLLoop], "-summary") == 0) || (strcmp(argv[CLLoop], "-s") == 0))) {
            Summary = 1;
        }
        if ((argc > CLLoop) && (strcmp(argv[CLLoop], "-help") == 0)) {
            printf("Usage: fortest [-v[erbose] (l[ow]|m[edium]|h[igh]|0-9)] \n");
            printf("               [-[e]x[clude] name+] \n");
            printf("               [-o[nly] name+] \n");
            printf("               [-b[egin] name] \n");
            printf("               [-s[ummary]]  \n");
            printf("               [-c[leanno]]  \n");
            printf("\n\n");
            printf("verbose   controls the amount of information displayed\n");
            printf("exclude   to exclude tests by name\n");
            printf("only      to name tests which should be run\n");
            printf("begin     start at the name of the test given\n");
            printf("summary   prints a summary of test results at the end\n");
            printf("cleanno   does not delete *.hdf files after execution of tests\n");
            printf("\n\n");
            printf("This program currently tests the following: \n\n");
            printf("%16s %s\n", "Name", "Description");
            printf("%16s %s\n", "----", "-----------");
            for (Loop = 0; Loop < num_tests; Loop++) {
                printf("%16s %s\n", Test[Loop].Name, Test[Loop].Description);
            }
            printf("\n\n");
            exit(0);
        }
        if ((argc > CLLoop) &&
            ((strcmp(argv[CLLoop], "-cleanno") == 0) || (strcmp(argv[CLLoop], "-c") == 0))) {
            CleanUp = 0;
            fprintf(cmdfile, "%s %s\n", CLEAN_STR, "No");
        }
        if ((argc > CLLoop + 1) &&
            ((strcmp(argv[CLLoop], "-exclude") == 0) || (strcmp(argv[CLLoop], "-x") == 0))) {
            Loop = CLLoop + 1;
            while ((Loop < argc) && (argv[Loop][0] != '-')) {
                for (Loop1 = 0; Loop1 < num_tests; Loop1++) {
                    if (strcmp(argv[Loop], Test[Loop1].Name) == 0)
                        Test[Loop1].SkipFlag = 1;
                }
                Loop++;
            }
        }
        if ((argc > CLLoop + 1) &&
            ((strcmp(argv[CLLoop], "-begin") == 0) || (strcmp(argv[CLLoop], "-b") == 0))) {
            Loop = CLLoop + 1;
            while ((Loop < argc) && (argv[Loop][0] != '-')) {
                for (Loop1 = 0; Loop1 < num_tests; Loop1++) {
                    if (strcmp(argv[Loop], Test[Loop1].Name) != 0)
                        Test[Loop1].SkipFlag = 1;
                    if (strcmp(argv[Loop], Test[Loop1].Name) == 0)
                        Loop1 = num_tests;
                }
                Loop++;
            }
        }
        if ((argc > CLLoop + 1) &&
            ((strcmp(argv[CLLoop], "-only") == 0) || (strcmp(argv[CLLoop], "-o") == 0))) {
            for (Loop = 0; Loop < num_tests; Loop++) {
                Test[Loop].SkipFlag = 1;
            }
            Loop = CLLoop + 1;
            while ((Loop < argc) && (argv[Loop][0] != '-')) {
                for (Loop1 = 0; Loop1 < num_tests; Loop1++) {
                    if (strcmp(argv[Loop], Test[Loop1].Name) == 0)
                        Test[Loop1].SkipFlag = 0;
                }
                Loop++;
            }
        }
    }

    for (Loop = 0; Loop < num_tests; Loop++) {
        if (Test[Loop].SkipFlag) {
            fprintf(cmdfile, "%s %s\n", SKIP_STR, Test[Loop].Name);
        }
        else {
            fprintf(cmdfile, "%s %s\n", TEST_STR, Test[Loop].Name);
        }
    }

    fclose(cmdfile);

    /* flush stdout to guarantee output precedes that of fortestF */
    fflush(stdout);

#ifndef CMAKE_INTDIR /* not built with cmake */
    return system("./fortestF");
#else
    return 0; /*(system("./fortestF"));*/
#endif
}