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
|
/*
* Copyright (c) 2004-2010 The Trustees of Indiana University and Indiana
* University Research and Technology
* Corporation. All rights reserved.
* Copyright (c) 2004-2011 The University of Tennessee and The University
* of Tennessee Research Foundation. All rights
* reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* Copyright (c) 2006-2013 Los Alamos National Security, LLC.
* All rights reserved.
* Copyright (c) 2009-2012 Cisco Systems, Inc. All rights reserved.
* Copyright (c) 2011 Oak Ridge National Labs. All rights reserved.
* Copyright (c) 2013-2019 Intel, Inc. All rights reserved.
* Copyright (c) 2015 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
* Copyright (c) 2015-2018 Mellanox Technologies, Inc.
* All rights reserved.
* Copyright (c) 2020-2021 Triad National Security, LLC.
* All rights reserved.
*
* Copyright (c) 2021-2022 Nanook Consulting. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*
*/
#include <limits.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include "src/util/pmix_output.h"
#include "src/util/pmix_environ.h"
#include "server_callbacks.h"
#include "test_common.h"
#include "test_server.h"
bool spawn_wait = false;
int main(int argc, char **argv)
{
char **client_env = NULL;
char **client_argv = NULL;
int rc, i;
test_params params;
validation_params val_params;
struct stat stat_buf;
int test_fail = 0;
char *tmp;
sigset_t unblock;
char **test_argv = NULL;
default_params(¶ms, &val_params);
/* smoke test */
if (PMIX_SUCCESS != 0) {
TEST_ERROR_EXIT(("ERROR IN COMPUTING CONSTANTS: PMIX_SUCCESS = %d", PMIX_SUCCESS));
}
TEST_VERBOSE(("Testing version %s", PMIx_Get_version()));
parse_cmd_server(argc, argv, ¶ms, &val_params, &test_argv);
TEST_VERBOSE(("Start PMIx_lite smoke test (timeout is %d)", params.timeout));
/* set common argv and env */
client_env = PMIx_Argv_copy(environ);
if (NULL != test_argv) {
TEST_VERBOSE(("Before set_client_argv, test_argv[0] = %s", test_argv[0]));
}
set_client_argv(¶ms, &client_argv, test_argv);
//set_client_argv(¶ms, &client_argv);
TEST_VERBOSE(("After set_client_argv"));
tmp = PMIx_Argv_join(client_argv, ' ');
TEST_VERBOSE(("Executing test: %s", tmp));
free(tmp);
/* verify executable */
if (0 > (rc = stat(params.binary, &stat_buf))) {
TEST_ERROR_EXIT(
("Cannot stat() executable \"%s\": %d: %s", params.binary, errno, strerror(errno)));
} else if (!S_ISREG(stat_buf.st_mode)) {
TEST_ERROR_EXIT(("Client executable \"%s\": is not a regular file", params.binary));
} else if (!(stat_buf.st_mode & S_IXUSR)) {
TEST_ERROR_EXIT(("Client executable \"%s\": has no executable flag", params.binary));
}
/* ensure that SIGCHLD is unblocked as we need to capture it */
if (0 != sigemptyset(&unblock)) {
TEST_ERROR_EXIT(("SIGEMPTYSET FAILED"));
}
if (0 != sigaddset(&unblock, SIGCHLD)) {
TEST_ERROR_EXIT(("SIGADDSET FAILED"));
}
if (0 != sigprocmask(SIG_UNBLOCK, &unblock, NULL)) {
TEST_ERROR_EXIT(("SIG_UNBLOCK FAILED"));
}
// fork of other servers happens below in server_init
if (PMIX_SUCCESS != (rc = server_init(&val_params))) {
free_params(¶ms, &val_params);
return rc;
}
// at this point, we can have multiple servers executing this code
cli_init(val_params.pmix_local_size);
/* set namespaces and fork clients
* we always have a single namespace for all clients, unlike original version of this test */
int launched = 0;
launched += server_launch_clients(¶ms, &val_params, &client_env, &client_argv);
if (val_params.pmix_local_size != (uint32_t) launched) {
TEST_ERROR(
("srv #%d: Total number of processes doesn't correspond to pmix_local_size parameter.",
my_server_id));
cli_kill_all();
test_fail = 1;
goto done;
}
/* hang around until the client(s) finalize */
while (!test_complete) {
struct timespec ts;
ts.tv_sec = 0;
ts.tv_nsec = 100000;
nanosleep(&ts, NULL);
}
if (test_abort) {
TEST_ERROR(("srv #%d: Test was aborted!", my_server_id));
/* do not simply kill the clients as that generates
* event notifications which these tests then print
* out, flooding the log */
// cli_kill_all();
test_fail = 1;
}
for (i = 0; i < cli_info_cnt; i++) {
if (cli_info[i].exit_code != 0) {
++test_fail;
}
TEST_VERBOSE(
("client %d exit code = %d, test_fail = %d", i, cli_info[i].exit_code, test_fail));
}
/* deregister the errhandler */
PMIx_Deregister_event_handler(0, op_callbk, NULL);
done:
TEST_VERBOSE(("srv #%d: calling server_finalize", my_server_id));
test_fail += server_finalize(&val_params, test_fail);
TEST_VERBOSE(("srv #%d: exit sequence", my_server_id));
free_params(¶ms, &val_params);
PMIx_Argv_free(client_argv);
PMIx_Argv_free(client_env);
if (!test_fail && !test_timeout) {
if (0 == my_server_id) {
TEST_OUTPUT(("Test SUCCEEDED! All servers completed normally."));
}
}
else if (!test_timeout) {
if (PMIX_ERR_TIMEOUT == test_fail){
TEST_OUTPUT(("Test TIMED OUT for server id: %d", my_server_id));
}
else {
TEST_OUTPUT(("Test FAILED for server id: %d, failure code = %d", my_server_id, test_fail));
}
}
else {
TEST_OUTPUT(("Test TIMED OUT for server id: %d", my_server_id));
return test_timeout;
}
return test_fail;
}
|