This source file includes following definitions.
- errhandler
- op_callbk
- errhandler_reg_callbk
- 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 #include <src/include/pmix_config.h>
26 #include <pmix.h>
27
28 #include <stdio.h>
29 #include <stdlib.h>
30 #include <unistd.h>
31 #include <time.h>
32
33 #include "src/class/pmix_object.h"
34 #include "test_common.h"
35 #include "test_fence.h"
36 #include "test_publish.h"
37 #include "test_spawn.h"
38 #include "test_cd.h"
39 #include "test_resolve_peers.h"
40 #include "test_error.h"
41 #include "test_replace.h"
42 #include "test_internal.h"
43
44 static void errhandler(size_t evhdlr_registration_id,
45 pmix_status_t status,
46 const pmix_proc_t *source,
47 pmix_info_t info[], size_t ninfo,
48 pmix_info_t results[], size_t nresults,
49 pmix_event_notification_cbfunc_fn_t cbfunc,
50 void *cbdata)
51 {
52 TEST_ERROR(("PMIX client: Error handler with status = %d", status))
53 }
54
55 static void op_callbk(pmix_status_t status,
56 void *cbdata)
57 {
58 TEST_VERBOSE(( "OP CALLBACK CALLED WITH STATUS %d", status));
59 }
60
61 static void errhandler_reg_callbk (pmix_status_t status,
62 size_t errhandler_ref,
63 void *cbdata)
64 {
65 TEST_VERBOSE(("PMIX client ERRHANDLER REGISTRATION CALLBACK CALLED WITH STATUS %d, ref=%lu",
66 status, (unsigned long)errhandler_ref));
67 }
68
69 int main(int argc, char **argv)
70 {
71 int rc;
72 pmix_value_t value;
73 pmix_value_t *val = &value;
74 test_params params;
75 INIT_TEST_PARAMS(params);
76 pmix_proc_t myproc, proc;
77
78 parse_cmd(argc, argv, ¶ms);
79
80
81 TEST_VERBOSE(("Client %s:%d started PID:%d", params.nspace, params.rank, getpid()));
82
83
84 if (1 == params.early_fail && 0 == params.rank) {
85 exit(0);
86 }
87
88
89 pmix_info_t info[1];
90 size_t ninfo = 0;
91 if (NULL != params.gds_mode) {
92 (void)strncpy(info[0].key, PMIX_GDS_MODULE, PMIX_MAX_KEYLEN);
93 info[0].value.type = PMIX_STRING;
94 info[0].value.data.string = strdup(params.gds_mode);
95 ninfo = 1;
96 }
97 if (PMIX_SUCCESS != (rc = PMIx_Init(&myproc, info, ninfo))) {
98 TEST_ERROR(("Client ns %s rank %d: PMIx_Init failed: %d", params.nspace, params.rank, rc));
99 FREE_TEST_PARAMS(params);
100 exit(0);
101 }
102 PMIx_Register_event_handler(NULL, 0, NULL, 0, errhandler, errhandler_reg_callbk, NULL);
103 if (myproc.rank != params.rank) {
104 TEST_ERROR(("Client ns %s Rank returned in PMIx_Init %d does not match to rank from command line %d.", myproc.nspace, myproc.rank, params.rank));
105 FREE_TEST_PARAMS(params);
106 exit(0);
107 }
108 if ( NULL != params.prefix && -1 != params.ns_id) {
109 TEST_SET_FILE(params.prefix, params.ns_id, params.rank);
110 }
111 TEST_VERBOSE((" Client ns %s rank %d: PMIx_Init success", myproc.nspace, myproc.rank));
112
113 (void)strncpy(proc.nspace, myproc.nspace, PMIX_MAX_NSLEN);
114 proc.rank = PMIX_RANK_WILDCARD;
115 if (PMIX_SUCCESS != (rc = PMIx_Get(&proc, PMIX_UNIV_SIZE, NULL, 0, &val))) {
116 TEST_ERROR(("rank %d: PMIx_Get universe size failed: %d", myproc.rank, rc));
117 FREE_TEST_PARAMS(params);
118 exit(0);
119 }
120 if (NULL == val) {
121 TEST_ERROR(("rank %d: PMIx_Get universe size returned NULL value", myproc.rank));
122 FREE_TEST_PARAMS(params);
123 exit(0);
124 }
125 if (val->type != PMIX_UINT32 || val->data.uint32 != (uint32_t)params.ns_size ) {
126 TEST_ERROR(("rank %d: Universe size value or type mismatch,"
127 " want %d(%d) get %d(%d)",
128 myproc.rank, params.ns_size, PMIX_UINT32,
129 val->data.integer, val->type));
130 FREE_TEST_PARAMS(params);
131 exit(0);
132 }
133
134 TEST_VERBOSE(("rank %d: Universe size check: PASSED", myproc.rank));
135
136 if( NULL != params.nspace && 0 != strcmp(myproc.nspace, params.nspace) ) {
137 TEST_ERROR(("rank %d: Bad nspace!", myproc.rank));
138 FREE_TEST_PARAMS(params);
139 exit(0);
140 }
141
142 if (NULL != params.fences) {
143 rc = test_fence(params, myproc.nspace, myproc.rank);
144 if (PMIX_SUCCESS != rc) {
145 FREE_TEST_PARAMS(params);
146 TEST_ERROR(("%s:%d Fence test failed: %d", myproc.nspace, myproc.rank, rc));
147 exit(0);
148 }
149 }
150
151 if (0 != params.test_job_fence) {
152 rc = test_job_fence(params, myproc.nspace, myproc.rank);
153 if (PMIX_SUCCESS != rc) {
154 FREE_TEST_PARAMS(params);
155 TEST_ERROR(("%s:%d Job fence test failed: %d", myproc.nspace, myproc.rank, rc));
156 exit(0);
157 }
158 }
159
160 if (0 != params.test_publish) {
161 rc = test_publish_lookup(myproc.nspace, myproc.rank);
162 if (PMIX_SUCCESS != rc) {
163 FREE_TEST_PARAMS(params);
164 TEST_ERROR(("%s:%d Publish/Lookup test failed: %d", myproc.nspace, myproc.rank, rc));
165 exit(0);
166 }
167 }
168
169 if (0 != params.test_spawn) {
170 rc = test_spawn(myproc.nspace, myproc.rank);
171 if (PMIX_SUCCESS != rc) {
172 FREE_TEST_PARAMS(params);
173 TEST_ERROR(("%s:%d Spawn test failed: %d", myproc.nspace, myproc.rank, rc));
174 exit(0);
175 }
176 }
177
178 if (0 != params.test_connect) {
179 rc = test_connect_disconnect(myproc.nspace, myproc.rank);
180 if (PMIX_SUCCESS != rc) {
181 FREE_TEST_PARAMS(params);
182 TEST_ERROR(("%s:%d Connect/Disconnect test failed: %d", myproc.nspace, myproc.rank, rc));
183 exit(0);
184 }
185 }
186
187 if (0 != params.test_resolve_peers) {
188 rc = test_resolve_peers(myproc.nspace, myproc.rank, params);
189 if (PMIX_SUCCESS != rc) {
190 FREE_TEST_PARAMS(params);
191 TEST_ERROR(("%s:%d Resolve peers test failed: %d", myproc.nspace, myproc.rank, rc));
192 exit(0);
193 }
194 }
195
196 if (0 != params.test_error) {
197 rc = test_error(myproc.nspace, myproc.rank, params);
198 if (PMIX_SUCCESS != rc) {
199 FREE_TEST_PARAMS(params);
200 TEST_ERROR(("%s:%d error registration and event handling test failed: %d", myproc.nspace, myproc.rank, rc));
201 exit(0);
202 }
203 }
204
205 if (NULL != params.key_replace) {
206 rc = test_replace(myproc.nspace, myproc.rank, params);
207 if (PMIX_SUCCESS != rc) {
208 FREE_TEST_PARAMS(params);
209 TEST_ERROR(("%s:%d error key replace test failed: %d", myproc.nspace, myproc.rank, rc));
210 exit(0);
211 }
212 }
213
214 if (params.test_internal) {
215 rc = test_internal(myproc.nspace, myproc.rank, params);
216 if (PMIX_SUCCESS != rc) {
217 FREE_TEST_PARAMS(params);
218 TEST_ERROR(("%s:%d error key store internal test failed: %d", myproc.nspace, myproc.rank, rc));
219 exit(0);
220 }
221 }
222
223 TEST_VERBOSE(("Client ns %s rank %d: PASSED", myproc.nspace, myproc.rank));
224 PMIx_Deregister_event_handler(1, op_callbk, NULL);
225
226
227
228
229 PMIx_Fence(NULL, 0, NULL, 0);
230
231
232 TEST_VERBOSE(("Client ns %s rank %d: Finalizing", myproc.nspace, myproc.rank));
233 if (PMIX_SUCCESS != (rc = PMIx_Finalize(NULL, 0))) {
234 TEST_ERROR(("Client ns %s rank %d:PMIx_Finalize failed: %d", myproc.nspace, myproc.rank, rc));
235 } else {
236 TEST_VERBOSE(("Client ns %s rank %d:PMIx_Finalize successfully completed", myproc.nspace, myproc.rank));
237 }
238
239 TEST_VERBOSE(("Client %s:%d finished PID:%d", params.nspace, params.rank, getpid()));
240 TEST_OUTPUT_CLEAR(("OK\n"));
241 TEST_CLOSE_FILE();
242 FREE_TEST_PARAMS(params);
243 exit(0);
244 }