提交 c6a7c4c4 编写于 作者: C chenxuihui

hilog/hitrace xts suite bugfix

Signed-off-by: Nchenxuihui <chenxuhui2@huawei.com>
上级 0285ba3a
...@@ -207,7 +207,7 @@ describe('HilogJsTest', function () { ...@@ -207,7 +207,7 @@ describe('HilogJsTest', function () {
it('testHilogJsApi13', 2, function () { it('testHilogJsApi13', 2, function () {
console.info('testHilogJsApi13 start'); console.info('testHilogJsApi13 start');
const res = hilog.isLoggable(0xD001400, "HILOGTEST", 100); const res = hilog.isLoggable(0xD001400, "HILOGTEST", 100);
expect(res).assertEqual(true); expect(res).assertEqual(false);
console.info('testHilogJsApi13 end'); console.info('testHilogJsApi13 end');
}) })
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import HiTraceChain from '@ohos.HiTraceChain' import hiTraceChain from '@ohos.hiTraceChain'
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
import hilog from '@ohos.hilog' import hilog from '@ohos.hilog'
...@@ -37,7 +37,7 @@ describe('HiTraceJsTest', function () { ...@@ -37,7 +37,7 @@ describe('HiTraceJsTest', function () {
* @tc.name hitrace interface test * @tc.name hitrace interface test
* @tc.desc hitrace begin interface test. * @tc.desc hitrace begin interface test.
*/ */
it('testHiAppEventApi01', 1, async function (done) { it('testHitraceApi01', 1, async function (done) {
console.info('testHitraceApi01 start'); console.info('testHitraceApi01 start');
try{ try{
let traceId = hiTraceChain.begin("hitrace01"); let traceId = hiTraceChain.begin("hitrace01");
...@@ -61,7 +61,7 @@ describe('HiTraceJsTest', function () { ...@@ -61,7 +61,7 @@ describe('HiTraceJsTest', function () {
* @tc.name hitrace interface test * @tc.name hitrace interface test
* @tc.desc hitrace begin interface test. * @tc.desc hitrace begin interface test.
*/ */
it('testHiAppEventApi02', 1, async function (done) { it('testHitraceApi02', 1, async function (done) {
console.info('testHitraceApi02 start'); console.info('testHitraceApi02 start');
try{ try{
let traceId = hiTraceChain.begin("hitrace02", hiTraceChain.HiTraceFlag.INCLUDE_ASYNC | let traceId = hiTraceChain.begin("hitrace02", hiTraceChain.HiTraceFlag.INCLUDE_ASYNC |
...@@ -86,15 +86,16 @@ describe('HiTraceJsTest', function () { ...@@ -86,15 +86,16 @@ describe('HiTraceJsTest', function () {
* @tc.name hitrace interface test * @tc.name hitrace interface test
* @tc.desc hitrace begin interface test. * @tc.desc hitrace begin interface test.
*/ */
it('testHiAppEventApi03', 1, async function (done) { it('testHitraceApi03', 1, async function (done) {
console.info('testHitraceApi03 start'); console.info('testHitraceApi03 start');
try{ try{
let traceId = hiTraceChain.begin("hitrace03", hiTraceChain.HiTraceFlag.TP_INFO); let traceId = hiTraceChain.begin("hitrace03", hiTraceChain.HiTraceFlag.TP_INFO);
let curTraceId = hiTraceChain.getId(); let curTraceId = hiTraceChain.getId();
if(traceId !== curTraceId){ if(traceId.chainId != curTraceId.chainId){
expect().assertFail(); expect().assertFail();
console.log(`testHitraceApi03 got an error: ${JSON.stringify(error)}`); console.log(`testHitraceApi03 got an error: ${JSON.stringify(error)}`);
} }
hiTraceChain.tracepoint(hiTraceChain.HiTraceCommunicationMode.THREAD, hiTraceChain.HiTraceTracepointType.SS, traceId, "hitrace api test.");
hiTraceChain.end(traceId); hiTraceChain.end(traceId);
} catch (error){ } catch (error){
console.log(`testHitraceApi03 got an error: ${JSON.stringify(error)}`); console.log(`testHitraceApi03 got an error: ${JSON.stringify(error)}`);
...@@ -110,7 +111,7 @@ describe('HiTraceJsTest', function () { ...@@ -110,7 +111,7 @@ describe('HiTraceJsTest', function () {
* @tc.name hitrace interface test * @tc.name hitrace interface test
* @tc.desc hitrace begin interface test. * @tc.desc hitrace begin interface test.
*/ */
it('testHiAppEventApi04', 1, async function (done) { it('testHitraceApi04', 1, async function (done) {
console.info('testHitraceApi04 start'); console.info('testHitraceApi04 start');
try{ try{
let traceId = hiTraceChain.begin("hitrace04", hiTraceChain.HiTraceFlag.NO_BE_INFO); let traceId = hiTraceChain.begin("hitrace04", hiTraceChain.HiTraceFlag.NO_BE_INFO);
...@@ -135,11 +136,11 @@ describe('HiTraceJsTest', function () { ...@@ -135,11 +136,11 @@ describe('HiTraceJsTest', function () {
* @tc.name hitrace interface test * @tc.name hitrace interface test
* @tc.desc hitrace begin interface test. * @tc.desc hitrace begin interface test.
*/ */
it('testHiAppEventApi05', 1, async function (done) { it('testHitraceApi05', 1, async function (done) {
console.info('testHitraceApi05 start'); console.info('testHitraceApi05 start');
try{ try{
let traceId = hiTraceChain.begin("hitrace05"); let traceId = hiTraceChain.begin("hitrace05");
hiTraceChain.enable(asyncTraceId, hiTraceChain.HiTraceFlag.DISABLE_LOG); hiTraceChain.enableFlag(traceId, hiTraceChain.HiTraceFlag.DISABLE_LOG);
let enabledDoNotCreateSpanFlag = hiTraceChain.isFlagEnabled(traceId, hiTraceChain.HiTraceFlag.DISABLE_LOG); let enabledDoNotCreateSpanFlag = hiTraceChain.isFlagEnabled(traceId, hiTraceChain.HiTraceFlag.DISABLE_LOG);
if(!enabledDoNotCreateSpanFlag){ if(!enabledDoNotCreateSpanFlag){
expect().assertFail(); expect().assertFail();
...@@ -160,11 +161,11 @@ describe('HiTraceJsTest', function () { ...@@ -160,11 +161,11 @@ describe('HiTraceJsTest', function () {
* @tc.name hitrace interface test * @tc.name hitrace interface test
* @tc.desc hitrace begin interface test. * @tc.desc hitrace begin interface test.
*/ */
it('testHiAppEventApi06', 1, async function (done) { it('testHitraceApi06', 1, async function (done) {
console.info('testHitraceApi06 start'); console.info('testHitraceApi06 start');
try{ try{
let traceId = hiTraceChain.begin("hitrace06"); let traceId = hiTraceChain.begin("hitrace06");
hiTraceChain.enable(asyncTraceId, hiTraceChain.HiTraceFlag.FAILURE_TRIGGER); hiTraceChain.enableFlag(traceId, hiTraceChain.HiTraceFlag.FAILURE_TRIGGER);
let enabledDoNotCreateSpanFlag = hiTraceChain.isFlagEnabled(traceId, let enabledDoNotCreateSpanFlag = hiTraceChain.isFlagEnabled(traceId,
hiTraceChain.HiTraceFlag.FAILURE_TRIGGER); hiTraceChain.HiTraceFlag.FAILURE_TRIGGER);
if(!enabledDoNotCreateSpanFlag){ if(!enabledDoNotCreateSpanFlag){
...@@ -186,7 +187,7 @@ describe('HiTraceJsTest', function () { ...@@ -186,7 +187,7 @@ describe('HiTraceJsTest', function () {
* @tc.name hitrace interface test * @tc.name hitrace interface test
* @tc.desc hitrace begin interface test. * @tc.desc hitrace begin interface test.
*/ */
it('testHiAppEventApi07', 1, async function (done) { it('testHitraceApi07', 1, async function (done) {
console.info('testHitraceApi07 start'); console.info('testHitraceApi07 start');
try{ try{
let traceId = hiTraceChain.begin("hitrace07", hiTraceChain.HiTraceFlag.D2D_TP_INFO); let traceId = hiTraceChain.begin("hitrace07", hiTraceChain.HiTraceFlag.D2D_TP_INFO);
...@@ -195,6 +196,7 @@ describe('HiTraceJsTest', function () { ...@@ -195,6 +196,7 @@ describe('HiTraceJsTest', function () {
expect().assertFail(); expect().assertFail();
console.log(`testHitraceApi07 got an error: ${JSON.stringify(error)}`); console.log(`testHitraceApi07 got an error: ${JSON.stringify(error)}`);
} }
hiTraceChain.tracepoint(hiTraceChain.HiTraceCommunicationMode.PROCESS, hiTraceChain.HiTraceTracepointType.CS, traceId, "hitrace test");
hiTraceChain.end(traceId); hiTraceChain.end(traceId);
} catch (error){ } catch (error){
console.log(`testHitraceApi07 got an error: ${JSON.stringify(error)}`); console.log(`testHitraceApi07 got an error: ${JSON.stringify(error)}`);
...@@ -210,17 +212,17 @@ describe('HiTraceJsTest', function () { ...@@ -210,17 +212,17 @@ describe('HiTraceJsTest', function () {
* @tc.name hitrace interface test * @tc.name hitrace interface test
* @tc.desc hitrace begin interface test. * @tc.desc hitrace begin interface test.
*/ */
it('testHiAppEventApi08', 1, async function (done) { it('testHitraceApi08', 1, async function (done) {
console.info('testHitraceApi08 start'); console.info('testHitraceApi08 start');
hiTraceChain.clearId(); hiTraceChain.clearId();
let traceId = hiTraceChain.begin("hitrace08", hiTraceChain.HiTraceFlag.INCLUDE_ASYNC); let traceId = hiTraceChain.begin("testHitraceApi08", hiTraceChain.HiTraceFlag.INCLUDE_ASYNC);
let curChainId = traceId.chainId; let curChainId = traceId.chainId;
new Promise(function(resolve, reject){ new Promise(function(resolve, reject){
resolve() resolve()
}).then(() => { }).then(() => {
console.info('in testHitraceApi08 then callback') console.info('in testHitraceApi08 then callback')
console.info(`testHitraceApi08 ${hiTraceChain.getId().chainId} <> ${curChainId}`) console.info(`testHitraceApi08 ${hiTraceChain.getId().chainId} <> ${curChainId}`)
except(hiTraceChain.getId().chainId == curChainId).assertTrue() expect(hiTraceChain.getId().chainId == curChainId).assertTrue()
done() done()
}) })
hiTraceChain.end(traceId); hiTraceChain.end(traceId);
...@@ -234,7 +236,7 @@ describe('HiTraceJsTest', function () { ...@@ -234,7 +236,7 @@ describe('HiTraceJsTest', function () {
* @tc.name hitrace interface test * @tc.name hitrace interface test
* @tc.desc hitrace begin interface test. * @tc.desc hitrace begin interface test.
*/ */
it('testHiAppEventApi09', 1, async function (done) { it('testHitraceApi09', 1, async function (done) {
console.info('testHitraceApi09 start'); console.info('testHitraceApi09 start');
hiTraceChain.clearId(); hiTraceChain.clearId();
let traceId = hiTraceChain.begin("hitrace09", hiTraceChain.HiTraceFlag.INCLUDE_ASYNC); let traceId = hiTraceChain.begin("hitrace09", hiTraceChain.HiTraceFlag.INCLUDE_ASYNC);
...@@ -244,11 +246,105 @@ describe('HiTraceJsTest', function () { ...@@ -244,11 +246,105 @@ describe('HiTraceJsTest', function () {
asyncTask().then(() => { asyncTask().then(() => {
console.info('in testhiTraceApi09 then callback') console.info('in testhiTraceApi09 then callback')
console.info(`testHitraceApi09 ${hiTraceChain.getId().chainId} <> ${curChainId}`) console.info(`testHitraceApi09 ${hiTraceChain.getId().chainId} <> ${curChainId}`)
except(hiTraceChain.getId().chainId == curChainId).assertTrue() expect(hiTraceChain.getId().chainId == curChainId).assertTrue()
done() done()
}) })
hiTraceChain.end(traceId); hiTraceChain.end(traceId);
done() done()
console.info('testHitraceApi09 end'); console.info('testHitraceApi09 end');
}) })
/**
* @tc.name: 接口测试-hitrace接口支持跨设备跟踪
* @tc.number DFX_DFT_Hitrace_JS_010
* @tc.function A01010
* @tc.feature DFX_DFT_Hitrace
* @tc.level Level3
* @tc.type FUNC
* @tc.author chenxuhui
*/
it('testHitraceApi10', 0, async function (done) {
console.info('testHitraceApi10 start')
hiTraceChain.clearId();
try {
let traceId = hiTraceChain.begin("hitrace10", hiTraceChain.HiTraceFlag.D2D_TP_INFO);
let enabledDoNotCreateSpanFlag = hiTraceChain.isFlagEnabled(traceId, hiTraceChain.HiTraceFlag.D2D_TP_INFO);
if(!enabledDoNotCreateSpanFlag){
expect().assertFail();
console.log(`testHitraceApi10 got an error: ${JSON.stringify(error)}`);
}
hiTraceChain.tracepoint(hiTraceChain.HiTraceCommunicationMode.DEVICE, hiTraceChain.HiTraceTracepointType.CR, traceId, "hitrace test");
hiTraceChain.end(traceId);
} catch (error) {
console.log(`testHitraceApi10 got an error: ${JSON.stringify(error)}`);
expect().assertFail();
done()
}
console.info('testHitraceApi10 end')
done()
});
/**
* @tc.name: 接口测试-hitrace接口支持跨设备跟踪
* @tc.number DFX_DFT_Hitrace_JS_011
* @tc.function A01011
* @tc.feature DFX_DFT_Hitrace
* @tc.level Level3
* @tc.type FUNC
* @tc.author chenxuhui
*/
it('testHitraceApi11', 0, async function (done) {
console.info('testHitraceApi11 start')
hiTraceChain.setId(12345678);
hiTraceChain.clearId();
try {
let traceId = hiTraceChain.begin("hitrace11", hiTraceChain.HiTraceFlag.D2D_TP_INFO);
let flags = traceId.flags
let parentSpanId = traceId.parentSpanId
let spanId = traceId.spanId
let enabledDoNotCreateSpanFlag = hiTraceChain.isFlagEnabled(traceId, hiTraceChain.HiTraceFlag.D2D_TP_INFO);
if(!enabledDoNotCreateSpanFlag){
expect().assertFail();
console.log(`testHitraceApi11 got an error: ${JSON.stringify(error)}`);
}
hiTraceChain.tracepoint(hiTraceChain.HiTraceCommunicationMode.DEFAULT, hiTraceChain.HiTraceTracepointType.SR, traceId, "hitrace test");
hiTraceChain.end(traceId);
} catch (error) {
console.log(`testHitraceApi11 got an error: ${JSON.stringify(error)}`);
expect().assertFail();
done()
}
console.info('testHitraceApi11 end')
done()
});
/**
* @tc.name: 接口测试-hitrace接口支持跨设备跟踪
* @tc.number DFX_DFT_Hitrace_JS_012
* @tc.function A01010
* @tc.feature DFX_DFT_Hitrace
* @tc.level Level3
* @tc.type FUNC
* @tc.author chenxuhui
*/
it('testHitraceApi12', 0, async function (done) {
console.info('testHitraceApi12 start')
try {
let traceId = hiTraceChain.begin("hitrace12", hiTraceChain.HiTraceFlag.D2D_TP_INFO);
let enabledDoNotCreateSpanFlag = hiTraceChain.isFlagEnabled(traceId, hiTraceChain.HiTraceFlag.D2D_TP_INFO);
if(!enabledDoNotCreateSpanFlag){
expect().assertFail();
console.log(`testHitraceApi12 got an error: ${JSON.stringify(error)}`);
}
hiTraceChain.tracepoint(hiTraceChain.HiTraceCommunicationMode.DEVICE, hiTraceChain.HiTraceTracepointType.GENERAL, traceId, "hitrace test");
hiTraceChain.end(traceId);
} catch (error) {
console.log(`testHitraceApi12 got an error: ${JSON.stringify(error)}`);
expect().assertFail();
done()
}
console.info('testHitraceApi12 end')
done()
});
}) })
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册