struct pbsnode *determine_node_from_str( char *str, struct pbsnode *parent, struct pbsnode *current) { struct pbsnode *next = NULL; char *node_id = str + strlen("node="); if ((current == NULL) || (strcmp(node_id, current->nd_name))) { if (current != NULL) unlock_node(current, __func__, NULL, 0); if ((next = find_alpsnode_by_name(parent, node_id)) == NULL) { /* create the node */ next = create_alps_subnode(parent, node_id); } } else { next = current; } if (next != NULL) next->nd_lastupdate = time(NULL); return(next); } /* END determine_node_from_str() */
END_TEST START_TEST(find_alpsnode_test) { struct pbsnode parent; const char *node_id = (char *)"tom"; struct pbsnode *alpsnode; parent.alps_subnodes = new all_nodes(); alpsnode = find_alpsnode_by_name(&parent, node_id); fail_unless(alpsnode == NULL, "returned a non-NULL node?"); }
END_TEST START_TEST(find_alpsnode_test) { struct pbsnode parent; char *node_id = "tom"; struct pbsnode *alpsnode; parent.alps_subnodes.allnodes_mutex = calloc(1, sizeof(pthread_mutex_t)); pthread_mutex_init(parent.alps_subnodes.allnodes_mutex, NULL); alpsnode = find_alpsnode_by_name(&parent, node_id); fail_unless(alpsnode == NULL, "returned a non-NULL node?"); }