* add basic unit test shell
This commit was SVN r235.
Этот коммит содержится в:
родитель
6f7811f9d5
Коммит
812b9e5897
13
test/unit/lam/oob_cofs/Makefile.am
Обычный файл
13
test/unit/lam/oob_cofs/Makefile.am
Обычный файл
@ -0,0 +1,13 @@
|
||||
# -*- makefile -*-
|
||||
#
|
||||
# $HEADER$
|
||||
#
|
||||
|
||||
include $(top_srcdir)/config/Makefile.options
|
||||
|
||||
bin_PROGRAMS = oob_cofs_test
|
||||
|
||||
oob_cofs_test_SOURCES = oob_cofs_test.c
|
||||
oob_cofs_test_LDADD = \
|
||||
../../../../src/mca/lam/oob/cofs/libmca_lam_oob_cofs.la \
|
||||
../../../../src/lam/liblam.la
|
74
test/unit/lam/oob_cofs/oob_cofs_test.c
Обычный файл
74
test/unit/lam/oob_cofs/oob_cofs_test.c
Обычный файл
@ -0,0 +1,74 @@
|
||||
#include "mca/lam/oob/oob.h"
|
||||
#include "mca/lam/oob/cofs/src/oob_cofs.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int
|
||||
main(int argc, char* argv[])
|
||||
{
|
||||
int ret;
|
||||
char *tmp;
|
||||
int priority = 0;
|
||||
struct mca_oob_1_0_0 *init_ret;
|
||||
int target_vpid, source_vpid, source_tag;
|
||||
size_t source_len;
|
||||
char *source_data;
|
||||
char buffer[2048];
|
||||
int msg_count = 0;
|
||||
|
||||
if (argc != 3) {
|
||||
printf("usage: %s my_vpid target_vpid\n", argv[0]);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
tmp = malloc(strlen("MCA_OOB_BASE_VPID") + strlen(argv[1]) + 2);
|
||||
sprintf(tmp, "MCA_OOB_BASE_VPID=%s", argv[1]);
|
||||
putenv(tmp);
|
||||
|
||||
target_vpid = atoi(argv[2]);
|
||||
|
||||
ret = mca_oob_cofs_open(NULL);
|
||||
if (ret != LAM_SUCCESS) {
|
||||
printf("mca_oob_cofs_open returned %d\n", ret);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
ret = mca_oob_cofs_query(&priority);
|
||||
if (ret != LAM_SUCCESS) {
|
||||
printf("mca_oob_cofs_query returned %d\n", ret);
|
||||
exit(1);
|
||||
} else {
|
||||
printf("mca_oob_cofs_query said \"go\" with priority %d\n", priority);
|
||||
}
|
||||
|
||||
init_ret = mca_oob_cofs_init();
|
||||
if (init_ret == NULL) {
|
||||
printf("mca_oob_cofs_init returned NULL\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
printf("#\n# Sending Messages\n#\n");
|
||||
for (msg_count = 0 ; msg_count < 20 ; ++msg_count) {
|
||||
sprintf(buffer, "%s's message number %d\n", argv[1], msg_count);
|
||||
ret = mca_oob_cofs_send("foobar", target_vpid, 1, buffer, strlen(buffer) + 1);
|
||||
if (ret != LAM_SUCCESS) {
|
||||
printf("mca_oob_cofs_send failed on msg_count %d\n", msg_count);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
printf("#\n# Receiving Messages\n#\n");
|
||||
for (msg_count = 0 ; msg_count < 20 ; ++msg_count) {
|
||||
ret = mca_oob_cofs_recv("foobar", &source_vpid, &source_tag, (void**) &source_data, &source_len);
|
||||
if (ret != LAM_SUCCESS) {
|
||||
printf("mca_oob_cofs_recv failed on msg_count %d\n", msg_count);
|
||||
exit(1);
|
||||
}
|
||||
printf("%d %d: %s\n", source_vpid, source_tag, source_data);
|
||||
lam_free(source_data);
|
||||
}
|
||||
|
||||
printf("#\n# Finished\n#\n");
|
||||
return 0;
|
||||
}
|
Загрузка…
x
Ссылка в новой задаче
Block a user