Commit 8e8fbcc8 authored by Oliver Heidmann's avatar Oliver Heidmann
Browse files

added create_pstream function which allow to create pstreams with set...

added create_pstream function which allow to create pstreams with set filenames, removed warnings form bandit tests, added new bandit test
parent feb5db55
......@@ -248,6 +248,9 @@ processAddInputStream(pstream_t *p_pstream_ptr)
{
process.nchild++;
}
else
{
}
int sindex = process.getInStreamCnt();
if (sindex >= MAX_STREAM)
......@@ -844,8 +847,11 @@ createProcesses(int argc, const char **argv)
current_process = call_stack.top();
for(int i = 0; i < root_process->m_module.streamOutCnt; i++)
{
pstream_t *new_out_stream = create_pstream();
root_process->outputStreams.push_back(new_out_stream);
if(CdoDebug::PROCESS)
{
MESSAGE("Creating new pstream for output file: ", argv[argc - (i + 1)]);
}
root_process->outputStreams.push_back(create_pstream(std::string(argv[argc - (i + 1)])));
}
do
{
......@@ -871,9 +877,8 @@ createProcesses(int argc, const char **argv)
if(CdoDebug::PROCESS){
MESSAGE("adding file to ", current_process->operatorName);
}
pstream_t *new_in_stream = create_pstream();
// new_pstream->pstreamOpenReadFile(argv[i]);
current_process->inputStreams.push_back(new_in_stream);
MESSAGE(argv[idx]);
current_process->inputStreams.push_back(create_pstream(argv[idx]));
}
while (current_process->hasAllInputs() && current_process != root_process)
......@@ -1038,6 +1043,7 @@ operatorInputArg(const char *enter)
// reset_text_color(stderr);
}
while (lreadline)
{
readline(stdin, pline, 1024);
......@@ -1061,6 +1067,7 @@ operatorInputArg(const char *enter)
while (pline[len] != ' ' && pline[len] != ',' && pline[len] != '\\' && len < linelen)
len++;
process.oargv[oargc] = (char *) Malloc(len + 1);
memcpy(process.oargv[oargc], pline, len);
process.oargv[oargc][len] = '\0';
......
......@@ -54,6 +54,9 @@ public:
std::vector<process_t *> parentProcesses;
std::vector<pstream_t *> inputStreams;
std::vector<pstream_t *> outputStreams;
short m_cntIn;
short m_cntOut;
double s_utime;
double s_stime;
double a_utime;
......@@ -62,19 +65,20 @@ public:
size_t nvals;
short nvars;
int ntimesteps;
short m_streamCnt;
std::vector<argument_t> streamArguments;
const char *m_operatorCommand;
const char *operatorName;
char *operatorArg;
int oargc;
std::vector<char *> oargv;
char prompt[64];
short noper;
oper_t oper[MAX_OPERATOR];
modules_t m_module;
std::vector<char *> oargv;
int oargc;
oper_t oper[MAX_OPERATOR];
int getInStreamCnt();
int getOutStreamCnt();
......
......@@ -147,6 +147,20 @@ pstream_init_pointer(void)
return &new_entry.first->second;
}
//temporary function: will be replaced by according pstream_t::pstream_t(..)
pstream_t *create_pstream(std::vector<std::string> p_filenameList)
{
pstream_t* new_entry = create_pstream();
new_entry->m_mfnames = p_filenameList;
return new_entry;
}
//temporary function: will be replaced by according pstream_t::pstream_t(..)
pstream_t *create_pstream(std::string p_filename)
{
return create_pstream(std::vector<std::string>{p_filename});
}
static pstream_t * pstream_to_pointer(int idx)
{
......
......@@ -97,5 +97,7 @@ void cdoVlistCopyFlag(int vlistID2, int vlistID1);
const int &getPthreadScope();
pstream_t *create_pstream();
pstream_t *create_pstream(std::vector<std::string> p_filenameList);
pstream_t *create_pstream(std::string p_filename);
#endif /* PSTREAM_H */
#include "bandit/bandit/bandit.h"
//BANDIT NEEDS TO BE INCLUDED FIRST!!!
#include "../../src/cdoDebugOutput.h"
#include "../../src/modules.h"
#include "../../src/operator_help.h"
#include "../../src/process.h"
#include <iostream>
void *Oper1(void *test) { return test; }
void *Oper2(void *test) { return test; }
void *Oper3(void *test) { return test; }
void *Oper4(void *test) { return test; }
go_bandit([]() {
bandit::describe("Process creation", []() {
// oper1: child oper 2
// oper2: child oper3 and oper4:
// oper3: infile: 1
// oper4: infile 2
// outfile: filled by oper1
std::vector<const char *> test_argv{"-oper1", "-oper2", "-oper3",
"input_file1", "-oper4", "input_file2",
"output_file"};
std::vector<int> expectedInputs{1,2,1,1};
std::vector<int> expectedOutputs{1,1,1,1};
/*clang-format off*/
// Name Func Help oper mod in
// num out
add_module("Oper1", {Oper1, {}, {"oper1"}, 1, 0, 1, 1});
add_module("Oper2", {Oper2, {}, {"oper2"}, 1, 0, 2, 1});
add_module("Oper3", {Oper3, {}, {"oper3"}, 1, 0, 1, 1});
add_module("Oper4", {Oper4, {}, {"oper4"}, 1, 0, 1, 1});
/*clang-format on*/
createProcesses(test_argv.size(), &test_argv[0]);
for (unsigned int i = 0; i < Process.size(); i++) {
auto process = Process.at(i);
bandit::it("created inputs for:"+ std::string(Process.at(i).operatorName), [&]() {
AssertThat(
process.childProcesses.size() + process.inputStreams.size(),
snowhouse::Equals(expectedInputs[i]));
});
bandit::it("created outputs for: " + std::string(Process.at(i).operatorName) , [&]() {
AssertThat(
process.parentProcesses.size() + process.outputStreams.size(),
snowhouse::Equals(expectedOutputs[i]));
});
}
CdoDebug::CdoEndMessage();
});
});
int main(int argc, char **argv) {
CdoDebug::outfile = "chained_debug.txt";
CdoDebug::print_to_seperate_file = true;
CdoDebug::CdoStartMessage();
return bandit::run(argc, argv);
}
#include "bandit/bandit/bandit.h"
#include "bandit/bandit/bandit.h"
#include "../../src/modules.h"
#include "../../src/operator_help.h"
#include "../../src/process.h"
#include <iostream>
void *Test(void *ptr){return ptr;}
void *Test(void *ptr) { return ptr; }
std::vector<std::string> TestHelp = {"TEST", "HELP"};
std::vector<const char *> test_argv{"-test", "in_file","out_file" };
std::vector<const char *> test_argv{"-test", "in_file", "out_file"};
go_bandit([]() {
bandit::describe("Process: 1 input, 1 output", []() {
add_module("Test", {Test, TestHelp, {"test"}, 1,0,1, 2});
add_module("Test", {Test, TestHelp, {"test"}, 1, 0, 1, 2});
createProcesses(test_argv.size(), &test_argv[0]);
......
......@@ -5,15 +5,14 @@
#include "../../src/process.h"
#include <iostream>
void *Test(void *ptr){return ptr;}
void *Test(void *ptr) { return ptr; }
std::vector<std::string> TestHelp = {"TEST", "HELP"};
std::vector<const char *> test_argv{"-test", "in_file","out_file" };
std::vector<const char *> test_argv{"-test", "in_file", "out_file"};
go_bandit([]() {
bandit::describe("Process: 1 input, 1 output", []() {
add_module("Test", {Test, TestHelp, {"test"}, 1,0,1, 1});
add_module("Test", {Test, TestHelp, {"test"}, 1, 0, 1, 1});
createProcesses(test_argv.size(), &test_argv[0]);
......
......@@ -5,8 +5,7 @@
#include "../../src/process.h"
#include <iostream>
void *Info(void *test){return test;}
void *Info(void *test) { return test; }
go_bandit([]() {
bandit::describe("Process creation", []() {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment