提交 93a4d50d 编写于 作者: R raoxian

update securitylabel.test.js

Signed-off-by: Nraoxian <raoxian@huawei.com>
上级 d2778341
...@@ -33,7 +33,7 @@ describe('securitylabel', function () { ...@@ -33,7 +33,7 @@ describe('securitylabel', function () {
fileio.openSync(fpath, 0o102, 0o666); fileio.openSync(fpath, 0o102, 0o666);
try { try {
securitylabel.setSecurityLabel(fpath, 's0', function (err, flag) { securitylabel.setSecurityLabel(fpath, 's0', function (err) {
securitylabel.getSecurityLabel(fpath, function (err, dataLevel) { securitylabel.getSecurityLabel(fpath, function (err, dataLevel) {
expect(dataLevel == 's0').assertTrue(); expect(dataLevel == 's0').assertTrue();
expect(fileio.unlinkSync(fpath) == null).assertTrue(); expect(fileio.unlinkSync(fpath) == null).assertTrue();
...@@ -60,7 +60,7 @@ describe('securitylabel', function () { ...@@ -60,7 +60,7 @@ describe('securitylabel', function () {
fileio.openSync(fpath, 0o102, 0o666); fileio.openSync(fpath, 0o102, 0o666);
try { try {
securitylabel.setSecurityLabel(fpath, 's1', async function (err, flag) { securitylabel.setSecurityLabel(fpath, 's1', async function (err) {
let dataLevel = await securitylabel.getSecurityLabel(fpath); let dataLevel = await securitylabel.getSecurityLabel(fpath);
expect(dataLevel == 's1').assertTrue(); expect(dataLevel == 's1').assertTrue();
expect(fileio.unlinkSync(fpath) == null).assertTrue(); expect(fileio.unlinkSync(fpath) == null).assertTrue();
...@@ -86,7 +86,7 @@ describe('securitylabel', function () { ...@@ -86,7 +86,7 @@ describe('securitylabel', function () {
fileio.openSync(fpath, 0o102, 0o666); fileio.openSync(fpath, 0o102, 0o666);
try { try {
let flag = await securitylabel.setSecurityLabel(fpath, 's2'); await securitylabel.setSecurityLabel(fpath, 's2');
securitylabel.getSecurityLabel(fpath, function (err, dataLevel) { securitylabel.getSecurityLabel(fpath, function (err, dataLevel) {
expect(dataLevel == 's2').assertTrue(); expect(dataLevel == 's2').assertTrue();
expect(fileio.unlinkSync(fpath) == null).assertTrue(); expect(fileio.unlinkSync(fpath) == null).assertTrue();
...@@ -112,7 +112,7 @@ describe('securitylabel', function () { ...@@ -112,7 +112,7 @@ describe('securitylabel', function () {
fileio.openSync(fpath, 0o102, 0o666); fileio.openSync(fpath, 0o102, 0o666);
try { try {
let flag = await securitylabel.setSecurityLabel(fpath, 's3'); await securitylabel.setSecurityLabel(fpath, 's3');
let dataLevel = await securitylabel.getSecurityLabel(fpath); let dataLevel = await securitylabel.getSecurityLabel(fpath);
expect(dataLevel == 's3').assertTrue(); expect(dataLevel == 's3').assertTrue();
expect(fileio.unlinkSync(fpath) == null).assertTrue(); expect(fileio.unlinkSync(fpath) == null).assertTrue();
...@@ -137,7 +137,7 @@ describe('securitylabel', function () { ...@@ -137,7 +137,7 @@ describe('securitylabel', function () {
fileio.openSync(fpath, 0o102, 0o666); fileio.openSync(fpath, 0o102, 0o666);
try { try {
let flag = await securitylabel.setSecurityLabel(fpath, 's4'); await securitylabel.setSecurityLabel(fpath, 's4');
let dataLevel = await securitylabel.getSecurityLabel(fpath); let dataLevel = await securitylabel.getSecurityLabel(fpath);
expect(dataLevel == 's4').assertTrue(); expect(dataLevel == 's4').assertTrue();
expect(fileio.unlinkSync(fpath) == null).assertTrue(); expect(fileio.unlinkSync(fpath) == null).assertTrue();
...@@ -159,9 +159,10 @@ describe('securitylabel', function () { ...@@ -159,9 +159,10 @@ describe('securitylabel', function () {
*/ */
it('securitylabel_test_set_security_label_async_005', 0, async function (done) { it('securitylabel_test_set_security_label_async_005', 0, async function (done) {
try { try {
let flag = await securitylabel.setSecurityLabel('', 's0'); securitylabel.setSecurityLabel('', 's0', function (err) {
expect(flag == false).assertTrue(); expect(err.code == '-1').assertTrue();
done(); done();
});
} catch (e) { } catch (e) {
console.log('securitylabel_test_set_security_label_async_005 has failed for ' + e); console.log('securitylabel_test_set_security_label_async_005 has failed for ' + e);
expect(null).assertFail(); expect(null).assertFail();
...@@ -180,9 +181,10 @@ describe('securitylabel', function () { ...@@ -180,9 +181,10 @@ describe('securitylabel', function () {
*/ */
it('securitylabel_test_set_security_label_async_006', 0, async function (done) { it('securitylabel_test_set_security_label_async_006', 0, async function (done) {
try { try {
let flag = await securitylabel.setSecurityLabel('/data/test.txt', 's0'); securitylabel.setSecurityLabel('/data/test.txt', 's0', function (err) {
expect(flag == false).assertTrue(); expect(err.code == '-1').assertTrue();
done(); done();
});
} catch (e) { } catch (e) {
console.log('securitylabel_test_set_security_label_async_006 has failed for ' + e); console.log('securitylabel_test_set_security_label_async_006 has failed for ' + e);
expect(null).assertFail(); expect(null).assertFail();
...@@ -225,10 +227,13 @@ describe('securitylabel', function () { ...@@ -225,10 +227,13 @@ describe('securitylabel', function () {
fileio.openSync(fpath, 0o102, 0o666); fileio.openSync(fpath, 0o102, 0o666);
try { try {
let flag = await securitylabel.setSecurityLabel(fpath, ''); securitylabel.setSecurityLabel(fpath, '', async function (err) {
expect(flag == false).assertTrue(); expect(err.code == '-1').assertTrue();
expect(fileio.unlinkSync(fpath) == null).assertTrue(); let dataLevel = await securitylabel.getSecurityLabel(fpath);
done(); expect(dataLevel == '').assertTrue();
expect(fileio.unlinkSync(fpath) == null).assertTrue();
done();
});
} catch (e) { } catch (e) {
console.log('securitylabel_test_set_security_label_async_008 has failed for ' + e); console.log('securitylabel_test_set_security_label_async_008 has failed for ' + e);
expect(null).assertFail(); expect(null).assertFail();
...@@ -250,10 +255,13 @@ describe('securitylabel', function () { ...@@ -250,10 +255,13 @@ describe('securitylabel', function () {
fileio.openSync(fpath, 0o102, 0o666); fileio.openSync(fpath, 0o102, 0o666);
try { try {
let flag = await securitylabel.setSecurityLabel(fpath, 'ss'); securitylabel.setSecurityLabel(fpath, 'ss', async function (err) {
expect(flag == false).assertTrue(); expect(err.code == '-1').assertTrue();
expect(fileio.unlinkSync(fpath) == null).assertTrue(); let dataLevel = await securitylabel.getSecurityLabel(fpath);
done(); expect(dataLevel == '').assertTrue();
expect(fileio.unlinkSync(fpath) == null).assertTrue();
done();
});
} catch (e) { } catch (e) {
console.log('securitylabel_test_set_security_label_async_009 has failed for ' + e); console.log('securitylabel_test_set_security_label_async_009 has failed for ' + e);
expect(null).assertFail(); expect(null).assertFail();
...@@ -300,7 +308,7 @@ describe('securitylabel', function () { ...@@ -300,7 +308,7 @@ describe('securitylabel', function () {
fileio.openSync(fpath, 0o102, 0o666); fileio.openSync(fpath, 0o102, 0o666);
try { try {
securitylabel.setSecurityLabel(fpath, 's0', '', function (err, flag) { securitylabel.setSecurityLabel(fpath, 's0', '', function (err) {
done(); done();
}) })
} catch (e) { } catch (e) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册