• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved.
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 
19 #include "clock_filter_ex.h"
20 #include "trace_data_cache.h"
21 #include "trace_streamer_filters.h"
22 
23 using namespace testing::ext;
24 using namespace SysTuning::TraceStreamer;
25 namespace SysTuning {
26 namespace TraceStreamer {
27 const uint64_t TS_BOOT_TIME = 100;
28 const uint64_t TS_MONOTONIC_TIME = 200;
29 const uint64_t TS_REAL_TIME = 300;
30 const uint64_t TS_REAL_TIME_COARSE_TIME = 400;
31 const uint64_t TS_SECOND_BOOT_TIME = 200;
32 const uint64_t TS_SECOND_MONOTONIC_TIME = 350;
33 const uint64_t TS_SECOND_REAL_TIME = 400;
34 const uint64_t TS_SECOND_REAL_TIME_COARSE_TIME = 800;
35 
36 class ClockFilterTest : public ::testing::Test {
37 public:
SetUp()38     void SetUp()
39     {
40         streamFilters_.clockFilter_ = std::make_unique<ClockFilterEx>(&traceDataCache_, &streamFilters_);
41     }
42 
TearDown()43     void TearDown() {}
44 
45 public:
46     SysTuning::TraceStreamer::TraceStreamerFilters streamFilters_;
47     SysTuning::TraceStreamer::TraceDataCache traceDataCache_;
48 };
49 
50 /**
51  * @tc.name: ConvertBoottimeToMonitonicTime
52  * @tc.desc: convert Boottime to MonitonicTime
53  * @tc.type: FUNC
54  */
55 HWTEST_F(ClockFilterTest, ConvertBoottimeToMonitonicTime, TestSize.Level1)
56 {
57     TS_LOGI("test3-1");
58     std::vector<SnapShot> snapShot0;
59     snapShot0.push_back({TS_CLOCK_BOOTTIME, TS_BOOT_TIME});
60     snapShot0.push_back({TS_MONOTONIC, TS_MONOTONIC_TIME});
61     streamFilters_.clockFilter_->AddClockSnapshot(snapShot0);
62 
63     uint64_t time1 = 150;
64     uint64_t expectTime1 = 250;
65     EXPECT_EQ(streamFilters_.clockFilter_->Convert(TS_CLOCK_BOOTTIME, time1, TS_MONOTONIC), expectTime1);
66 }
67 
68 /**
69  * @tc.name: ConvertBoottimeToMonitonicTimeTwice
70  * @tc.desc: convert twice Boottime to MonitonicTime
71  * @tc.type: FUNC
72  */
73 HWTEST_F(ClockFilterTest, ConvertBoottimeToMonitonicTimeTwice, TestSize.Level1)
74 {
75     TS_LOGI("test3-2");
76     std::vector<SnapShot> snapShot0;
77     snapShot0.push_back({TS_CLOCK_BOOTTIME, TS_BOOT_TIME});
78     snapShot0.push_back({TS_MONOTONIC, TS_MONOTONIC_TIME});
79     streamFilters_.clockFilter_->AddClockSnapshot(snapShot0);
80 
81     uint64_t time1 = 150;
82     uint64_t expectTime1 = 250;
83     EXPECT_EQ(streamFilters_.clockFilter_->Convert(TS_CLOCK_BOOTTIME, time1, TS_MONOTONIC), expectTime1);
84     uint64_t time2 = 200;
85     uint64_t expectTime2 = 300;
86     EXPECT_EQ(streamFilters_.clockFilter_->Convert(TS_CLOCK_BOOTTIME, time2, TS_MONOTONIC), expectTime2);
87 }
88 
89 /**
90  * @tc.name: ConvertTimestampInvalid
91  * @tc.desc: Convert timeStamp invalid
92  * @tc.type: FUNC
93  */
94 HWTEST_F(ClockFilterTest, ConvertTimestampInvalid, TestSize.Level1)
95 {
96     TS_LOGI("test3-3");
97     std::vector<SnapShot> snapShot0;
98     snapShot0.push_back({TS_CLOCK_BOOTTIME, TS_BOOT_TIME});
99     snapShot0.push_back({TS_MONOTONIC, TS_MONOTONIC_TIME});
100     streamFilters_.clockFilter_->AddClockSnapshot(snapShot0);
101 
102     std::vector<SnapShot> snapShot1;
103     snapShot1.push_back({TS_CLOCK_BOOTTIME, TS_SECOND_BOOT_TIME});
104     snapShot1.push_back({TS_MONOTONIC, TS_SECOND_MONOTONIC_TIME});
105     streamFilters_.clockFilter_->AddClockSnapshot(snapShot1);
106     uint64_t time2 = 200;
107     uint64_t expectTime2 = 200;
108     EXPECT_EQ(streamFilters_.clockFilter_->Convert(TS_CLOCK_BOOTTIME, time2, TS_CLOCK_REALTIME), expectTime2);
109 }
110 
111 /**
112  * @tc.name: ConvertTimestampBoottimeToRealtime
113  * @tc.desc: convert Boottime to Realtime
114  * @tc.type: FUNC
115  */
116 HWTEST_F(ClockFilterTest, ConvertTimestampBoottimeToRealtime, TestSize.Level1)
117 {
118     TS_LOGI("test3-4");
119     std::vector<SnapShot> snapShot0;
120     snapShot0.push_back({TS_CLOCK_BOOTTIME, TS_BOOT_TIME});
121     snapShot0.push_back({TS_CLOCK_REALTIME, TS_REAL_TIME});
122     streamFilters_.clockFilter_->AddClockSnapshot(snapShot0);
123 
124     std::vector<SnapShot> snapShot1;
125     snapShot1.push_back({TS_CLOCK_BOOTTIME, TS_SECOND_BOOT_TIME});
126     snapShot1.push_back({TS_CLOCK_REALTIME, TS_SECOND_REAL_TIME});
127     streamFilters_.clockFilter_->AddClockSnapshot(snapShot1);
128     uint64_t time3 = 101;
129     uint64_t expectTime3 = 301;
130     EXPECT_EQ(streamFilters_.clockFilter_->Convert(TS_CLOCK_BOOTTIME, time3, TS_CLOCK_REALTIME), expectTime3);
131 }
132 
133 /**
134  * @tc.name: ConvertBoottimeToRealtimeTwiceWithTwoSnapShot
135  * @tc.desc: convert Boottime to Realtime twice with two snapShot
136  * @tc.type: FUNC
137  */
138 HWTEST_F(ClockFilterTest, ConvertBoottimeToRealtimeTwiceWithTwoSnapShot, TestSize.Level1)
139 {
140     TS_LOGI("test3-5");
141     std::vector<SnapShot> snapShot0;
142     snapShot0.push_back({TS_CLOCK_BOOTTIME, TS_BOOT_TIME});
143     snapShot0.push_back({TS_CLOCK_REALTIME, TS_REAL_TIME});
144     streamFilters_.clockFilter_->AddClockSnapshot(snapShot0);
145 
146     std::vector<SnapShot> snapShot1;
147     snapShot1.push_back({TS_CLOCK_BOOTTIME, TS_SECOND_BOOT_TIME});
148     snapShot1.push_back({TS_CLOCK_REALTIME, TS_SECOND_REAL_TIME});
149     streamFilters_.clockFilter_->AddClockSnapshot(snapShot1);
150     uint64_t time3 = 101;
151     uint64_t expectTime3 = 301;
152     EXPECT_EQ(streamFilters_.clockFilter_->Convert(TS_CLOCK_BOOTTIME, time3, TS_CLOCK_REALTIME), expectTime3);
153     time3 = 201;
154     expectTime3 = 401;
155     EXPECT_EQ(streamFilters_.clockFilter_->Convert(TS_CLOCK_BOOTTIME, time3, TS_CLOCK_REALTIME), expectTime3);
156 }
157 
158 /**
159  * @tc.name: ConvertBoottimeToRealtimeWithSingleSnapShot
160  * @tc.desc: convert Boottime to Realtime twice with single snapShot
161  * @tc.type: FUNC
162  */
163 HWTEST_F(ClockFilterTest, ConvertBoottimeToRealtimeWithSingleSnapShot, TestSize.Level1)
164 {
165     TS_LOGI("test3-6");
166     std::vector<SnapShot> snapShot0;
167     snapShot0.push_back({TS_CLOCK_BOOTTIME, TS_BOOT_TIME});
168     snapShot0.push_back({TS_CLOCK_REALTIME, TS_REAL_TIME});
169     streamFilters_.clockFilter_->AddClockSnapshot(snapShot0);
170 
171     uint64_t time3 = 101;
172     uint64_t expectTime3 = 301;
173     EXPECT_EQ(streamFilters_.clockFilter_->Convert(TS_CLOCK_BOOTTIME, time3, TS_CLOCK_REALTIME), expectTime3);
174     time3 = 201;
175     expectTime3 = 401;
176     EXPECT_EQ(streamFilters_.clockFilter_->Convert(TS_CLOCK_BOOTTIME, time3, TS_CLOCK_REALTIME), expectTime3);
177 }
178 
179 /**
180  * @tc.name: ConvertRealtimeToBoottime
181  * @tc.desc: convert Realtime to Boottime with single snapShot
182  * @tc.type: FUNC
183  */
184 HWTEST_F(ClockFilterTest, ConvertRealtimeToBoottime, TestSize.Level1)
185 {
186     TS_LOGI("test3-7");
187     std::vector<SnapShot> snapShot0;
188     snapShot0.push_back({TS_CLOCK_BOOTTIME, TS_BOOT_TIME});
189     snapShot0.push_back({TS_CLOCK_REALTIME, TS_REAL_TIME});
190     streamFilters_.clockFilter_->AddClockSnapshot(snapShot0);
191     uint64_t time7 = 301;
192     uint64_t expectTime7 = 101;
193     EXPECT_EQ(streamFilters_.clockFilter_->Convert(TS_CLOCK_REALTIME, time7, TS_CLOCK_BOOTTIME), expectTime7);
194 }
195 
196 /**
197  * @tc.name: ConvertRealtimeToBoottimeTwice
198  * @tc.desc: convert Realtime to Boottime twice with single snapShot
199  * @tc.type: FUNC
200  */
201 HWTEST_F(ClockFilterTest, ConvertRealtimeToBoottimeTwice, TestSize.Level1)
202 {
203     TS_LOGI("test3-8");
204     std::vector<SnapShot> snapShot0;
205     snapShot0.push_back({TS_CLOCK_BOOTTIME, TS_BOOT_TIME});
206     snapShot0.push_back({TS_CLOCK_REALTIME, TS_REAL_TIME});
207     streamFilters_.clockFilter_->AddClockSnapshot(snapShot0);
208     uint64_t time7 = 301;
209     uint64_t expectTime7 = 101;
210     EXPECT_EQ(streamFilters_.clockFilter_->Convert(TS_CLOCK_REALTIME, time7, TS_CLOCK_BOOTTIME), expectTime7);
211     time7 = 501;
212     expectTime7 = 301;
213     EXPECT_EQ(streamFilters_.clockFilter_->Convert(TS_CLOCK_REALTIME, time7, TS_CLOCK_BOOTTIME), expectTime7);
214 }
215 
216 /**
217  * @tc.name: ConvertRealtimeToBoottimeTwiceWithTwoSnapshot
218  * @tc.desc: convert Realtime to Boottime twice with two snapShot
219  * @tc.type: FUNC
220  */
221 HWTEST_F(ClockFilterTest, ConvertRealtimeToBoottimeTwiceWithTwoSnapshot, TestSize.Level1)
222 {
223     TS_LOGI("test3-9");
224     std::vector<SnapShot> snapShot0;
225     snapShot0.push_back({TS_CLOCK_BOOTTIME, TS_BOOT_TIME});
226     snapShot0.push_back({TS_CLOCK_REALTIME, TS_REAL_TIME});
227     streamFilters_.clockFilter_->AddClockSnapshot(snapShot0);
228 
229     std::vector<SnapShot> snapShot1;
230     snapShot1.push_back({TS_CLOCK_BOOTTIME, TS_SECOND_BOOT_TIME});
231     snapShot1.push_back({TS_CLOCK_REALTIME, TS_SECOND_REAL_TIME});
232     streamFilters_.clockFilter_->AddClockSnapshot(snapShot1);
233     uint64_t time7 = 401;
234     uint64_t expectTime7 = 201;
235     EXPECT_EQ(streamFilters_.clockFilter_->Convert(TS_CLOCK_REALTIME, time7, TS_CLOCK_BOOTTIME), expectTime7);
236     time7 = 301;
237     expectTime7 = 101;
238     EXPECT_EQ(streamFilters_.clockFilter_->Convert(TS_CLOCK_REALTIME, time7, TS_CLOCK_BOOTTIME), expectTime7);
239 }
240 
241 /**
242  * @tc.name: ConvertTimestamp
243  * @tc.desc: muti type timeStamp convert
244  * @tc.type: FUNC
245  */
246 HWTEST_F(ClockFilterTest, ConvertTimestamp, TestSize.Level1)
247 {
248     TS_LOGI("test3-10");
249     std::vector<SnapShot> snapShot0;
250     snapShot0.push_back({TS_CLOCK_BOOTTIME, TS_BOOT_TIME});
251     snapShot0.push_back({TS_MONOTONIC, TS_MONOTONIC_TIME});
252     snapShot0.push_back({TS_CLOCK_REALTIME, TS_REAL_TIME});
253     snapShot0.push_back({TS_CLOCK_REALTIME_COARSE, TS_REAL_TIME_COARSE_TIME});
254     streamFilters_.clockFilter_->AddClockSnapshot(snapShot0);
255 
256     std::vector<SnapShot> snapShot1;
257     snapShot1.push_back({TS_CLOCK_BOOTTIME, TS_SECOND_BOOT_TIME});
258     snapShot1.push_back({TS_MONOTONIC, TS_SECOND_MONOTONIC_TIME});
259     snapShot1.push_back({TS_CLOCK_REALTIME, TS_SECOND_REAL_TIME});
260     snapShot1.push_back({TS_CLOCK_REALTIME_COARSE, TS_SECOND_REAL_TIME_COARSE_TIME});
261     streamFilters_.clockFilter_->AddClockSnapshot(snapShot1);
262     uint64_t time1 = 150;
263     uint64_t expectTime1 = 250;
264     EXPECT_EQ(streamFilters_.clockFilter_->Convert(TS_CLOCK_BOOTTIME, time1, TS_MONOTONIC), expectTime1);
265     uint64_t time2 = 200;
266     uint64_t expectTime2 = 350;
267     EXPECT_EQ(streamFilters_.clockFilter_->Convert(TS_CLOCK_BOOTTIME, time2, TS_MONOTONIC), expectTime2);
268     uint64_t time3 = 101;
269     uint64_t expectTime3 = 301;
270     EXPECT_EQ(streamFilters_.clockFilter_->Convert(TS_CLOCK_BOOTTIME, time3, TS_CLOCK_REALTIME), expectTime3);
271     uint64_t time4 = 102;
272     uint64_t expectTime4 = 402;
273     EXPECT_EQ(streamFilters_.clockFilter_->Convert(TS_CLOCK_BOOTTIME, time4, TS_CLOCK_REALTIME_COARSE), expectTime4);
274     uint64_t time5 = 102;
275     uint64_t expectTime5 = 202;
276     EXPECT_EQ(streamFilters_.clockFilter_->Convert(TS_MONOTONIC, time5, TS_CLOCK_REALTIME), expectTime5);
277     uint64_t time6 = 351;
278     uint64_t expectTime6 = 251;
279     EXPECT_EQ(streamFilters_.clockFilter_->Convert(TS_CLOCK_REALTIME, time6, TS_MONOTONIC), expectTime6);
280     uint64_t time7 = 401;
281     uint64_t expectTime7 = 351;
282     EXPECT_EQ(streamFilters_.clockFilter_->Convert(TS_CLOCK_REALTIME, time7, TS_MONOTONIC), expectTime7);
283     uint64_t time8 = 150;
284     uint64_t expectTime8 = 50;
285     EXPECT_EQ(streamFilters_.clockFilter_->Convert(TS_MONOTONIC, time8, TS_CLOCK_BOOTTIME), expectTime8);
286     uint64_t time9 = 250;
287     uint64_t expectTime9 = 150;
288     EXPECT_EQ(streamFilters_.clockFilter_->Convert(TS_MONOTONIC, time9, TS_CLOCK_BOOTTIME), expectTime9);
289     uint64_t time10 = 351;
290     uint64_t expectTime10 = 201;
291     EXPECT_EQ(streamFilters_.clockFilter_->Convert(TS_MONOTONIC, time10, TS_CLOCK_BOOTTIME), expectTime10);
292 }
293 
294 /**
295  * @tc.name: ConvertToPrimary
296  * @tc.desc: set realtime as primary time type, and convert boottime to Primary time type
297  * @tc.type: FUNC
298  */
299 HWTEST_F(ClockFilterTest, ConvertToPrimary, TestSize.Level1)
300 {
301     TS_LOGI("test3-11");
302     std::vector<SnapShot> snapShot0;
303     snapShot0.push_back({TS_CLOCK_BOOTTIME, TS_BOOT_TIME});
304     snapShot0.push_back({TS_CLOCK_REALTIME, TS_REAL_TIME});
305     streamFilters_.clockFilter_->AddClockSnapshot(snapShot0);
306 
307     std::vector<SnapShot> snapShot1;
308     snapShot1.push_back({TS_CLOCK_BOOTTIME, TS_SECOND_BOOT_TIME});
309     snapShot1.push_back({TS_CLOCK_REALTIME, TS_SECOND_REAL_TIME});
310     streamFilters_.clockFilter_->AddClockSnapshot(snapShot1);
311 
312     streamFilters_.clockFilter_->SetPrimaryClock(TS_CLOCK_REALTIME);
313     uint64_t time1 = 150;
314     uint64_t expectTime1 = 350;
315     EXPECT_EQ(streamFilters_.clockFilter_->ToPrimaryTraceTime(TS_CLOCK_BOOTTIME, time1), expectTime1);
316 }
317 
318 /**
319  * @tc.name: ConvertToPrimaryTwice
320  * @tc.desc: set realtime as primary time type, and convert boottime to Primary time type twice
321  * @tc.type: FUNC
322  */
323 HWTEST_F(ClockFilterTest, ConvertToPrimaryTwice, TestSize.Level1)
324 {
325     TS_LOGI("test3-12");
326     std::vector<SnapShot> snapShot0;
327     snapShot0.push_back({TS_CLOCK_BOOTTIME, TS_BOOT_TIME});
328     snapShot0.push_back({TS_CLOCK_REALTIME, TS_REAL_TIME});
329     streamFilters_.clockFilter_->AddClockSnapshot(snapShot0);
330 
331     std::vector<SnapShot> snapShot1;
332     snapShot1.push_back({TS_CLOCK_BOOTTIME, TS_SECOND_BOOT_TIME});
333     snapShot1.push_back({TS_CLOCK_REALTIME, TS_SECOND_REAL_TIME});
334     streamFilters_.clockFilter_->AddClockSnapshot(snapShot1);
335 
336     streamFilters_.clockFilter_->SetPrimaryClock(TS_CLOCK_BOOTTIME);
337     uint64_t time1 = 350;
338     uint64_t expectTime1 = 150;
339     EXPECT_EQ(streamFilters_.clockFilter_->ToPrimaryTraceTime(TS_CLOCK_REALTIME, time1), expectTime1);
340 }
341 
342 /**
343  * @tc.name: ConvertToPrimaryTimestampLessThanSnapShop
344  * @tc.desc: convert realtime to primary time type, and timeStamp less than snapshop
345  * @tc.type: FUNC
346  */
347 HWTEST_F(ClockFilterTest, ConvertToPrimaryTimestampLessThanSnapShop, TestSize.Level1)
348 {
349     TS_LOGI("test3-13");
350     std::vector<SnapShot> snapShot0;
351     snapShot0.push_back({TS_CLOCK_BOOTTIME, TS_BOOT_TIME});
352     snapShot0.push_back({TS_CLOCK_REALTIME, TS_REAL_TIME});
353     streamFilters_.clockFilter_->AddClockSnapshot(snapShot0);
354 
355     streamFilters_.clockFilter_->SetPrimaryClock(TS_CLOCK_BOOTTIME);
356     uint64_t time1 = 250;
357     uint64_t expectTime1 = 50;
358     EXPECT_EQ(streamFilters_.clockFilter_->ToPrimaryTraceTime(TS_CLOCK_REALTIME, time1), expectTime1);
359 }
360 
361 /**
362  * @tc.name: ConvertMonotonicTimeToPrimaryTwice
363  * @tc.desc: convert TS_MONOTONIC to primary time type with single snapshop
364  * @tc.type: FUNC
365  */
366 HWTEST_F(ClockFilterTest, ConvertMonotonicTimeToPrimaryTwice, TestSize.Level1)
367 {
368     TS_LOGI("test3-14");
369     std::vector<SnapShot> snapShot0;
370     snapShot0.push_back({TS_MONOTONIC, TS_MONOTONIC_TIME});
371     snapShot0.push_back({TS_CLOCK_REALTIME_COARSE, TS_REAL_TIME_COARSE_TIME});
372     streamFilters_.clockFilter_->AddClockSnapshot(snapShot0);
373 
374     streamFilters_.clockFilter_->SetPrimaryClock(TS_CLOCK_REALTIME_COARSE);
375     uint64_t time1 = 250;
376     uint64_t expectTime1 = 450;
377     EXPECT_EQ(streamFilters_.clockFilter_->ToPrimaryTraceTime(TS_MONOTONIC, time1), expectTime1);
378     time1 = 550;
379     expectTime1 = 750;
380     EXPECT_EQ(streamFilters_.clockFilter_->ToPrimaryTraceTime(TS_MONOTONIC, time1), expectTime1);
381 }
382 
383 /**
384  * @tc.name: ConvertToPrimaryTwiceWithTwoSnapshop
385  * @tc.desc: convert TS_MONOTONIC & TS_CLOCK_BOOTTIME to primary time type with two snapshop
386  * @tc.type: FUNC
387  */
388 HWTEST_F(ClockFilterTest, ConvertToPrimaryTwiceWithTwoSnapshop, TestSize.Level1)
389 {
390     TS_LOGI("test3-15");
391     std::vector<SnapShot> snapShot0;
392     snapShot0.push_back({TS_MONOTONIC, TS_MONOTONIC_TIME});
393     snapShot0.push_back({TS_CLOCK_REALTIME_COARSE, TS_REAL_TIME_COARSE_TIME});
394     streamFilters_.clockFilter_->AddClockSnapshot(snapShot0);
395 
396     std::vector<SnapShot> snapShot1;
397     uint64_t tsBootTime2 = 350;
398     snapShot1.push_back({TS_CLOCK_BOOTTIME, tsBootTime2});
399     snapShot1.push_back({TS_CLOCK_REALTIME_COARSE, TS_SECOND_REAL_TIME_COARSE_TIME});
400     streamFilters_.clockFilter_->AddClockSnapshot(snapShot1);
401 
402     streamFilters_.clockFilter_->SetPrimaryClock(TS_CLOCK_REALTIME_COARSE);
403 
404     uint64_t time1 = 250;
405     uint64_t expectTime1 = 450;
406     EXPECT_EQ(streamFilters_.clockFilter_->ToPrimaryTraceTime(TS_MONOTONIC, time1), expectTime1);
407 
408     uint64_t time2 = 450;
409     uint64_t expectTime2 = 900;
410     EXPECT_EQ(streamFilters_.clockFilter_->ToPrimaryTraceTime(TS_CLOCK_BOOTTIME, time2), expectTime2);
411 }
412 
413 /**
414  * @tc.name: MutiTimeTypeConvertWithMutiSnapshop
415  * @tc.desc: convert muti time type to primary time type with muti snapshop
416  * @tc.type: FUNC
417  */
418 HWTEST_F(ClockFilterTest, MutiTimeTypeConvertWithMutiSnapshop, TestSize.Level1)
419 {
420     TS_LOGI("test3-16");
421     std::vector<SnapShot> snapShot0;
422     snapShot0.push_back({TS_CLOCK_BOOTTIME, TS_BOOT_TIME});
423     snapShot0.push_back({TS_MONOTONIC, TS_MONOTONIC_TIME});
424     snapShot0.push_back({TS_CLOCK_REALTIME, TS_REAL_TIME});
425     snapShot0.push_back({TS_CLOCK_REALTIME_COARSE, TS_REAL_TIME_COARSE_TIME});
426     streamFilters_.clockFilter_->AddClockSnapshot(snapShot0);
427 
428     std::vector<SnapShot> snapShot1;
429     snapShot1.push_back({TS_CLOCK_BOOTTIME, TS_SECOND_BOOT_TIME});
430     snapShot1.push_back({TS_MONOTONIC, TS_SECOND_MONOTONIC_TIME});
431     snapShot1.push_back({TS_CLOCK_REALTIME, TS_SECOND_REAL_TIME});
432     snapShot1.push_back({TS_CLOCK_REALTIME_COARSE, TS_SECOND_REAL_TIME_COARSE_TIME});
433     streamFilters_.clockFilter_->AddClockSnapshot(snapShot1);
434 
435     streamFilters_.clockFilter_->SetPrimaryClock(TS_CLOCK_REALTIME);
436     uint64_t time1 = 150;
437     uint64_t expectTime1 = 350;
438     EXPECT_EQ(streamFilters_.clockFilter_->ToPrimaryTraceTime(TS_CLOCK_BOOTTIME, time1), expectTime1);
439     uint64_t time2 = 101;
440     uint64_t expectTime2 = 301;
441     EXPECT_EQ(streamFilters_.clockFilter_->ToPrimaryTraceTime(TS_CLOCK_BOOTTIME, time2), expectTime2);
442     uint64_t time3 = 101;
443     uint64_t expectTime3 = 101;
444     EXPECT_EQ(streamFilters_.clockFilter_->ToPrimaryTraceTime(TS_CLOCK_REALTIME, time3), expectTime3);
445     uint64_t time4 = 351;
446     uint64_t expectTime4 = 351;
447     EXPECT_EQ(streamFilters_.clockFilter_->ToPrimaryTraceTime(TS_CLOCK_REALTIME, time4), expectTime4);
448     uint64_t time5 = 350;
449     uint64_t expectTime5 = 250;
450     EXPECT_EQ(streamFilters_.clockFilter_->ToPrimaryTraceTime(TS_CLOCK_REALTIME_COARSE, time5), expectTime5);
451     uint64_t time6 = 420;
452     uint64_t expectTime6 = 320;
453     EXPECT_EQ(streamFilters_.clockFilter_->ToPrimaryTraceTime(TS_CLOCK_REALTIME_COARSE, time6), expectTime6);
454     uint64_t time7 = 801;
455     uint64_t expectTime7 = 401;
456     EXPECT_EQ(streamFilters_.clockFilter_->ToPrimaryTraceTime(TS_CLOCK_REALTIME_COARSE, time7), expectTime7);
457 }
458 } // namespace TraceStreamer
459 } // namespace SysTuning
460