Ejemplo n.º 1
0
END_TEST


START_TEST(register_before_dep_test)
  {
  batch_request  preq;
  job            pjob;
  pbs_attribute *pattr;
  struct depend *pdep;
  int            rc = 0;
  char           buf[1000];
  
  memset(&preq, 0, sizeof(preq));
  memset(&pjob, 0, sizeof(pjob));

  strcpy(preq.rq_ind.rq_register.rq_owner, "dbeer");
  strcpy(preq.rq_ind.rq_register.rq_child, job1);
  strcpy(preq.rq_ind.rq_register.rq_svr, host);

  pattr = &pjob.ji_wattr[JOB_ATR_depend];
  initialize_depend_attr(pattr);
  pdep = make_depend(1, pattr);
  make_dependjob(pdep, job1, host);
  rc = register_dependency(&preq, &pjob, JOB_DEPEND_TYPE_BEFOREOK);
  snprintf(buf, sizeof(buf), "rc = %d", rc);
  fail_unless(rc == PBSE_NONE, "first, rc = %d", rc);
  
  pattr = &pjob.ji_wattr[JOB_ATR_depend];
  initialize_depend_attr(pattr);
  pdep = make_depend(JOB_DEPEND_TYPE_ON, pattr);
  make_dependjob(pdep, job1, host);
  fail_unless(register_before_dep(&preq, &pjob, 1) == PBSE_NONE, "second");
  }
Ejemplo n.º 2
0
END_TEST




START_TEST(build_depend_test)
  {
  pbs_attribute  pattr;
  
  initialize_depend_attr(&pattr);

  // value must be in the format dependency_type[:job_id][:job_id2...]
  fail_unless(build_depend(&pattr, "") == PBSE_BADATVAL);
  fail_unless(build_depend(&pattr, NULL) == PBSE_BADATVAL);

  // should accept empty dependencies for dependency removal
  fail_unless(build_depend(&pattr, "afterok") != PBSE_BADATVAL);

  fail_unless(build_depend(&pattr, strdup("afterok:1.napali")) == 0, "didn't build");
  fail_unless(build_depend(&pattr, strdup("bob:1.napali")) == PBSE_BADATVAL, "bad dependency didn't fail");
  fail_unless(build_depend(&pattr, strdup("syncwith:1.napali")) == PBSE_BADATVAL, "bad combo not rejected");
  fail_unless(build_depend(&pattr, strdup("on:1.napali")) == PBSE_BADATVAL, "bad combo 2 not rejected");
  
  strcpy(server_name, host);
  initialize_depend_attr(&pattr);
  fail_unless(build_depend(&pattr, strdup("on:6")) == PBSE_NONE, "on build");

  initialize_depend_attr(&pattr);
  fail_unless(build_depend(&pattr, strdup("beforeok:2.napali@bob")) == PBSE_NONE, "@server");
  fail_unless(build_depend(&pattr, strdup("afterokarray:10[].napali")) == PBSE_BADATVAL, "array combo didn't fail");
  }
Ejemplo n.º 3
0
END_TEST


START_TEST(set_depend_hold_test)
  {
  pbs_attribute *pattr;
  job            pjob;
  job            pjob2;
  struct depend *pdep;
 
  memset(&pjob, 0, sizeof(pjob));
  pattr = &pjob.ji_wattr[JOB_ATR_depend];
  initialize_depend_attr(pattr);
  pdep = make_depend(JOB_DEPEND_TYPE_AFTERNOTOK, pattr);
  make_dependjob(pdep, job2, host);

  set_depend_hold(&pjob, pattr);
  fail_unless((pjob.ji_wattr[JOB_ATR_hold].at_flags & ATR_VFLAG_SET) != 0);
  fail_unless(pjob.ji_qs.ji_state == JOB_STATE_HELD);
  
  memset(&pjob2, 0, sizeof(pjob2));
  pjob2.ji_qs.ji_substate = JOB_SUBSTATE_DEPNHOLD;
  pattr = &pjob2.ji_wattr[JOB_ATR_depend];
  initialize_depend_attr(pattr);
  pdep = make_depend(JOB_DEPEND_TYPE_AFTEROK, pattr);
  make_dependjob(pdep, job2, host);

  set_depend_hold(&pjob2, pattr);
  fail_unless((pjob2.ji_wattr[JOB_ATR_hold].at_flags & ATR_VFLAG_SET) == 0);
  fail_unless(pjob2.ji_qs.ji_state != JOB_STATE_HELD);
  }
Ejemplo n.º 4
0
END_TEST


START_TEST(register_dependency_test)
  {
  batch_request  preq;
  job            pjob;
  pbs_attribute *pattr;
  
  memset(&preq, 0, sizeof(preq));
  memset(&pjob, 0, sizeof(pjob));

  strcpy(preq.rq_ind.rq_register.rq_owner, "dbeer");
  strcpy(preq.rq_ind.rq_register.rq_child, job1);
  strcpy(preq.rq_ind.rq_register.rq_svr, host);
  strcpy(preq.rq_ind.rq_register.rq_parent, job1);

  fail_unless(register_dependency(&preq, &pjob, 1) == PBSE_IVALREQ);
  strcpy(preq.rq_ind.rq_register.rq_parent, job2);
  fail_unless(register_dependency(&preq, &pjob, -1) == PBSE_IVALREQ);

  pattr = &pjob.ji_wattr[JOB_ATR_depend];
  initialize_depend_attr(pattr);

  fail_unless(register_dependency(&preq, &pjob, JOB_DEPEND_TYPE_AFTERSTART) == PBSE_NONE);
  }
Ejemplo n.º 5
0
END_TEST


START_TEST(release_before_dependency_test)
  {
  batch_request  preq;
  job            pjob;
  pbs_attribute *pattr;
  struct depend *pdep;
  
  memset(&preq, 0, sizeof(preq));
  memset(&pjob, 0, sizeof(pjob));

  strcpy(preq.rq_ind.rq_register.rq_owner, "dbeer");
  strcpy(preq.rq_ind.rq_register.rq_child, job1);
  strcpy(preq.rq_ind.rq_register.rq_svr, host);

  pattr = &pjob.ji_wattr[JOB_ATR_depend];
  initialize_depend_attr(pattr);
  pdep = make_depend(1, pattr);
  make_dependjob(pdep, job1, host);
  register_dependency(&preq, &pjob, JOB_DEPEND_TYPE_BEFOREOK);

  fail_unless(release_before_dependency(&preq, &pjob, JOB_DEPEND_TYPE_BEFOREOK) == PBSE_NONE);
  fail_unless(release_before_dependency(&preq, &pjob, JOB_DEPEND_TYPE_BEFOREOK) == PBSE_IVALREQ);
  }
Ejemplo n.º 6
0
END_TEST




START_TEST(unregister_dep_test)
  {
  pbs_attribute  pattr;
  struct depend *pdep;
  batch_request  preq;
  
  memset(&preq, 0, sizeof(preq));
  strcpy(preq.rq_ind.rq_register.rq_svr, host);
  strcpy(preq.rq_ind.rq_register.rq_child, job1);
  preq.rq_ind.rq_register.rq_dependtype = 1;

  initialize_depend_attr(&pattr);

  fail_unless(unregister_dep(&pattr, &preq) == PBSE_IVALREQ, "didn't error on non-existent dep");

  pdep = make_depend(5, &pattr);
  make_dependjob(pdep, job1, host);

  fail_unless(unregister_dep(&pattr, &preq) == PBSE_NONE, "didn't unregister");
  }
Ejemplo n.º 7
0
END_TEST




START_TEST(find_depend_test)
  {
  pbs_attribute  pattr;
  struct depend *pdep;

  initialize_depend_attr(&pattr);
  pdep = make_depend(1, &pattr);
  pdep = make_depend(2, &pattr);
  pdep = make_depend(3, &pattr);

  pdep = find_depend(1, &pattr);
  fail_unless(pdep != NULL, "couldn't find 1");
  fail_unless(pdep->dp_type == 1, "bad type returned");

  pdep = find_depend(2, &pattr);
  fail_unless(pdep != NULL, "couldn't find 2");
  fail_unless(pdep->dp_type == 2, "bad type returned");

  pdep = find_depend(3, &pattr);
  fail_unless(pdep != NULL, "couldn't find 3");
  fail_unless(pdep->dp_type == 3, "bad type returned");

  pdep = find_depend(0, &pattr);
  fail_unless(pdep == NULL, "found non-existent thing");
  }
END_TEST




START_TEST(release_syncwith_dependency_test)
  {
  pbs_attribute *pattr;
  job            pjob;
  struct depend *pdep;
  batch_request  preq;

  memset(&preq, 0, sizeof(preq));
  memset(&pjob, 0, sizeof(pjob));
  pattr = &pjob.ji_wattr[JOB_ATR_depend];
  initialize_depend_attr(pattr);

  fail_unless(release_syncwith_dependency(&preq, &pjob) == PBSE_NOSYNCMSTR);

  pdep = make_depend(JOB_DEPEND_TYPE_SYNCWITH, pattr);
  make_dependjob(pdep, job1, host);
  pdep->dp_released = 0;
  
  fail_unless(release_syncwith_dependency(&preq, &pjob) == PBSE_NONE);
  }
Ejemplo n.º 9
0
END_TEST


START_TEST(set_depend_test)
  {
  pbs_attribute  pattr;
  pbs_attribute  pa2;
  struct depend *pdep;
  tlist_head     phead;
  
  initialize_depend_attr(&pattr);
  initialize_depend_attr(&pa2);
  CLEAR_HEAD(phead);

  pdep = make_depend(5, &pattr);
  make_dependjob(pdep, job1, host);
  pdep = make_depend(6, &pattr);
  make_dependjob(pdep, job2, host);

  fail_unless(set_depend(&pa2, &pattr, INCR) == PBSE_IVALREQ, "INCR worked?");
  fail_unless(set_depend(&pa2, &pattr, SET) == PBSE_NONE, "fail set?");
  }
Ejemplo n.º 10
0
END_TEST


START_TEST(decode_depend_test)
  {
  pbs_attribute pattr;
  
  initialize_depend_attr(&pattr);

  fail_unless(decode_depend(&pattr, NULL, NULL, NULL, 0) == 0, "null failed");
  fail_unless(decode_depend(&pattr, NULL, NULL, "", 0) == 0, "empty failed");
  fail_unless(decode_depend(&pattr, NULL, NULL, strdup("afterok:1.napali,beforeany:2.napali"), 0) == 0, "empty failed");
  fail_unless(decode_depend(&pattr, NULL, NULL, strdup("bart"), 0) != PBSE_NONE, "bad worked?");
  }
END_TEST




START_TEST(build_depend_test)
  {
  pbs_attribute  pattr;
  
  initialize_depend_attr(&pattr);

  fail_unless(build_depend(&pattr, strdup("afterok:1.napali")) == 0, "didn't build");
  fail_unless(build_depend(&pattr, strdup("bob:1.napali")) == PBSE_BADATVAL, "bad dependency didn't fail");
  fail_unless(build_depend(&pattr, strdup("syncwith:1.napali")) == PBSE_BADATVAL, "bad combo not rejected");
  fail_unless(build_depend(&pattr, strdup("on:1.napali")) == PBSE_BADATVAL, "bad combo 2 not rejected");
  
  strcpy(server_name, host);
  initialize_depend_attr(&pattr);
  fail_unless(build_depend(&pattr, strdup("on:6")) == PBSE_NONE, "on build");

  initialize_depend_attr(&pattr);
  fail_unless(build_depend(&pattr, strdup("beforeok:2.napali@bob")) == PBSE_NONE, "@server");
  fail_unless(build_depend(&pattr, strdup("afterokarray:10[].napali")) == PBSE_BADATVAL, "array combo didn't fail");
  }
Ejemplo n.º 12
0
END_TEST




START_TEST(dup_depend_test)
  {
  struct depend      pdep;
  pbs_attribute      pattr;

  initialize_depend_attr(&pattr);
  memset(&pdep, 0, sizeof(pdep));

  make_dependjob(&pdep, job1, host);
  make_dependjob(&pdep, job2, host);
  fail_unless(dup_depend(&pattr, &pdep) == PBSE_NONE, "didn't work");
  }
Ejemplo n.º 13
0
END_TEST


START_TEST(remove_array_dependency_from_job_test)
  {
  job                 *pjob = (job *)calloc(1, sizeof(job));
  struct depend       *pdep;
  struct depend_job   *d1;
  struct array_depend  array_dep;

  initialize_depend_attr(&pjob->ji_wattr[JOB_ATR_depend]);
  pdep = make_depend(JOB_DEPEND_TYPE_AFTEROKARRAY, &pjob->ji_wattr[JOB_ATR_depend]);
  fail_unless((d1 = make_dependjob(pdep, job1, host)) != NULL, "didn't create dep 1");

  array_dep.dp_type = JOB_DEPEND_TYPE_AFTEROKARRAY;
  fail_unless(remove_array_dependency_job_from_job(&array_dep, pjob, job1) == true);
  }
END_TEST




START_TEST(depend_clrrdy_test)
  {
  pbs_attribute *pattr;
  job            pjob;
  struct depend *pdep;

  memset(&pjob, 0, sizeof(pjob));
  pattr = &pjob.ji_wattr[JOB_ATR_depend];
  initialize_depend_attr(pattr);
  pdep = make_depend(JOB_DEPEND_TYPE_SYNCCT, pattr);
  make_dependjob(pdep, job1, host);
  depend_clrrdy(&pjob);
  }
Ejemplo n.º 15
0
END_TEST




START_TEST(free_depend_test)
  {
  pbs_attribute  pattr;
  struct depend *pdep;
  
  initialize_depend_attr(&pattr);
  pdep = make_depend(5, &pattr);
  make_dependjob(pdep, job1, host);
  pdep = make_depend(6, &pattr);
  make_dependjob(pdep, job2, host);

  free_depend(&pattr);
  fail_unless((pattr.at_flags & ATR_VFLAG_SET) == 0, "didn't free?");
  }
Ejemplo n.º 16
0
END_TEST




START_TEST(register_dep_test)
  {
  pbs_attribute  pattr;
  batch_request  preq;
  int            made = 0;

  initialize_depend_attr(&pattr);
  memset(&preq, 0, sizeof(preq));
  strcpy(preq.rq_ind.rq_register.rq_svr, host);
  strcpy(preq.rq_ind.rq_register.rq_child, job1);

  strcpy(server_name, host);

  fail_unless(register_dep(&pattr, &preq, 1, &made) == PBSE_NONE, "didn't register");
  fail_unless(register_dep(&pattr, &preq, 1, &made) == PBSE_NONE, "didn't register");
  }
Ejemplo n.º 17
0
END_TEST


START_TEST(encode_depend_test)
  {
  pbs_attribute  pattr;
  struct depend *pdep;
  tlist_head     phead;
  
  initialize_depend_attr(&pattr);
  CLEAR_HEAD(phead);
  
  fail_unless(encode_depend(NULL, NULL, NULL, NULL, 0, 0) == -1, "null");
  fail_unless(encode_depend(&pattr, NULL, NULL, NULL, 0, 0) == 0, "empty");

  pdep = make_depend(5, &pattr);
  make_dependjob(pdep, job1, host);
  pdep = make_depend(6, &pattr);
  make_dependjob(pdep, job2, host);

  fail_unless(encode_depend(&pattr, &phead, "depend", NULL, 0, 0) == 1, "encoding");
  }
Ejemplo n.º 18
0
END_TEST


/*
START_TEST(unregister_sync_test)
  {
  pbs_attribute  pattr;
  struct depend *pdep;
  batch_request  preq;
  
  initialize_depend_attr(&pattr);
  memset(&preq, 0, sizeof(preq));
  
  pdep = make_depend(JOB_DEPEND_TYPE_SYNCCT, &pattr);
  make_dependjob(pdep, job1, host);
  make_dependjob(pdep, job2, host);
  pdep->dp_released = 1;

  fail_unless(unregister_sync(&pattr, &preq) == PBSE_IVALREQ, "bad name worked?");
  strcpy(preq.rq_ind.rq_register.rq_child, job1);
  fail_unless(unregister_sync(&pattr, &preq) == PBSE_NONE, "success");
  }
END_TEST*/


START_TEST(depend_clrrdy_test)
  {
  pbs_attribute *pattr;
  job            pjob;
  struct depend *pdep;

  memset(&pjob, 0, sizeof(pjob));
  pattr = &pjob.ji_wattr[JOB_ATR_depend];
  initialize_depend_attr(pattr);
  pdep = make_depend(JOB_DEPEND_TYPE_SYNCCT, pattr);
  make_dependjob(pdep, job1, host);
  depend_clrrdy(&pjob);
  }