/* * 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 { StateProcessThread, SPTChild, SPT, } from '../../../dist/trace/bean/StateProcessThread.js'; describe('StateProcessThread Test', () => { it('StateProcessThreadTest01', function () { let stateProcessThread = new StateProcessThread(); stateProcessThread = { id: 'id', pid: 'pid', title: 'title', process: 'process', processId: -1, thread: 'thread', threadId: -1, state: 'state', wallDuration: 0, avgDuration: 'avgDuration', count: 0, minDuration: 0, maxDuration: 0, stdDuration: 'stdDuration', }; expect(stateProcessThread).not.toBeUndefined(); expect(stateProcessThread).toMatchInlineSnapshot( { id: expect.any(String), pid: expect.any(String), title: expect.any(String), process: expect.any(String), processId: expect.any(Number), thread: expect.any(String), threadId: expect.any(Number), wallDuration: expect.any(Number), avgDuration: expect.any(String), count: expect.any(Number), minDuration: expect.any(Number), maxDuration: expect.any(Number), stdDuration: expect.any(String) }, ` { "avgDuration": Any, "count": Any, "id": Any, "maxDuration": Any, "minDuration": Any, "pid": Any, "process": Any, "processId": Any, "state": "state", "stdDuration": Any, "thread": Any, "threadId": Any, "title": Any, "wallDuration": Any, } `); }); it('SPTChildTest02', function () { let sptChild = new SPTChild(); sptChild = { process: 'process', processId: 0, processName: 'processName', thread: 'thread', threadId: 0, threadName: 'threadName', state: 'state', startNs: 0, startTime: 'startTime', duration: 0, cpu: 1, core: 'core', priority: 0, prior: 'prior', note: 'note', }; expect(sptChild).not.toBeUndefined(); expect(sptChild).toMatchInlineSnapshot( { process: expect.any(String), processId: expect.any(Number), processName: expect.any(String), thread: expect.any(String), threadId: expect.any(Number), threadName: expect.any(String), state: expect.any(String), startNs: expect.any(Number), startTime: expect.any(String), duration: expect.any(Number), cpu: expect.any(Number), core: expect.any(String), priority: expect.any(Number), prior: expect.any(String), note: expect.any(String) }, ` { "core": Any, "cpu": Any, "duration": Any, "note": Any, "prior": Any, "priority": Any, "process": Any, "processId": Any, "processName": Any, "startNs": Any, "startTime": Any, "state": Any, "thread": Any, "threadId": Any, "threadName": Any, } ` ); }); it('SPTTest03', function () { let spt = new SPT(); spt = { process: 'process', processId: 0, thread: 'thread', threadId: 0, state: 'state', dur: 0, start_ts: 0, end_ts: 0, cpu: 0, priority: 'priority', note: 'note', }; expect(spt).not.toBeUndefined(); expect(spt).toMatchInlineSnapshot( { process: expect.any(String), processId: expect.any(Number), thread: expect.any(String), threadId: expect.any(Number), state: expect.any(String), dur: expect.any(Number), start_ts: expect.any(Number), end_ts: expect.any(Number), cpu: expect.any(Number), priority: expect.any(String), note: expect.any(String) }, ` { "cpu": Any, "dur": Any, "end_ts": Any, "note": Any, "priority": Any, "process": Any, "processId": Any, "start_ts": Any, "state": Any, "thread": Any, "threadId": Any, } ` ); }); });