automate verification of tests results and add use of test support routines
This commit was SVN r2002.
Этот коммит содержится в:
родитель
b47e1daac6
Коммит
b3245d5762
@ -4,10 +4,14 @@
|
||||
*/
|
||||
|
||||
#include "ompi_config.h"
|
||||
#include "support.h"
|
||||
|
||||
#include "mca/llm/base/base.h"
|
||||
#include "mca/llm/base/base_internal.h"
|
||||
|
||||
static char *cmd1_str="diff ./test1_out ./test1_out_std";
|
||||
static char *cmd2_str="diff ./test2_out ./test2_out_std";
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
@ -15,46 +19,86 @@ main(int argc, char *argv[])
|
||||
mca_llm_base_node_t *node;
|
||||
mca_llm_base_valuepair_t *valpair;
|
||||
ompi_list_item_t *nodeitem, *valpairitem;
|
||||
FILE *test1_out=NULL; /* output file for first test */
|
||||
FILE *test2_out=NULL; /* output file for second test */
|
||||
int result; /* result of system call */
|
||||
|
||||
test_init("parse_hostfile_t");
|
||||
|
||||
/* Open output files for the tests */
|
||||
test1_out = fopen("./test1_out", "w+" );
|
||||
if( test1_out == NULL ) {
|
||||
printf("can't open test 1 output file\n");
|
||||
exit(-1);
|
||||
}
|
||||
test2_out = fopen("./test2_out", "w+" );
|
||||
if( test2_out == NULL ) {
|
||||
printf("can't open test 2 output file\n");
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
/* test 1 - test base_parse_hostfile */
|
||||
hostlist = mca_llm_base_parse_hostfile("testfile");
|
||||
assert(hostlist != NULL);
|
||||
|
||||
printf("Original hostfile\n");
|
||||
fprintf(test1_out,"Original hostfile\n");
|
||||
|
||||
for (nodeitem = ompi_list_get_first(hostlist);
|
||||
nodeitem != ompi_list_get_end(hostlist);
|
||||
nodeitem = ompi_list_get_next(nodeitem)) {
|
||||
|
||||
node = (mca_llm_base_node_t*) nodeitem;
|
||||
printf("\t%s %d\n", node->hostname, node->count);
|
||||
fprintf(test1_out, "\t%s %d\n", node->hostname, node->count);
|
||||
|
||||
for (valpairitem = ompi_list_get_first(&(node->info));
|
||||
valpairitem != ompi_list_get_end(&(node->info));
|
||||
valpairitem = ompi_list_get_next(valpairitem)) {
|
||||
valpair = (mca_llm_base_valuepair_t*) valpairitem;
|
||||
printf("\t\t%s = %s\n", valpair->key, valpair->value);
|
||||
fprintf(test1_out, "\t\t%s = %s\n", valpair->key, valpair->value);
|
||||
}
|
||||
}
|
||||
fclose( test1_out );
|
||||
|
||||
/* See if the file matches the test standard */
|
||||
result = system( cmd1_str );
|
||||
if( result == 0 ) {
|
||||
test_success();
|
||||
}
|
||||
else {
|
||||
test_failure( "parse_hostfile test1 failed" );
|
||||
}
|
||||
|
||||
/* test 2 */
|
||||
mca_llm_base_collapse_resources(hostlist);
|
||||
printf("Compressed hostfile\n");
|
||||
fprintf(test2_out, "Compressed hostfile\n");
|
||||
|
||||
for (nodeitem = ompi_list_get_first(hostlist);
|
||||
nodeitem != ompi_list_get_end(hostlist);
|
||||
nodeitem = ompi_list_get_next(nodeitem)) {
|
||||
|
||||
node = (mca_llm_base_node_t*) nodeitem;
|
||||
printf("\t%s %d\n", node->hostname, node->count);
|
||||
fprintf(test2_out, "\t%s %d\n", node->hostname, node->count);
|
||||
|
||||
for (valpairitem = ompi_list_get_first(&(node->info));
|
||||
valpairitem != ompi_list_get_end(&(node->info));
|
||||
valpairitem = ompi_list_get_next(valpairitem)) {
|
||||
valpair = (mca_llm_base_valuepair_t*) valpairitem;
|
||||
printf("\t\t%s = %s\n", valpair->key, valpair->value);
|
||||
fprintf(test2_out, "\t\t%s = %s\n", valpair->key, valpair->value);
|
||||
}
|
||||
}
|
||||
}
|
||||
fclose( test2_out );
|
||||
|
||||
/* See if the file matches the test standard */
|
||||
result = system( cmd2_str );
|
||||
if( result == 0 ) {
|
||||
test_success();
|
||||
}
|
||||
else {
|
||||
test_failure( "parse_hostfile test2 failed" );
|
||||
}
|
||||
|
||||
OBJ_RELEASE(hostlist);
|
||||
|
||||
test_finalize();
|
||||
return 0;
|
||||
}
|
||||
|
24
test/mca/llm/base/test1_out_std
Обычный файл
24
test/mca/llm/base/test1_out_std
Обычный файл
@ -0,0 +1,24 @@
|
||||
Original hostfile
|
||||
host1.example.com 1
|
||||
key = val
|
||||
host2.example.com 3
|
||||
user = anju
|
||||
string = "I am a string"
|
||||
host3.example.com 1
|
||||
192.168.1.1 1
|
||||
192.168.2.1 4
|
||||
user = brbarret
|
||||
string = "Go away"
|
||||
host2.example.com 2
|
||||
user = bbarrett
|
||||
host3.example.com 2
|
||||
host4.example.com 2
|
||||
user = bbarrett
|
||||
foo = bar
|
||||
host4.example.com 5
|
||||
user = bbarrett
|
||||
bar = foo
|
||||
host5.example.com 1
|
||||
foo = bar
|
||||
host5.example.com 1
|
||||
bar = foo
|
21
test/mca/llm/base/test2_out_std
Обычный файл
21
test/mca/llm/base/test2_out_std
Обычный файл
@ -0,0 +1,21 @@
|
||||
Compressed hostfile
|
||||
host1.example.com 1
|
||||
key = val
|
||||
host2.example.com 3
|
||||
user = anju
|
||||
string = "I am a string"
|
||||
host3.example.com 3
|
||||
192.168.1.1 1
|
||||
192.168.2.1 4
|
||||
user = brbarret
|
||||
string = "Go away"
|
||||
host2.example.com 2
|
||||
user = bbarrett
|
||||
host4.example.com 7
|
||||
user = bbarrett
|
||||
foo = bar
|
||||
user = bbarrett
|
||||
bar = foo
|
||||
host5.example.com 2
|
||||
foo = bar
|
||||
bar = foo
|
Загрузка…
x
Ссылка в новой задаче
Block a user