/* * Copyright (C) 2022 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ // @ts-ignore import {PerfFile, PerfThread, PerfCallChain, PerfCallChainMerageData, PerfSample, PerfStack, PerfCall, PerfCmdLine} from "../../../dist/trace/bean/PerfProfile.js" describe('PerfProfile Test', ()=>{ let perfFile = new PerfFile(); let perfThread = new PerfThread(); let perfCallChain = new PerfCallChain(); let perfCallChainMerageData = new PerfCallChainMerageData(); let perfSample = new PerfSample(); let perfStack = new PerfStack(); let perfCall = new PerfCall(); let perfCmdLine = new PerfCmdLine(); it('PerfFile Test', function () { perfFile = { fileId: 0, symbol: "symbol", path: "path", fileName: "fileName", }; expect(perfFile).not.toBeUndefined() expect(perfFile).toMatchInlineSnapshot({ fileId: expect.any(Number), symbol: expect.any(String), path: expect.any(String), fileName: expect.any(String) }, ` Object { "fileId": Any, "fileName": Any, "path": Any, "symbol": Any, } `); }); it('PerfThread Test', function () { perfThread = { tid: 0, pid: 0, threadName: "threadName", processName: "processName", } expect(perfThread).not.toBeUndefined() expect(perfThread).toMatchInlineSnapshot({ tid: expect.any(Number), pid: expect.any(Number), threadName: expect.any(String), processName: expect.any(String) }, ` Object { "pid": Any, "processName": Any, "threadName": Any, "tid": Any, } `); }); it('perfCallChain Test', function () { perfCallChain = { tid: 0, pid: 0, name: "name", fileName: "fileName", threadState: "threadState", startNS: 0, dur: 0, sampleId: 0, callChainId: 0, vaddrInFile: 0, fileId: 0, symbolId: 0, parentId: "parentId", id: "id", topDownMerageId: "topDownMerageId", topDownMerageParentId: "topDownMerageParentId", bottomUpMerageId: "bottomUpMerageId", bottomUpMerageParentId: "bottomUpMerageParentId", depth: 0, } expect(perfCallChain).not.toBeUndefined() expect(perfCallChain).toMatchInlineSnapshot({ tid: expect.any(Number), pid: expect.any(Number), name: expect.any(String), fileName: expect.any(String), threadState: expect.any(String), startNS: expect.any(Number), dur: expect.any(Number), sampleId: expect.any(Number), callChainId: expect.any(Number), vaddrInFile: expect.any(Number), fileId: expect.any(Number), symbolId: expect.any(Number), parentId: expect.any(String), id: expect.any(String), topDownMerageId: expect.any(String), topDownMerageParentId: expect.any(String), bottomUpMerageId: expect.any(String), bottomUpMerageParentId: expect.any(String), depth: expect.any(Number) }, ` Object { "bottomUpMerageId": Any, "bottomUpMerageParentId": Any, "callChainId": Any, "depth": Any, "dur": Any, "fileId": Any, "fileName": Any, "id": Any, "name": Any, "parentId": Any, "pid": Any, "sampleId": Any, "startNS": Any, "symbolId": Any, "threadState": Any, "tid": Any, "topDownMerageId": Any, "topDownMerageParentId": Any, "vaddrInFile": Any, } `) }) it('perfCallChain Test', function () { perfCallChainMerageData = { id: "id", parentId: "parentId", symbolName: "symbolName", symbol: "symbol", libName: "libName", self: "self", weight: "weight", selfDur: 0, dur: 0, tid: 0, pid: 0, type: 0, isSelected: false, } expect(perfCallChainMerageData).not.toBeUndefined() expect(perfCallChainMerageData).toMatchInlineSnapshot({ id: expect.any(String), parentId: expect.any(String), symbolName: expect.any(String), symbol: expect.any(String), libName: expect.any(String), self: expect.any(String), weight: expect.any(String), selfDur: expect.any(Number), dur: expect.any(Number), tid: expect.any(Number), pid: expect.any(Number), type: expect.any(Number), isSelected: expect.any(Boolean) }, ` Object { "dur": Any, "id": Any, "isSelected": Any, "libName": Any, "parentId": Any, "pid": Any, "self": Any, "selfDur": Any, "symbol": Any, "symbolName": Any, "tid": Any, "type": Any, "weight": Any, } `) }) it('perfSample Test', function () { perfSample = { sampleId: 0, time: 0, timeString: "timeString", core: 0, coreName: "coreName", state: "state", pid: 0, processName: "processName", tid: 0, threadName: "threadName", depth: 0, addr: "addr", fileId: 0, symbolId: 0, } expect(perfSample).not.toBeUndefined() expect(perfSample).toMatchInlineSnapshot({ sampleId: expect.any(Number), time: expect.any(Number), timeString: expect.any(String), core: expect.any(Number), coreName: expect.any(String), state: expect.any(String), pid: expect.any(Number), processName: expect.any(String), tid: expect.any(Number), threadName: expect.any(String), depth: expect.any(Number), addr: expect.any(String), fileId: expect.any(Number), symbolId: expect.any(Number) }, ` Object { "addr": Any, "core": Any, "coreName": Any, "depth": Any, "fileId": Any, "pid": Any, "processName": Any, "sampleId": Any, "state": Any, "symbolId": Any, "threadName": Any, "tid": Any, "time": Any, "timeString": Any, } `) }) it('perfStack Test', function () { perfStack = { symbol: "", path: "", fileId: 0, type: 0, } expect(perfStack).not.toBeUndefined() expect(perfStack).toMatchInlineSnapshot({ symbol: expect.any(String), path: expect.any(String), fileId: expect.any(Number), type: expect.any(Number) }, ` Object { "fileId": Any, "path": Any, "symbol": Any, "type": Any, } `) }) it('perfCall Test', function () { perfCall = { sampleId: 0, depth: 0, name: "name", } expect(perfCall).not.toBeUndefined() expect(perfCall).toMatchInlineSnapshot({ sampleId: expect.any(Number), depth: expect.any(Number), name: expect.any(String) }, ` Object { "depth": Any, "name": Any, "sampleId": Any, } `) }) it('PerfFile Test01', function () { let perfFile = new PerfFile(); expect(perfFile.setFileName()).toBeUndefined(); }); it('PerfFile Test02', function () { let perfFile = new PerfFile(); let perfF = { fileId: 0, symbol: "symbol", path: "path", fileName: "fileName", }; expect(perfFile.setFileName(perfF)).toBeUndefined(); }); it('PerfCmdLine Test', function () { perfCmdLine = { report_value: 'report_value', }; expect(perfCmdLine).not.toBeUndefined(); expect(perfCmdLine).toMatchInlineSnapshot({ report_value: expect.any(String) }, ` Object { "report_value": Any, } `); }); })