2012-12-28 15:40:03 +00:00
|
|
|
/*!
|
|
|
|
* \file single_test_main.cc
|
|
|
|
* \brief This file contains the main function for tests (used with CTest).
|
|
|
|
* \author Carles Fernandez-Prades, 2012. cfernandez(at)cttc.es
|
|
|
|
*
|
|
|
|
*
|
2020-07-28 14:57:15 +00:00
|
|
|
* -----------------------------------------------------------------------------
|
2012-12-28 15:40:03 +00:00
|
|
|
*
|
2020-12-30 12:35:06 +00:00
|
|
|
* GNSS-SDR is a Global Navigation Satellite System software-defined receiver.
|
2012-12-28 15:40:03 +00:00
|
|
|
* This file is part of GNSS-SDR.
|
|
|
|
*
|
2020-12-30 12:35:06 +00:00
|
|
|
* Copyright (C) 2010-2020 (see AUTHORS file for a list of contributors)
|
2020-02-08 00:20:02 +00:00
|
|
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
2012-12-28 15:40:03 +00:00
|
|
|
*
|
2020-07-28 14:57:15 +00:00
|
|
|
* -----------------------------------------------------------------------------
|
2012-12-28 15:40:03 +00:00
|
|
|
*/
|
|
|
|
|
2019-03-05 18:31:41 +00:00
|
|
|
|
2014-03-16 19:58:29 +00:00
|
|
|
#include "concurrent_map.h"
|
2018-12-09 21:00:09 +00:00
|
|
|
#include "concurrent_queue.h"
|
2024-06-23 09:10:40 +00:00
|
|
|
#include "gnss_sdr_flags.h"
|
2024-07-23 15:32:47 +00:00
|
|
|
#include "gps_acq_assist.h"
|
2018-02-26 02:15:53 +00:00
|
|
|
#include <gtest/gtest.h>
|
2024-04-29 06:27:33 +00:00
|
|
|
#include <fstream>
|
2018-02-26 02:15:53 +00:00
|
|
|
#include <iostream>
|
2024-04-29 06:27:33 +00:00
|
|
|
#include <ostream>
|
|
|
|
#include <string>
|
2018-02-26 02:15:53 +00:00
|
|
|
|
2024-04-29 06:27:33 +00:00
|
|
|
#if USE_GLOG_AND_GFLAGS
|
|
|
|
#include <gflags/gflags.h>
|
|
|
|
#include <glog/logging.h>
|
2020-08-13 18:54:22 +00:00
|
|
|
#if GFLAGS_OLD_NAMESPACE
|
|
|
|
namespace gflags
|
|
|
|
{
|
|
|
|
using namespace google;
|
|
|
|
}
|
2024-04-29 06:27:33 +00:00
|
|
|
DECLARE_string(log_dir);
|
2020-08-13 18:54:22 +00:00
|
|
|
#endif
|
2024-04-29 06:27:33 +00:00
|
|
|
#else
|
|
|
|
#include <absl/flags/flag.h>
|
|
|
|
#include <absl/flags/parse.h>
|
2024-05-01 10:14:06 +00:00
|
|
|
#include <absl/log/flags.h>
|
2024-04-29 06:27:33 +00:00
|
|
|
#include <absl/log/initialize.h>
|
|
|
|
#include <absl/log/log.h>
|
|
|
|
#include <absl/log/log_sink.h>
|
|
|
|
#include <absl/log/log_sink_registry.h>
|
|
|
|
class TestLogSink : public absl::LogSink
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
TestLogSink()
|
|
|
|
{
|
|
|
|
if (!absl::GetFlag(FLAGS_log_dir).empty())
|
|
|
|
{
|
|
|
|
logfile.open(absl::GetFlag(FLAGS_log_dir) + "/test.log");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
logfile.open(GetTempDir() + "/test.log");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
void Send(const absl::LogEntry &entry) override
|
|
|
|
{
|
|
|
|
logfile << entry.text_message_with_prefix_and_newline() << std::flush;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
std::ofstream logfile;
|
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
2018-02-26 02:15:53 +00:00
|
|
|
|
2019-02-22 09:47:24 +00:00
|
|
|
Concurrent_Queue<Gps_Acq_Assist> global_gps_acq_assist_queue;
|
2012-12-28 15:40:03 +00:00
|
|
|
|
2019-02-22 09:47:24 +00:00
|
|
|
Concurrent_Map<Gps_Acq_Assist> global_gps_acq_assist_map;
|
2013-11-15 17:45:24 +00:00
|
|
|
|
|
|
|
|
2012-12-28 15:40:03 +00:00
|
|
|
int main(int argc, char **argv)
|
|
|
|
{
|
2024-04-29 06:27:33 +00:00
|
|
|
#if USE_GLOG_AND_GFLAGS
|
2017-06-07 15:32:37 +00:00
|
|
|
try
|
2018-03-03 01:03:39 +00:00
|
|
|
{
|
2017-06-07 15:32:37 +00:00
|
|
|
testing::InitGoogleTest(&argc, argv);
|
2024-02-20 14:52:30 +00:00
|
|
|
gflags::ParseCommandLineFlags(&argc, &argv, true);
|
2018-03-03 01:03:39 +00:00
|
|
|
}
|
|
|
|
catch (...)
|
|
|
|
{
|
|
|
|
} // catch the "testing::internal::<unnamed>::ClassUniqueToAlwaysTrue" from gtest
|
2024-04-29 06:27:33 +00:00
|
|
|
#else
|
|
|
|
absl::ParseCommandLine(argc, argv);
|
|
|
|
try
|
|
|
|
{
|
|
|
|
testing::InitGoogleTest(&argc, argv);
|
|
|
|
}
|
|
|
|
catch (...)
|
|
|
|
{
|
|
|
|
} // catch the "testing::internal::<unnamed>::ClassUniqueToAlwaysTrue" from gtest
|
|
|
|
absl::LogSink *testLogSink = new TestLogSink;
|
|
|
|
absl::AddLogSink(testLogSink);
|
|
|
|
absl::InitializeLog();
|
|
|
|
#endif
|
2017-02-15 21:10:06 +00:00
|
|
|
int res = 0;
|
|
|
|
try
|
2018-03-03 01:03:39 +00:00
|
|
|
{
|
2017-02-15 21:10:06 +00:00
|
|
|
res = RUN_ALL_TESTS();
|
2018-03-03 01:03:39 +00:00
|
|
|
}
|
|
|
|
catch (...)
|
|
|
|
{
|
2017-02-15 21:10:06 +00:00
|
|
|
LOG(WARNING) << "Unexpected catch";
|
2018-03-03 01:03:39 +00:00
|
|
|
}
|
2024-04-29 06:27:33 +00:00
|
|
|
#if USE_GLOG_AND_GFLAGS
|
2020-08-13 18:54:22 +00:00
|
|
|
gflags::ShutDownCommandLineFlags();
|
2024-04-29 06:27:33 +00:00
|
|
|
#else
|
|
|
|
absl::FlushLogSinks();
|
|
|
|
#endif
|
2017-02-15 21:10:06 +00:00
|
|
|
return res;
|
2012-12-28 15:40:03 +00:00
|
|
|
}
|