提交 c69434c3 编写于 作者: U uoengopen

guofeng43@huawei.com

Signed-off-by: Nuoengopen <guofeng43@huawei.com>
上级 f8d517ac
...@@ -66,14 +66,13 @@ describe('HiCheckerTest', function () { ...@@ -66,14 +66,13 @@ describe('HiCheckerTest', function () {
it('HiCheckerTest002', 0, function () { it('HiCheckerTest002', 0, function () {
console.info('HiCheckerTest002 start'); console.info('HiCheckerTest002 start');
hichecker.addRule(hichecker.RULE_THREAD_CHECK_SLOW_PROCESS | hichecker.RULE_CHECK_SLOW_EVENT); hichecker.addRule(hichecker.RULE_THREAD_CHECK_SLOW_PROCESS | hichecker.RULE_CHECK_SLOW_EVENT);
hichecker.addRule(hichecker.RULE_CHECK_ABILITY_CONNECTION_LEAK | hichecker.RULE_CAUTION_PRINT_LOG | hichecker.RULE_CAUTION_TRIGGER_CRASH); hichecker.addRule(hichecker.RULE_CHECK_ABILITY_CONNECTION_LEAK | hichecker.RULE_CAUTION_PRINT_LOG);
console.log('add rule success!'); console.log('add rule success!');
expect(hichecker.contains(hichecker.RULE_THREAD_CHECK_SLOW_PROCESS)).assertTrue(); expect(hichecker.contains(hichecker.RULE_THREAD_CHECK_SLOW_PROCESS)).assertTrue();
expect(hichecker.contains(hichecker.RULE_CHECK_SLOW_EVENT)).assertTrue(); expect(hichecker.contains(hichecker.RULE_CHECK_SLOW_EVENT)).assertTrue();
expect(hichecker.contains(hichecker.RULE_CHECK_ABILITY_CONNECTION_LEAK)).assertTrue(); expect(hichecker.contains(hichecker.RULE_CHECK_ABILITY_CONNECTION_LEAK)).assertTrue();
expect(hichecker.contains(hichecker.RULE_CAUTION_PRINT_LOG)).assertTrue(); expect(hichecker.contains(hichecker.RULE_CAUTION_PRINT_LOG)).assertTrue();
expect(hichecker.contains(hichecker.RULE_CAUTION_TRIGGER_CRASH)).assertTrue(); let tmp = (hichecker.RULE_THREAD_CHECK_SLOW_PROCESS | hichecker.RULE_CHECK_SLOW_EVENT | hichecker.RULE_CHECK_ABILITY_CONNECTION_LEAK | hichecker.RULE_CAUTION_PRINT_LOG);
let tmp = (hichecker.RULE_THREAD_CHECK_SLOW_PROCESS | hichecker.RULE_CHECK_SLOW_EVENT | hichecker.RULE_CHECK_ABILITY_CONNECTION_LEAK | hichecker.RULE_CAUTION_PRINT_LOG | hichecker.RULE_CAUTION_TRIGGER_CRASH);
expect(hichecker.getRule() == tmp).assertTrue(); expect(hichecker.getRule() == tmp).assertTrue();
}) })
...@@ -117,12 +116,12 @@ describe('HiCheckerTest', function () { ...@@ -117,12 +116,12 @@ describe('HiCheckerTest', function () {
it('HiCheckerTest005', 0, function () { it('HiCheckerTest005', 0, function () {
console.info('HiCheckerTest005 start'); console.info('HiCheckerTest005 start');
hichecker.addRule(hichecker.RULE_THREAD_CHECK_SLOW_PROCESS | hichecker.RULE_CHECK_SLOW_EVENT); hichecker.addRule(hichecker.RULE_THREAD_CHECK_SLOW_PROCESS | hichecker.RULE_CHECK_SLOW_EVENT);
hichecker.addRule(hichecker.RULE_CHECK_ABILITY_CONNECTION_LEAK | hichecker.RULE_CAUTION_PRINT_LOG | hichecker.RULE_CAUTION_TRIGGER_CRASH); hichecker.addRule(hichecker.RULE_CHECK_ABILITY_CONNECTION_LEAK | hichecker.RULE_CAUTION_PRINT_LOG);
console.log('add rule success!'); console.log('add rule success!');
let tmp = (hichecker.RULE_CHECK_ABILITY_CONNECTION_LEAK | hichecker.RULE_CAUTION_PRINT_LOG | hichecker.RULE_CAUTION_TRIGGER_CRASH); let tmp = (hichecker.RULE_CHECK_ABILITY_CONNECTION_LEAK | hichecker.RULE_CAUTION_PRINT_LOG);
hichecker.removeRule(hichecker.RULE_THREAD_CHECK_SLOW_PROCESS | hichecker.RULE_CHECK_SLOW_EVENT); hichecker.removeRule(hichecker.RULE_THREAD_CHECK_SLOW_PROCESS | hichecker.RULE_CHECK_SLOW_EVENT);
expect(hichecker.getRule() == tmp).assertTrue(); expect(hichecker.getRule() == tmp).assertTrue();
hichecker.removeRule(hichecker.RULE_CHECK_ABILITY_CONNECTION_LEAK | hichecker.RULE_CAUTION_PRINT_LOG | hichecker.RULE_CAUTION_TRIGGER_CRASH); hichecker.removeRule(hichecker.RULE_CHECK_ABILITY_CONNECTION_LEAK | hichecker.RULE_CAUTION_PRINT_LOG);
expect(hichecker.getRule() == 0).assertTrue(); expect(hichecker.getRule() == 0).assertTrue();
}) })
...@@ -134,9 +133,9 @@ describe('HiCheckerTest', function () { ...@@ -134,9 +133,9 @@ describe('HiCheckerTest', function () {
it('HiCheckerTest006', 0, function () { it('HiCheckerTest006', 0, function () {
console.info('HiCheckerTest006 start'); console.info('HiCheckerTest006 start');
hichecker.addRule(hichecker.RULE_THREAD_CHECK_SLOW_PROCESS | hichecker.RULE_CHECK_SLOW_EVENT); hichecker.addRule(hichecker.RULE_THREAD_CHECK_SLOW_PROCESS | hichecker.RULE_CHECK_SLOW_EVENT);
hichecker.addRule(hichecker.RULE_CHECK_ABILITY_CONNECTION_LEAK | hichecker.RULE_CAUTION_PRINT_LOG | hichecker.RULE_CAUTION_TRIGGER_CRASH); hichecker.addRule(hichecker.RULE_CHECK_ABILITY_CONNECTION_LEAK | hichecker.RULE_CAUTION_PRINT_LOG);
console.log('add rule success!'); console.log('add rule success!');
let tmp = (hichecker.RULE_THREAD_CHECK_SLOW_PROCESS | hichecker.RULE_CHECK_SLOW_EVENT | hichecker.RULE_CHECK_ABILITY_CONNECTION_LEAK | hichecker.RULE_CAUTION_PRINT_LOG | hichecker.RULE_CAUTION_TRIGGER_CRASH); let tmp = (hichecker.RULE_THREAD_CHECK_SLOW_PROCESS | hichecker.RULE_CHECK_SLOW_EVENT | hichecker.RULE_CHECK_ABILITY_CONNECTION_LEAK | hichecker.RULE_CAUTION_PRINT_LOG);
hichecker.removeRule(-1); hichecker.removeRule(-1);
expect(hichecker.getRule() == tmp).assertTrue(); expect(hichecker.getRule() == tmp).assertTrue();
hichecker.removeRule(0); hichecker.removeRule(0);
......
...@@ -27,12 +27,11 @@ describe('HidebugJsTest', function () { ...@@ -27,12 +27,11 @@ describe('HidebugJsTest', function () {
console.log('************* DFX_DFR_Hiprofiler_Interface_0001 Test start*************'); console.log('************* DFX_DFR_Hiprofiler_Interface_0001 Test start*************');
try { try {
let heapSize = hidebug.getNativeHeapSize(); let heapSize = hidebug.getNativeHeapSize();
expect(heapSize).assertEqual(BigInt(0)); expect(heapSize>=BigInt(0)).assertTrue();
} catch (error) { } catch (error) {
expect().assertFail(); expect().assertFail();
} }
console.log('************* DFX_DFR_Hiprofiler_Interface_0001 Test end*************'); console.log('************* DFX_DFR_Hiprofiler_Interface_0001 Test end*************');
done();
}); });
/* /*
...@@ -40,16 +39,15 @@ describe('HidebugJsTest', function () { ...@@ -40,16 +39,15 @@ describe('HidebugJsTest', function () {
* @tc.name : getNativeHeapAllocatedSize * @tc.name : getNativeHeapAllocatedSize
* @tc.desc : Get Native heap memory allocation size. * @tc.desc : Get Native heap memory allocation size.
*/ */
it('DFX_DFR_Hiprofiler_Interface_0002', 0, function(done) { it('DFX_DFR_Hiprofiler_Interface_0002', 0, function() {
console.log('************* DFX_DFR_Hiprofiler_Interface_0002 Test start*************'); console.log('************* DFX_DFR_Hiprofiler_Interface_0002 Test start*************');
try { try {
let heapAllocatedSize = hidebug.getNativeHeapAllocatedSize(); let heapAllocatedSize = hidebug.getNativeHeapAllocatedSize();
expect(heapAllocatedSize).assertEqual(BigInt(0)); expect(heapAllocatedSize>=BigInt(0)).assertTrue();
} catch (error) { } catch (error) {
expect().assertFail(); expect().assertFail();
} }
console.log('************* DFX_DFR_Hiprofiler_Interface_0002 Test end*************'); console.log('************* DFX_DFR_Hiprofiler_Interface_0002 Test end*************');
done();
}); });
/* /*
...@@ -57,16 +55,15 @@ describe('HidebugJsTest', function () { ...@@ -57,16 +55,15 @@ describe('HidebugJsTest', function () {
* @tc.name : getNativeHeapFreeSize * @tc.name : getNativeHeapFreeSize
* @tc.desc : Get Native heap memory free size * @tc.desc : Get Native heap memory free size
*/ */
it('DFX_DFR_Hiprofiler_Interface_0003', 0, function(done) { it('DFX_DFR_Hiprofiler_Interface_0003', 0, function() {
console.log('************* DFX_DFR_Hiprofiler_Interface_0003 Test start*************'); console.log('************* DFX_DFR_Hiprofiler_Interface_0003 Test start*************');
try { try {
let heapFreeSize = hidebug.getNativeHeapFreeSize(); let heapFreeSize = hidebug.getNativeHeapFreeSize();
expect(heapFreeSize).assertEqual(BigInt(0)); expect(heapFreeSize>=BigInt(0)).assertTrue();
} catch (error) { } catch (error) {
expect().assertFail(); expect().assertFail();
} }
console.log('************* DFX_DFR_Hiprofiler_Interface_0003 Test end*************'); console.log('************* DFX_DFR_Hiprofiler_Interface_0003 Test end*************');
done();
}); });
/* /*
...@@ -122,7 +119,7 @@ describe('HidebugJsTest', function () { ...@@ -122,7 +119,7 @@ describe('HidebugJsTest', function () {
let timestamp = Date.now(); let timestamp = Date.now();
let filename = 'cpuprofiler-' + timestamp.toString(); let filename = 'cpuprofiler-' + timestamp.toString();
console.info(filename); console.info(filename);
let path = '/data/accounts/account_0/appdata/com.hidebug.test/files/' + filename + '.json' let path = '/data/app/el2/100/base/com.hidebug.test/files/' + filename + '.json'
hidebug.startProfiling(filename); hidebug.startProfiling(filename);
let temp = 100; let temp = 100;
hidebug.stopProfiling(); hidebug.stopProfiling();
...@@ -144,9 +141,9 @@ describe('HidebugJsTest', function () { ...@@ -144,9 +141,9 @@ describe('HidebugJsTest', function () {
it('DFX_DFR_Hiprofiler_Interface_0007', 0, async function (done) { it('DFX_DFR_Hiprofiler_Interface_0007', 0, async function (done) {
console.log('************* DFX_DFR_Hiprofiler_Interface_0007 Test start*************'); console.log('************* DFX_DFR_Hiprofiler_Interface_0007 Test start*************');
try { try {
let path1 = '/data/accounts/account_0/appdata/com.hidebug.test/files/cpuprofiler-111.json' let path1 = '/data/app/el2/100/base/com.hidebug.test/files/cpuprofiler-111.json'
let path2 = '/data/accounts/account_0/appdata/com.hidebug.test/files/cpuprofiler-222.json' let path2 = '/data/app/el2/100/base/com.hidebug.test/files/cpuprofiler-222.json'
let path3 = '/data/accounts/account_0/appdata/com.hidebug.test/files/cpuprofiler-333.json' let path3 = '/data/app/el2/100/base/com.hidebug.test/files/cpuprofiler-333.json'
hidebug.startProfiling('cpuprofiler-111'); hidebug.startProfiling('cpuprofiler-111');
hidebug.startProfiling('cpuprofiler-222'); hidebug.startProfiling('cpuprofiler-222');
hidebug.startProfiling('cpuprofiler-333'); hidebug.startProfiling('cpuprofiler-333');
...@@ -179,7 +176,7 @@ describe('HidebugJsTest', function () { ...@@ -179,7 +176,7 @@ describe('HidebugJsTest', function () {
*/ */
it('DFX_DFR_Hiprofiler_Interface_0008', 0, async function (done) { it('DFX_DFR_Hiprofiler_Interface_0008', 0, async function (done) {
console.log('************* DFX_DFR_Hiprofiler_Interface_0008 Test start*************'); console.log('************* DFX_DFR_Hiprofiler_Interface_0008 Test start*************');
let path = '/data/accounts/account_0/appdata/com.hidebug.test/files/.json' let path = '/data/app/el2/100/base/com.hidebug.test/files/undefined.json'
try { try {
fileio.accessSync(path, 0); fileio.accessSync(path, 0);
let res = fileio.unlinkSync(path); let res = fileio.unlinkSync(path);
...@@ -193,9 +190,9 @@ describe('HidebugJsTest', function () { ...@@ -193,9 +190,9 @@ describe('HidebugJsTest', function () {
hidebug.stopProfiling(); hidebug.stopProfiling();
fileio.accessSync(path, 0); fileio.accessSync(path, 0);
console.info('file is exists:', path); console.info('file is exists:', path);
expect().assertFail();
} catch (error) {
expect(true).assertTrue(); expect(true).assertTrue();
} catch (error) {
expect().assertFail();
} }
console.log('************* DFX_DFR_Hiprofiler_Interface_0008 Test end*************'); console.log('************* DFX_DFR_Hiprofiler_Interface_0008 Test end*************');
done(); done();
...@@ -208,7 +205,7 @@ describe('HidebugJsTest', function () { ...@@ -208,7 +205,7 @@ describe('HidebugJsTest', function () {
*/ */
it('DFX_DFR_Hiprofiler_Interface_0009', 0, async function (done) { it('DFX_DFR_Hiprofiler_Interface_0009', 0, async function (done) {
console.log('************* DFX_DFR_Hiprofiler_Interface_0009 Test start*************'); console.log('************* DFX_DFR_Hiprofiler_Interface_0009 Test start*************');
let path = '/data/accounts/account_0/appdata/com.hidebug.test/files/undefined.json' let path = '/data/app/el2/100/base/com.hidebug.test/files/undefined.json'
try { try {
fileio.accessSync(path, 0); fileio.accessSync(path, 0);
let res = fileio.unlinkSync(path); let res = fileio.unlinkSync(path);
...@@ -245,7 +242,7 @@ describe('HidebugJsTest', function () { ...@@ -245,7 +242,7 @@ describe('HidebugJsTest', function () {
let timestamp = Date.now(); let timestamp = Date.now();
let filename = 'heap-' + timestamp.toString(); let filename = 'heap-' + timestamp.toString();
console.info(filename); console.info(filename);
let path = '/data/accounts/account_0/appdata/com.hidebug.test/files/' + filename + '.heapsnapshot' let path = '/data/app/el2/100/base/com.hidebug.test/files/' + filename + '.heapsnapshot'
hidebug.dumpHeapData(filename); hidebug.dumpHeapData(filename);
fileio.accessSync(path, 0); fileio.accessSync(path, 0);
console.info('file is exists:', path); console.info('file is exists:', path);
...@@ -264,7 +261,7 @@ describe('HidebugJsTest', function () { ...@@ -264,7 +261,7 @@ describe('HidebugJsTest', function () {
*/ */
it('DFX_DFR_Hiprofiler_Interface_0011', 0, async function (done) { it('DFX_DFR_Hiprofiler_Interface_0011', 0, async function (done) {
console.log('************* DFX_DFR_Hiprofiler_Interface_0011 Test start*************'); console.log('************* DFX_DFR_Hiprofiler_Interface_0011 Test start*************');
let path = '/data/accounts/account_0/appdata/com.hidebug.test/files/.heapsnapshot' let path = '/data/app/el2/100/base/com.hidebug.test/files/undefined.heapsnapshot'
try { try {
fileio.accessSync(path, 0); fileio.accessSync(path, 0);
let res = fileio.unlinkSync(path); let res = fileio.unlinkSync(path);
...@@ -276,9 +273,9 @@ describe('HidebugJsTest', function () { ...@@ -276,9 +273,9 @@ describe('HidebugJsTest', function () {
hidebug.dumpHeapData(''); hidebug.dumpHeapData('');
fileio.accessSync(path, 0); fileio.accessSync(path, 0);
console.info('file is exists:', path); console.info('file is exists:', path);
expect().assertFail();
} catch (error) {
expect(true).assertTrue(); expect(true).assertTrue();
} catch (error) {
expect().assertFail();
} }
console.log('************* DFX_DFR_Hiprofiler_Interface_0011 Test end*************'); console.log('************* DFX_DFR_Hiprofiler_Interface_0011 Test end*************');
done(); done();
...@@ -291,7 +288,7 @@ describe('HidebugJsTest', function () { ...@@ -291,7 +288,7 @@ describe('HidebugJsTest', function () {
*/ */
it('DFX_DFR_Hiprofiler_Interface_0012', 0, async function (done) { it('DFX_DFR_Hiprofiler_Interface_0012', 0, async function (done) {
console.log('************* DFX_DFR_Hiprofiler_Interface_0012 Test start*************'); console.log('************* DFX_DFR_Hiprofiler_Interface_0012 Test start*************');
let path = '/data/accounts/account_0/appdata/com.hidebug.test/files/undefined.heapsnapshot' let path = '/data/app/el2/100/base/com.hidebug.test/files/undefined.heapsnapshot'
try { try {
fileio.accessSync(path, 0); fileio.accessSync(path, 0);
let res = fileio.unlinkSync(path); let res = fileio.unlinkSync(path);
...@@ -314,5 +311,96 @@ describe('HidebugJsTest', function () { ...@@ -314,5 +311,96 @@ describe('HidebugJsTest', function () {
console.log('************* DFX_DFR_Hiprofiler_Interface_0012 Test end*************'); console.log('************* DFX_DFR_Hiprofiler_Interface_0012 Test end*************');
done(); done();
}); });
/*
* @tc.number : DFX_DFR_Hiprofiler_Interface_0013
* @tc.name : getPrivateDirty
* @tc.desc : Get the size of the private dirty memory
*/
it('DFX_DFR_Hiprofiler_Interface_0013', 0, function() {
console.log('************* DFX_DFR_Hiprofiler_Interface_0013 Test start*************');
try {
let temp = hidebug.getPrivateDirty();
expect(temp>=BigInt(0)).assertTrue();
} catch (error) {
expect().assertFail();
}
console.log('************* DFX_DFR_Hiprofiler_Interface_0013 Test end*************');
});
/*
* @tc.number : DFX_DFR_Hiprofiler_Interface_0014
* @tc.name : getCpuUsage
* @tc.desc : Get the cpu usage of a process
*/
it('DFX_DFR_Hiprofiler_Interface_0014', 0, function() {
console.log('************* DFX_DFR_Hiprofiler_Interface_0014 Test start*************');
try {
let temp = -1;
for(let i=0;i<10001;i++){
for(let j=0;j<10001;j++){
if(i+j == 20002){
temp = hidebug.getCpuUsage();
console.info("CpuUsage is " + temp);
}
}
}
expect(temp>=0 && temp<=1).assertTrue();
} catch (error) {
expect().assertFail();
}
console.log('************* DFX_DFR_Hiprofiler_Interface_0014 Test end*************');
});
/*
* @tc.number : DFX_DFR_Hiprofiler_Interface_0015
* @tc.name : getServiceDump with normal parameter
* @tc.desc : getServiceDump
*/
it('DFX_DFR_Hiprofiler_Interface_0015', 0, function() {
console.log('************* DFX_DFR_Hiprofiler_Interface_0015 Test start*************');
try {
let temp = hidebug.getServiceDump(10);
console.info("ServiceDump is " + temp);
expect(temp.indexof('Success')!=-1).assertTrue();
} catch (error) {
expect().assertFail();
}
console.log('************* DFX_DFR_Hiprofiler_Interface_0015 Test end*************');
});
/*
* @tc.number : DFX_DFR_Hiprofiler_Interface_0016
* @tc.name : getServiceDump with abnormal parameter
* @tc.desc : getServiceDump
*/
it('DFX_DFR_Hiprofiler_Interface_0016', 0, function() {
console.log('************* DFX_DFR_Hiprofiler_Interface_0016 Test start*************');
try {
let temp = hidebug.getServiceDump(-1);
console.info("ServiceDump is " + temp);
expect(temp=="Error: no such system ability service.").assertTrue();
} catch (error) {
expect().assertFail();
}
console.log('************* DFX_DFR_Hiprofiler_Interface_0016 Test end*************');
});
/*
* @tc.number : DFX_DFR_Hiprofiler_Interface_0017
* @tc.name : getServiceDump with overlog parameter
* @tc.desc : getServiceDump
*/
it('DFX_DFR_Hiprofiler_Interface_0017', 0, function() {
console.log('************* DFX_DFR_Hiprofiler_Interface_0017 Test start*************');
try {
let temp = hidebug.getServiceDump(9007199254740993);
console.info("ServiceDump is " + temp);
expect(temp=="Error: invalid param").assertTrue();
} catch (error) {
expect().assertFail();
}
console.log('************* DFX_DFR_Hiprofiler_Interface_0017 Test end*************');
});
}) })
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册