• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include <hwext/gtest-ext.h>
17 #include <hwext/gtest-tag.h>
18 #include <fcntl.h>
19 #include <fstream>
20 #include <iostream>
21 #include <string>
22 #include <unistd.h>
23 
24 #include "file.h"
25 #include "trace_streamer_selector.h"
26 
27 using namespace testing::ext;
28 using namespace SysTuning::TraceStreamer;
29 namespace SysTuning {
30 namespace TraceStreamer {
31 class QueryFileTest : public ::testing::Test {
32 protected:
SetUp()33     void SetUp() {}
TearDown()34     void TearDown() {}
35 };
36 
37 /**
38  * @tc.name: QuerySingleSqlWithFile
39  * @tc.desc: Query single sql with file
40  * @tc.type: FUNC
41  */
42 HWTEST_F(QueryFileTest, QuerySingleSqlWithFile, TestSize.Level1)
43 {
44     TS_LOGE("test41-1");
45     std::string sqlOperatorFilePath = "../../test/resource/query_single_file.sql";
46     std::string traceFilePath = "../../test/resource/trace_small_10.systrace";
47     TraceStreamerSelector ts;
48     ts.EnableMetaTable(false);
49     ts.SetCleanMode(false);
50     EXPECT_EQ(ts.ReadSqlFileAndPrintResult(sqlOperatorFilePath), true);
51 }
52 
53 /**
54  * @tc.name: QuerySqlWithFile
55  * @tc.desc: Query Sql With File
56  * @tc.type: FUNC
57  */
58 HWTEST_F(QueryFileTest, QueryMultiSqlWithFile, TestSize.Level1)
59 {
60     TS_LOGE("test41-2");
61     std::string sqlOperatorFilePath = "../../test/resource/query_multi_file.sql";
62     std::string traceFilePath = "../../test/resource/trace_small_10.systrace";
63     TraceStreamerSelector ts;
64     ts.EnableMetaTable(false);
65     ts.SetCleanMode(false);
66     EXPECT_EQ(ts.ReadSqlFileAndPrintResult(sqlOperatorFilePath), true);
67 }
68 
69 /**
70  * @tc.name: QuerySqlWithFile
71  * @tc.desc: Query Sql With File
72  * @tc.type: FUNC
73  */
74 HWTEST_F(QueryFileTest, QuerySingleSqlWithNoSpaceFile, TestSize.Level1)
75 {
76     TS_LOGE("test41-3");
77     std::string sqlOperatorFilePath = "../../test/resource/query_single_file_no_space.sql";
78     std::string traceFilePath = "../../test/resource/trace_small_10.systrace";
79     TraceStreamerSelector ts;
80     ts.EnableMetaTable(false);
81     ts.SetCleanMode(false);
82     EXPECT_EQ(ts.ReadSqlFileAndPrintResult(sqlOperatorFilePath), true);
83 }
84 
85 /**
86  * @tc.name: QuerySqlWithFile
87  * @tc.desc: Query Sql With File
88  * @tc.type: FUNC
89  */
90 HWTEST_F(QueryFileTest, QueryMultiSqlWithNoSpaceFile, TestSize.Level1)
91 {
92     TS_LOGE("test41-4");
93     std::string sqlOperatorFilePath = "../../test/resource/query_multi_file_no_space.sql";
94     std::string traceFilePath = "../../test/resource/trace_small_10.systrace";
95     TraceStreamerSelector ts;
96     ts.EnableMetaTable(false);
97     ts.SetCleanMode(false);
98     EXPECT_EQ(ts.ReadSqlFileAndPrintResult(sqlOperatorFilePath), true);
99 }
100 } // namespace TraceStreamer
101 } // namespace SysTuning
102