TEST_F(LoadTests, simple_query_with_two_loadops) { std::string q = loadFromFile("test/json/two_loadop_one_unload.json"); const auto& outone = executeAndWait(q); if(outone) { q = loadFromFile("test/json/unload_io.json"); const auto& out = executeAndWait(q); ASSERT_TRUE(!out); } }
TEST_F(LayouterOpsTest, parse_full_scenario_candidate) { std::string data = loadFromFile("test/json/simple_layouter_candidate.json"); const auto& e = executeAndWait(data); std::string header = loadFromFile("test/header/layouter_simple_cand.tbl"); ASSERT_EQ(e->getValue<std::string>(0, 0), header); }
TEST_P(TpcchQueryTest, query_execute_test) { const auto& out = executeAndWait(this->query); ASSERT_TRUE(out != nullptr); EXPECT_RELATION_EQ(out, this->reference()); }
bool executeAndWait(const std::function<void()>& func) { int status; if (!executeAndWait(func, status)) { return false; } return isExecutionSuccessful(status); }
bool executeAndWait(const uid_t uid, const std::vector<std::string>& argv) { int status; if (!executeAndWait(uid, argv, status)) { return false; } return isExecutionSuccessful(status); }
bool executeAndWait(const char* fname, const char* const* argv) { int status; if (!executeAndWait(UNSPEC_UID, fname, argv, status)) { return false; } return isExecutionSuccessful(status); }
TEST_F(JSONTests, parse_papi_badevent_set) { StorageManager::getInstance()->loadTableFile("lin_xxs", "lin_xxs.tbl"); StorageManager::getInstance()->loadTableFile("lin_xxs_comp", "reference/simple_projection.tbl"); std::string q = loadFromFile("test/json/simple_query_with_papi_bad.json"); std::string papi; ASSERT_THROW( { executeAndWait(q, 1, &papi); }, std::runtime_error);
bool executeAndWait(const uid_t uid, const std::vector<std::string>& argv, int& status) { std::vector<const char *> args; args.reserve(argv.size() + 1); for (const auto& arg : argv) { args.push_back(arg.c_str()); } args.push_back(nullptr); return executeAndWait(uid, args[0], args.data(), status); }
TEST_F(JSONTests, parse_papi_event_set) { StorageManager::getInstance()->loadTableFile("lin_xxs", "lin_xxs.tbl"); StorageManager::getInstance()->loadTableFile("lin_xxs_comp", "reference/simple_projection.tbl"); std::string q = loadFromFile("test/json/simple_query_with_papi.json"); std::string papi; const auto& out = executeAndWait(q, 1, &papi); ASSERT_FALSE(!out); ASSERT_TABLE_EQUAL(out, StorageManager::getInstance()->getTable("lin_xxs_comp")); ASSERT_EQ("PAPI_L2_DCM", papi); StorageManager::getInstance()->removeAll(); }
virtual void SetUp() { io::ResourceManager::getInstance().clear(); //convert parameters for test std::string numberString(GetParam()); // load input tables executeAndWait(loadFromFile("test/tpcc/load_tpcc_tables.json")); // load expected output table hyrise::io::StorageManager *sm = hyrise::io::StorageManager::getInstance(); sm->loadTableFile("refTable", "tpcch/query"+numberString+"_result.tbl"); // load query from file query = loadFromFile("test/tpcch/query"+numberString+".json"); }
bool executeAndWait(const std::vector<std::string>& argv) { return executeAndWait(UNSPEC_UID, argv); }
bool executeAndWait(const char* fname, const char* const* argv, int& status) { return executeAndWait(UNSPEC_UID, fname, argv, status); }
bool setupMsvcEnvironmentImpl() { if (getenv("VSINSTALLDIR")) return true; llvm::SmallString<128> tmpFilePath; if (llvm::sys::fs::createTemporaryFile("ldc_dumpEnv", "", tmpFilePath)) return false; /* Run `%ComSpec% /s /c "...\dumpEnv.bat <x86|amd64> > <tmpFilePath>"` to dump * the MSVC environment to the temporary file. * * cmd.exe /c treats the following string argument (the command) * in a very peculiar way if it starts with a double-quote. * By adding /s and enclosing the command in extra double-quotes * (WITHOUT additionally escaping the command), the command will * be parsed properly. */ auto comspecEnv = getenv("ComSpec"); if (!comspecEnv) { warning(Loc(), "'ComSpec' environment variable is not set, assuming 'cmd.exe'."); comspecEnv = "cmd.exe"; } std::string cmdExecutable = comspecEnv; std::string batchFile = exe_path::prependBinDir("dumpEnv.bat"); std::string arch = global.params.targetTriple->isArch64Bit() ? "amd64" : "x86"; llvm::SmallString<512> commandLine; commandLine += quoteArg(cmdExecutable); commandLine += " /s /c \""; commandLine += quoteArg(batchFile); commandLine += ' '; commandLine += arch; commandLine += " > "; commandLine += quoteArg(tmpFilePath); commandLine += '"'; const int exitCode = executeAndWait(commandLine.c_str()); if (exitCode != 0) { error(Loc(), "`%s` failed with status: %d", commandLine.c_str(), exitCode); llvm::sys::fs::remove(tmpFilePath); return false; } auto fileBuffer = llvm::MemoryBuffer::getFile(tmpFilePath); llvm::sys::fs::remove(tmpFilePath); if (fileBuffer.getError()) return false; const auto contents = (*fileBuffer)->getBuffer(); const auto size = contents.size(); // Parse the file. std::vector<std::pair<llvm::StringRef, llvm::StringRef>> env; size_t i = 0; // for each line while (i < size) { llvm::StringRef key, value; for (size_t j = i; j < size; ++j) { const char c = contents[j]; if (c == '=' && key.empty()) { key = contents.slice(i, j); i = j + 1; } else if (c == '\n' || c == '\r' || c == '\0') { if (!key.empty()) { value = contents.slice(i, j); } // break and continue with next line i = j + 1; break; } } if (!key.empty() && !value.empty()) env.emplace_back(key, value); } if (global.params.verbose) fprintf(global.stdmsg, "Applying environment variables:\n"); bool haveVsInstallDir = false; for (const auto &pair : env) { const std::string key = pair.first.str(); const std::string value = pair.second.str(); if (global.params.verbose) fprintf(global.stdmsg, " %s=%s\n", key.c_str(), value.c_str()); SetEnvironmentVariableA(key.c_str(), value.c_str()); if (key == "VSINSTALLDIR") haveVsInstallDir = true; } return haveVsInstallDir; }
TEST_F(LoadTests, simple_query_with_load_with_header) { std::string q = loadFromFile("test/json/simple_query_load_with_header.json"); const auto& out = executeAndWait(q); ASSERT_TRUE((bool)out); StorageManager::getInstance()->removeAll(); }
TEST_F(LoadTests, simple_query_with_load_with_header) { std::string q = loadFromFile("test/json/simple_query_load_with_header.json"); const auto& out = executeAndWait(q); ASSERT_TRUE((bool)out); }
TEST_F(LoadTests, load_exception) { std::string q = loadFromFile("test/json/load_exception.json"); ASSERT_THROW( { executeAndWait(q); }, std::runtime_error);
TEST_F(LayouterOpsTest, load_layout_replace) { std::string data = loadFromFile("test/json/load_layout_replace.json"); const auto& e = executeAndWait(data); ASSERT_EQ(e->partitionCount(), 3u); ASSERT_EQ(3u, StorageManager::getInstance()->getTable("revenue")->partitionCount()); }