示例#1
0
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, FALSE);
    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");
}
示例#2
0
END_TEST


/*
START_TEST(save_characteristic_test)
  {
  pbsnode node;
  node_check_info node_info;
  save_characteristic(NULL, &node_info);
  save_characteristic(&node, NULL);
  save_characteristic(&node, &node_info);
  }
END_TEST


START_TEST(chk_characteristic_test)
  {
  pbsnode node;
  node_check_info 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(status_nodeattrib_test)
  {
  struct svrattrl attributes;
  struct attribute_def node_attributes;
  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));
  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);
  }
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);
  // delete shouldn't work with nameless node
  node = new pbsnode();
  effective_node_delete(&node);
  fail_unless(node != NULL, "shouldn't delete a nameless node");
  node->change_name("nodename");
  effective_node_delete(&node);
  fail_unless(node != NULL, "shouldn't delete a non-inserted node");

  allnodes.insert(node, node->get_name());
  effective_node_delete(&node);
  fail_unless(node == NULL, "unsuccessful node deletion %d", node);

  }
END_TEST


START_TEST(update_nodes_file_test)
  {
  int result = -1;
  pbsnode node;

  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(name);
  fail_unless(result->name == name, "name init fail");
  }
END_TEST 

START_TEST(create_a_gpusubnode_test)
  {
  int result = -1;
  pbsnode node;

  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;
  pbsnode source_node;
  pbsnode destination_node;

  result = source_node.copy_properties(NULL);
  fail_unless(result != PBSE_NONE, "NULL destanation pointer input fail");

  // TODO: fill in source node
  result = source_node.copy_properties(&destination_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");

  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;
  pbsnode node;
  struct pbs_attribute attributes;

  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;
  pbsnode node;
  struct pbs_attribute attributes;

  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");
  }