END_TEST START_TEST(clear_depend_test) { struct depend pd; i = 1; clear_depend(&pd, 0, 0); fail_unless(pd.dp_type == 0, "type not set"); fail_unless(pd.dp_numexp == 0, "attr not set correctly"); fail_unless(pd.dp_numreg == 0, "attr not set correctly"); fail_unless(pd.dp_released == 0, "attr not set correctly"); i = 1; memset(&pd, 0, sizeof(pd)); make_dependjob(&pd, job1, host); make_dependjob(&pd, job2, host); clear_depend(&pd, 0, 1); fail_unless(pd.dp_type == 0, "type not set"); fail_unless(pd.dp_numexp == 0, "attr not set correctly"); fail_unless(pd.dp_numreg == 0, "attr not set correctly"); fail_unless(pd.dp_released == 0, "attr not set correctly"); }
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); }
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"); }
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); }
END_TEST START_TEST(del_depend_test) { struct depend *pdep = (depend *)calloc(1, sizeof(struct depend)); CLEAR_HEAD(pdep->dp_link); make_dependjob(pdep, job1, host); make_dependjob(pdep, job2, host); del_depend(pdep); }
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"); }
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); }
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"); }
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?"); }
END_TEST START_TEST(make_dependjob_test) { struct depend pdep; struct depend_job *d1; struct depend_job *d2; memset(&pdep, 0, sizeof(pdep)); fail_unless((d1 = make_dependjob(&pdep, job1, host)) != NULL, "didn't create dep 1"); fail_unless((d2 = make_dependjob(&pdep, job2, host)) != NULL, "didn't create dep 2"); fail_unless(d1->dc_cost == 0, "bad cost"); fail_unless(d1->dc_state == 0, "bad state"); fail_unless(strcmp(d1->dc_child, job1) == 0, "bad job id1"); fail_unless(strcmp(d2->dc_child, job2) == 0, "bad job id2"); }
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?"); }
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"); }
END_TEST START_TEST(find_dependjob_test) { struct depend pdep; struct depend_job *d1; struct depend_job *d2; memset(&pdep, 0, sizeof(pdep)); fail_unless((d1 = make_dependjob(&pdep, job1, host)) != NULL, "didn't create dep 1"); fail_unless((d2 = make_dependjob(&pdep, job2, host)) != NULL, "didn't create dep 2"); fail_unless(d1 == find_dependjob(&pdep, job1), "didn't find job1"); fail_unless(d2 == find_dependjob(&pdep, job2), "didn't find job2"); fail_unless(find_dependjob(&pdep, (char *)"bob") == NULL, "found bob?"); svr = 10; // will make display server suffix false, see scaffolding fail_unless(d1 == find_dependjob(&pdep, (char *)"1"), "didn't find job1 without suffix"); fail_unless(d2 == find_dependjob(&pdep, (char *)"2"), "didn't find job2 without suffix"); }
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(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); }