* 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.
Этот коммит содержится в:
родитель
43822c6ec6
Коммит
7a8e646fff
@ -172,6 +172,7 @@ int
|
|||||||
opal_mem_free_unregister_handler(opal_mem_free_unpin_fn_t *func)
|
opal_mem_free_unregister_handler(opal_mem_free_unpin_fn_t *func)
|
||||||
{
|
{
|
||||||
opal_list_item_t *item;
|
opal_list_item_t *item;
|
||||||
|
opal_list_item_t *found_item = NULL;
|
||||||
callback_list_item_t *cbitem;
|
callback_list_item_t *cbitem;
|
||||||
int ret = OMPI_ERR_NOT_FOUND;
|
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) {
|
if (cbitem->cbfunc == func) {
|
||||||
opal_list_remove_item(&callback_list, item);
|
opal_list_remove_item(&callback_list, item);
|
||||||
|
found_item = item;
|
||||||
ret = OMPI_SUCCESS;
|
ret = OMPI_SUCCESS;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -192,5 +194,11 @@ opal_mem_free_unregister_handler(opal_mem_free_unpin_fn_t *func)
|
|||||||
|
|
||||||
opal_atomic_unlock(&callback_lock);
|
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;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -60,8 +60,8 @@ char *opal_os_path(bool relative, ...)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (0 == num_elements) { /* must be looking for a simple answer */
|
if (0 == num_elements) { /* must be looking for a simple answer */
|
||||||
path = (char *)malloc(2);
|
path = (char *)malloc(3);
|
||||||
path[0] = 0;
|
path[0] = '\0';
|
||||||
if (relative) {
|
if (relative) {
|
||||||
strcpy(path, ".");
|
strcpy(path, ".");
|
||||||
strcat(path, orte_system_info.path_sep);
|
strcat(path, orte_system_info.path_sep);
|
||||||
|
@ -21,7 +21,8 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "support.h"
|
#include "support.h"
|
||||||
#include "opal/class/opal_object.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;
|
static FILE *error_out=NULL;
|
||||||
|
|
||||||
@ -158,6 +159,8 @@ static void test_static(void)
|
|||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
opal_init();
|
||||||
/* local variables */
|
/* local variables */
|
||||||
test_init("opal_hash_table_t");
|
test_init("opal_hash_table_t");
|
||||||
|
|
||||||
@ -174,5 +177,7 @@ int main(int argc, char **argv)
|
|||||||
fclose( error_out );
|
fclose( error_out );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
opal_finalize();
|
||||||
|
|
||||||
return test_finalize();
|
return test_finalize();
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
#include "support.h"
|
#include "support.h"
|
||||||
#include "opal/class/opal_list.h"
|
#include "opal/class/opal_list.h"
|
||||||
|
#include "opal/runtime/opal.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Data type used for testing
|
* Data type used for testing
|
||||||
@ -43,6 +44,8 @@ int main(int argc, char **argv)
|
|||||||
test_data_t *elements, *ele;
|
test_data_t *elements, *ele;
|
||||||
opal_list_item_t *item;
|
opal_list_item_t *item;
|
||||||
|
|
||||||
|
opal_init();
|
||||||
|
|
||||||
test_init("opal_list_t");
|
test_init("opal_list_t");
|
||||||
|
|
||||||
/* initialize list */
|
/* initialize list */
|
||||||
@ -329,5 +332,9 @@ int main(int argc, char **argv)
|
|||||||
test_success();
|
test_success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (NULL != elements) free(elements);
|
||||||
|
|
||||||
|
opal_finalize();
|
||||||
|
|
||||||
return test_finalize();
|
return test_finalize();
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
|
|
||||||
#include "support.h"
|
#include "support.h"
|
||||||
#include "opal/class/opal_value_array.h"
|
#include "opal/class/opal_value_array.h"
|
||||||
|
#include "opal/runtime/opal.h"
|
||||||
|
|
||||||
#define NUM_ITEMS 10
|
#define NUM_ITEMS 10
|
||||||
|
|
||||||
@ -35,8 +35,10 @@ int main(int argc, char **argv)
|
|||||||
{
|
{
|
||||||
uint64_t i, val;
|
uint64_t i, val;
|
||||||
uint64_t count;
|
uint64_t count;
|
||||||
|
|
||||||
opal_value_array_t array;
|
opal_value_array_t array;
|
||||||
|
|
||||||
|
opal_init();
|
||||||
|
|
||||||
OBJ_CONSTRUCT(&array, opal_value_array_t);
|
OBJ_CONSTRUCT(&array, opal_value_array_t);
|
||||||
|
|
||||||
test_init("opal_value_array_t");
|
test_init("opal_value_array_t");
|
||||||
@ -102,5 +104,8 @@ int main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
OBJ_DESTRUCT(&array);
|
OBJ_DESTRUCT(&array);
|
||||||
|
|
||||||
|
opal_finalize();
|
||||||
|
|
||||||
return test_finalize();
|
return test_finalize();
|
||||||
}
|
}
|
||||||
|
@ -28,6 +28,7 @@
|
|||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
|
||||||
#include "support.h"
|
#include "support.h"
|
||||||
|
#include "opal/runtime/opal.h"
|
||||||
#include "opal/include/constants.h"
|
#include "opal/include/constants.h"
|
||||||
#include "opal/util/sys_info.h"
|
#include "opal/util/sys_info.h"
|
||||||
#include "opal/util/os_path.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[])
|
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 */
|
/* All done */
|
||||||
|
|
||||||
@ -68,8 +69,9 @@ int main(int argc, char* argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
test_finalize();
|
test_finalize();
|
||||||
return 0;
|
opal_finalize();
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -119,6 +121,8 @@ static bool test2(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
rmdir(tmp);
|
rmdir(tmp);
|
||||||
|
|
||||||
|
free(tmp);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -147,5 +151,8 @@ static bool test3(void)
|
|||||||
rmdir(out);
|
rmdir(out);
|
||||||
return(false);
|
return(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
free(out);
|
||||||
|
|
||||||
return(true);
|
return(true);
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "opal/runtime/opal.h"
|
||||||
#include "util/sys_info.h"
|
#include "util/sys_info.h"
|
||||||
#include "opal/util/os_path.h"
|
#include "opal/util/os_path.h"
|
||||||
#include "support.h"
|
#include "support.h"
|
||||||
@ -35,10 +36,9 @@ static bool test5(void); /* very long path name test */
|
|||||||
|
|
||||||
int main(int argc, char* argv[])
|
int main(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
|
opal_init();
|
||||||
|
|
||||||
test_init("opal_os_path_t");
|
test_init("opal_os_path_t");
|
||||||
/* setup the system info structure */
|
|
||||||
orte_sys_info();
|
|
||||||
|
|
||||||
if (test1()) {
|
if (test1()) {
|
||||||
test_success();
|
test_success();
|
||||||
@ -75,6 +75,8 @@ int main(int argc, char* argv[])
|
|||||||
test_failure("opal_os_path_t test5 failed");
|
test_failure("opal_os_path_t test5 failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
opal_finalize();
|
||||||
|
|
||||||
test_finalize();
|
test_finalize();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -82,19 +84,22 @@ int main(int argc, char* argv[])
|
|||||||
|
|
||||||
static bool test1(void)
|
static bool test1(void)
|
||||||
{
|
{
|
||||||
char *out, *answer;
|
char *out, answer[100];
|
||||||
|
|
||||||
/* Test trivial functionality. Program should return ".[separator]" when called in relative
|
/* Test trivial functionality. Program should return ".[separator]" when called in relative
|
||||||
* mode, and the separator character when called in absolute mode. */
|
* mode, and the separator character when called in absolute mode. */
|
||||||
if (NULL != (out = opal_os_path(true,NULL))) {
|
if (NULL != (out = opal_os_path(true,NULL))) {
|
||||||
answer = strdup(".");
|
answer[0] = '\0';
|
||||||
|
strcat(answer, ".");
|
||||||
strcat(answer, orte_system_info.path_sep);
|
strcat(answer, orte_system_info.path_sep);
|
||||||
if (0 != strcmp(answer, out))
|
if (0 != strcmp(answer, out))
|
||||||
return(false);
|
return(false);
|
||||||
|
free(out);
|
||||||
}
|
}
|
||||||
if (NULL != (out = opal_os_path(false,NULL))) {
|
if (NULL != (out = opal_os_path(false,NULL))) {
|
||||||
if (0 != strcmp(orte_system_info.path_sep, out))
|
if (0 != strcmp(orte_system_info.path_sep, out))
|
||||||
return(false);
|
return(false);
|
||||||
|
free(out);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -103,7 +108,8 @@ static bool test1(void)
|
|||||||
|
|
||||||
static bool test2(void)
|
static bool test2(void)
|
||||||
{
|
{
|
||||||
char *out;
|
char out[1024];
|
||||||
|
char *tmp;
|
||||||
char *a[] = { "aaa", "bbb", "ccc", NULL };
|
char *a[] = { "aaa", "bbb", "ccc", NULL };
|
||||||
|
|
||||||
if (NULL == orte_system_info.path_sep) {
|
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. */
|
/* Construct a relative path name and see if it comes back correctly. Check multiple depths. */
|
||||||
out = strdup(".");
|
out[0] = '\0';
|
||||||
out = strcat(out, orte_system_info.path_sep);
|
strcat(out, ".");
|
||||||
out = strcat(out, a[0]);
|
strcat(out, orte_system_info.path_sep);
|
||||||
if (0 != strcmp(out, opal_os_path(true, a[0], NULL)))
|
strcat(out, a[0]);
|
||||||
return(false);
|
|
||||||
|
|
||||||
out = strcat(out, orte_system_info.path_sep);
|
tmp = opal_os_path(true, a[0], NULL);
|
||||||
out = strcat(out, a[1]);
|
if (0 != strcmp(out, tmp))
|
||||||
if (0 != strcmp(out, opal_os_path(true, a[0], a[1], NULL)))
|
|
||||||
return(false);
|
return(false);
|
||||||
|
free(tmp);
|
||||||
|
|
||||||
out = strcat(out, orte_system_info.path_sep);
|
strcat(out, orte_system_info.path_sep);
|
||||||
out = strcat(out, a[2]);
|
strcat(out, a[1]);
|
||||||
if (0 != strcmp(out, opal_os_path(true, a[0], a[1], a[2], NULL)))
|
tmp = opal_os_path(true, a[0], a[1], NULL);
|
||||||
|
if (0 != strcmp(out, tmp))
|
||||||
return(false);
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
@ -134,7 +148,8 @@ static bool test2(void)
|
|||||||
|
|
||||||
static bool test3(void)
|
static bool test3(void)
|
||||||
{
|
{
|
||||||
char *out;
|
char out[1024];
|
||||||
|
char *tmp;
|
||||||
char *a[] = { "aaa", "bbb", "ccc", NULL };
|
char *a[] = { "aaa", "bbb", "ccc", NULL };
|
||||||
|
|
||||||
if (NULL == orte_system_info.path_sep) {
|
if (NULL == orte_system_info.path_sep) {
|
||||||
@ -143,20 +158,27 @@ static bool test3(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Same as prior test, only with absolute path name */
|
/* Same as prior test, only with absolute path name */
|
||||||
out = strdup(orte_system_info.path_sep);
|
out[0] = '\0';
|
||||||
out = strcat(out, a[0]);
|
strcat(out, orte_system_info.path_sep);
|
||||||
if (0 != strcmp(out, opal_os_path(false, a[0], NULL)))
|
strcat(out, a[0]);
|
||||||
|
tmp = opal_os_path(false, a[0], NULL);
|
||||||
|
if (0 != strcmp(out, tmp))
|
||||||
return(false);
|
return(false);
|
||||||
|
free(tmp);
|
||||||
|
|
||||||
out = strcat(out, orte_system_info.path_sep);
|
strcat(out, orte_system_info.path_sep);
|
||||||
out = strcat(out, a[1]);
|
strcat(out, a[1]);
|
||||||
if (0 != strcmp(out, opal_os_path(false, a[0], a[1], NULL)))
|
tmp = opal_os_path(false, a[0], a[1], NULL);
|
||||||
|
if (0 != strcmp(out, tmp))
|
||||||
return(false);
|
return(false);
|
||||||
|
free(tmp);
|
||||||
|
|
||||||
out = strcat(out, orte_system_info.path_sep);
|
strcat(out, orte_system_info.path_sep);
|
||||||
out = strcat(out, a[2]);
|
strcat(out, a[2]);
|
||||||
if (0 != strcmp(out, opal_os_path(false, a[0], a[1], a[2], NULL)))
|
tmp = opal_os_path(false, a[0], a[1], a[2], NULL);
|
||||||
|
if (0 != strcmp(out, tmp))
|
||||||
return(false);
|
return(false);
|
||||||
|
free(tmp);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -174,6 +196,7 @@ static bool test4(void)
|
|||||||
for (i=0; i< MAXPATHLEN+5; i++) {
|
for (i=0; i< MAXPATHLEN+5; i++) {
|
||||||
a[i] = 'a';
|
a[i] = 'a';
|
||||||
}
|
}
|
||||||
|
a[i] = '\0';
|
||||||
if (NULL != opal_os_path(false, a, NULL)) {
|
if (NULL != opal_os_path(false, a, NULL)) {
|
||||||
return(false);
|
return(false);
|
||||||
}
|
}
|
||||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user