From 4c6c3890363b4e0e7620c5c41bfdaa85227d86c4 Mon Sep 17 00:00:00 2001 From: VladimirStarostenkov Date: Tue, 18 Dec 2012 08:46:39 -0800 Subject: [PATCH 1/2] Unit tests for node_func --- src/include/pbs_nodes.h | 2 +- src/server/node_func.c | 437 +++++++++- src/server/node_func.h | 83 +- src/server/test/node_func/scaffolding.c | 142 ++- src/server/test/node_func/test_node_func.c | 960 ++++++++++++++++++++- src/server/test/pbsd_init/scaffolding.c | 3 +- 6 files changed, 1504 insertions(+), 123 deletions(-) diff --git a/src/include/pbs_nodes.h b/src/include/pbs_nodes.h index aa714fc6d7..87c621b887 100644 --- a/src/include/pbs_nodes.h +++ b/src/include/pbs_nodes.h @@ -390,7 +390,7 @@ typedef struct hello_container } hello_container; -void initialize_hello_container(hello_container *); +hello_container * initialize_hello_container(hello_container *); int needs_hello(hello_container *, char *); int add_hello(hello_container *, char *); int add_hello_after(hello_container *, char *, int); diff --git a/src/server/node_func.c b/src/server/node_func.c index 7ad9200877..cf38708ef8 100644 --- a/src/server/node_func.c +++ b/src/server/node_func.c @@ -265,6 +265,17 @@ struct pbsnode *find_node_in_allnodes( struct pbsnode *pnode = NULL; int index; + if (an == NULL) + { + log_err(PBSE_BAD_PARAMETER, __func__, "NULL input all_nodes pointer"); + return(NULL); + } + if (nodename == NULL) + { + log_err(PBSE_BAD_PARAMETER, __func__, "NULL input nodename"); + return(NULL); + } + pthread_mutex_lock(an->allnodes_mutex); index = get_value_hash(an->ht, nodename); @@ -304,6 +315,12 @@ struct pbsnode *find_nodebyname( int i; int numa_index; long cray_enabled = FALSE; + + if (nodename == NULL) + { + log_err(PBSE_BAD_PARAMETER, __func__, "allnodes is not initialized"); + return(NULL); + } if ((pslash = strchr((char *)nodename, (int)'/')) != NULL) *pslash = '\0'; @@ -313,10 +330,20 @@ struct pbsnode *find_nodebyname( i = get_value_hash(allnodes.ht, (void *)nodename); if (i >= 0) + { + + if (allnodes.ra == NULL) + { + log_err(PBSE_BAD_PARAMETER, __func__, "allnodes is not initialized"); + return(NULL); + } pnode = (struct pbsnode *)allnodes.ra->slots[i].item; + } if (pnode != NULL) + { lock_node(pnode, __func__, NULL, LOGLEVEL); + } else { get_svr_attr_l(SRV_ATR_CrayEnabled, &cray_enabled); @@ -395,6 +422,17 @@ void save_characteristic( node_check_info *nci) { + if (pnode == NULL) + { + log_err(PBSE_BAD_PARAMETER,__func__, "NULL input pbsnode pointer"); + return; + } + if (nci == NULL) + { + log_err(PBSE_BAD_PARAMETER,__func__, "NULL input node_check_info pointer"); + return; + } + nci->state = pnode->nd_state; nci->ntype = pnode->nd_ntype; nci->nprops = pnode->nd_nprops; @@ -433,6 +471,22 @@ int chk_characteristic( char tmpLine[1024]; char log_buf[LOCAL_LOG_BUF_SIZE+1]; + if (pnode == NULL) + { + log_err(PBSE_BAD_PARAMETER, __func__, "NULL input pbsnode pointer"); + return(PBSE_BAD_PARAMETER); + } + if (nci == NULL) + { + log_err(PBSE_BAD_PARAMETER, __func__, "NULL input node_check_info pointer"); + return(PBSE_BAD_PARAMETER); + } + if (pneed_todo == NULL) + { + log_err(PBSE_BAD_PARAMETER, __func__, "NULL input mask pointer"); + return(PBSE_BAD_PARAMETER); + } + tmpLine[0] = '\0'; if (pnode->nd_state != nci->state) @@ -503,6 +557,22 @@ int login_encode_jobs( char str_buf[MAXLINE*2]; svrattrl *pal; + if (pnode == NULL) + { + log_err(PBSE_BAD_PARAMETER, __func__, "NULL input pbsnode pointer"); + return(PBSE_BAD_PARAMETER); + } + if (phead == NULL) + { + log_err(PBSE_BAD_PARAMETER, __func__, "NULL input tlist_head pointer"); + return(PBSE_BAD_PARAMETER); + } + if (job_str == NULL) + { + log_err(PBSE_BAD_PARAMETER, __func__, "job_str was not allocated"); + return(PBSE_BAD_PARAMETER); + } + for (psubn = pnode->nd_psn; psubn != NULL; psubn = psubn->next) { for (jip = psubn->jobs; jip != NULL; jip = jip->next) @@ -529,6 +599,12 @@ int login_encode_jobs( } } + if ((job_str->str) == NULL) + { + log_err(PBSE_BAD_PARAMETER, __func__, "job_str value was not initialized"); + return(PBSE_BAD_PARAMETER); + } + if ((pal = attrlist_create((char *)ATTR_NODE_jobs, (char *)NULL, strlen(job_str->str) + 1)) == NULL) { log_err(ENOMEM, __func__, ""); @@ -578,6 +654,26 @@ int status_nodeattrib( int nth; /*tracks list position (ordinal tacker) */ pbs_attribute atemp[ND_ATR_LAST]; /*temporary array of attributes */ + + if (padef == NULL) + { + rc = PBSE_BAD_PARAMETER; + log_err(rc, __func__, "input defined node attributes pointer is NULL"); + return(rc); + } + if (pnode == NULL) + { + rc = PBSE_BAD_PARAMETER; + log_err(rc, __func__, "input pbsnode pointer is NULL"); + return(rc); + } + if (bad == NULL) + { + rc = PBSE_BAD_PARAMETER; + log_err(rc, __func__, "input result mask pointer is NULL"); + return(rc); + } + memset(&atemp, 0, sizeof(atemp)); priv &= ATR_DFLAG_RDACC; /* user-client privilege */ @@ -585,7 +681,6 @@ int status_nodeattrib( for (i = 0;i < ND_ATR_LAST;i++) { /*set up attributes using data from node*/ - if (i == ND_ATR_state) atemp[i].at_val.at_short = pnode->nd_state; else if (i == ND_ATR_properties) @@ -620,19 +715,21 @@ int status_nodeattrib( atemp[i].at_val.at_long = pnode->nd_ngpus; } - else if (!strcmp((padef + i)->at_name, ATTR_NODE_mics)) + else if ((padef + i)->at_name != NULL) { - if (pnode->nd_nmics == 0) - continue; + if (!strcmp((padef + i)->at_name, ATTR_NODE_mics)) + { + if (pnode->nd_nmics == 0) + continue; - atemp[i].at_val.at_long = pnode->nd_nmics; + atemp[i].at_val.at_long = pnode->nd_nmics; + } + else if (!strcmp((padef + i)->at_name, ATTR_NODE_micstatus)) + atemp[i].at_val.at_arst = pnode->nd_micstatus; } - else if (!strcmp((padef + i)->at_name, ATTR_NODE_micstatus)) - atemp[i].at_val.at_arst = pnode->nd_micstatus; else { /*we don't ever expect this*/ - *bad = 0; return(PBSE_UNKNODEATR); @@ -700,7 +797,6 @@ int status_nodeattrib( else { /* non-specific request, return all readable attributes */ - for (index = 0; index < limit; index++) { if ((index == ND_ATR_jobs) && @@ -756,6 +852,12 @@ int initialize_pbsnode( int ntype) /* time-shared or cluster */ { + if (pnode == NULL) + { + log_err(PBSE_BAD_PARAMETER, __func__, "NULL pointer was passed for initialization"); + return(PBSE_BAD_PARAMETER); + } + memset(pnode, 0, sizeof(struct pbsnode)); pnode->nd_name = pname; @@ -811,6 +913,11 @@ static void subnode_delete( struct pbssubn *psubn) { + if (psubn == NULL) + { + log_err(PBSE_BAD_PARAMETER, __func__, "NULL subnode pointer delete call"); + return; + } struct jobinfo *jip, *jipt; @@ -833,7 +940,7 @@ static void subnode_delete( void effective_node_delete( - struct pbsnode *pnode) + struct pbsnode **ppnode) { @@ -841,6 +948,20 @@ void effective_node_delete( struct pbssubn *pnxt; u_long *up; + struct pbsnode* pnode = NULL; + + if (ppnode == NULL) + { + log_err(PBSE_BAD_PARAMETER, __func__, "NULL node pointer to pointer delete call"); + return; + } + + pnode = *ppnode; + if (pnode == NULL) + { + log_err(PBSE_BAD_PARAMETER, __func__, "NULL node pointer delete call"); + return; + } remove_node(&allnodes,pnode); unlock_node(pnode, __func__, NULL, LOGLEVEL); @@ -885,6 +1006,7 @@ void effective_node_delete( free(pnode->nd_name); free(pnode); + *ppnode = NULL; return; } /* END effective_node_delete() */ @@ -1337,6 +1459,12 @@ struct pbssubn *create_subnode( struct pbssubn *nxtsn = NULL; struct pbssubn *lastsn = NULL; + if (pnode == NULL) + { + log_err(PBSE_BAD_PARAMETER, __func__, "NULL pbsnode pointer input"); + return(NULL); + } + psubn = (struct pbssubn *)calloc(1, sizeof(struct pbssubn)); if (psubn == NULL) @@ -1378,7 +1506,16 @@ int create_a_gpusubnode( { int rc = PBSE_NONE; - struct gpusubn *tmp = (struct gpusubn *)calloc((1 + pnode->nd_ngpus), sizeof(struct gpusubn)); + struct gpusubn *tmp = NULL; + + if (pnode == NULL) + { + rc = PBSE_BAD_PARAMETER; + log_err(rc, __func__, "NULL pbsnode pointer input"); + return(rc); + } + + tmp = (struct gpusubn *)calloc((1 + pnode->nd_ngpus), sizeof(struct gpusubn)); if (tmp == NULL) { @@ -1438,6 +1575,17 @@ int copy_properties( struct array_strings *sub; struct array_strings *main_node; + if (dest == NULL) + { + log_err(PBSE_BAD_PARAMETER, __func__, "NULL destanation pointer input"); + return(PBSE_BAD_PARAMETER); + } + if (src == NULL) + { + log_err(PBSE_BAD_PARAMETER, __func__, "NULL source pointer input"); + return(PBSE_BAD_PARAMETER); + } + /* copy features/properties */ if (src->nd_prop == NULL) return(PBSE_NONE); @@ -1493,7 +1641,7 @@ int copy_properties( * number in val and advances the string to the next number past the comma */ -int read_val_and_advance( +static int read_val_and_advance( int *val, char **str) @@ -1503,7 +1651,7 @@ int read_val_and_advance( if ((*str == NULL) || (val == NULL)) - return(-1); + return(PBSE_BAD_PARAMETER); *val = atoi(*str); @@ -1525,7 +1673,7 @@ int read_val_and_advance( * * @return 0 on success, -1 on failure */ -int setup_node_boards( +static int setup_node_boards( struct pbsnode *pnode, u_long *pul) @@ -1545,7 +1693,11 @@ int setup_node_boards( char log_buf[LOCAL_LOG_BUF_SIZE]; if (pnode == NULL) - return(-1); + { + rc = PBSE_BAD_PARAMETER; + log_err(rc, __func__, "NULL input pbsnode poiner"); + return(rc); + } pnode->parent = NULL; @@ -1667,7 +1819,7 @@ int setup_node_boards( * periodically to see if the node is now resolvable and if so * add it to the list of available MOM nodes. */ -void recheck_for_node( +static void recheck_for_node( struct work_task *ptask) @@ -1862,7 +2014,7 @@ int create_pbs_node( if (rc != 0) { - effective_node_delete(pnode); + effective_node_delete(&pnode); return(rc); } @@ -2494,6 +2646,18 @@ int node_np_action( short old_np; short new_np; + if (new_attr == NULL) + { + log_err(PBSE_BAD_PARAMETER,__func__, "NULL input attributes"); + return(PBSE_BAD_PARAMETER); + } + + if (pobj == NULL) + { + log_err(PBSE_BAD_PARAMETER,__func__, "NULL input node"); + return(PBSE_BAD_PARAMETER); + } + switch (actmode) { @@ -2526,6 +2690,9 @@ int node_np_action( pnode->nd_nsn = old_np; break; + default: + log_err(-1,__func__, "unexpected action mode"); + return(-1); } return 0; @@ -2546,6 +2713,20 @@ int node_mom_port_action( struct pbsnode *pnode = (struct pbsnode *)pobj; int rc = 0; + if (new_attr == NULL) + { + rc = PBSE_BAD_PARAMETER; + log_err(rc,__func__, "NULL input attributes"); + return(rc); + } + + if (pobj == NULL) + { + rc = PBSE_BAD_PARAMETER; + log_err(rc,__func__, "NULL input node"); + return(rc); + } + switch (actmode) { @@ -2579,6 +2760,20 @@ int node_mom_rm_port_action( struct pbsnode *pnode = (struct pbsnode *)pobj; int rc = 0; + if (new_attr == NULL) + { + rc = PBSE_BAD_PARAMETER; + log_err(rc,__func__, "NULL input attributes"); + return(rc); + } + + if (pobj == NULL) + { + rc = PBSE_BAD_PARAMETER; + log_err(rc,__func__, "NULL input node"); + return(rc); + } + switch (actmode) { @@ -2612,6 +2807,20 @@ int node_gpus_action( int new_gp; int rc = 0; + if (new_attr == NULL) + { + rc = PBSE_BAD_PARAMETER; + log_err(rc,__func__, "NULL input attributes"); + return(rc); + } + + if (pnode == NULL) + { + rc = PBSE_BAD_PARAMETER; + log_err(rc,__func__, "NULL input node"); + return(rc); + } + switch (actmode) { case ATR_ACTION_NEW: @@ -2725,6 +2934,20 @@ int node_numa_action( struct pbsnode *np = (struct pbsnode *)pnode; int rc = 0; + if (new_attr == NULL) + { + rc = PBSE_BAD_PARAMETER; + log_err(rc,__func__, "NULL input attributes"); + return(rc); + } + + if (pnode == NULL) + { + rc = PBSE_BAD_PARAMETER; + log_err(rc,__func__, "NULL input node"); + return(rc); + } + switch (actmode) { case ATR_ACTION_NEW: @@ -2753,7 +2976,19 @@ int numa_str_action( { struct pbsnode *np = (struct pbsnode *)pnode; - int len; + int len = 0; + + if (new_attr == NULL) + { + log_err(PBSE_BAD_PARAMETER,__func__, "NULL input attributes"); + return(PBSE_BAD_PARAMETER); + } + + if (pnode == NULL) + { + log_err(PBSE_BAD_PARAMETER,__func__, "NULL input node"); + return(PBSE_BAD_PARAMETER); + } switch (actmode) { @@ -2811,6 +3046,18 @@ int gpu_str_action( struct pbsnode *np = (struct pbsnode *)pnode; int len; + if (new_attr == NULL) + { + log_err(PBSE_BAD_PARAMETER,__func__, "NULL input attributes"); + return(PBSE_BAD_PARAMETER); + } + + if (pnode == NULL) + { + log_err(PBSE_BAD_PARAMETER,__func__, "NULL input node"); + return(PBSE_BAD_PARAMETER); + } + switch (actmode) { case ATR_ACTION_NEW: @@ -2875,6 +3122,12 @@ int create_partial_pbs_node( u_long *pul = NULL; char *pname = NULL; + if (nodename == NULL) + { + log_err(PBSE_BAD_PARAMETER,__func__, "NULL input name"); + return(PBSE_BAD_PARAMETER); + } + pnode = (struct pbsnode *)calloc(1, sizeof(struct pbsnode)); if (pnode == NULL) @@ -2928,7 +3181,7 @@ int create_partial_pbs_node( if (rc != 0) { lock_node(pnode, __func__, NULL, LOGLEVEL); - effective_node_delete(pnode); + effective_node_delete(&pnode); return(rc); } @@ -2949,7 +3202,7 @@ int create_partial_pbs_node( /* * @return a pointer to an initialized node iterator */ -node_iterator *get_node_iterator() +static node_iterator *get_node_iterator() { node_iterator *iter = (node_iterator *)calloc(1, sizeof(node_iterator)); @@ -2986,7 +3239,7 @@ void reinitialize_node_iterator( -struct pbsnode *get_my_next_node_board( +static struct pbsnode *get_my_next_node_board( node_iterator *iter, struct pbsnode *pnode) @@ -3007,7 +3260,7 @@ struct pbsnode *get_my_next_node_board( -struct pbsnode *get_my_next_alps_node( +static struct pbsnode *get_my_next_alps_node( node_iterator *iter, struct pbsnode *pnode) @@ -3036,6 +3289,17 @@ struct pbsnode *next_node( struct pbsnode *next; struct pbsnode *tmp; + if (an == NULL) + { + log_err(PBSE_BAD_PARAMETER,__func__, "NULL input all_nodes pointer"); + return(NULL); + } + if (iter == NULL) + { + log_err(PBSE_BAD_PARAMETER,__func__, "NULL input iter pointer"); + return(NULL); + } + if (current == NULL) { pthread_mutex_lock(an->allnodes_mutex); @@ -3070,6 +3334,11 @@ struct pbsnode *next_node( { tmp = current->parent; unlock_node(current, __func__, "current == NULL && numa_index > 0", LOGLEVEL); + if (tmp == NULL) /* TODO: think about this check and apropriate return*/ + { + log_err(-1, __func__, "current->parent == NULL"); + return(NULL); + } lock_node(tmp, __func__, "tmp && numa_index > 0", LOGLEVEL); current = tmp; } @@ -3156,6 +3425,12 @@ void initialize_all_nodes_array( all_nodes *an) { + if (an == NULL) + { + log_err(PBSE_BAD_PARAMETER, __func__, "NULL input pointer"); + return; + } + an->ra = initialize_resizable_array(INITIAL_NODE_SIZE); an->ht = create_hash(INITIAL_HASH_SIZE); @@ -3179,7 +3454,20 @@ int insert_node( struct pbsnode *pnode) /* I */ { - int rc; + int rc = 0; + + if (an == NULL) + { + rc = PBSE_BAD_PARAMETER; + log_err(rc, __func__, "NULL input all_nodes pointer"); + return(rc); + } + if (pnode == NULL) + { + rc = PBSE_BAD_PARAMETER; + log_err(rc, __func__, "NULL input node pointer"); + return(rc); + } pthread_mutex_lock(an->allnodes_mutex); @@ -3216,7 +3504,20 @@ int remove_node( struct pbsnode *pnode) { - int rc = PBSE_NONE; + int rc = 0; + + if (an == NULL) + { + rc = PBSE_BAD_PARAMETER; + log_err(rc, __func__, "NULL input all_nodes pointer"); + return(rc); + } + if (pnode == NULL) + { + rc = PBSE_BAD_PARAMETER; + log_err(rc, __func__, "NULL input node pointer"); + return(rc); + } if (pthread_mutex_trylock(an->allnodes_mutex)) { @@ -3245,6 +3546,17 @@ struct pbsnode *next_host( struct pbsnode *pnode; char *name = NULL; + if (an == NULL) + { + log_err(PBSE_BAD_PARAMETER, __func__, "NULL input all_nodes pointer"); + return(NULL); + } + if (iter == NULL) + { + log_err(PBSE_BAD_PARAMETER, __func__, "NULL input iter pointer"); + return(NULL); + } + if (pthread_mutex_trylock(an->allnodes_mutex)) { if (held != NULL) @@ -3259,7 +3571,9 @@ struct pbsnode *next_host( if ((pnode != NULL) && ((pnode != held) && (name == NULL))) + { lock_node(pnode, __func__, NULL, LOGLEVEL); + } pthread_mutex_unlock(an->allnodes_mutex); @@ -3282,10 +3596,22 @@ void *send_hierarchy_threadtask( { hello_info *hi = (hello_info *)vp; - struct pbsnode *pnode = find_nodebyname(hi->name); + struct pbsnode *pnode = NULL; char log_buf[LOCAL_LOG_BUF_SIZE+1]; unsigned short port; + if (hi == NULL) + { + log_err(PBSE_BAD_PARAMETER, __func__, "NULL input pointer"); + return(NULL); + } + if (hi->name == NULL) + { + log_err(PBSE_BAD_PARAMETER, __func__, "NULL hello_info->name pointer"); + return(NULL); + } + pnode = find_nodebyname(hi->name); + if (pnode != NULL) { port = pnode->nd_mom_rm_port; @@ -3293,7 +3619,7 @@ void *send_hierarchy_threadtask( if (send_hierarchy(hi->name, port) != PBSE_NONE) { - if (hi->num_retries < 3) + if (hi->num_retries < 3) /*TODO: why 3? remove magic number*/ { hi->num_retries++; hi->last_retry = time(NULL); @@ -3406,7 +3732,10 @@ int send_hierarchy( close_conn(sock, FALSE); if (chan != NULL) + { + DIS_tcp_cleanup(chan); + } return(ret); } /* END send_hierarchy() */ @@ -3414,15 +3743,23 @@ int send_hierarchy( -void initialize_hello_container( +struct hello_container* initialize_hello_container( hello_container *hc) { - hc->ra = initialize_resizable_array(INITIAL_NODE_SIZE); + if (hc != NULL) + { + hc->ra = initialize_resizable_array(INITIAL_NODE_SIZE); - hc->hello_mutex = (pthread_mutex_t *)calloc(1, sizeof(pthread_mutex_t)); - pthread_mutex_init(hc->hello_mutex, NULL); + hc->hello_mutex = (pthread_mutex_t *)calloc(1, sizeof(pthread_mutex_t)); + pthread_mutex_init(hc->hello_mutex, NULL); + } + else + { + log_err(PBSE_BAD_PARAMETER, __func__, "NULL input container pointer was passed for initialization"); + } + return hc; } /* END initialize_hello_container() */ @@ -3480,9 +3817,16 @@ int add_hello_after( int index) { - hello_info *hi = (hello_info *)calloc(1, sizeof(hello_info)); - int rc; + hello_info *hi = NULL; + int rc = -1; + + if (hc == NULL) + { + log_err(PBSE_BAD_PARAMETER, __func__, "NULL input container pointer"); + return(PBSE_BAD_PARAMETER); + } + hi = (hello_info *)calloc(1, sizeof(hello_info)); hi->name = node_name; pthread_mutex_lock(hc->hello_mutex); @@ -3504,11 +3848,16 @@ int add_hello_after( int add_hello_info( - hello_container *hc, - hello_info *hi) + struct hello_container *hc, + struct hello_info *hi) { - int rc; + int rc = -1; + if (hc == NULL) + { + log_err(PBSE_BAD_PARAMETER, __func__, "NULL input container pointer"); + return(PBSE_BAD_PARAMETER); + } pthread_mutex_lock(hc->hello_mutex); if ((rc = insert_thing(hc->ra, hi)) == -1) @@ -3528,6 +3877,11 @@ hello_info *pop_hello( { hello_info *hi = NULL; int index; + if (hc == NULL) + { + log_err(PBSE_BAD_PARAMETER, __func__, "NULL input container pointer"); + return(NULL); + } pthread_mutex_lock(hc->hello_mutex); index = hc->ra->slots[ALWAYS_EMPTY_INDEX].next; @@ -3558,6 +3912,19 @@ int remove_hello( int prev_index = -1; hello_info *hi; + if (hc == NULL) + { + rc = PBSE_BAD_PARAMETER; + log_err(rc, __func__, "NULL input container pointer"); + return(rc); + } + if (node_name == NULL) + { + rc = PBSE_BAD_PARAMETER; + log_err(rc, __func__, "NULL input name pointer"); + return(rc); + } + pthread_mutex_lock(hc->hello_mutex); while ((hi = (hello_info *)next_thing(hc->ra, &iter)) != NULL) { diff --git a/src/server/node_func.h b/src/server/node_func.h index 72d0c76d29..82ee6e3e97 100644 --- a/src/server/node_func.h +++ b/src/server/node_func.h @@ -1,17 +1,24 @@ #ifndef _NODE_FUNC_H #define _NODE_FUNC_H #include "license_pbs.h" /* See here for the software license */ - -#include "server_limits.h" /* pbs_net_t. Also defined in net_connect.h */ -#include "pbs_nodes.h" /* pbs_nodes, node_check_info, node_iterator, all_nodes */ -#include "attribute.h" /* svrattrl, pbs_attribute */ #include "list_link.h" /* tlist_head */ -#include "work_task.h" /* work_task */ + +/* Forward declarations. */ +typedef unsigned long pbs_net_t; +struct pbsnode; +struct node_check_info; +struct node_iterator; +struct all_nodes; +struct svrattrl; +struct pbs_attribute; +struct attribute_def; +struct hello_info; +struct hello_container; typedef struct _node_info_ { char *nodename; - svrattrl *plist; + struct svrattrl *plist; int perms; tlist_head atrlist; } node_info; @@ -26,15 +33,15 @@ struct pbsnode *find_nodebyname(const char *nodename); struct pbssubn *find_subnodebyname(char *nodename); -void save_characteristic(struct pbsnode *pnode, node_check_info *nci); +void save_characteristic(struct pbsnode *pnode, struct node_check_info *nci); -int chk_characteristic(struct pbsnode *pnode, node_check_info *nci, int *pneed_todo); +int chk_characteristic(struct pbsnode *pnode, struct node_check_info *nci, int *pneed_todo); -int status_nodeattrib(svrattrl *pal, attribute_def *padef, struct pbsnode *pnode, int limit, int priv, tlist_head *phead, int *bad); +int status_nodeattrib(struct svrattrl *pal, struct attribute_def *padef, struct pbsnode *pnode, int limit, int priv, tlist_head *phead, int *bad); /* static void subnode_delete(struct pbssubn *psubn); */ -void effective_node_delete(struct pbsnode *pnode); +void effective_node_delete(struct pbsnode **pnode); /* static int process_host_name_part(char *objname, u_long **pul, char **pname, int *ntype); */ @@ -48,13 +55,13 @@ int create_a_gpusubnode(struct pbsnode *pnode); int copy_properties(struct pbsnode *dest, struct pbsnode *src); -int read_val_and_advance(int *val, char **str); +/*static int read_val_and_advance(int *val, char **str);*/ -int setup_node_boards(struct pbsnode *pnode, u_long *pul); +/*static int setup_node_boards(struct pbsnode *pnode, u_long *pul);*/ -void recheck_for_node(struct work_task *ptask); +/*static void recheck_for_node(struct work_task *ptask);*/ -int create_pbs_node(char *objname, svrattrl *plist, int perms, int *bad); +int create_pbs_node(char *objname, struct svrattrl *plist, int perms, int *bad); /* static char *parse_node_token(char *start, int cok, int comma, int *err, char *term); */ @@ -64,36 +71,54 @@ int setup_nodes(void); /* static void delete_a_gpusubnode(struct pbsnode *pnode); */ -int node_np_action(pbs_attribute *new_attr, void *pobj, int actmode); +int node_np_action(struct pbs_attribute *new_, void *pobj, int actmode); /*TODO: this functions need clarification & refactoring*/ -int node_mom_port_action(pbs_attribute *new_attr, void *pobj, int actmode); +int node_mom_port_action(struct pbs_attribute *new_, void *pobj, int actmode); /*TODO: this functions need clarification & refactoring*/ -int node_mom_rm_port_action(pbs_attribute *new_attr, void *pobj, int actmode); +int node_mom_rm_port_action(struct pbs_attribute *new_, void *pobj, int actmode); /*TODO: this functions need clarification & refactoring*/ -int node_gpus_action(pbs_attribute *new_attr, void *pnode, int actmode); +int node_gpus_action(struct pbs_attribute *new_, void *pnode, int actmode); /*TODO: this functions need clarification & refactoring*/ -int node_numa_action(pbs_attribute *new_attr, void *pnode, int actmode); +int node_numa_action(struct pbs_attribute *new_, void *pnode, int actmode); /*TODO: this functions need clarification & refactoring*/ -int numa_str_action(pbs_attribute *new_attr, void *pnode, int actmode); +int numa_str_action(struct pbs_attribute *new_, void *pnode, int actmode); /*TODO: this functions need clarification & refactoring*/ -int gpu_str_action(pbs_attribute *new_attr, void *pnode, int actmode); +int gpu_str_action(struct pbs_attribute *new_, void *pnode, int actmode); /*TODO: this functions need clarification & refactoring*/ int create_partial_pbs_node(char *nodename, unsigned long addr, int perms); -node_iterator *get_node_iterator(); +/*static node_iterator *get_node_iterator();*/ + +void reinitialize_node_iterator(struct node_iterator *iter); + +/*static struct pbsnode *get_my_next_node_board(node_iterator *iter, struct pbsnode *np);*/ + +struct pbsnode *next_node(struct all_nodes *an, struct pbsnode *current, struct node_iterator *iter); + +void initialize_all_nodes_array(struct all_nodes *an); + +int insert_node(struct all_nodes *an, struct pbsnode *pnode); + +int remove_node(struct all_nodes *an, struct pbsnode *pnode); + +struct pbsnode *next_host(struct all_nodes *an, int *iter, struct pbsnode *held); + +void *send_hierarchy_threadtask(void *vp); + +int send_hierarchy(char *name, unsigned short port); -void reinitialize_node_iterator(node_iterator *iter); +struct hello_container* initialize_hello_container(struct hello_container *); -struct pbsnode *get_my_next_node_board(node_iterator *iter, struct pbsnode *np); +int needs_hello(struct hello_container *hc, char *node_name); -struct pbsnode *next_node(all_nodes *an, struct pbsnode *current, node_iterator *iter); +int add_hello(struct hello_container *hc, char *node_name); -void initialize_all_nodes_array(all_nodes *an); +int add_hello_after(struct hello_container *hc, char *node_name, int index); -int insert_node(all_nodes *an, struct pbsnode *pnode); +int add_hello_info(struct hello_container *hc, struct hello_info *hi); -int remove_node(all_nodes *an, struct pbsnode *pnode); +struct hello_info *pop_hello(struct hello_container *hc); -struct pbsnode *next_host(all_nodes *an, int *iter, struct pbsnode *held); +int remove_hello(struct hello_container *hc, char *node_name); #endif /* _NODE_FUNC_H */ diff --git a/src/server/test/node_func/scaffolding.c b/src/server/test/node_func/scaffolding.c index 84814f0f6a..04b89e4055 100644 --- a/src/server/test/node_func/scaffolding.c +++ b/src/server/test/node_func/scaffolding.c @@ -52,20 +52,20 @@ extern int cray_enabled; int insert_thing(resizable_array *ra, void *thing) { - fprintf(stderr, "The call to insert_thing needs to be mocked!!\n"); - exit(1); + fprintf(stderr, "This mock insert_thing always returns 0!!\n"); + return(0); } svrattrl *attrlist_create(const char *aname, const char *rname, int vsize) { - fprintf(stderr, "The call to attrlist_create needs to be mocked!!\n"); - exit(1); + fprintf(stderr, "This mock attrlist_create always returns NULL!!\n"); + return(NULL); } int remove_thing(resizable_array *ra, void *thing) { - fprintf(stderr, "The call to remove_thing needs to be mocked!!\n"); - exit(1); + fprintf(stderr, "This mock remove_thing always returns 0!!\n"); + return(0); } AvlTree AVL_delete_node(u_long key, uint16_t port, AvlTree tree) @@ -76,32 +76,37 @@ AvlTree AVL_delete_node(u_long key, uint16_t port, AvlTree tree) int add_hash(hash_table_t *ht, int value, void *key) { - fprintf(stderr, "The call to add_hash needs to be mocked!!\n"); - exit(1); + fprintf(stderr, "This mock add_hash always returns 0!!\n"); + return(0); } struct work_task *set_task(enum work_type type, long event_id, void (*func)(), void *parm, int get_lock) { - fprintf(stderr, "The call to set_task needs to be mocked!!\n"); - exit(1); + fprintf(stderr, "This mock set_task always returns NULL!!\n"); + return(NULL); } int find_attr(struct attribute_def *attr_def, const char *name, int limit) { - fprintf(stderr, "The call to find_attr needs to be mocked!!\n"); - exit(1); + fprintf(stderr, "This mock find_attr always returns 0!!\n"); + return(0); } int mgr_set_node_attr(struct pbsnode *pnode, attribute_def *pdef, int limit, svrattrl *plist, int privil, int *bad, void *parent, int mode) { - fprintf(stderr, "The call to mgr_set_node_attr needs to be mocked!!\n"); - exit(1); + fprintf(stderr, "This mock mgr_set_node_attr always returns 0!!\n"); + return(0); } void free_prop_list(struct prop *prop) { - fprintf(stderr, "The call to free_prop_list needs to be mocked!!\n"); - exit(1); + struct prop *pp; + while (prop) + { + pp = prop->next; + free(prop); + prop = pp; + } } int get_value_hash(hash_table_t *ht, void *key) @@ -120,14 +125,24 @@ int get_value_hash(hash_table_t *ht, void *key) void *get_next(list_link pl, char *file, int line) { - fprintf(stderr, "The call to get_next needs to be mocked!!\n"); - exit(1); + fprintf(stderr, "This mock get_next always returns NULL!!\n"); + return(NULL); } resizable_array *initialize_resizable_array(int size) { - fprintf(stderr, "The call to initialize_resizable_array needs to be mocked!!\n"); - exit(1); + size = 10; + resizable_array *ra = calloc(1, sizeof(resizable_array)); + size_t amount = sizeof(slot) * size; + + ra->max = size; + ra->num = 0; + ra->next_slot = 1; + ra->last = 0; + + ra->slots = calloc(1, amount); + + return(ra); } struct pbsnode *AVL_find(u_long key, uint16_t port, AvlTree tree) @@ -153,8 +168,7 @@ void free_attrlist(tlist_head *pattrlisthead) void *next_thing(resizable_array *ra, int *iter) { - fprintf(stderr, "The call to next_thing needs to be mocked!!\n"); - exit(1); + return(NULL); } void append_link(tlist_head *head, list_link *new_link, void *pobj) @@ -165,8 +179,14 @@ void append_link(tlist_head *head, list_link *new_link, void *pobj) hash_table_t *create_hash(int size) { - fprintf(stderr, "The call to create_hash needs to be mocked!!\n"); - exit(1); + hash_table_t *ht = calloc(1, sizeof(hash_table_t)); + size_t amount = sizeof(bucket *) * size; + + ht->size = size; + ht->num = 0; + ht->buckets = calloc(1, amount); + + return(ht); } char *pbs_strerror(int err) @@ -177,13 +197,13 @@ char *pbs_strerror(int err) AvlTree AVL_insert(u_long key, uint16_t port, struct pbsnode *node, AvlTree tree) { - fprintf(stderr, "The call to AVL_insert needs to be mocked!!\n"); - exit(1); + fprintf(stderr, "This mock AVL_insert is always returns 0!!\n"); + return(NULL); } int unlock_node(struct pbsnode *the_node, const char *id, char *msg, int logging) { - return(0); + return(0); } int lock_node(struct pbsnode *the_node, const char *id, char *msg, int logging) @@ -204,10 +224,10 @@ int is_present(resizable_array *ra, void *thing) } -void DIS_tcp_setup(int sock) +struct tcp_chan* DIS_tcp_setup(int sock) { - fprintf(stderr, "The call to DIS_tcp_setup needs to be mocked!!\n"); - exit(1); + fprintf(stderr, "This mock DIS_tcp_setup always returns NULL!!\n"); + return(NULL); } @@ -228,8 +248,8 @@ int diswcs (int stream, const char *value, int len) int tcp_connect_sockaddr(struct sockaddr *sa, size_t s) { - fprintf(stderr, "The call to tcp_connect_sockaddr needs to be mocked!!\n"); - exit(1); + fprintf(stderr, "This mock tcp_connect_sockaddr always returns 0!!\n"); + return(0); } int diswsi(int sock, int value) @@ -262,14 +282,14 @@ int get_svr_attr_str(int index, char **str) int remove_thing_from_index(resizable_array *ra, int index) { - fprintf(stderr, "The call to remove_thing_from_index needs to be mocked!!\n"); - exit(1); + fprintf(stderr, "This mock remove_thing_from_index always returns 0!!\n"); + return(0); } int insert_thing_after(resizable_array *ra, void *thing, int index) { - fprintf(stderr, "The call to insert_thing_after needs to be mocked!!\n"); - exit(1); + fprintf(stderr, "This mock insert_thing_after always returns 0!!\n"); + return(0); } int get_addr_info(char *name, struct sockaddr_in *sa_info, int retry) @@ -308,15 +328,43 @@ int append_dynamic_string( return(0); } -dynamic_string *get_dynamic_string( +dynamic_string *get_dynamic_string(int initial_size, const char *str) + { + dynamic_string *ds = calloc(1, sizeof(dynamic_string)); - int size, - const char *str) + if (ds == NULL) + return(ds); - { - return(NULL); + if (initial_size > 0) + ds->size = initial_size; + else + ds->size = DS_INITIAL_SIZE; + + ds->str = calloc(1, ds->size); + + if (ds->str == NULL) + { + free(ds); + return(NULL); + } + + /* initialize empty str */ + ds->used = 0; + + /* add the string if it exists */ + if (str != NULL) + { + if (append_dynamic_string(ds,str) != PBSE_NONE) + { + free_dynamic_string(ds); + return(NULL); + } + } + + return(ds); } + int login_node_count() { @@ -359,3 +407,15 @@ int unlock_ji_mutex(job *pjob, const char *id, const char *msg, int logging) const char *alps_reporter_feature = "alps_reporter"; const char *alps_starter_feature = "alps_starter"; + +void log_event(int eventtype, int objclass, const char *objname, char *text) + { + return; + } + +void log_err(int errnum, const char *routine, char *text) {} + +void log_record(int eventtype, int objclass, const char *objname, char *text) + { + return; + } diff --git a/src/server/test/node_func/test_node_func.c b/src/server/test/node_func/test_node_func.c index 56989b5369..814ab82b89 100644 --- a/src/server/test/node_func/test_node_func.c +++ b/src/server/test/node_func/test_node_func.c @@ -1,30 +1,122 @@ #include "license_pbs.h" /* See here for the software license */ -#include -#include -#include - -#include "test_node_func.h" #include "node_func.h" +#include "test_node_func.h" #include "pbs_error.h" -#include "resizable_array.h" - +#include +#include +#include "pbs_nodes.h" /* pbs_nodes, node_check_info, node_iterator, all_nodes */ +#include "attribute.h" /* svrattrl, struct */ -struct pbsnode *find_nodebyname(const char *nodeid); int cray_enabled; - void initialize_allnodes(all_nodes *an, struct pbsnode *n1, struct pbsnode *n2) { an->allnodes_mutex = calloc(1, sizeof(pthread_mutex_t)); an->ra = calloc(1, sizeof(resizable_array)); an->ra->slots = calloc(3, sizeof(slot)); - + an->ra->slots[0].item = NULL; an->ra->slots[1].item = n1; an->ra->slots[2].item = n2; } +START_TEST(PGetNodeFromAddr_test) + { + pbs_net_t address = 0; + //alloc mutex, use, restore + pthread_mutex_t *mutex = allnodes.allnodes_mutex; + allnodes.allnodes_mutex = (pthread_mutex_t *)calloc(1, sizeof(pthread_mutex_t)); + pthread_mutex_init(allnodes.allnodes_mutex, NULL); + + struct pbsnode *result = PGetNodeFromAddr(address); + + free((void*)allnodes.allnodes_mutex); + allnodes.allnodes_mutex = mutex; + + fail_unless(result == NULL, "null address input fail"); + } +END_TEST + +START_TEST(bad_node_warning_test) + { + pbs_net_t address = 0; + struct pbsnode node; + initialize_pbsnode(&node, NULL, NULL, 0); + + //alloc mutex, use, restore + pthread_mutex_t *mutex = allnodes.allnodes_mutex; + allnodes.allnodes_mutex = (pthread_mutex_t *)calloc(1, sizeof(pthread_mutex_t)); + pthread_mutex_init(allnodes.allnodes_mutex, NULL); + + bad_node_warning(address, NULL); + bad_node_warning(address, &node); + + //free((void*)allnodes.allnodes_mutex); + allnodes.allnodes_mutex = mutex; + } +END_TEST + +START_TEST(addr_ok_test) + { + pbs_net_t address = 0; + struct pbsnode node; + initialize_pbsnode(&node, NULL, NULL, 0); + + //alloc mutex, use, restore + pthread_mutex_t *mutex = allnodes.allnodes_mutex; + allnodes.allnodes_mutex = (pthread_mutex_t *)calloc(1, sizeof(pthread_mutex_t)); + pthread_mutex_init(allnodes.allnodes_mutex, NULL); + + int result = addr_ok(address, NULL); + fail_unless(result == 1, "NULL node input fail: %d", result); + + result = addr_ok(address, &node); + fail_unless(result == 1, "empty node input fail: %d", result); + + free((void*)allnodes.allnodes_mutex); + allnodes.allnodes_mutex = mutex; + } +END_TEST +START_TEST(initialize_all_nodes_array_test) + { + struct all_nodes allnodes; + memset(&allnodes, 0, sizeof(allnodes)); + initialize_all_nodes_array(&allnodes); + fail_unless(allnodes.ra != NULL, "all_nodes resizable_array was not initialized"); + fail_unless(allnodes.ht != NULL, "all_nodes hash_table_t was not initialized"); + fail_unless(allnodes.allnodes_mutex != NULL, "all_nodes pthread_mutex_t was not initialized"); + } +END_TEST + +START_TEST(find_node_in_allnodes_test) + { + struct pbsnode *result = NULL; + struct all_nodes allnodes; + struct pbsnode test_node; + char *test_node_name = "test_node"; + test_node.nd_name = test_node_name; + + initialize_pbsnode(&test_node, NULL, NULL, 0); + memset(&allnodes, 0, sizeof(allnodes)); + initialize_all_nodes_array(&allnodes); + + result = find_node_in_allnodes(NULL, "nodename"); + fail_unless(result == NULL, "NULL input all_nodes struct pointer fail"); + + result = find_node_in_allnodes(&allnodes, NULL); + fail_unless(result == NULL, "NULL input nodename fail"); + + result = find_node_in_allnodes(&allnodes, "nodename"); + fail_unless(result == NULL, "find unexpected node fail"); + +/* TODO: think about apropriate mocking for the test below + insert_node(&allnodes, &test_node); + result = find_node_in_allnodes(&allnodes, "test_node"); + fail_unless(result == &test_node, "find node fail"); +*/ + } +END_TEST START_TEST(find_nodebyname_test) { @@ -45,6 +137,9 @@ START_TEST(find_nodebyname_test) cray_enabled = FALSE; + pnode = find_nodebyname(NULL); + fail_unless(pnode == NULL, "NULL nodename input fail"); + pnode = find_nodebyname("george"); fail_unless(pnode == NULL, "george found but doesn't exist"); @@ -73,7 +168,7 @@ START_TEST(find_nodebyname_test) pnode = find_nodebyname("tom"); fail_unless(pnode == &node2, "couldn't find tom?"); - + cray_enabled = TRUE; pnode = find_nodebyname("bob"); @@ -83,32 +178,865 @@ START_TEST(find_nodebyname_test) pnode = find_nodebyname("george"); fail_unless(pnode == NULL, "george found but doesn't exist"); - + + } +END_TEST + +START_TEST(save_characteristic_test) + { + struct pbsnode node; + struct node_check_info node_info; + initialize_pbsnode(&node, NULL, NULL, 0); + memset(&node_info, 0, sizeof(node_info)); + save_characteristic(NULL, &node_info); + save_characteristic(&node, NULL); + save_characteristic(&node, &node_info); + } +END_TEST + +START_TEST(chk_characteristic_test) + { + struct pbsnode node; + struct node_check_info node_info; + initialize_pbsnode(&node, NULL, NULL, 0); + memset(&node_info, 0, sizeof(node_info)); + int result = 0; + int mask = 0; + + result = chk_characteristic(NULL, &node_info, &mask); + fail_unless(result != PBSE_NONE, "NULL input node pointer fail"); + + result = chk_characteristic(&node, NULL, &mask); + fail_unless(result != PBSE_NONE, "NULL input node info pointer fail"); + + result = chk_characteristic(&node, &node_info, NULL); + fail_unless(result != PBSE_NONE, "NULL input mask pointer fail"); + + result = chk_characteristic(&node, &node_info, &mask); + fail_unless(result == PBSE_NONE, "chk_characteristic fail"); + } +END_TEST + +START_TEST(login_encode_jobs_test) + { + struct pbsnode node; + struct list_link list; + initialize_pbsnode(&node, NULL, NULL, 0); + memset(&list, 0, sizeof(list)); + + int result = login_encode_jobs(NULL, &list); + fail_unless(result != PBSE_NONE, "NULL input node pointer fail"); + + result = login_encode_jobs(&node, NULL); + fail_unless(result != PBSE_NONE, "NULL input list_link pointer fail"); + + result = login_encode_jobs(&node, &list); + fail_unless(result != PBSE_NONE, "login_encode_jobs_test fail"); + } +END_TEST + +START_TEST(status_nodeattrib_test) + { + struct svrattrl attributes; + struct attribute_def node_attributes; + struct pbsnode node; + struct list_link list; + int result_mask = 0; + int result = 0; + memset(&attributes, 0, sizeof(attributes)); + memset(&node_attributes, 0, sizeof(node_attributes)); + initialize_pbsnode(&node, NULL, NULL, 0); + memset(&list, 0, sizeof(list)); + + + result = status_nodeattrib(&attributes, + NULL, + &node, + 0, + 0, + &list, + &result_mask); + fail_unless(result != PBSE_NONE, "NULL input attribute_def pointer fail: %d" ,result); + + result = status_nodeattrib(&attributes, + &node_attributes, + NULL, + 0, + 0, + &list, + &result_mask); + fail_unless(result != PBSE_NONE, "NULL input pbsnode pointer fail: %d" ,result); + + result = status_nodeattrib(&attributes, + &node_attributes, + &node, + 0, + 0, + NULL, + &result_mask); + fail_unless(result != PBSE_NONE, "NULL input tlist_head pointer fail: %d" ,result); + + result = status_nodeattrib(&attributes, + &node_attributes, + &node, + 0, + 0, + &list, + NULL); + fail_unless(result != PBSE_NONE, "NULL input result_mask pointer fail: %d" ,result); + + result = status_nodeattrib(NULL, + &node_attributes, + &node, + 0, + 0, + &list, + &result_mask); + /*FIXME: NOTE: this is probably a correct set of input parameters, but still returns -1*/ + // fail_unless(result != PBSE_NONE, "NULL input svrattrl pointer fail: %d" ,result); + + result = status_nodeattrib(&attributes, + &node_attributes, + &node, + 0, + 0, + &list, + &result_mask); + /*FIXME: NOTE: this is probably a correct set of input parameters, but still returns -1*/ + fail_unless(result != PBSE_NONE, "status_nodeattrib fail: %d" ,result); + } +END_TEST + +START_TEST(initialize_pbsnode_test) + { + struct pbsnode node; + int result = -1; + + result = initialize_pbsnode(NULL, NULL, NULL, 0); + fail_unless(result != PBSE_NONE, "NULL input node pointer fail"); + + result = initialize_pbsnode(&node, NULL, NULL, 0); + fail_unless(result == PBSE_NONE, "initialization fail"); + } +END_TEST + +START_TEST(effective_node_delete_test) + { + struct pbsnode *node = NULL; + + initialize_all_nodes_array(&allnodes); + //alloc mutex, use, restore + pthread_mutex_t *mutex = allnodes.allnodes_mutex; + allnodes.allnodes_mutex = (pthread_mutex_t *)calloc(1, sizeof(pthread_mutex_t)); + pthread_mutex_init(allnodes.allnodes_mutex, NULL); + + /*accidental null pointer delete call*/ + effective_node_delete(NULL); + effective_node_delete(&node); + + //pthread_mutex_init(allnodes.allnodes_mutex, NULL); + node = (struct pbsnode *)malloc(sizeof(struct pbsnode)); + initialize_pbsnode(node, NULL, NULL, 0); + effective_node_delete(&node); + + fail_unless(node == NULL, "unsuccessfull node delition %d", node); + + free((void*)allnodes.allnodes_mutex); + allnodes.allnodes_mutex = mutex; + } +END_TEST + +START_TEST(update_nodes_file_test) + { + int result = -1; + struct pbsnode node; + initialize_pbsnode(&node, NULL, NULL, 0); + + result = update_nodes_file(NULL); + fail_unless(result != PBSE_NONE, "update_nodes_file_test NULL input fail"); + + result = update_nodes_file(&node); + fail_unless(result != PBSE_NONE, "update_nodes_file_test empty node fail"); + } +END_TEST + +START_TEST(recompute_ntype_cnts_test) + { + recompute_ntype_cnts(); + } +END_TEST + +START_TEST(init_prop_test) + { + char name[] = "node_name"; + struct prop * result = init_prop(NULL); + fail_unless(result->name == NULL, "NULL name init fail"); + + result = init_prop(name); + fail_unless(result->name == name, "name init fail"); + } +END_TEST + +START_TEST(create_subnode_test) + { + struct pbsnode node; + struct pbssubn *result = NULL; + initialize_pbsnode(&node, NULL, NULL, 0); + + result = create_subnode(NULL); + fail_unless(result == NULL, "NULL node pointer input fail"); + + result = create_subnode(&node); + fail_unless(result->host == &node, "create_subnode_test fail"); + } +END_TEST + +START_TEST(create_a_gpusubnode_test) + { + int result = -1; + struct pbsnode node; + initialize_pbsnode(&node, NULL, NULL, 0); + + result = create_a_gpusubnode(NULL); + fail_unless(result != PBSE_NONE, "NULL node pointer input fail"); + + result = create_a_gpusubnode(&node); + fail_unless(result == PBSE_NONE, "create_a_gpusubnode fail"); + } +END_TEST + +START_TEST(copy_properties_test) + { + int result = -1; + struct pbsnode source_node; + struct pbsnode destanation_node; + initialize_pbsnode(&source_node, NULL, NULL, 0); + initialize_pbsnode(&destanation_node, NULL, NULL, 0); + + result = copy_properties(NULL, &source_node); + fail_unless(result != PBSE_NONE, "NULL destanation pointer input fail"); + + result = copy_properties(&destanation_node, NULL); + fail_unless(result != PBSE_NONE, "NULL source pointer input fail"); + + /*TODO: fill in source node*/ + result = copy_properties(&destanation_node, &source_node); + fail_unless(result == PBSE_NONE, "copy_properties return fail"); + } +END_TEST + +START_TEST(create_pbs_node_test) + { + int result = -1; + char name[] = "name"; + char value[] = "value"; + int mask = 0; + struct svrattrl attributes; + memset(&attributes, 0, sizeof(attributes)); + attributes.al_atopl.value = value; + + result = create_pbs_node(NULL, &attributes, 0, &mask); + fail_unless(result != PBSE_NONE, "NULL input name fail"); + + result = create_pbs_node(name, NULL, 0, &mask); + fail_unless(result != PBSE_NONE, "NULL input attributes fail"); + + result = create_pbs_node(name, &attributes, 0, NULL); + fail_unless(result != PBSE_NONE, "NULL input mask fail"); + + /*TODO: mock properly in order to success*/ + result = create_pbs_node(name, &attributes, 0, &mask); + fail_unless(result != PBSE_NONE, "create_pbs_node fail"); + } +END_TEST + +START_TEST(setup_nodes_test) + { + int result = -1; + + result = setup_nodes(); + fail_unless(result == PBSE_NONE, "setup_nodes fail"); + } +END_TEST + +START_TEST(node_np_action_test) + { + int result = -1; + struct pbsnode node; + struct pbs_attribute attributes; + + initialize_pbsnode(&node, NULL, NULL, 0); + memset(&attributes, 0, sizeof(attributes)); + + result = node_np_action(NULL, (void*)(&node), ATR_ACTION_NEW); + fail_unless(result != PBSE_NONE, "NULL input attributes fail"); + + result = node_np_action(&attributes, NULL, ATR_ACTION_NEW); + fail_unless(result != PBSE_NONE, "NULL input node fail"); + + result = node_np_action(&attributes, (void*)(&node), 0); + fail_unless(result != PBSE_NONE, "node_np_action fail"); + + result = node_np_action(&attributes, (void*)(&node), ATR_ACTION_NEW); + fail_unless(result == PBSE_NONE, "ATR_ACTION_NEW fail"); + + result = node_np_action(&attributes, (void*)(&node), ATR_ACTION_ALTER); + fail_unless(result == PBSE_BADATVAL, "ATR_ACTION_ALTER fail"); + } +END_TEST + +START_TEST(node_mom_port_action_test) + { + int result = -1; + struct pbsnode node; + struct pbs_attribute attributes; + + initialize_pbsnode(&node, NULL, NULL, 0); + memset(&attributes, 0, sizeof(attributes)); + + result = node_mom_port_action(NULL, (void*)(&node), ATR_ACTION_NEW); + fail_unless(result != PBSE_NONE, "NULL input attributes fail"); + + result = node_mom_port_action(&attributes, NULL, ATR_ACTION_NEW); + fail_unless(result != PBSE_NONE, "NULL input node fail"); + + result = node_mom_port_action(&attributes, (void*)(&node), 0); + fail_unless(result == PBSE_INTERNAL, "node_np_action fail"); + + result = node_mom_port_action(&attributes, (void*)(&node), ATR_ACTION_NEW); + fail_unless(result == PBSE_NONE, "ATR_ACTION_NEW fail"); + + result = node_mom_port_action(&attributes, (void*)(&node), ATR_ACTION_ALTER); + fail_unless(result == PBSE_NONE, "ATR_ACTION_ALTER fail"); + } +END_TEST + +START_TEST(node_mom_rm_port_action_test) + { + int result = -1; + struct pbsnode node; + struct pbs_attribute attributes; + + initialize_pbsnode(&node, NULL, NULL, 0); + memset(&attributes, 0, sizeof(attributes)); + + result = node_mom_rm_port_action(NULL, (void*)(&node), ATR_ACTION_NEW); + fail_unless(result != PBSE_NONE, "NULL input attributes fail"); + + result = node_mom_rm_port_action(&attributes, NULL, ATR_ACTION_NEW); + fail_unless(result != PBSE_NONE, "NULL input node fail"); + + result = node_mom_rm_port_action(&attributes, (void*)(&node), 0); + fail_unless(result == PBSE_INTERNAL, "node_np_action fail"); + + result = node_mom_rm_port_action(&attributes, (void*)(&node), ATR_ACTION_NEW); + fail_unless(result == PBSE_NONE, "ATR_ACTION_NEW fail"); + + result = node_mom_rm_port_action(&attributes, (void*)(&node), ATR_ACTION_ALTER); + fail_unless(result == PBSE_NONE, "ATR_ACTION_ALTER fail"); + } +END_TEST + +START_TEST(node_gpus_action_test) + { + int result = -1; + struct pbsnode node; + struct pbs_attribute attributes; + + initialize_pbsnode(&node, NULL, NULL, 0); + memset(&attributes, 0, sizeof(attributes)); + + result = node_gpus_action(NULL, (void*)(&node), ATR_ACTION_NEW); + fail_unless(result != PBSE_NONE, "NULL input attributes fail"); + + result = node_gpus_action(&attributes, NULL, ATR_ACTION_NEW); + fail_unless(result != PBSE_NONE, "NULL input node fail"); + + result = node_gpus_action(&attributes, (void*)(&node), 0); + fail_unless(result == PBSE_INTERNAL, "node_np_action fail"); + + result = node_gpus_action(&attributes, (void*)(&node), ATR_ACTION_NEW); + fail_unless(result == PBSE_NONE, "ATR_ACTION_NEW fail"); + + result = node_gpus_action(&attributes, (void*)(&node), ATR_ACTION_ALTER); + fail_unless(result == PBSE_BADATVAL, "ATR_ACTION_ALTER fail"); + } +END_TEST + +START_TEST(node_numa_action_test) + { + int result = -1; + struct pbsnode node; + struct pbs_attribute attributes; + + initialize_pbsnode(&node, NULL, NULL, 0); + memset(&attributes, 0, sizeof(attributes)); + + result = node_numa_action(NULL, (void*)(&node), ATR_ACTION_NEW); + fail_unless(result != PBSE_NONE, "NULL input attributes fail"); + + result = node_numa_action(&attributes, NULL, ATR_ACTION_NEW); + fail_unless(result != PBSE_NONE, "NULL input node fail"); + + result = node_numa_action(&attributes, (void*)(&node), 0); + fail_unless(result == PBSE_INTERNAL, "node_np_action fail"); + + result = node_numa_action(&attributes, (void*)(&node), ATR_ACTION_NEW); + fail_unless(result == PBSE_NONE, "ATR_ACTION_NEW fail"); + + result = node_numa_action(&attributes, (void*)(&node), ATR_ACTION_ALTER); + fail_unless(result == PBSE_NONE, "ATR_ACTION_ALTER fail"); + } +END_TEST + +START_TEST(numa_str_action_test) + { + int result = -1; + struct pbsnode node; + struct pbs_attribute attributes; + + initialize_pbsnode(&node, NULL, NULL, 0); + memset(&attributes, 0, sizeof(attributes)); + + result = numa_str_action(NULL, (void*)(&node), ATR_ACTION_NEW); + fail_unless(result != PBSE_NONE, "NULL input attributes fail"); + + result = numa_str_action(&attributes, NULL, ATR_ACTION_NEW); + fail_unless(result != PBSE_NONE, "NULL input node fail"); + + result = numa_str_action(&attributes, (void*)(&node), 0); + fail_unless(result == PBSE_INTERNAL, "node_np_action fail"); + + result = numa_str_action(&attributes, (void*)(&node), ATR_ACTION_NEW); + fail_unless(result == PBSE_NONE, "ATR_ACTION_NEW fail"); + + result = numa_str_action(&attributes, (void*)(&node), ATR_ACTION_ALTER); + fail_unless(result == PBSE_NONE, "ATR_ACTION_ALTER fail"); + } +END_TEST + +START_TEST(gpu_str_action_test) + { + int result = -1; + struct pbsnode node; + struct pbs_attribute attributes; + + initialize_pbsnode(&node, NULL, NULL, 0); + memset(&attributes, 0, sizeof(attributes)); + + result = gpu_str_action(NULL, (void*)(&node), ATR_ACTION_NEW); + fail_unless(result != PBSE_NONE, "NULL input attributes fail"); + + result = gpu_str_action(&attributes, NULL, ATR_ACTION_NEW); + fail_unless(result != PBSE_NONE, "NULL input node fail"); + + result = gpu_str_action(&attributes, (void*)(&node), 0); + fail_unless(result == PBSE_INTERNAL, "node_np_action fail"); + + result = gpu_str_action(&attributes, (void*)(&node), ATR_ACTION_NEW); + fail_unless(result == PBSE_NONE, "ATR_ACTION_NEW fail"); + + result = gpu_str_action(&attributes, (void*)(&node), ATR_ACTION_ALTER); + fail_unless(result == PBSE_NONE, "ATR_ACTION_ALTER fail"); + } +END_TEST + +START_TEST(create_partial_pbs_node_test) + { + int result = -1; + char name[] = "name"; + initialize_all_nodes_array(&allnodes); + //alloc mutex, use, restore + pthread_mutex_t *mutex = allnodes.allnodes_mutex; + allnodes.allnodes_mutex = (pthread_mutex_t *)calloc(1, sizeof(pthread_mutex_t)); + pthread_mutex_init(allnodes.allnodes_mutex, NULL); + + result = create_partial_pbs_node(NULL, 0, 0); + fail_unless(result != PBSE_NONE, "NULL input name fail"); + + result = create_partial_pbs_node(name, 0, 0); + fail_unless(result == PBSE_NONE, "create_partial_pbs_node fail"); + + free((void*)allnodes.allnodes_mutex); + allnodes.allnodes_mutex = mutex; + } +END_TEST + +START_TEST(next_node_test) + { + struct pbsnode *result = NULL; + char name[] = "name"; + struct pbsnode node; + struct node_iterator it; + initialize_pbsnode(&node, NULL, NULL, 0); + memset(&it, 0, sizeof(it)); + + initialize_all_nodes_array(&allnodes); + //alloc mutex, use, restore + pthread_mutex_t *mutex = allnodes.allnodes_mutex; + allnodes.allnodes_mutex = (pthread_mutex_t *)calloc(1, sizeof(pthread_mutex_t)); + pthread_mutex_init(allnodes.allnodes_mutex, NULL); + + result = next_node(NULL, &node, &it); + fail_unless(result == NULL, "NULL input all_nodes fail"); + + /*TODO: NOTE: needs more complicated solution to get apropriate result*/ + result = next_node(&allnodes, NULL, &it); + fail_unless(result == NULL, "NULL input pbsnode fail"); + + result = next_node(&allnodes, &node, NULL); + fail_unless(result == NULL, "NULL input iterator fail"); + + result = next_node(&allnodes, &node, &it); + fail_unless(result == NULL, "next_node fail"); + + free((void*)allnodes.allnodes_mutex); + allnodes.allnodes_mutex = mutex; + } +END_TEST + +START_TEST(insert_node_test) + { + struct all_nodes test_all_nodes; + struct pbsnode node; + int result = -1; + + initialize_all_nodes_array(&test_all_nodes); + initialize_pbsnode(&node, NULL, NULL, 0); + + result = insert_node(NULL, &node); + fail_unless(result != PBSE_NONE, "NULL input all_nodes pointer fail"); + + result = insert_node(&test_all_nodes, NULL); + fail_unless(result != PBSE_NONE, "NULL input pbsnode pointer fail"); + + result = insert_node(&test_all_nodes, &node); + fail_unless(result == PBSE_NONE, "insert_node fail"); + + } +END_TEST + +START_TEST(remove_node_test) + { + struct all_nodes test_all_nodes; + struct pbsnode node; + int result = -1; + + initialize_all_nodes_array(&test_all_nodes); + initialize_pbsnode(&node, NULL, NULL, 0); + + result = remove_node(NULL, &node); + fail_unless(result != PBSE_NONE, "NULL input all_nodes pointer fail"); + + result = remove_node(&test_all_nodes, NULL); + fail_unless(result != PBSE_NONE, "NULL input pbsnode pointer fail"); + + result = remove_node(&test_all_nodes, &node); + fail_unless(result == PBSE_NONE, "insert_node fail"); + + } +END_TEST + +START_TEST(next_host_test) + { + struct all_nodes test_all_nodes; + struct pbsnode node; + int it = 0; + struct pbsnode *result = NULL; + + initialize_all_nodes_array(&test_all_nodes); + initialize_pbsnode(&node, NULL, NULL, 0); + + result = next_host(NULL, &it, &node); + fail_unless(result == NULL, "NULL input all_nodes pointer fail"); + + result = next_host(&test_all_nodes, NULL, &node); + fail_unless(result == NULL, "NULL input iterator pointer fail"); + + result = next_host(&test_all_nodes, &it, NULL); + fail_unless(result == NULL, "NULL input pbsnode pointer fail"); + + result = next_host(&test_all_nodes, &it, &node); + fail_unless(result == NULL, "insert_node fail"); + + } +END_TEST + +START_TEST(send_hierarchy_threadtask_test) + { + struct hello_info info; + memset(&info, 0, sizeof(info)); + + send_hierarchy_threadtask(NULL); + send_hierarchy_threadtask((void*)(&info)); + } +END_TEST + +START_TEST(send_hierarchy_test) + { + int result = -1; + char* name = "name"; + + result = send_hierarchy(NULL, 0); + fail_unless(result != PBSE_NONE, "NULL input name fail"); + + result = send_hierarchy(name, 0); + fail_unless(result != PBSE_NONE, "send_hierarchy fail"); + } +END_TEST + +START_TEST(initialize_hello_container_test) + { + struct hello_container container; + struct hello_container* result = NULL; + memset(&container, 0, sizeof(container)); + + result = initialize_hello_container(NULL); + fail_unless(result == NULL, "NULL input fail"); + + result = initialize_hello_container(&container); + fail_unless(result == &container, "wrong returned pointer"); + fail_unless(result->ra != NULL, "resizeble array was not initialized"); + + result = initialize_hello_container(result); + fail_unless(result->hello_mutex != NULL, "mutex was not initialized"); + + } +END_TEST + +START_TEST(add_hello_after_test) + { + struct hello_container container; + char* node_name = "node_name"; + int result = -1; + memset(&container, 0, sizeof(container)); + initialize_hello_container(&container); + + result = add_hello_after(NULL, node_name, 0); + fail_unless(result != PBSE_NONE, "NULL input container pointer fail"); + + result = add_hello_after(&container, NULL, 0); + fail_unless(result == PBSE_NONE, "NULL input name pointer fail"); + + result = add_hello_after(&container, node_name, 0); + fail_unless(result == PBSE_NONE, "add_hello_after fail"); + } END_TEST +START_TEST(add_hello_info_test) + { + struct hello_container container; + struct hello_info info; + int result = -1; + memset(&container, 0, sizeof(container)); + memset(&info, 0, sizeof(info)); + initialize_hello_container(&container); + + result = add_hello_info(NULL, &info); + fail_unless(result != PBSE_NONE, "NULL input container pointer fail"); + result = add_hello_info(&container, NULL); + fail_unless(result == PBSE_NONE, "NULL input hello_info pointer fail"); + result = add_hello_info(&container, &info); + fail_unless(result == PBSE_NONE, "add_hello_info fail"); + + } +END_TEST -START_TEST(test_two) +START_TEST(pop_hello_test) { + struct hello_container container; + struct hello_info *result = NULL; + memset(&container, 0, sizeof(container)); + initialize_hello_container(&container); + result = pop_hello(NULL); + fail_unless(result == NULL, "NULL input container pointer fail"); + result = pop_hello(&container); + fail_unless(result == NULL, "pop_hello fail"); } END_TEST +START_TEST(remove_hello_test) + { + struct hello_container container; + char* node_name = "node_name"; + int result = -1; + memset(&container, 0, sizeof(container)); + initialize_hello_container(&container); + + result = remove_hello(NULL, node_name); + fail_unless(result != PBSE_NONE, "NULL input container pointer fail"); + + result = remove_hello(&container, NULL); + fail_unless(result != PBSE_NONE, "NULL input name pointer fail"); + result = remove_hello(&container, node_name); + fail_unless(result == PBSE_NONE, "add_hello_after fail"); + } +END_TEST Suite *node_func_suite(void) { Suite *s = suite_create("node_func_suite methods"); - TCase *tc_core = tcase_create("find_nodebyname_test"); + TCase *tc_core = tcase_create("PGetNodeFromAddr_test"); + tcase_add_test(tc_core, PGetNodeFromAddr_test); + suite_add_tcase(s, tc_core); + + tc_core = tcase_create("bad_node_warning_test"); + tcase_add_test(tc_core, bad_node_warning_test); + suite_add_tcase(s, tc_core); + + tc_core = tcase_create("addr_ok_test"); + tcase_add_test(tc_core, addr_ok_test); + suite_add_tcase(s, tc_core); + + tc_core = tcase_create("initialize_all_nodes_array_test"); + tcase_add_test(tc_core, initialize_all_nodes_array_test); + suite_add_tcase(s, tc_core); + + tc_core = tcase_create("find_node_in_allnodes_test"); + tcase_add_test(tc_core, find_node_in_allnodes_test); + suite_add_tcase(s, tc_core); + + tc_core = tcase_create("find_nodebyname_test"); tcase_add_test(tc_core, find_nodebyname_test); suite_add_tcase(s, tc_core); - tc_core = tcase_create("test_two"); - tcase_add_test(tc_core, test_two); + tc_core = tcase_create("save_characteristic_test"); + tcase_add_test(tc_core, save_characteristic_test); + suite_add_tcase(s, tc_core); + + tc_core = tcase_create("chk_characteristic_test"); + tcase_add_test(tc_core, chk_characteristic_test); + suite_add_tcase(s, tc_core); + + tc_core = tcase_create("login_encode_jobs_test"); + tcase_add_test(tc_core, login_encode_jobs_test); + suite_add_tcase(s, tc_core); + + tc_core = tcase_create("status_nodeattrib_test"); + tcase_add_test(tc_core, status_nodeattrib_test); + suite_add_tcase(s, tc_core); + + tc_core = tcase_create("initialize_pbsnode_test"); + tcase_add_test(tc_core, initialize_pbsnode_test); + suite_add_tcase(s, tc_core); + + tc_core = tcase_create("effective_node_delete_test"); + tcase_add_test(tc_core, effective_node_delete_test); + suite_add_tcase(s, tc_core); + + tc_core = tcase_create("update_nodes_file_test"); + tcase_add_test(tc_core, update_nodes_file_test); + suite_add_tcase(s, tc_core); + + tc_core = tcase_create("recompute_ntype_cnts_test"); + tcase_add_test(tc_core, recompute_ntype_cnts_test); + suite_add_tcase(s, tc_core); + + tc_core = tcase_create("init_prop_test"); + tcase_add_test(tc_core, init_prop_test); + suite_add_tcase(s, tc_core); + + tc_core = tcase_create("create_subnode_test"); + tcase_add_test(tc_core, create_subnode_test); + suite_add_tcase(s, tc_core); + + tc_core = tcase_create("create_a_gpusubnode_test"); + tcase_add_test(tc_core, create_a_gpusubnode_test); + suite_add_tcase(s, tc_core); + + tc_core = tcase_create("copy_properties_test"); + tcase_add_test(tc_core, copy_properties_test); + suite_add_tcase(s, tc_core); + + tc_core = tcase_create("create_pbs_node_test"); + tcase_add_test(tc_core, create_pbs_node_test); + suite_add_tcase(s, tc_core); + + tc_core = tcase_create("setup_nodes_test"); + tcase_add_test(tc_core, setup_nodes_test); + suite_add_tcase(s, tc_core); + + tc_core = tcase_create("node_np_action_test"); + tcase_add_test(tc_core, node_np_action_test); + suite_add_tcase(s, tc_core); + + tc_core = tcase_create("node_mom_port_action_test"); + tcase_add_test(tc_core, node_mom_port_action_test); + suite_add_tcase(s, tc_core); + + tc_core = tcase_create("node_mom_rm_port_action_test"); + tcase_add_test(tc_core, node_mom_rm_port_action_test); + suite_add_tcase(s, tc_core); + + tc_core = tcase_create("node_gpus_action_test"); + tcase_add_test(tc_core, node_gpus_action_test); + suite_add_tcase(s, tc_core); + + tc_core = tcase_create("node_numa_action_test"); + tcase_add_test(tc_core, node_numa_action_test); + suite_add_tcase(s, tc_core); + + tc_core = tcase_create("numa_str_action_test"); + tcase_add_test(tc_core, numa_str_action_test); + suite_add_tcase(s, tc_core); + + tc_core = tcase_create("gpu_str_action_test"); + tcase_add_test(tc_core, gpu_str_action_test); + suite_add_tcase(s, tc_core); + + tc_core = tcase_create("create_partial_pbs_node_test"); + tcase_add_test(tc_core, create_partial_pbs_node_test); + suite_add_tcase(s, tc_core); + + tc_core = tcase_create("next_node_test"); + tcase_add_test(tc_core, next_node_test); + suite_add_tcase(s, tc_core); + + tc_core = tcase_create("insert_node_test"); + tcase_add_test(tc_core, insert_node_test); + suite_add_tcase(s, tc_core); + + tc_core = tcase_create("remove_node_test"); + tcase_add_test(tc_core, remove_node_test); + suite_add_tcase(s, tc_core); + + tc_core = tcase_create("next_host_test"); + tcase_add_test(tc_core, next_host_test); + suite_add_tcase(s, tc_core); + + tc_core = tcase_create("send_hierarchy_threadtask_test"); + tcase_add_test(tc_core, send_hierarchy_threadtask_test); + suite_add_tcase(s, tc_core); + + tc_core = tcase_create("send_hierarchy_test"); + tcase_add_test(tc_core, send_hierarchy_test); + suite_add_tcase(s, tc_core); + + tc_core = tcase_create("initialize_hello_container_test"); + tcase_add_test(tc_core, initialize_hello_container_test); + suite_add_tcase(s, tc_core); + + tc_core = tcase_create("add_hello_after_test"); + tcase_add_test(tc_core, add_hello_after_test); + suite_add_tcase(s, tc_core); + + tc_core = tcase_create("add_hello_info_test"); + tcase_add_test(tc_core, add_hello_info_test); + suite_add_tcase(s, tc_core); + + tc_core = tcase_create("pop_hello_test"); + tcase_add_test(tc_core, pop_hello_test); + suite_add_tcase(s, tc_core); + + tc_core = tcase_create("remove_hello_test"); + tcase_add_test(tc_core, remove_hello_test); suite_add_tcase(s, tc_core); return s; diff --git a/src/server/test/pbsd_init/scaffolding.c b/src/server/test/pbsd_init/scaffolding.c index 3e29475baa..a8640d9502 100644 --- a/src/server/test/pbsd_init/scaffolding.c +++ b/src/server/test/pbsd_init/scaffolding.c @@ -507,8 +507,9 @@ struct pbsnode *find_nodebyname(const char *name) return(NULL); } -void initialize_hello_container(hello_container *hc) +hello_container *initialize_hello_container(hello_container *hc) { + retunr(NULL); } void free_dynamic_string(dynamic_string *ds) From 22cdd2ad6925951b938a2aac108c3307c9e786ef Mon Sep 17 00:00:00 2001 From: VladimirStarostenkov Date: Tue, 18 Dec 2012 09:05:21 -0800 Subject: [PATCH 2/2] Remove resolved TODO comments --- src/server/node_func.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/server/node_func.h b/src/server/node_func.h index 82ee6e3e97..9eae7ae6dc 100644 --- a/src/server/node_func.h +++ b/src/server/node_func.h @@ -71,19 +71,19 @@ int setup_nodes(void); /* static void delete_a_gpusubnode(struct pbsnode *pnode); */ -int node_np_action(struct pbs_attribute *new_, void *pobj, int actmode); /*TODO: this functions need clarification & refactoring*/ +int node_np_action(struct pbs_attribute *new_attr, void *pobj, int actmode); -int node_mom_port_action(struct pbs_attribute *new_, void *pobj, int actmode); /*TODO: this functions need clarification & refactoring*/ +int node_mom_port_action(struct pbs_attribute *new_attr, void *pobj, int actmode); -int node_mom_rm_port_action(struct pbs_attribute *new_, void *pobj, int actmode); /*TODO: this functions need clarification & refactoring*/ +int node_mom_rm_port_action(struct pbs_attribute *new_attr, void *pobj, int actmode); -int node_gpus_action(struct pbs_attribute *new_, void *pnode, int actmode); /*TODO: this functions need clarification & refactoring*/ +int node_gpus_action(struct pbs_attribute *new_attr, void *pnode, int actmode); -int node_numa_action(struct pbs_attribute *new_, void *pnode, int actmode); /*TODO: this functions need clarification & refactoring*/ +int node_numa_action(struct pbs_attribute *new_attr, void *pnode, int actmode); -int numa_str_action(struct pbs_attribute *new_, void *pnode, int actmode); /*TODO: this functions need clarification & refactoring*/ +int numa_str_action(struct pbs_attribute *new_attr, void *pnode, int actmode); -int gpu_str_action(struct pbs_attribute *new_, void *pnode, int actmode); /*TODO: this functions need clarification & refactoring*/ +int gpu_str_action(struct pbs_attribute *new_attr, void *pnode, int actmode); int create_partial_pbs_node(char *nodename, unsigned long addr, int perms);