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