blob: 1a5cd24def52f24f46c1d0a328ee55b29b77da7c [file] [log] [blame]
/*
* The MIT License (MIT)
*
* Copyright (c) 2015 Microsoft Corporation
*
* -=- Robust Distributed System Nucleus (rDSN) -=-
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#include <gtest/gtest.h>
#include <chrono>
#include <string>
#include <thread>
#include <vector>
#include "common/replication_common.h"
#include "runtime/app_model.h"
#include "runtime/service_app.h"
#include "utils/error_code.h"
int g_test_count = 0;
int g_test_ret = 0;
class gtest_app : public dsn::service_app
{
public:
explicit gtest_app(const dsn::service_app_info *info) : ::dsn::service_app(info) {}
dsn::error_code start(const std::vector<std::string> &args) override
{
g_test_ret = RUN_ALL_TESTS();
g_test_count = 1;
return dsn::ERR_OK;
}
dsn::error_code stop(bool) override { return dsn::ERR_OK; }
};
GTEST_API_ int main(int argc, char **argv)
{
testing::InitGoogleTest(&argc, argv);
dsn::service_app::register_factory<gtest_app>(
dsn::replication::replication_options::kReplicaAppType.c_str());
dsn_run_config("config-test.ini", false);
while (g_test_count == 0) {
std::this_thread::sleep_for(std::chrono::seconds(1));
}
dsn_exit(g_test_ret);
}