Skip to content

Commit d1ad90f

Browse files
committed
regx/test: update regex test
Signed-off-by: Boris Karasev <karasev.b@gmail.com>
1 parent 29915fc commit d1ad90f

File tree

1 file changed

+42
-7
lines changed

1 file changed

+42
-7
lines changed

orte/test/system/regex.c

Lines changed: 42 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,19 @@
1313
#include "opal/util/argv.h"
1414

1515
#include "orte/util/proc_info.h"
16-
#include "orte/util/regex.h"
1716
#include "orte/mca/errmgr/errmgr.h"
1817
#include "orte/runtime/runtime.h"
18+
#include "orte/mca/regx/regx.h"
19+
#include "orte/mca/regx/base/base.h"
1920

2021
int main(int argc, char **argv)
2122
{
2223
int rc;
23-
char *regex, *save;
24+
char *regex, **nodelist;
2425
char **nodes=NULL;
2526
int i;
27+
opal_pointer_array_t *node_pool;
28+
orte_node_t *nptr;
2629

2730
if (argc < 1 || NULL == argv[1]) {
2831
fprintf(stderr, "usage: regex <comma-separated list of nodes>\n");
@@ -31,10 +34,19 @@ int main(int argc, char **argv)
3134

3235
orte_init(&argc, &argv, ORTE_PROC_NON_MPI);
3336

37+
if (ORTE_SUCCESS != (rc = mca_base_framework_open(&orte_regx_base_framework, 0))) {
38+
ORTE_ERROR_LOG(rc);
39+
return rc;
40+
}
41+
if (ORTE_SUCCESS != (rc = orte_regx_base_select())) {
42+
ORTE_ERROR_LOG(rc);
43+
return rc;
44+
}
45+
3446
if (NULL != strchr(argv[1], '[')) {
3547
/* given a regex to analyze */
3648
fprintf(stderr, "ANALYZING REGEX: %s\n", argv[1]);
37-
if (ORTE_SUCCESS != (rc = orte_regex_extract_node_names(argv[1], &nodes))) {
49+
if (ORTE_SUCCESS != (rc = orte_regx.extract_node_names(argv[1], &nodes))) {
3850
ORTE_ERROR_LOG(rc);
3951
}
4052
for (i=0; NULL != nodes[i]; i++) {
@@ -45,12 +57,30 @@ int main(int argc, char **argv)
4557
return 0;
4658
}
4759

48-
save = strdup(argv[1]);
49-
if (ORTE_SUCCESS != (rc = orte_regex_create(save, &regex))) {
60+
node_pool = OBJ_NEW(opal_pointer_array_t);
61+
nodelist = opal_argv_split(argv[1], ',');
62+
for (i=0; NULL != nodelist[i]; i++) {
63+
orte_proc_t *daemon = NULL;
64+
65+
nptr = OBJ_NEW(orte_node_t);
66+
nptr->name = strdup(nodelist[i]);
67+
daemon = OBJ_NEW(orte_proc_t);
68+
daemon->name.jobid = 123;
69+
daemon->name.vpid = i;
70+
nptr->daemon = daemon;
71+
72+
nptr->index = opal_pointer_array_add(node_pool, nptr);
73+
}
74+
opal_argv_free(nodelist);
75+
76+
77+
if (ORTE_SUCCESS != (rc = orte_regx.nidmap_create(node_pool, &regex))) {
5078
ORTE_ERROR_LOG(rc);
5179
} else {
80+
char *vpids = strchr(regex, '@');
81+
vpids[0] = '\0';
5282
fprintf(stderr, "REGEX: %s\n", regex);
53-
if (ORTE_SUCCESS != (rc = orte_regex_extract_node_names(regex, &nodes))) {
83+
if (ORTE_SUCCESS != (rc = orte_regx.extract_node_names(regex, &nodes))) {
5484
ORTE_ERROR_LOG(rc);
5585
}
5686
free(regex);
@@ -63,5 +93,10 @@ int main(int argc, char **argv)
6393
}
6494
free(regex);
6595
}
66-
free(save);
96+
97+
for (i=0; (nptr = opal_pointer_array_get_item(node_pool, i)) != NULL; i++) {
98+
free(nptr->name);
99+
OBJ_RELEASE(nptr->daemon);
100+
}
101+
OBJ_RELEASE(node_pool);
67102
}

0 commit comments

Comments
 (0)