Skip to content

Commit

Permalink
Coverage++
Browse files Browse the repository at this point in the history
  • Loading branch information
henricasanova committed Nov 7, 2019
1 parent f29daf1 commit fdfc6ce
Showing 1 changed file with 60 additions and 4 deletions.
64 changes: 60 additions & 4 deletions test/wms/JobManagerTest.cpp
Expand Up @@ -215,39 +215,95 @@ class JobManagerCreateJobTestWMS : public wrench::WMS {
}


// Create a job with a nullptr task in it
try {
job_manager->createStandardJob((std::vector<wrench::WorkflowTask *>) {nullptr}, {});
throw std::runtime_error("Should not be able to create a standard job with a nullptr task in it");
} catch (std::invalid_argument &e) {
}


// Create a job with nothing in it
try {
std::vector<wrench::WorkflowTask *> tasks; // empty
job_manager->createStandardJob(tasks, {});
throw std::runtime_error("Should not be able to create a standard job with nothing in it");
} catch (std::invalid_argument &e) {
}


wrench::WorkflowTask *t1 = this->getWorkflow()->addTask("t1", 1.0, 1, 1, 1.0, 0.0);
wrench::WorkflowTask *t2 = this->getWorkflow()->addTask("t2", 1.0, 1, 1, 1.0, 0.0);
wrench::WorkflowFile *f = this->getWorkflow()->addFile("f", 100);
t1->addOutputFile(f);
t2->addInputFile(f);

// Create an "ok" job
// Create a job with a null stuff in pre file copy
try {
job_manager->createStandardJob({t1, t2}, {});
std::set<std::tuple<wrench::WorkflowFile *, std::shared_ptr<wrench::FileLocation>, std::shared_ptr<wrench::FileLocation> > > pre_file_copies;
pre_file_copies.insert(std::make_tuple((wrench::WorkflowFile *)nullptr, wrench::FileLocation::SCRATCH, wrench::FileLocation::SCRATCH));
job_manager->createStandardJob({}, {}, pre_file_copies, {}, {});
throw std::runtime_error("Should not be able to create a standard job with a (nullptr, *, *) pre file copy");
} catch (std::invalid_argument &e) {
}
try {
std::set<std::tuple<wrench::WorkflowFile *, std::shared_ptr<wrench::FileLocation>, std::shared_ptr<wrench::FileLocation> > > pre_file_copies;
pre_file_copies.insert(std::make_tuple(f, nullptr, wrench::FileLocation::SCRATCH));
job_manager->createStandardJob({}, {}, pre_file_copies, {}, {});
throw std::runtime_error("Should not be able to create a standard job with a (*, nullptr, *) pre file copy");
} catch (std::invalid_argument &e) {
}
try {
std::set<std::tuple<wrench::WorkflowFile *, std::shared_ptr<wrench::FileLocation>, std::shared_ptr<wrench::FileLocation> > > pre_file_copies;
pre_file_copies.insert(std::make_tuple(f, wrench::FileLocation::SCRATCH, nullptr));
job_manager->createStandardJob({}, {}, pre_file_copies, {}, {});
throw std::runtime_error("Should not be able to create a standard job with a (*, *, nullptr) pre file copy");
} catch (std::invalid_argument &e) {
throw std::runtime_error("Should be able to create a standard job with two dependent tasks");
}

// Create a "not ok" job

// Create a job with a null stuff in post file copy
try {
std::set<std::tuple<wrench::WorkflowFile *, std::shared_ptr<wrench::FileLocation>, std::shared_ptr<wrench::FileLocation> > > post_file_copies;
post_file_copies.insert(std::make_tuple((wrench::WorkflowFile *)nullptr, wrench::FileLocation::SCRATCH, wrench::FileLocation::SCRATCH));
job_manager->createStandardJob({}, {}, {}, post_file_copies, {});
throw std::runtime_error("Should not be able to create a standard job with a (nullptr, *, *) post file copy");
} catch (std::invalid_argument &e) {
}
try {
std::set<std::tuple<wrench::WorkflowFile *, std::shared_ptr<wrench::FileLocation>, std::shared_ptr<wrench::FileLocation> > > post_file_copies;
post_file_copies.insert(std::make_tuple(f, nullptr, wrench::FileLocation::SCRATCH));
job_manager->createStandardJob({}, {}, {}, post_file_copies, {});
throw std::runtime_error("Should not be able to create a standard job with a (*, nullptr, *) post file copy");
} catch (std::invalid_argument &e) {
}
try {
std::set<std::tuple<wrench::WorkflowFile *, std::shared_ptr<wrench::FileLocation>, std::shared_ptr<wrench::FileLocation> > > post_file_copies;
post_file_copies.insert(std::make_tuple(f, wrench::FileLocation::SCRATCH, nullptr));
job_manager->createStandardJob({}, {}, {}, post_file_copies, {});
throw std::runtime_error("Should not be able to create a standard job with a (*, *, nullptr) post file copy");
} catch (std::invalid_argument &e) {
}


// Create a job with not ok task dependencies
try {
job_manager->createStandardJob((std::vector<wrench::WorkflowTask *>) {t2}, {});
throw std::runtime_error("Should not be able to create a standard job with a not-self-contained task");
} catch (std::invalid_argument &e) {
}


// Create an "ok" job
try {
job_manager->createStandardJob({t1, t2}, {});
} catch (std::invalid_argument &e) {
throw std::runtime_error("Should be able to create a standard job with two dependent tasks");
}




return 0;
}
};
Expand Down

0 comments on commit fdfc6ce

Please sign in to comment.