• 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 {StateProcessThread,SPTChild,SPT,ThreadState,ThreadProcess,SptSlice} from "../../../dist/trace/bean/StateProcessThread.js"
18
19describe('StateProcessThread Test', ()=>{
20
21    it('StateProcessThreadTest01', function () {
22        let stateProcessThread = new StateProcessThread();
23        stateProcessThread = {
24            id: "id",
25            pid: "pid",
26            title: "title",
27            process: "process",
28            processId: -1,
29            thread: "thread",
30            threadId: -1,
31            state: "state",
32            wallDuration: 0,
33            avgDuration: "avgDuration",
34            count: 0,
35            minDuration: 0,
36            maxDuration: 0,
37            stdDuration: "stdDuration",
38        }
39        expect(stateProcessThread).not.toBeUndefined()
40        expect(stateProcessThread).toMatchInlineSnapshot({
41  id: expect.any(String),
42  pid: expect.any(String),
43  title: expect.any(String),
44  process: expect.any(String),
45  processId: expect.any(Number),
46  thread: expect.any(String),
47  threadId: expect.any(Number),
48  wallDuration: expect.any(Number),
49  avgDuration: expect.any(String),
50  count: expect.any(Number),
51  minDuration: expect.any(Number),
52  maxDuration: expect.any(Number),
53  stdDuration: expect.any(String) }, `
54Object {
55  "avgDuration": Any<String>,
56  "count": Any<Number>,
57  "id": Any<String>,
58  "maxDuration": Any<Number>,
59  "minDuration": Any<Number>,
60  "pid": Any<String>,
61  "process": Any<String>,
62  "processId": Any<Number>,
63  "state": "state",
64  "stdDuration": Any<String>,
65  "thread": Any<String>,
66  "threadId": Any<Number>,
67  "title": Any<String>,
68  "wallDuration": Any<Number>,
69}
70`)
71    });
72
73    it('SPTChildTest02', function () {
74        let sptChild = new SPTChild();
75        sptChild = {
76            process: "process",
77            processId: 0,
78            processName: "processName",
79            thread: "thread",
80            threadId: 0,
81            threadName: "threadName",
82            state: "state",
83            startNs: 0,
84            startTime: "startTime",
85            duration: 0,
86            cpu: 1,
87            core: "core",
88            priority: 0,
89            prior: "prior",
90            note: "note",
91        }
92        expect(sptChild).not.toBeUndefined()
93        expect(sptChild).toMatchInlineSnapshot({
94  process: expect.any(String),
95  processId: expect.any(Number),
96  processName: expect.any(String),
97  thread: expect.any(String),
98  threadId: expect.any(Number),
99  threadName: expect.any(String),
100  state: expect.any(String),
101  startNs: expect.any(Number),
102  startTime: expect.any(String),
103  duration: expect.any(Number),
104  cpu: expect.any(Number),
105  core: expect.any(String),
106  priority: expect.any(Number),
107  prior: expect.any(String),
108  note: expect.any(String) }, `
109Object {
110  "core": Any<String>,
111  "cpu": Any<Number>,
112  "duration": Any<Number>,
113  "note": Any<String>,
114  "prior": Any<String>,
115  "priority": Any<Number>,
116  "process": Any<String>,
117  "processId": Any<Number>,
118  "processName": Any<String>,
119  "startNs": Any<Number>,
120  "startTime": Any<String>,
121  "state": Any<String>,
122  "thread": Any<String>,
123  "threadId": Any<Number>,
124  "threadName": Any<String>,
125}
126`)
127    });
128
129    it('SPTTest03', function () {
130        let spt = new SPT();
131        spt = {
132            process: "process",
133            processId: 0,
134            thread: "thread",
135            threadId: 0,
136            state: "state",
137            dur: 0,
138            start_ts: 0,
139            end_ts: 0,
140            cpu: 0,
141            priority: "priority",
142            note: "note",
143        }
144        expect(spt).not.toBeUndefined()
145        expect(spt).toMatchInlineSnapshot({
146  process: expect.any(String),
147  processId: expect.any(Number),
148  thread: expect.any(String),
149  threadId: expect.any(Number),
150  state: expect.any(String),
151  dur: expect.any(Number),
152  start_ts: expect.any(Number),
153  end_ts: expect.any(Number),
154  cpu: expect.any(Number),
155  priority: expect.any(String),
156  note: expect.any(String) }, `
157Object {
158  "cpu": Any<Number>,
159  "dur": Any<Number>,
160  "end_ts": Any<Number>,
161  "note": Any<String>,
162  "priority": Any<String>,
163  "process": Any<String>,
164  "processId": Any<Number>,
165  "start_ts": Any<Number>,
166  "state": Any<String>,
167  "thread": Any<String>,
168  "threadId": Any<Number>,
169}
170`)
171    });
172
173    it('ThreadStateTest04', function () {
174        let threadState = new ThreadState();
175        threadState = {
176            itid: 0,
177            state: "state",
178            dur: 0,
179            ts: 0,
180            end_ts: 0,
181            start_ts: 0,
182            cpu: 0,
183        }
184        expect(threadState).not.toBeUndefined()
185        expect(threadState).toMatchInlineSnapshot({
186  itid: expect.any(Number),
187  state: expect.any(String),
188  dur: expect.any(Number),
189  ts: expect.any(Number),
190  end_ts: expect.any(Number),
191  start_ts: expect.any(Number),
192  cpu: expect.any(Number) }, `
193Object {
194  "cpu": Any<Number>,
195  "dur": Any<Number>,
196  "end_ts": Any<Number>,
197  "itid": Any<Number>,
198  "start_ts": Any<Number>,
199  "state": Any<String>,
200  "ts": Any<Number>,
201}
202`);
203    });
204
205    it('ThreadProcessTest05', function () {
206        let threadProcess = new ThreadProcess();
207        threadProcess = {
208            id:0,
209            threadId: 0,
210            thread: "thread",
211            processId: 0,
212            process: "process",
213        }
214        expect(threadProcess).not.toBeUndefined();
215        expect(threadProcess).toMatchInlineSnapshot({
216  id: expect.any(Number),
217  threadId: expect.any(Number),
218  thread: expect.any(String),
219  processId: expect.any(Number),
220  process: expect.any(String) }, `
221Object {
222  "id": Any<Number>,
223  "process": Any<String>,
224  "processId": Any<Number>,
225  "thread": Any<String>,
226  "threadId": Any<Number>,
227}
228`);
229    });
230
231    it('SptSliceTest06', function () {
232        let sptSlice = new SptSlice();
233        sptSlice = {
234            itid: 0,
235            ts: 0,
236            priority: 0,
237        }
238        expect(sptSlice).not.toBeUndefined();
239        expect(sptSlice).toMatchInlineSnapshot({
240  itid: expect.any(Number),
241  ts: expect.any(Number),
242  priority: expect.any(Number) }, `
243Object {
244  "itid": Any<Number>,
245  "priority": Any<Number>,
246  "ts": Any<Number>,
247}
248`);
249    });
250})
251