• 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 {
18  ProcedureLogicWorkerFileSystem,
19  FileCallChain,
20  FileSample,
21  Stack,
22  FileSysEvent,
23  FileMerageBean,
24  IoCompletionTimes,
25  VirtualMemoryEvent,
26  FileAnalysisSample,
27  //@ts-ignore
28} from '../../../../dist/trace/database/logic-worker/ProcedureLogicWorkerFileSystem.js';
29
30describe('ProcedureLogicWorkerFileSystem Test', () => {
31  let procedureLogicWorkerF = new ProcedureLogicWorkerFileSystem();
32
33  procedureLogicWorkerF.queryData = jest.fn();
34  procedureLogicWorkerF.initCallchains();
35  it('procedureLogicWorkerFileSystemTest', function () {
36    let procedureLogicWorkerFileSystem = new ProcedureLogicWorkerFileSystem();
37    expect(procedureLogicWorkerFileSystem).not.toBeUndefined();
38  });
39
40  it('procedureLogicWorkerFileSystemTest01', function () {
41    let procedureLogicWorkerFileSystem = new ProcedureLogicWorkerFileSystem();
42    window.postMessage = jest.fn(() => true);
43    let data = {
44      type: 'fileSystem-init',
45    };
46    expect(procedureLogicWorkerFileSystem.handle(data)).toBeUndefined();
47  });
48  it('procedureLogicWorkerFileSystemTest35', function () {
49    let procedureLogicWorkerFileSystem = new ProcedureLogicWorkerFileSystem();
50    window.postMessage = jest.fn(() => true);
51    let data = {
52      type: 'fileSystem-queryCallchains',
53      params: {
54        list: [],
55      },
56    };
57    expect(procedureLogicWorkerFileSystem.handle(data)).toBeUndefined();
58  });
59  it('procedureLogicWorkerFileSystemTest36', function () {
60    window.postMessage = jest.fn(() => true);
61    let data = {
62      type: 'fileSystem-queryFileSamples',
63      params: {
64        list: [],
65      },
66    };
67    expect(procedureLogicWorkerF.handle(data)).toBeUndefined();
68  });
69  it('procedureLogicWorkerFileSystemTest37', function () {
70    window.postMessage = jest.fn(() => true);
71    let data = {
72      type: 'fileSystem-action',
73      length: 0,
74      params: {
75        callType: 'fileSystem',
76        args: [],
77        list: [],
78        filter: () => {
79          return [];
80        },
81      },
82    };
83    expect(procedureLogicWorkerF.handle(data)).toBeUndefined();
84  });
85  it('procedureLogicWorkerFileSystemTest38', function () {
86    let procedureLogicWorkerFileSystem = new ProcedureLogicWorkerFileSystem();
87    window.postMessage = jest.fn(() => true);
88    let data = {
89      type: 'fileSystem-queryStack',
90      params: {
91        list: [],
92      },
93    };
94    expect(procedureLogicWorkerFileSystem.handle(data)).toBeUndefined();
95  });
96  it('procedureLogicWorkerFileSystemTest39', function () {
97    let procedureLogicWorkerFileSystem = new ProcedureLogicWorkerFileSystem();
98    window.postMessage = jest.fn(() => true);
99    let data = {
100      type: 'fileSystem-queryFileSysEvents',
101      params: {
102        list: [],
103      },
104    };
105    expect(procedureLogicWorkerFileSystem.handle(data)).toBeUndefined();
106  });
107
108  it('procedureLogicWorkerFileSystemTest07', function () {
109    let handlerMap = procedureLogicWorkerF.handlerMap.get('fileSystem');
110    expect(handlerMap.clearSplitMapData([true])).toBeUndefined();
111  });
112
113  it('procedureLogicWorkerFileSystemTest08', function () {
114    let fileCallChain = {
115      callChainId: 0,
116      depth: 0,
117      symbolsId: 0,
118      pathId: 0,
119      ip: '',
120    };
121    expect(fileCallChain).not.toBeUndefined();
122  });
123
124  it('procedureLogicWorkerFileSystemTest09', function () {
125    let stack = new Stack();
126    stack = {
127      type: 0,
128      symbol: '',
129      path: '',
130    };
131    expect(stack).not.toBeUndefined();
132  });
133
134  it('procedureLogicWorkerFileSystemTest10', function () {
135    let fileSysEvent = new FileSysEvent();
136    fileSysEvent = {
137      id: 0,
138      callchainId: 0,
139      startTs: 0,
140      startTsStr: '',
141      durStr: '',
142      dur: 0,
143      process: 0,
144      type: 0,
145      typeStr: '',
146      fd: '',
147      size: 0,
148      depth: 0,
149      firstArg: '',
150      secondArg: '',
151      thirdArg: '',
152      fourthArg: '',
153      returnValue: '',
154      error: '',
155      path: '',
156      symbol: '',
157      backtrace: [],
158    };
159    expect(fileSysEvent).not.toBeUndefined();
160  });
161
162  it('procedureLogicWorkerFileSystemTest11', function () {
163    let fileMerageBean = new FileMerageBean();
164    expect(fileMerageBean).not.toBeUndefined();
165  });
166
167  it('procedureLogicWorkerFileSystemTest13', function () {
168    let fileSample = {
169      callChainId: 0,
170      dur: 0,
171      pid: 0,
172      processName: '',
173    };
174    expect(fileSample).not.toBeUndefined();
175  });
176
177  it('procedureLogicWorkerFileSystemTest14', function () {
178    let handlerMap = procedureLogicWorkerF.handlerMap.get('fileSystem');
179    expect(handlerMap.clearAll()).toBeUndefined();
180  });
181
182  it('procedureLogicWorkerFileSystemTest15', function () {
183    window.postMessage = jest.fn(() => true);
184    let map = new Map();
185    map.set('symbol', '');
186    map.set('path', '');
187    map.set('libName', '');
188    map.set('symbolName', '');
189    let data = {
190      type: 'fileSystem-init',
191      params: map,
192    };
193    procedureLogicWorkerF.handle(data);
194    let handlerMap = procedureLogicWorkerF.handlerMap.get('fileSystem');
195    let currentNode = {
196      symbol: 'symbol',
197      path: 'path',
198      libName: 'libName',
199      symbolName: 'symbolName',
200    };
201    expect(handlerMap.setMerageName(currentNode)).toBeUndefined();
202  });
203
204  it('procedureLogicWorkerFileSystemTest33', function () {
205    let handlerMap = procedureLogicWorkerF.handlerMap.get('fileSystem');
206    let currentNode = {
207      pathId: -1,
208      symbol: '',
209      path: '',
210      libName: '',
211      symbolName: '',
212    };
213    expect(handlerMap.setMerageName(currentNode)).toBeUndefined();
214  });
215
216  it('procedureLogicWorkerFileSystemTest18', function () {
217    let procedureLogicWorkerFileSystem = new ProcedureLogicWorkerFileSystem();
218    expect(procedureLogicWorkerFileSystem.initCallChainTopDown([])).toBeUndefined();
219  });
220
221  it('procedureLogicWorkerFileSystemTest19', function () {
222    let procedureLogicWorkerFileSystem = new ProcedureLogicWorkerFileSystem();
223    expect(procedureLogicWorkerFileSystem.supplementFileSysEvents([], 'events'));
224  });
225
226  it('procedureLogicWorkerFileSystemTest21', function () {
227    let procedureLogicWorkerFileSystem = new ProcedureLogicWorkerFileSystem();
228    expect(procedureLogicWorkerFileSystem.supplementFileSysEvents([], ''));
229  });
230  it('procedureLogicWorkerFileSystemTest22', function () {
231    let procedureLogicWorkerFileSystem = new ProcedureLogicWorkerFileSystem();
232    expect(procedureLogicWorkerFileSystem.supplementFileSysEvents([]));
233  });
234
235  it('procedureLogicWorkerFileSystemTest20', function () {
236    let procedureLogicWorkerFileSystem = new ProcedureLogicWorkerFileSystem();
237    expect(procedureLogicWorkerFileSystem.getStacksByCallchainId([]));
238  });
239
240  it('procedureLogicWorkerFileSystemTest23', function () {
241    let handlerMap = procedureLogicWorkerF.handlerMap.get('fileSystem');
242    let params = {
243      funcName: 'getCallChainsBySampleIds',
244    };
245    expect(handlerMap.resolvingAction(params));
246  });
247
248  it('procedureLogicWorkerFileSystemTest24', function () {
249    let handlerMap = procedureLogicWorkerF.handlerMap.get('fileSystem');
250    let params = {
251      funcName: 'getCurrentDataFromDb',
252    };
253    expect(handlerMap.resolvingAction(params));
254  });
255
256  it('procedureLogicWorkerFileSystemTest25', function () {
257    let handlerMap = procedureLogicWorkerF.handlerMap.get('fileSystem');
258    let params = {
259      funcName: 'hideSystemLibrary',
260    };
261    expect(handlerMap.resolvingAction(params));
262  });
263
264  it('procedureLogicWorkerFileSystemTest26', function () {
265    let handlerMap = procedureLogicWorkerF.handlerMap.get('fileSystem');
266    let params = {
267      funcName: 'hideNumMaxAndMin',
268    };
269    expect(handlerMap.resolvingAction(params));
270  });
271
272  it('procedureLogicWorkerFileSystemTest27', function () {
273    let handlerMap = procedureLogicWorkerF.handlerMap.get('fileSystem');
274    let params = {
275      funcName: 'splitAllProcess',
276    };
277    expect(handlerMap.resolvingAction(params));
278  });
279
280  it('procedureLogicWorkerFileSystemTest28', function () {
281    let handlerMap = procedureLogicWorkerF.handlerMap.get('fileSystem');
282    let params = {
283      funcName: 'resetAllNode',
284    };
285    expect(handlerMap.resolvingAction(params));
286  });
287
288  it('procedureLogicWorkerFileSystemTest29', function () {
289    let handlerMap = procedureLogicWorkerF.handlerMap.get('fileSystem');
290    let params = {
291      funcName: 'resotreAllNode',
292    };
293    expect(handlerMap.resolvingAction(params));
294  });
295
296  it('procedureLogicWorkerFileSystemTest30', function () {
297    let handlerMap = procedureLogicWorkerF.handlerMap.get('fileSystem');
298    let params = {
299      funcName: 'clearSplitMapData',
300    };
301    expect(handlerMap.resolvingAction(params));
302  });
303
304  it('procedureLogicWorkerFileSystemTest31', function () {
305    let handlerMap = procedureLogicWorkerF.handlerMap.get('fileSystem');
306    let params = {
307      funcName: 'splitTree',
308    };
309    expect(handlerMap.resolvingAction(params));
310  });
311
312  it('procedureLogicWorkerFileSystemTest32', function () {
313    let handlerMap = procedureLogicWorkerF.handlerMap.get('fileSystem');
314    let params = {
315      funcName: 'setSearchValue',
316    };
317    expect(handlerMap.resolvingAction(params));
318  });
319  it('procedureLogicWorkerFileSystemTest34', function () {
320    let currentNode = {
321      processName: '',
322      ip: '',
323      pid: 1,
324      pathId: '',
325      symbolsId: '',
326      selfDur: 1,
327      self: 1,
328      count: 1,
329    };
330    let callChain = {
331      ip: '',
332      pid: 1,
333      pathId: '',
334      symbolsId: '',
335    };
336    let sample = {
337      processName: '',
338      dur: 1,
339    };
340    let isEnd = true;
341    expect(FileMerageBean.merageCallChainSample(currentNode, callChain, sample, isEnd));
342  });
343  it('procedureLogicWorkerFileSystemTest40', function () {
344    let handlerMap = procedureLogicWorkerF.handlerMap.get('fileSystem');
345    let selectionParam = {
346      diskIOipids: {
347        length: 1,
348        join: jest.fn(() => true),
349      },
350      fileSystemType: {
351        length: 1,
352        join: jest.fn(() => true),
353      },
354    };
355    window.postMessage = jest.fn(() => true);
356    expect(handlerMap.queryFileSamples(selectionParam)).toBeUndefined();
357  });
358  it('procedureLogicWorkerFileSystemTest41', function () {
359    let handlerMap = procedureLogicWorkerF.handlerMap.get('fileSystem');
360    let sample = {
361      callChainId: 1,
362      type: {
363        toString,
364      },
365    };
366    window.postMessage = jest.fn(() => true);
367    expect(handlerMap.createThreadAndType(sample)).toBeTruthy();
368  });
369  it('procedureLogicWorkerFileSystemTest42', function () {
370    let handlerMap = procedureLogicWorkerF.handlerMap.get('fileSystem');
371    let currentNode = {
372      initChildren: {
373        filter: jest.fn(() => -1),
374      },
375    };
376    let callChainDataList = {
377      length: 1,
378    };
379    let index = 0;
380    let sample = {};
381    let isTopDown = {};
382    window.postMessage = jest.fn(() => true);
383    expect(handlerMap.merageChildrenByIndex(currentNode, callChainDataList, index, sample, isTopDown)).toBeUndefined();
384  });
385  it('procedureLogicWorkerFileSystemTest43', function () {
386    let handlerMap = procedureLogicWorkerF.handlerMap.get('fileSystem');
387    let params = {
388      length: 1,
389      forEach: jest.fn(() => true),
390    };
391    window.postMessage = jest.fn(() => true);
392    expect(handlerMap.resolvingAction(params)).toStrictEqual([]);
393  });
394
395  it('procedureLogicWorkerFileSystemTest45', function () {
396    let ioCompletionTimes = new IoCompletionTimes();
397    expect(ioCompletionTimes).toBeDefined();
398  });
399
400  it('procedureLogicWorkerFileSystemTest46', function () {
401    let virtualMemoryEvent = new VirtualMemoryEvent();
402    expect(virtualMemoryEvent).toBeDefined();
403  });
404  it('procedureLogicWorkerFileSystemTest47', function () {
405    let procedureLogicWorkerFileSystem = new ProcedureLogicWorkerFileSystem();
406    expect(procedureLogicWorkerFileSystem.queryFileSysEvents(1, 0, [1], true)).toBeUndefined();
407  });
408  it('procedureLogicWorkerFileSystemTest48', function () {
409    let procedureLogicWorkerFileSystem = new ProcedureLogicWorkerFileSystem();
410    expect(procedureLogicWorkerFileSystem.queryVMEvents(1, 0, [1])).toBeUndefined();
411  });
412  it('procedureLogicWorkerFileSystemTest49', function () {
413    let procedureLogicWorkerFileSystem = new ProcedureLogicWorkerFileSystem();
414    expect(procedureLogicWorkerFileSystem.queryVMEvents(1, 0, [1])).toBeUndefined();
415  });
416  it('procedureLogicWorkerFileSystemTest50', function () {
417    let procedureLogicWorkerFileSystem = new ProcedureLogicWorkerFileSystem();
418    expect(procedureLogicWorkerFileSystem.queryIOEvents(1, 0, [1])).toBeUndefined();
419  });
420  it('procedureLogicWorkerFileSystemTest51', function () {
421    let procedureLogicWorkerFileSystem = new ProcedureLogicWorkerFileSystem();
422    window.postMessage = jest.fn(() => true);
423    let data = {
424      type: 'fileSystem-queryIoSamples',
425      params: {
426        list: [],
427      },
428    };
429    expect(procedureLogicWorkerF.handle(data)).toBeUndefined();
430  });
431  it('procedureLogicWorkerFileSystemTest52', function () {
432    window.postMessage = jest.fn(() => true);
433    let data = {
434      type: 'fileSystem-queryVirtualMemorySamples',
435      params: {
436        list: [],
437      },
438    };
439    expect(procedureLogicWorkerF.handle(data)).toBeUndefined();
440  });
441  it('procedureLogicWorkerFileSystemTest53', function () {
442    window.postMessage = jest.fn(() => true);
443    let data = {
444      type: 'fileSystem-queryVMEvents',
445      params: {
446        list: [],
447      },
448    };
449    expect(procedureLogicWorkerF.handle(data)).toBeUndefined();
450  });
451  it('procedureLogicWorkerFileSystemTest54', function () {
452    window.postMessage = jest.fn(() => true);
453    let data = {
454      type: 'fileSystem-queryIOEvents',
455      params: {
456        list: [],
457      },
458    };
459    expect(procedureLogicWorkerF.handle(data)).toBeUndefined();
460  });
461  it('procedureLogicWorkerFileSystemTest55', function () {
462    let procedureLogicWorkerFileSystem = new ProcedureLogicWorkerFileSystem();
463    expect(procedureLogicWorkerFileSystem.clearAll()).toBeUndefined();
464  });
465  it('procedureLogicWorkerFileSystemTest56', function () {
466    let handlerMap = procedureLogicWorkerF.handlerMap.get('fileSystem');
467    let selectionParam = {
468      diskIOipids: {
469        length: 1,
470        join: jest.fn(() => true),
471      },
472      fileSystemType: {
473        length: 1,
474        join: jest.fn(() => true),
475      },
476    };
477    window.postMessage = jest.fn(() => true);
478    expect(handlerMap.queryCallChainsSamples(selectionParam)).toBeUndefined();
479  });
480  it('procedureLogicWorkerFileSystemTest57', function () {
481    let handlerMap = procedureLogicWorkerF.handlerMap.get('fileSystem');
482    window.postMessage = jest.fn(() => true);
483    expect(handlerMap.clear()).toBeUndefined();
484  });
485  it('procedureLogicWorkerFileSystemTest59', function () {
486    let handlerMap = procedureLogicWorkerF.handlerMap.get('fileSystem');
487    let selectionParam = {
488      diskIOipids: {
489        length: 1,
490        join: jest.fn(() => true),
491      },
492      fileSystemType: {
493        length: 1,
494        join: jest.fn(() => true),
495      },
496    };
497    window.postMessage = jest.fn(() => true);
498    expect(handlerMap.queryPageFaultSamples(selectionParam)).toBeUndefined();
499  });
500});
501