2 * Copyright (c) 2013 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.
18 * @file summary_collector.cpp
19 * @author Michal Witanowski (m.witanowski@samsung.com)
21 * @brief Implementation of custom test results collector needed by summary view.
24 #include <summary_collector.h>
28 const char* summaryFileName = "/tmp/security-tests-summary-file";
29 const char* summaryCollectorName = "summary";
32 SummaryCollector::SummaryCollector()
38 // Overrides DPL::Test::TestResultsCollectorBase::Start() virtual method.
39 void SummaryCollector::Start()
41 m_total = m_succeeded = m_failed = m_ignored = 0;
44 // append results to the file
45 void SummaryCollector::Finish()
47 std::ofstream outputFile;
48 outputFile.open(summaryFileName, std::ofstream::out | std::ofstream::app);
50 return; //failed to open file
52 outputFile << m_total << ' '
55 << m_ignored << std::endl;
59 void SummaryCollector::CollectResult(const std::string& /*id*/,
60 const std::string& /*description*/,
61 const FailStatus::Type status,
62 const std::string& /*reason = ""*/,
63 const bool& isPerformanceTest,
64 const std::chrono::system_clock::duration& performanceTime,
65 const std::chrono::system_clock::duration& performanceMaxTime)
67 (void)isPerformanceTest;
68 (void)performanceTime;
69 (void)performanceMaxTime;
71 case FailStatus::IGNORED: ++m_ignored; break;
72 case FailStatus::INTERNAL: // internal error count as fail
73 case FailStatus::FAILED: ++m_failed; break;
74 case FailStatus::NONE: ++m_succeeded; break;
79 void SummaryCollector::CollectResult(const std::string& /*id*/,
80 const std::string& /*description*/,
81 const FailStatus::Type status,
82 const std::string& /*reason = ""*/)
85 case FailStatus::IGNORED: ++m_ignored; break;
86 case FailStatus::INTERNAL: // internal error count as fail
87 case FailStatus::FAILED: ++m_failed; break;
88 case FailStatus::NONE: ++m_succeeded; break;
93 DPL::Test::TestResultsCollectorBase* SummaryCollector::Constructor()
95 return new SummaryCollector();
98 void SummaryCollector::Register()
100 //register custom results collector
101 DPL::Test::TestResultsCollectorBase::RegisterCollectorConstructor(summaryCollectorName,
102 &SummaryCollector::Constructor);