| 1 |
/* |
| 2 |
* Copyright (c) 2002-2005, Network Appliance, Inc. All rights reserved. |
| 3 |
* |
| 4 |
* This Software is licensed under one of the following licenses: |
| 5 |
* |
| 6 |
* 1) under the terms of the "Common Public License 1.0" a copy of which is |
| 7 |
* in the file LICENSE.txt in the root directory. The license is also |
| 8 |
* available from the Open Source Initiative, see |
| 9 |
* http://www.opensource.org/licenses/cpl.php. |
| 10 |
* |
| 11 |
* 2) under the terms of the "The BSD License" a copy of which is in the file |
| 12 |
* LICENSE2.txt in the root directory. The license is also available from |
| 13 |
* the Open Source Initiative, see |
| 14 |
* http://www.opensource.org/licenses/bsd-license.php. |
| 15 |
* |
| 16 |
* 3) under the terms of the "GNU General Public License (GPL) Version 2" a |
| 17 |
* copy of which is in the file LICENSE3.txt in the root directory. The |
| 18 |
* license is also available from the Open Source Initiative, see |
| 19 |
* http://www.opensource.org/licenses/gpl-license.php. |
| 20 |
* |
| 21 |
* Licensee has the right to choose one of the above licenses. |
| 22 |
* |
| 23 |
* Redistributions of source code must retain the above copyright |
| 24 |
* notice and one of the license notices. |
| 25 |
* |
| 26 |
* Redistributions in binary form must reproduce both the above copyright |
| 27 |
* notice, one of the license notices in the documentation |
| 28 |
* and/or other materials provided with the distribution. |
| 29 |
*/ |
| 30 |
|
| 31 |
#include "dapl_proto.h" |
| 32 |
|
| 33 |
/* Main Entry Point */ |
| 34 |
int main(int argc, char *argv[]) |
| 35 |
{ |
| 36 |
return (dapltest(argc, argv)); |
| 37 |
} |
| 38 |
|
| 39 |
/* |
| 40 |
* dapltest main program |
| 41 |
*/ |
| 42 |
int dapltest(int argc, char *argv[]) |
| 43 |
{ |
| 44 |
Params_t *params_ptr; |
| 45 |
DAT_RETURN rc = DAT_SUCCESS; |
| 46 |
|
| 47 |
/* check memory leaking */ |
| 48 |
/* |
| 49 |
* DT_Mdep_LockInit(&Alloc_Count_Lock); alloc_count = 0; |
| 50 |
*/ |
| 51 |
|
| 52 |
#if defined(_WIN32) || defined(_WIN64) |
| 53 |
{ |
| 54 |
/* Cannot be done from DT_Mdep_Init as dapl_init makes some socket |
| 55 |
* calls....So need to do this before calling dapl_init */ |
| 56 |
WSADATA wsaData; |
| 57 |
int i; |
| 58 |
|
| 59 |
i = WSAStartup(MAKEWORD(2, 2), &wsaData); |
| 60 |
if (i != 0) { |
| 61 |
printf("%s WSAStartup(2.2) failed? (0x%x)\n", argv[0], |
| 62 |
i); |
| 63 |
exit(1); |
| 64 |
} |
| 65 |
} |
| 66 |
#endif |
| 67 |
|
| 68 |
#ifdef GPROF |
| 69 |
{ |
| 70 |
extern void dapl_init(void); |
| 71 |
dapl_init(); |
| 72 |
} |
| 73 |
#endif |
| 74 |
DT_dapltest_debug = 0; |
| 75 |
|
| 76 |
params_ptr = (Params_t *) DT_Mdep_Malloc(sizeof(Params_t)); |
| 77 |
if (!params_ptr) { |
| 78 |
DT_Mdep_printf("Cannot allocate memory for Params structure\n"); |
| 79 |
return (1); |
| 80 |
} |
| 81 |
|
| 82 |
DT_Tdep_Init(); /* init (kdapl/udapl)test-dependent code */ |
| 83 |
DT_Endian_Init(); /* init endian of local machine */ |
| 84 |
DT_Mdep_Init(); /* init OS, libraries, etc. */ |
| 85 |
|
| 86 |
params_ptr->local_is_little_endian = DT_local_is_little_endian; |
| 87 |
|
| 88 |
/* |
| 89 |
* parse command line arguments |
| 90 |
*/ |
| 91 |
if (!DT_Params_Parse(argc, argv, params_ptr)) { |
| 92 |
DT_Mdep_printf("Command line syntax error\n"); |
| 93 |
return 1; |
| 94 |
} |
| 95 |
params_ptr->cpu_mhz = DT_Mdep_GetCpuMhz(); |
| 96 |
/* call the test-dependent code for invoking the actual test */ |
| 97 |
rc = DT_Tdep_Execute_Test(params_ptr); |
| 98 |
|
| 99 |
/* cleanup */ |
| 100 |
|
| 101 |
DT_Mdep_End(); |
| 102 |
DT_Mdep_Free(params_ptr); |
| 103 |
DT_Tdep_End(); |
| 104 |
#ifdef GPROF |
| 105 |
{ |
| 106 |
extern void dapl_fini(void); |
| 107 |
dapl_fini(); |
| 108 |
} |
| 109 |
#endif |
| 110 |
|
| 111 |
/* |
| 112 |
* check memory leaking DT_Mdep_printf("App allocated Memory left: %d\n", |
| 113 |
* alloc_count); DT_Mdep_LockDestroy(&Alloc_Count_Lock); |
| 114 |
*/ |
| 115 |
|
| 116 |
return (rc); |
| 117 |
} |
| 118 |
|
| 119 |
void Dapltest_Main_Usage(void) |
| 120 |
{ |
| 121 |
DT_Mdep_printf("USAGE:\n"); |
| 122 |
DT_Mdep_printf("USAGE: dapltest -T <Test_Type> [-D IA_name] [-n port_number] [test-specific args]\n"); |
| 123 |
DT_Mdep_printf("USAGE: where <Test_Type>\n"); |
| 124 |
DT_Mdep_printf("USAGE: S = Run as a server\n"); |
| 125 |
DT_Mdep_printf("USAGE: T = Transaction Test\n"); |
| 126 |
DT_Mdep_printf("USAGE: Q = Quit Test\n"); |
| 127 |
DT_Mdep_printf("USAGE: P = Performance Test\n"); |
| 128 |
DT_Mdep_printf("USAGE: L = Limit Test\n"); |
| 129 |
DT_Mdep_printf("USAGE: F = FFT Test\n"); |
| 130 |
DT_Mdep_printf("USAGE:\n"); |
| 131 |
DT_Mdep_printf("USAGE: -D Interface_Adapter {default ibnic0v2}\n"); |
| 132 |
DT_Mdep_printf("USAGE:\n"); |
| 133 |
DT_Mdep_printf("USAGE: -n server_port_number {default 42768}\n"); |
| 134 |
DT_Mdep_printf("USAGE:\n"); |
| 135 |
DT_Mdep_printf |
| 136 |
("NOTE:\tRun as server taking defaults (dapltest -T S [-D ibnic0v2] [-p 42768])\n"); |
| 137 |
DT_Mdep_printf("NOTE: dapltest\n"); |
| 138 |
DT_Mdep_printf("NOTE:\n"); |
| 139 |
DT_Mdep_printf |
| 140 |
("NOTE:\tdapltest arguments may be supplied in a script file\n"); |
| 141 |
DT_Mdep_printf("NOTE:\tdapltest -f <script_file>\n"); |
| 142 |
DT_Mdep_printf("USAGE:\n"); |
| 143 |
} |