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 StateProcessThread, 19 SPTChild, 20 SPT, 21} from '../../../dist/trace/bean/StateProcessThread.js'; 22 23describe('StateProcessThread Test', () => { 24 it('StateProcessThreadTest01', function () { 25 let stateProcessThread = new StateProcessThread(); 26 stateProcessThread = { 27 id: 'id', 28 pid: 'pid', 29 title: 'title', 30 process: 'process', 31 processId: -1, 32 thread: 'thread', 33 threadId: -1, 34 state: 'state', 35 wallDuration: 0, 36 avgDuration: 'avgDuration', 37 count: 0, 38 minDuration: 0, 39 maxDuration: 0, 40 stdDuration: 'stdDuration', 41 }; 42 expect(stateProcessThread).not.toBeUndefined(); 43 expect(stateProcessThread).toMatchInlineSnapshot( 44{ 45 id: expect.any(String), 46 pid: expect.any(String), 47 title: expect.any(String), 48 process: expect.any(String), 49 processId: expect.any(Number), 50 thread: expect.any(String), 51 threadId: expect.any(Number), 52 wallDuration: expect.any(Number), 53 avgDuration: expect.any(String), 54 count: expect.any(Number), 55 minDuration: expect.any(Number), 56 maxDuration: expect.any(Number), 57 stdDuration: expect.any(String) }, ` 58{ 59 "avgDuration": Any<String>, 60 "count": Any<Number>, 61 "id": Any<String>, 62 "maxDuration": Any<Number>, 63 "minDuration": Any<Number>, 64 "pid": Any<String>, 65 "process": Any<String>, 66 "processId": Any<Number>, 67 "state": "state", 68 "stdDuration": Any<String>, 69 "thread": Any<String>, 70 "threadId": Any<Number>, 71 "title": Any<String>, 72 "wallDuration": Any<Number>, 73} 74`); 75 }); 76 77 it('SPTChildTest02', function () { 78 let sptChild = new SPTChild(); 79 sptChild = { 80 process: 'process', 81 processId: 0, 82 processName: 'processName', 83 thread: 'thread', 84 threadId: 0, 85 threadName: 'threadName', 86 state: 'state', 87 startNs: 0, 88 startTime: 'startTime', 89 duration: 0, 90 cpu: 1, 91 core: 'core', 92 priority: 0, 93 prior: 'prior', 94 note: 'note', 95 }; 96 expect(sptChild).not.toBeUndefined(); 97 expect(sptChild).toMatchInlineSnapshot( 98{ 99 process: expect.any(String), 100 processId: expect.any(Number), 101 processName: expect.any(String), 102 thread: expect.any(String), 103 threadId: expect.any(Number), 104 threadName: expect.any(String), 105 state: expect.any(String), 106 startNs: expect.any(Number), 107 startTime: expect.any(String), 108 duration: expect.any(Number), 109 cpu: expect.any(Number), 110 core: expect.any(String), 111 priority: expect.any(Number), 112 prior: expect.any(String), 113 note: expect.any(String) }, ` 114{ 115 "core": Any<String>, 116 "cpu": Any<Number>, 117 "duration": Any<Number>, 118 "note": Any<String>, 119 "prior": Any<String>, 120 "priority": Any<Number>, 121 "process": Any<String>, 122 "processId": Any<Number>, 123 "processName": Any<String>, 124 "startNs": Any<Number>, 125 "startTime": Any<String>, 126 "state": Any<String>, 127 "thread": Any<String>, 128 "threadId": Any<Number>, 129 "threadName": Any<String>, 130} 131` 132 ); 133 }); 134 135 it('SPTTest03', function () { 136 let spt = new SPT(); 137 spt = { 138 process: 'process', 139 processId: 0, 140 thread: 'thread', 141 threadId: 0, 142 state: 'state', 143 dur: 0, 144 start_ts: 0, 145 end_ts: 0, 146 cpu: 0, 147 priority: 'priority', 148 note: 'note', 149 }; 150 expect(spt).not.toBeUndefined(); 151 expect(spt).toMatchInlineSnapshot( 152{ 153 process: expect.any(String), 154 processId: expect.any(Number), 155 thread: expect.any(String), 156 threadId: expect.any(Number), 157 state: expect.any(String), 158 dur: expect.any(Number), 159 start_ts: expect.any(Number), 160 end_ts: expect.any(Number), 161 cpu: expect.any(Number), 162 priority: expect.any(String), 163 note: expect.any(String) }, ` 164{ 165 "cpu": Any<Number>, 166 "dur": Any<Number>, 167 "end_ts": Any<Number>, 168 "note": Any<String>, 169 "priority": Any<String>, 170 "process": Any<String>, 171 "processId": Any<Number>, 172 "start_ts": Any<Number>, 173 "state": Any<String>, 174 "thread": Any<String>, 175 "threadId": Any<Number>, 176} 177` 178 ); 179 }); 180}); 181