END_TEST START_TEST(initialize_pbsnode_test) { struct pbsnode node; int result = -1; result = initialize_pbsnode(NULL, NULL, NULL, 0, FALSE); fail_unless(result != PBSE_NONE, "NULL input node pointer fail"); result = initialize_pbsnode(&node, NULL, NULL, 0, FALSE); fail_unless(result == PBSE_NONE, "initialization 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, FALSE); 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(find_node_in_allnodes_test) { struct pbsnode *result = NULL; all_nodes allnodes; struct pbsnode test_node; const char *test_node_name = "test_node"; test_node.nd_name = (char *)test_node_name; initialize_pbsnode(&test_node, NULL, NULL, 0, FALSE); result = find_node_in_allnodes(NULL, (char *)"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, (char *)"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(insert_node_test) { all_nodes test_all_nodes; struct pbsnode node; int result = -1; test_all_nodes.lock(); test_all_nodes.clear(); test_all_nodes.unlock(); initialize_pbsnode(&node, NULL, NULL, 0, FALSE); 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"); node.nd_name = (char *)"node_name"; result = insert_node(&test_all_nodes, &node); fail_unless(result == PBSE_NONE, "insert_node fail"); }
END_TEST START_TEST(next_node_test) { struct pbsnode *result = NULL; struct pbsnode node; struct node_iterator it; initialize_pbsnode(&node, NULL, NULL, 0, FALSE); memset(&it, 0, sizeof(it)); it.node_index = NULL; allnodes.lock(); allnodes.clear(); allnodes.unlock(); 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"); }
struct pbsnode *create_alps_subnode( struct pbsnode *parent, char *node_id) { struct pbsnode *subnode = calloc(1, sizeof(struct pbsnode)); svrattrl *plist = NULL; int bad; int rc; if (initialize_pbsnode(subnode, strdup(node_id), NULL, NTYPE_CLUSTER) != PBSE_NONE) { free(subnode); log_err(ENOMEM, __func__, ""); return(NULL); } if (create_subnode(subnode) == NULL) { free(subnode); log_err(ENOMEM, __func__, ""); return(NULL); } /* do we need to do something else here? */ subnode->nd_addrs = parent->nd_addrs; rc = mgr_set_node_attr(subnode, node_attr_def, ND_ATR_LAST, plist, ATR_DFLAG_MGRD | ATR_DFLAG_MGWR, &bad, (void *)subnode, ATR_ACTION_ALTER); if (rc != PBSE_NONE) { free(subnode); log_err(rc, __func__, "Couldn't set node attributes"); return(NULL); } subnode->nd_ntype = NTYPE_CLUSTER; subnode->parent = parent; /* add any properties to the subnodes */ copy_properties(subnode, parent); lock_node(subnode, __func__, NULL, 0); insert_node(&(parent->alps_subnodes), subnode); return(subnode); } /* END create_alps_subnode() */
struct pbsnode *create_alps_subnode( struct pbsnode *parent, const char *node_id) { struct pbsnode *subnode = (struct pbsnode *)calloc(1, sizeof(struct pbsnode)); svrattrl *plist = NULL; int bad; int rc = PBSE_NONE; if (initialize_pbsnode(subnode, strdup(node_id), NULL, NTYPE_CLUSTER, FALSE) != PBSE_NONE) { free(subnode); log_err(ENOMEM, __func__, ""); return(NULL); } // all nodes have at least 1 core add_execution_slot(subnode); // we need to increment this count for accuracy svr_clnodes++; /* do we need to do something else here? */ subnode->nd_addrs = parent->nd_addrs; rc = mgr_set_node_attr(subnode, node_attr_def, ND_ATR_LAST, plist, ATR_DFLAG_MGRD | ATR_DFLAG_MGWR, &bad, (void *)subnode, ATR_ACTION_ALTER); if (rc != PBSE_NONE) { free(subnode); log_err(rc, __func__, "Couldn't set node attributes"); return(NULL); } subnode->nd_ntype = NTYPE_CLUSTER; subnode->parent = parent; /* add any properties to the subnodes */ copy_properties(subnode, parent); lock_node(subnode, __func__, NULL, LOGLEVEL); insert_node(&(parent->alps_subnodes), subnode); return(subnode); } /* END create_alps_subnode() */
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, FALSE); initialize_pbsnode(&destanation_node, NULL, NULL, 0, FALSE); 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(bad_node_warning_test) { pbs_net_t address = 0; struct pbsnode node; initialize_pbsnode(&node, NULL, NULL, 0, FALSE); bad_node_warning(address, NULL); bad_node_warning(address, &node); }
END_TEST START_TEST(save_characteristic_test) { struct pbsnode node; struct node_check_info node_info; initialize_pbsnode(&node, NULL, NULL, 0, FALSE); 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(create_a_gpusubnode_test) { int result = -1; struct pbsnode node; initialize_pbsnode(&node, NULL, NULL, 0, FALSE); 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(add_execution_slot_test) { struct pbsnode node; int result = 0; initialize_pbsnode(&node, NULL, NULL, 0, FALSE); result = add_execution_slot(NULL); fail_unless(result == PBSE_RMBADPARAM, "NULL node pointer input fail"); result = add_execution_slot(&node); fail_unless(result == PBSE_NONE, "add_execution_slot_test fail"); }
END_TEST START_TEST(update_nodes_file_test) { int result = -1; struct pbsnode node; initialize_pbsnode(&node, NULL, NULL, 0, FALSE); 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(addr_ok_test) { pbs_net_t address = 0; struct pbsnode node; int result; initialize_pbsnode(&node, NULL, NULL, 0, FALSE); 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); }
END_TEST START_TEST(login_encode_jobs_test) { struct pbsnode node; struct list_link list; int result; initialize_pbsnode(&node, NULL, NULL, 0, FALSE); memset(&list, 0, sizeof(list)); 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(remove_node_test) { all_nodes test_all_nodes; struct pbsnode node; int result = -1; initialize_pbsnode(&node, NULL, NULL, 0, FALSE); 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(effective_node_delete_test) { struct pbsnode *node = NULL; allnodes.lock(); allnodes.clear(); allnodes.unlock(); /*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, FALSE); effective_node_delete(&node); fail_unless(node == NULL, "unsuccessfull node delition %d", node); }
END_TEST START_TEST(chk_characteristic_test) { struct pbsnode node; struct node_check_info node_info; int result = 0; int mask = 0; initialize_pbsnode(&node, NULL, NULL, 0, FALSE); memset(&node_info, 0, sizeof(node_info)); 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(next_host_test) { all_nodes test_all_nodes; struct pbsnode node; all_nodes_iterator *it = NULL; struct pbsnode *result = NULL; initialize_pbsnode(&node, NULL, NULL, 0, FALSE); 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(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, FALSE); 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); }