• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (C) 2022 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//@ts-ignore
17import {PerfDataQuery, perfDataQuery} from "../../../../dist/trace/component/hiperf/PerfDataQuery.js"
18
19describe('perfDataQuery Test',()=>{
20
21    it('perfDataQueryTest01 ', function () {
22        let callChain  = {
23            symbolId:-1,
24            fileId:1,
25            fileName:"unkown",
26            vaddrInFile:1,
27        }
28        expect(perfDataQuery.setCallChainName(callChain)).toBe("+0x1");
29    });
30
31    it('perfDataQueryTest15 ', function () {
32        let callChain  = {
33            symbolId:0,
34            fileId:1,
35            fileName:"unkown",
36            vaddrInFile:1,
37        }
38        expect(perfDataQuery.setCallChainName(callChain)).toBe("+0x1");
39    });
40
41    it('perfDataQueryTest02 ', function () {
42        let callChain  = {
43            tid:1,
44            threadState:"",
45            bottomUpMerageId:"1",
46        }
47        perfDataQuery.threadData[callChain.tid] = jest.fn(()=>[])
48        perfDataQuery.threadData[callChain.tid].threadName = jest.fn(()=>"")
49        expect(perfDataQuery.addProcessThreadStateData(callChain)).toBeUndefined();
50    });
51
52    it('perfDataQueryTest03 ', function () {
53        perfDataQuery.groupNewTreeNoId = jest.fn(()=>true)
54        expect(perfDataQuery.getCallChainsBySampleIds([{length:1}],true)).not.toBeUndefined();
55    });
56
57    it('perfDataQueryTest04 ', function () {
58        perfDataQuery.mapGroupBy = jest.fn(()=>true)
59        expect(perfDataQuery.recursionCreateData("","",true)).toBeUndefined();
60    });
61
62    it('perfDataQueryTest05 ', function () {
63        let merageData  = {
64            parentId:1,
65            parentNode:"",
66        }
67        expect(perfDataQuery.recursionCreateTree(merageData)).toBeUndefined();
68    });
69
70    it('perfDataQueryTest06 ', function () {
71        let callChain  = [{name:""}]
72        let currentNode  = {
73            initChildren:[],
74            id:"",
75            children:[],
76        }
77        expect(perfDataQuery.merageChildren(currentNode,callChain,true)).toBeUndefined();
78    });
79
80    it('perfDataQueryTest07 ', function () {
81        perfDataQuery.perfDataQuery = jest.fn(()=>true)
82        expect(perfDataQuery.splitTree([],"",true,true)).toBeUndefined();
83    });
84
85    it('perfDataQueryTest08 ', function () {
86        expect(perfDataQuery.clearSplitMapData("name")).toBeUndefined();
87    });
88
89    it('perfDataQueryTest09 ', function () {
90        expect(perfDataQuery.resetAllNode([])).toBeUndefined();
91    });
92
93    it('perfDataQueryTest10 ', function () {
94        expect(perfDataQuery.searchData([],'')).toBeUndefined();
95    });
96
97    it('perfDataQueryTest11 ', function () {
98        expect(perfDataQuery.findSearchNode([],'')).toBeUndefined();
99    });
100
101    it('perfDataQueryTest12 ', function () {
102        expect(perfDataQuery.initPrefData()).toBeUndefined();
103    });
104
105    it('perfDataQueryTest13 ', function () {
106        expect(perfDataQuery.initCallChain([])).toBeUndefined();
107    });
108
109    it('perfDataQueryTest14 ', function () {
110        expect(perfDataQuery.initCallChainBottomUp([])).toBeUndefined();
111    });
112
113    it('perfDataQueryTest16 ', function () {
114        expect(perfDataQuery.groupByCallChain([],true)).not.toBeUndefined();
115    });
116
117    it('perfDataQueryTest17 ', function () {
118        let callChainsData  = [{
119            tid: 0,
120            pid: 0,
121            name: "",
122            fileName: "",
123            threadState: "",
124            startNS: 0,
125            dur: 0,
126            sampleId: 0,
127            callChainId: 0,
128            vaddrInFile: 0,
129            fileId: 0,
130            symbolId: 0,
131            path: "",
132            parentId: "",
133            id: "",
134            topDownMerageId: "",
135            topDownMerageParentId: "",
136            bottomUpMerageId: "",
137            bottomUpMerageParentId: "",
138            depth: 0,
139            previousNode: undefined,
140            nextNode: undefined,
141        },{
142            tid: 1,
143            pid: 1,
144            name: "",
145            fileName: "",
146            threadState: "",
147            startNS: 1,
148            dur: 1,
149            sampleId: 1,
150            callChainId: 0,
151            vaddrInFile: 0,
152            fileId: 0,
153            symbolId: 0,
154            path: "",
155            parentId: "",
156            id: "",
157            topDownMerageId: "",
158            topDownMerageParentId: "",
159            bottomUpMerageId: "",
160            bottomUpMerageParentId: "",
161            depth: 0,
162            previousNode: undefined,
163            nextNode: undefined,
164        }]
165        expect(perfDataQuery.initCallChain(callChainsData)).toBeUndefined();
166    });
167
168    it('perfDataQueryTest18 ', function () {
169        let callChainsData  = [{
170            tid: 100,
171            pid: 100,
172            name: "",
173            fileName: "",
174            threadState: "",
175            startNS: 0,
176            dur: 0,
177            sampleId: 0,
178            callChainId: 0,
179            vaddrInFile: 0,
180            fileId: 0,
181            symbolId: 0,
182            path: "",
183            parentId: "",
184            id: "",
185            topDownMerageId: "",
186            topDownMerageParentId: "",
187            bottomUpMerageId: "",
188            bottomUpMerageParentId: "",
189            depth: 0,
190            previousNode: undefined,
191            nextNode: undefined,
192        },{
193            tid: 111,
194            pid: 111,
195            name: "",
196            fileName: "",
197            threadState: "",
198            startNS: 11,
199            dur: 11,
200            sampleId: 11,
201            callChainId: 0,
202            vaddrInFile: 0,
203            fileId: 0,
204            symbolId: 0,
205            path: "",
206            parentId: "",
207            id: "",
208            topDownMerageId: "",
209            topDownMerageParentId: "",
210            bottomUpMerageId: "",
211            bottomUpMerageParentId: "",
212            depth: 0,
213            previousNode: undefined,
214            nextNode: undefined,
215        },{
216            tid: 222,
217            pid: 222,
218            name: "",
219            fileName: "",
220            threadState: "",
221            startNS: 22,
222            dur: 22,
223            sampleId: 22,
224            callChainId: 0,
225            vaddrInFile: 0,
226            fileId: 0,
227            symbolId: 0,
228            path: "",
229            parentId: "",
230            id: "",
231            topDownMerageId: "",
232            topDownMerageParentId: "",
233            bottomUpMerageId: "",
234            bottomUpMerageParentId: "",
235            depth: 0,
236            previousNode: undefined,
237            nextNode: undefined,
238        }]
239        expect(perfDataQuery.initCallChainBottomUp(callChainsData)).toBeUndefined();
240    });
241
242    it('perfDataQueryTest19 ', function () {
243        let callChainsData  = [{
244            tid: 100,
245            pid: 100,
246            name: "",
247            fileName: "",
248            threadState: "",
249            startNS: 0,
250            dur: 0,
251            sampleId: 0,
252            callChainId: 0,
253            vaddrInFile: 0,
254            fileId: 0,
255            symbolId: -1,
256            path: "",
257            parentId: "",
258            id: "",
259            topDownMerageId: "",
260            topDownMerageParentId: "",
261            bottomUpMerageId: "",
262            bottomUpMerageParentId: "",
263            depth: 0,
264            previousNode: undefined,
265            nextNode: undefined,
266        }]
267        expect(perfDataQuery.setCallChainName(callChainsData)).not.toBeUndefined();
268    });
269
270    it('perfDataQueryTest20 ', function () {
271        let callChainsData  = [{
272            tid: 100,
273            pid: 100,
274            name: "",
275            fileName: "",
276            threadState: "",
277            startNS: 0,
278            dur: 0,
279            sampleId: 0,
280            callChainId: 0,
281            vaddrInFile: 0,
282            fileId: 0,
283            symbolId: -1,
284            path: "",
285            parentId: "",
286            id: "",
287            topDownMerageId: "",
288            topDownMerageParentId: "",
289            bottomUpMerageId: "",
290            bottomUpMerageParentId: "",
291            depth: 0,
292            previousNode: undefined,
293            nextNode: undefined,
294        }]
295        expect(perfDataQuery.groupByCallChain(callChainsData, true)).not.toBeUndefined();
296    });
297    it('perfDataQueryTest21 ', function () {
298        perfDataQuery.groupNewTreeNoId = jest.fn(()=>true);
299        let sampleIds  = [{
300            tid: 10,
301            pid: 100,
302            length: 0,
303            name: "",
304            fileName: "",
305            threadState: "",
306            startNS: 0,
307            dur: 0,
308            sampleId: 0,
309            callChainId: 0,
310            vaddrInFile: 0,
311            fileId: 0,
312            symbolId: -1,
313            path: "",
314            parentId: "",
315            id: "",
316            topDownMerageId: "",
317            topDownMerageParentId: "",
318            bottomUpMerageId: "",
319            bottomUpMerageParentId: "",
320            depth: 0,
321            previousNode: undefined,
322            nextNode: undefined,
323        }]
324        expect(perfDataQuery.getCallChainsBySampleIds(sampleIds, true)).not.toBeUndefined();
325    });
326
327    it('perfDataQueryTest12 ', function () {
328        let callChainsData  = [{
329            tid: 100,
330            pid: 100,
331            name: "",
332            fileName: "",
333            threadState: "",
334            startNS: 0,
335            dur: 0,
336            sampleId: 0,
337            callChainId: 0,
338            vaddrInFile: 0,
339            fileId: 0,
340            symbolId: -1,
341            path: "",
342            parentId: "",
343            id: "",
344            topDownMerageId: "",
345            topDownMerageParentId: "",
346            bottomUpMerageId: "",
347            bottomUpMerageParentId: "",
348            depth: 0,
349            previousNode: undefined,
350            nextNode: undefined,
351        }]
352
353        let currentData = {
354            id: "",
355            parentId: "",
356            currentTreeParentNode: undefined,
357            symbolName: "",
358            symbol: "",
359            libName: "",
360            path: "",
361            self: "0s",
362            weight: "",
363            selfDur: 0,
364            dur: 0,
365            tid: 0,
366            pid: 0,
367            isStore: 0,
368            children: [],
369            initChildren: [],
370            type: 0,
371            vaddrInFile: 0,
372            isSelected: false,
373            searchShow: true,
374        }
375        expect(perfDataQuery.merageChildren(currentData, callChainsData,true)).toBeUndefined();
376    });
377    it('perfDataQueryTest14 ', function () {
378        let node ={
379            id: "",
380            parentId: "",
381            currentTreeParentNode: undefined,
382            symbolName: "",
383            symbol: "",
384            libName: "",
385            path: "",
386            self: "0s",
387            weight: "",
388            selfDur: 0,
389            dur: 0,
390            tid: 0,
391            pid: 0,
392            isStore: 0,
393            children: [],
394            initChildren: [],
395            type: 0,
396            vaddrInFile: 0,
397            isSelected: false,
398            searchShow: true,
399        }
400        expect(perfDataQuery.recursionChargeInitTree(node,'',true)).toBeUndefined();
401
402    });
403
404    it('perfDataQueryTest15 ', function () {
405        let node ={
406            id: "",
407            parentId: "",
408            currentTreeParentNode: undefined,
409            symbolName: "",
410            symbol: "",
411            libName: "",
412            path: "",
413            self: "0s",
414            weight: "",
415            selfDur: 0,
416            dur: 0,
417            tid: 0,
418            pid: 0,
419            isStore: 0,
420            children: [],
421            initChildren: [],
422            type: 0,
423            vaddrInFile: 0,
424            isSelected: false,
425            searchShow: true,
426        }
427        expect(perfDataQuery.recursionChargeTree(node,'',true)).toBeUndefined();
428
429    });
430
431    it('perfDataQueryTest16 ', function () {
432        let node ={
433            id: "",
434            parentId: "",
435            currentTreeParentNode: undefined,
436            symbolName: "",
437            symbol: "",
438            libName: "",
439            path: "",
440            self: "0s",
441            weight: "",
442            selfDur: 0,
443            dur: 0,
444            tid: 0,
445            pid: 0,
446            isStore: 0,
447            children: [],
448            initChildren: [],
449            type: 0,
450            vaddrInFile: 0,
451            isSelected: false,
452            searchShow: true,
453        }
454        expect(perfDataQuery.recursionPruneInitTree(node,'',true)).toBeUndefined();
455
456    });
457
458    it('perfDataQueryTest17 ', function () {
459        let node ={
460            id: "",
461            parentId: "",
462            currentTreeParentNode: undefined,
463            symbolName: "",
464            symbol: "",
465            libName: "",
466            path: "",
467            self: "0s",
468            weight: "",
469            selfDur: 0,
470            dur: 0,
471            tid: 0,
472            pid: 0,
473            isStore: 0,
474            children: [],
475            initChildren: [],
476            type: 0,
477            vaddrInFile: 0,
478            isSelected: false,
479            searchShow: true,
480        }
481        expect(perfDataQuery.recursionPruneTree(node,'',true)).toBeUndefined();
482
483    });
484
485    it('perfDataQueryTest18 ', function () {
486        let node ={
487            id: "",
488            parentId: "",
489            currentTreeParentNode: undefined,
490            symbolName: "",
491            symbol: "",
492            libName: "",
493            path: "",
494            self: "0s",
495            weight: "",
496            selfDur: 0,
497            dur: 0,
498            tid: 0,
499            pid: 0,
500            isStore: 0,
501            children: [],
502            initChildren: [],
503            type: 0,
504            vaddrInFile: 0,
505            isSelected: false,
506            searchShow: true,
507        }
508        expect(perfDataQuery.recursionChargeByRule(node,'',true)).toBeUndefined();
509
510    });
511
512    it('perfDataQueryTest19 ', function () {
513        let node ={
514            id: "",
515            parentId: "",
516            currentTreeParentNode: undefined,
517            symbolName: "",
518            symbol: "",
519            libName: "",
520            path: "",
521            self: "0s",
522            weight: "",
523            selfDur: 0,
524            dur: 0,
525            tid: 0,
526            pid: 0,
527            isStore: 0,
528            children: [],
529            initChildren: [],
530            type: 0,
531            vaddrInFile: 0,
532            isSelected: false,
533            searchShow: true,
534        }
535        expect(perfDataQuery.pruneChildren(node,'')).toBeUndefined();
536
537    });
538
539    it('perfDataQueryTest20 ', function () {
540
541        expect(perfDataQuery.clearSplitMapData('')).toBeUndefined();
542
543    });
544    it('perfDataQueryTest21 ', function () {
545        expect(perfDataQuery.clearSearchNode()).toBeUndefined();
546    });
547
548})