Add --no-verbose option to HTML collector
[platform/core/test/security-tests.git] / src / framework / src / test_results_collector_commons.cpp
1 /*
2  * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
3  *
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
7  *
8  *        http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16 /*
17  * @file        test_results_collector_commons.cpp
18  * @author      Lukasz Wrzosek (l.wrzosek@samsung.com)
19  * @author      Marcin Niesluchowski (m.niesluchow@samsung.com)
20  * @version     1.0
21  * @brief       Source file containing definitions of collectors common
22  *              functions
23  */
24
25 #include "dpl/test/test_results_collector_commons.h"
26
27 namespace DPL {
28 namespace Test {
29
30 namespace {
31
32 const std::string NO_VERBOSE_ARG = "--no-verbose";
33
34 } // namespace
35
36 const std::string COLLECTOR_NO_VERBOSE_HELP =
37         NO_VERBOSE_ARG                          + " - turns off verbosity\n" +
38         std::string(NO_VERBOSE_ARG.size(), ' ') + "   verbosity turned on by default\n";
39
40 double get_milliseconds (const std::chrono::system_clock::duration& performanceTime)
41 {
42     return (static_cast<double>(std::chrono::duration_cast<std::chrono::microseconds>
43             (performanceTime).count()))/1000.0;
44 }
45
46 std::string CollectorFileHelp(const std::string &defaultFilename)
47 {
48     return "--file=<filename> - name of file for output\n"
49            "                    default - " + defaultFilename + "\n";
50 }
51
52 bool ParseCollectorFileArg(const std::string &arg, std::string &filename)
53 {
54     const std::string argname = "--file=";
55     if (arg.find(argname) == 0 ) {
56         filename = arg.substr(argname.size());
57         return true;
58     }
59     return false;
60 }
61
62 bool ParseCollectorNoVerboseArg(const std::string &arg, bool &verbosity)
63 {
64     if (arg != NO_VERBOSE_ARG)
65         return false;
66     verbosity=false;
67     return true;
68 }
69
70 } // namespace Test
71 } // namespace DPL
72