This source file includes following definitions.
- main
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 #include <stdio.h>
31 #include <stdlib.h>
32 #include <unistd.h>
33
34 #include "src/util/pmix_environ.h"
35 #include "src/util/output.h"
36
37 #include "server_callbacks.h"
38 #include "utils.h"
39 #include "test_server.h"
40 #include "test_common.h"
41
42 bool spawn_wait = false;
43
44 int main(int argc, char **argv)
45 {
46 char **client_env=NULL;
47 char **client_argv=NULL;
48 int rc;
49 struct stat stat_buf;
50 struct timeval tv;
51 double test_start;
52 test_params params;
53 INIT_TEST_PARAMS(params);
54 int test_fail = 0;
55 char *tmp;
56 int ns_nprocs;
57
58 gettimeofday(&tv, NULL);
59 test_start = tv.tv_sec + 1E-6*tv.tv_usec;
60
61
62 if (PMIX_SUCCESS != 0) {
63 TEST_ERROR(("ERROR IN COMPUTING CONSTANTS: PMIX_SUCCESS = %d", PMIX_SUCCESS));
64 exit(1);
65 }
66
67 TEST_VERBOSE(("Testing version %s", PMIx_Get_version()));
68
69 parse_cmd(argc, argv, ¶ms);
70 TEST_VERBOSE(("Start PMIx_lite smoke test (timeout is %d)", params.timeout));
71
72
73 client_env = pmix_argv_copy(environ);
74 set_client_argv(¶ms, &client_argv);
75
76 tmp = pmix_argv_join(client_argv, ' ');
77 TEST_VERBOSE(("Executing test: %s", tmp));
78 free(tmp);
79
80
81 if( 0 > ( rc = stat(params.binary, &stat_buf) ) ){
82 TEST_ERROR(("Cannot stat() executable \"%s\": %d: %s", params.binary, errno, strerror(errno)));
83 FREE_TEST_PARAMS(params);
84 return 0;
85 } else if( !S_ISREG(stat_buf.st_mode) ){
86 TEST_ERROR(("Client executable \"%s\": is not a regular file", params.binary));
87 FREE_TEST_PARAMS(params);
88 return 0;
89 }else if( !(stat_buf.st_mode & S_IXUSR) ){
90 TEST_ERROR(("Client executable \"%s\": has no executable flag", params.binary));
91 FREE_TEST_PARAMS(params);
92 return 0;
93 }
94
95 if (PMIX_SUCCESS != (rc = server_init(¶ms))) {
96 FREE_TEST_PARAMS(params);
97 return rc;
98 }
99
100 cli_init(params.lsize);
101
102 int launched = 0;
103
104 if (NULL == params.ns_dist) {
105 uint32_t i;
106 int base_rank = 0;
107
108
109 for(i = 0; i < (uint32_t)my_server_id; i++) {
110 base_rank += (params.nprocs % params.nservers) > (uint32_t)i ?
111 params.nprocs / params.nservers + 1 :
112 params.nprocs / params.nservers;
113 }
114
115 ns_nprocs = params.nprocs;
116 launched += server_launch_clients(params.lsize, params.nprocs, base_rank,
117 ¶ms, &client_env, &client_argv);
118 } else {
119 char *pch;
120 pch = strtok(params.ns_dist, ":");
121 while (NULL != pch) {
122 ns_nprocs = (int)strtol(pch, NULL, 10);
123 if (params.nprocs < (uint32_t)(launched+ns_nprocs)) {
124 TEST_ERROR(("Total number of processes doesn't correspond number specified by ns_dist parameter."));
125 FREE_TEST_PARAMS(params);
126 return PMIX_ERROR;
127 }
128 if (0 < ns_nprocs) {
129 launched += server_launch_clients(ns_nprocs, ns_nprocs, 0, ¶ms,
130 &client_env, &client_argv);
131 }
132 pch = strtok (NULL, ":");
133 }
134 }
135 if (params.lsize != (uint32_t)launched) {
136 TEST_ERROR(("Total number of processes doesn't correspond number specified by ns_dist parameter."));
137 cli_kill_all();
138 test_fail = 1;
139 }
140
141
142 while (!test_terminated()) {
143
144 double test_current;
145
146
147 gettimeofday(&tv, NULL);
148 test_current = tv.tv_sec + 1E-6*tv.tv_usec;
149 if( (test_current - test_start) > params.timeout ){
150 break;
151 }
152 cli_wait_all(0);
153 }
154
155 if( !test_terminated() ){
156 TEST_ERROR(("Test exited by a timeout!"));
157 cli_kill_all();
158 test_fail = 1;
159 }
160
161 if( test_abort ){
162 TEST_ERROR(("Test was aborted!"));
163
164
165
166
167 test_fail = 1;
168 }
169
170 if (0 != params.test_spawn) {
171 PMIX_WAIT_FOR_COMPLETION(spawn_wait);
172 }
173
174
175 PMIx_Deregister_event_handler(0, op_callbk, NULL);
176
177 cli_wait_all(1.0);
178
179 test_fail += server_finalize(¶ms);
180
181 FREE_TEST_PARAMS(params);
182 pmix_argv_free(client_argv);
183 pmix_argv_free(client_env);
184
185 return test_fail;
186 }