1
1

* add missing OBJ_RELEASE in memory manager code

* fix off-by-one error in os_path code
* Bunch of memory fixes for OPAL unit tests

This commit was SVN r7033.
Этот коммит содержится в:
Brian Barrett 2005-08-25 16:28:41 +00:00
родитель 43822c6ec6
Коммит 7a8e646fff
7 изменённых файлов: 89 добавлений и 34 удалений

Просмотреть файл

@ -172,6 +172,7 @@ int
opal_mem_free_unregister_handler(opal_mem_free_unpin_fn_t *func)
{
opal_list_item_t *item;
opal_list_item_t *found_item = NULL;
callback_list_item_t *cbitem;
int ret = OMPI_ERR_NOT_FOUND;
@ -185,6 +186,7 @@ opal_mem_free_unregister_handler(opal_mem_free_unpin_fn_t *func)
if (cbitem->cbfunc == func) {
opal_list_remove_item(&callback_list, item);
found_item = item;
ret = OMPI_SUCCESS;
break;
}
@ -192,5 +194,11 @@ opal_mem_free_unregister_handler(opal_mem_free_unpin_fn_t *func)
opal_atomic_unlock(&callback_lock);
/* OBJ_RELEASE calls free, so we can't release until we get out of
the lock */
if (NULL != found_item) {
OBJ_RELEASE(item);
}
return ret;
}

Просмотреть файл

@ -60,8 +60,8 @@ char *opal_os_path(bool relative, ...)
}
if (0 == num_elements) { /* must be looking for a simple answer */
path = (char *)malloc(2);
path[0] = 0;
path = (char *)malloc(3);
path[0] = '\0';
if (relative) {
strcpy(path, ".");
strcat(path, orte_system_info.path_sep);

Просмотреть файл

@ -21,7 +21,8 @@
#include <string.h>
#include "support.h"
#include "opal/class/opal_object.h"
#include "class/opal_hash_table.h"
#include "opal/class/opal_hash_table.h"
#include "opal/runtime/opal.h"
static FILE *error_out=NULL;
@ -158,6 +159,8 @@ static void test_static(void)
int main(int argc, char **argv)
{
opal_init();
/* local variables */
test_init("opal_hash_table_t");
@ -173,6 +176,8 @@ int main(int argc, char **argv)
#ifndef STANDALONE
fclose( error_out );
#endif
opal_finalize();
return test_finalize();
}

Просмотреть файл

@ -19,6 +19,7 @@
#include "support.h"
#include "opal/class/opal_list.h"
#include "opal/runtime/opal.h"
/*
* Data type used for testing
@ -43,6 +44,8 @@ int main(int argc, char **argv)
test_data_t *elements, *ele;
opal_list_item_t *item;
opal_init();
test_init("opal_list_t");
/* initialize list */
@ -329,5 +332,9 @@ int main(int argc, char **argv)
test_success();
}
if (NULL != elements) free(elements);
opal_finalize();
return test_finalize();
}

Просмотреть файл

@ -26,7 +26,7 @@
#include "support.h"
#include "opal/class/opal_value_array.h"
#include "opal/runtime/opal.h"
#define NUM_ITEMS 10
@ -35,8 +35,10 @@ int main(int argc, char **argv)
{
uint64_t i, val;
uint64_t count;
opal_value_array_t array;
opal_init();
OBJ_CONSTRUCT(&array, opal_value_array_t);
test_init("opal_value_array_t");
@ -102,5 +104,8 @@ int main(int argc, char **argv)
}
OBJ_DESTRUCT(&array);
opal_finalize();
return test_finalize();
}

Просмотреть файл

@ -28,6 +28,7 @@
#include <sys/stat.h>
#include "support.h"
#include "opal/runtime/opal.h"
#include "opal/include/constants.h"
#include "opal/util/sys_info.h"
#include "opal/util/os_path.h"
@ -40,9 +41,9 @@ static bool test3(void); /* test making a directory tree */
int main(int argc, char* argv[])
{
test_init("opal_os_create_dirpath_t");
opal_init();
orte_sys_info(); /* initialize system info */
test_init("opal_os_create_dirpath_t");
/* All done */
@ -68,8 +69,9 @@ int main(int argc, char* argv[])
}
test_finalize();
return 0;
opal_finalize();
return 0;
}
@ -119,6 +121,8 @@ static bool test2(void)
}
rmdir(tmp);
free(tmp);
return true;
}
@ -147,5 +151,8 @@ static bool test3(void)
rmdir(out);
return(false);
}
free(out);
return(true);
}

Просмотреть файл

@ -22,6 +22,7 @@
#include <sys/param.h>
#endif
#include "opal/runtime/opal.h"
#include "util/sys_info.h"
#include "opal/util/os_path.h"
#include "support.h"
@ -35,10 +36,9 @@ static bool test5(void); /* very long path name test */
int main(int argc, char* argv[])
{
opal_init();
test_init("opal_os_path_t");
/* setup the system info structure */
orte_sys_info();
if (test1()) {
test_success();
@ -75,6 +75,8 @@ int main(int argc, char* argv[])
test_failure("opal_os_path_t test5 failed");
}
opal_finalize();
test_finalize();
return 0;
}
@ -82,19 +84,22 @@ int main(int argc, char* argv[])
static bool test1(void)
{
char *out, *answer;
char *out, answer[100];
/* Test trivial functionality. Program should return ".[separator]" when called in relative
* mode, and the separator character when called in absolute mode. */
if (NULL != (out = opal_os_path(true,NULL))) {
answer = strdup(".");
answer[0] = '\0';
strcat(answer, ".");
strcat(answer, orte_system_info.path_sep);
if (0 != strcmp(answer, out))
return(false);
free(out);
}
if (NULL != (out = opal_os_path(false,NULL))) {
if (0 != strcmp(orte_system_info.path_sep, out))
return(false);
free(out);
}
return true;
@ -103,7 +108,8 @@ static bool test1(void)
static bool test2(void)
{
char *out;
char out[1024];
char *tmp;
char *a[] = { "aaa", "bbb", "ccc", NULL };
if (NULL == orte_system_info.path_sep) {
@ -112,21 +118,29 @@ static bool test2(void)
}
/* Construct a relative path name and see if it comes back correctly. Check multiple depths. */
out = strdup(".");
out = strcat(out, orte_system_info.path_sep);
out = strcat(out, a[0]);
if (0 != strcmp(out, opal_os_path(true, a[0], NULL)))
return(false);
out[0] = '\0';
strcat(out, ".");
strcat(out, orte_system_info.path_sep);
strcat(out, a[0]);
out = strcat(out, orte_system_info.path_sep);
out = strcat(out, a[1]);
if (0 != strcmp(out, opal_os_path(true, a[0], a[1], NULL)))
tmp = opal_os_path(true, a[0], NULL);
if (0 != strcmp(out, tmp))
return(false);
free(tmp);
out = strcat(out, orte_system_info.path_sep);
out = strcat(out, a[2]);
if (0 != strcmp(out, opal_os_path(true, a[0], a[1], a[2], NULL)))
strcat(out, orte_system_info.path_sep);
strcat(out, a[1]);
tmp = opal_os_path(true, a[0], a[1], NULL);
if (0 != strcmp(out, tmp))
return(false);
free(tmp);
strcat(out, orte_system_info.path_sep);
strcat(out, a[2]);
tmp = opal_os_path(true, a[0], a[1], a[2], NULL);
if (0 != strcmp(out, tmp))
return(false);
free(tmp);
return true;
}
@ -134,7 +148,8 @@ static bool test2(void)
static bool test3(void)
{
char *out;
char out[1024];
char *tmp;
char *a[] = { "aaa", "bbb", "ccc", NULL };
if (NULL == orte_system_info.path_sep) {
@ -143,20 +158,27 @@ static bool test3(void)
}
/* Same as prior test, only with absolute path name */
out = strdup(orte_system_info.path_sep);
out = strcat(out, a[0]);
if (0 != strcmp(out, opal_os_path(false, a[0], NULL)))
out[0] = '\0';
strcat(out, orte_system_info.path_sep);
strcat(out, a[0]);
tmp = opal_os_path(false, a[0], NULL);
if (0 != strcmp(out, tmp))
return(false);
free(tmp);
out = strcat(out, orte_system_info.path_sep);
out = strcat(out, a[1]);
if (0 != strcmp(out, opal_os_path(false, a[0], a[1], NULL)))
strcat(out, orte_system_info.path_sep);
strcat(out, a[1]);
tmp = opal_os_path(false, a[0], a[1], NULL);
if (0 != strcmp(out, tmp))
return(false);
free(tmp);
out = strcat(out, orte_system_info.path_sep);
out = strcat(out, a[2]);
if (0 != strcmp(out, opal_os_path(false, a[0], a[1], a[2], NULL)))
strcat(out, orte_system_info.path_sep);
strcat(out, a[2]);
tmp = opal_os_path(false, a[0], a[1], a[2], NULL);
if (0 != strcmp(out, tmp))
return(false);
free(tmp);
return true;
}
@ -174,6 +196,7 @@ static bool test4(void)
for (i=0; i< MAXPATHLEN+5; i++) {
a[i] = 'a';
}
a[i] = '\0';
if (NULL != opal_os_path(false, a, NULL)) {
return(false);
}