2 * Copyright (c) 2014-2015 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 * @file test_results_collector_summary.cpp
18 * @author Marcin Niesluchowski (m.niesluchow@samsung.com)
19 * @author Michal Witanowski (m.witanowski@samsung.com)
21 * @brief Source file containing SummaryCollector class definition.
24 #include <dpl/availability.h>
25 #include <dpl/log/log.h>
26 #include <dpl/test/test_results_collector_commons.h>
28 #include "dpl/test/test_results_collector_summary.h"
35 const std::string DEFAULT_SUMMARY_FILE_NAME = "summary.txt";
39 SummaryCollector::SummaryCollector()
40 : m_filename(DEFAULT_SUMMARY_FILE_NAME)
44 TestResultsCollectorBase* SummaryCollector::Constructor()
46 return new SummaryCollector();
49 std::string SummaryCollector::CollectorSpecificHelp() const
51 return CollectorFileHelp(DEFAULT_SUMMARY_FILE_NAME);
54 bool SummaryCollector::ParseCollectorSpecificArg(const std::string& arg)
56 return ParseCollectorFileArg(arg, m_filename);
59 void SummaryCollector::Start()
64 void SummaryCollector::CollectResult(const std::string& id, const TestResult &result)
68 m_stats.AddTest(result.GetFailStatus());
72 void SummaryCollector::Finish()
77 void SummaryCollector::writeStats(bool segfault)
79 m_output.open(m_filename.c_str(), std::ofstream::out | std::ofstream::trunc);
81 LogPedantic("Could not open file " << m_filename << " for writing");
84 m_output << m_stats.GetTotal() << ' '
85 << m_stats.GetPassed() << ' '
86 << m_stats.GetFailed() << ' '
87 << m_stats.GetIgnored() << (segfault ? " segfault" : "");
89 LogPedantic("Writing to " << m_filename << " file failed");
92 LogPedantic("Failed to close " << m_filename << " file");