提交 53dacae3 编写于 作者: R raoxian

update storage sandbox path

Signed-off-by: Nraoxian <raoxian@huawei.com>
上级 a7b585ad
......@@ -14,6 +14,7 @@
*/
import fileio from '@ohos.fileio'
import featureAbility from '@ohos.ability.featureAbility';
export const FILE_CONTENT = 'hello world'
......@@ -32,12 +33,16 @@ export function prepareFile(fpath, content) {
}
}
export function nextFileName(testName) {
const BASE_PATH = '/data/storage/el2/base/haps/entry/cache/'
export async function nextFileName(testName) {
let context = featureAbility.getContext();
let data = await context.getCacheDir();
let BASE_PATH = data + '/';
return BASE_PATH + testName
}
export function fileName(testName) {
const BASE_PATH = '/data/storage/el2/base/haps/entry/files/'
export async function fileName(testName) {
let context = featureAbility.getContext();
let data = await context.getFilesDir();
let BASE_PATH = data + '/';
return BASE_PATH + testName
}
......
......@@ -19,7 +19,7 @@ import {
it,
expect
}
from 'deccjsunit/index'
from 'deccjsunit/index'
import {
FILE_CONTENT,
prepareFile,
......@@ -38,8 +38,8 @@ describe('FileIOError', function () {
* @tc.name fileio_test_error_000
* @tc.desc Function of API, Delete directories with files
*/
it('fileio_test_error_000', 0, function () {
let dpath = fileName('fileio_test_error_000d');
it('fileio_test_error_000', 0, async function (done) {
let dpath = await fileName('fileio_test_error_000d');
let fpath = dpath + '/fileio_test_error_000f';
fileio.mkdirSync(dpath);
expect(prepareFile(fpath, 'hello')).assertTrue();
......@@ -49,10 +49,11 @@ describe('FileIOError', function () {
fileio.rmdirSync(dpath);
}
catch (err) {
console.log('fileio_test_error_000 has failed for ' + err);
console.info('fileio_test_error_000 has failed for ' + err);
expect(isInclude(err.message, 'Directory not empty')).assertTrue();
fileio.unlinkSync(fpath);
fileio.rmdirSync(dpath);
done();
}
});
......@@ -61,8 +62,8 @@ describe('FileIOError', function () {
* @tc.name fileio_test_error_001
* @tc.desc Function of API, delete file
*/
it('fileio_test_error_001', 0, function () {
let fpath = fileName('fileio_test_error_001f');
it('fileio_test_error_001', 0, async function (done) {
let fpath = await fileName('fileio_test_error_001f');
expect(prepareFile(fpath, 'hello')).assertTrue();
try {
let fd = fileio.openSync(fpath);
......@@ -71,9 +72,10 @@ describe('FileIOError', function () {
expect(null).assertFail();
}
catch (err) {
console.log('fileio_test_error_001 has failed for ' + err);
console.info('fileio_test_error_001 has failed for ' + err);
expect(isInclude(err.message, 'Not a directory')).assertTrue();
fileio.unlinkSync(fpath);
done();
}
});
......@@ -82,17 +84,18 @@ describe('FileIOError', function () {
* @tc.name fileio_test_error_002
* @tc.desc Function of API, flags=0o102. missing mode parameter.
*/
it('fileio_test_error_002', 0, function () {
let fpath = nextFileName('fileio_test_error_002');
it('fileio_test_error_002', 0, async function (done) {
let fpath = await nextFileName('fileio_test_error_002');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
fileio.openSync(fpath, 0o102);
expect(null).assertFail();
}
catch (err) {
console.log('fileio_test_error_002 has failed for ' + err);
console.info('fileio_test_error_002 has failed for ' + err);
expect(isInclude(err.message, 'called with O_CREAT/O_TMPFILE but no mode')).assertTrue();
fileio.unlinkSync(fpath);
done();
}
});
......@@ -101,15 +104,16 @@ describe('FileIOError', function () {
* @tc.name fileio_test_error_003
* @tc.desc Function of API, flags=0o102, missing mode parameter.
*/
it('fileio_test_error_003', 0, function () {
let fpath = nextFileName('fileio_test_error_003');
it('fileio_test_error_003', 0, async function (done) {
let fpath = await nextFileName('fileio_test_error_003');
try {
fileio.openSync(fpath, 0o102);
expect(null).assertFail();
}
catch (err) {
console.log('fileio_test_error_003 has failed for ' + err);
console.info('fileio_test_error_003 has failed for ' + err);
expect(isInclude(err.message, 'called with O_CREAT/O_TMPFILE but no mode')).assertTrue();
done();
}
});
......@@ -118,16 +122,17 @@ describe('FileIOError', function () {
* @tc.name fileio_test_error_004
* @tc.desc Function of API, flags=0o302. The test file is exist.
*/
it('fileio_test_error_004', 0, function () {
let fpath = nextFileName('fileio_test_error_004');
it('fileio_test_error_004', 0, async function (done) {
let fpath = await nextFileName('fileio_test_error_004');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
fileio.openSync(fpath, 0o302, 0o666);
}
catch (err) {
console.log('fileio_test_error_004 has failed for ' + err);
console.info('fileio_test_error_004 has failed for ' + err);
expect(isInclude(err.message, 'File exists')).assertTrue();
fileio.unlinkSync(fpath);
done();
}
});
......@@ -136,16 +141,17 @@ describe('FileIOError', function () {
* @tc.name fileio_test_error_005
* @tc.desc Function of API, flags=0o100002. The test file is exist.
*/
it('fileio_test_error_005', 0, function () {
let fpath = nextFileName('fileio_test_error_005');
it('fileio_test_error_005', 0, async function (done) {
let fpath = await nextFileName('fileio_test_error_005');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
fileio.openSync(fpath, 0o100002);
expect(null).assertFail();
}
catch (err) {
console.log('fileio_test_error_005 has failed for ' + err);
console.info('fileio_test_error_005 has failed for ' + err);
fileio.unlinkSync(fpath);
done();
}
});
......@@ -154,17 +160,18 @@ describe('FileIOError', function () {
* @tc.name fileio_test_error_006
* @tc.desc Function of API, flags=0o40002 The test file is exist.
*/
it('fileio_test_error_006', 0, function () {
let dpath = nextFileName('fileio_test_error_006');
it('fileio_test_error_006', 0, async function (done) {
let dpath = await nextFileName('fileio_test_error_006');
fileio.mkdirSync(dpath);
try {
fileio.openSync(dpath, 0o40002);
expect(null).assertFail();
}
catch (err) {
console.log('fileio_test_error_006 has failed for ' + err);
console.info('fileio_test_error_006 has failed for ' + err);
expect(isInclude(err.message, 'called with O_CREAT/O_TMPFILE but no mode')).assertTrue();
fileio.rmdirSync(dpath);
done();
}
});
......@@ -173,8 +180,8 @@ describe('FileIOError', function () {
* @tc.name fileio_test_error_007
* @tc.desc Function of API, flags=0o400002. The test file is exist.
*/
it('fileio_test_error_007', 0, function () {
let fpath = nextFileName('fileio_test_error_007');
it('fileio_test_error_007', 0, async function (done) {
let fpath = await nextFileName('fileio_test_error_007');
let txt = 'h'
expect(prepareFile(fpath, txt)).assertTrue();
try {
......@@ -182,8 +189,9 @@ describe('FileIOError', function () {
expect(null).assertFail();
}
catch (err) {
console.log('fileio_test_error_007 has failed for ' + err);
console.info('fileio_test_error_007 has failed for ' + err);
fileio.unlinkSync(fpath);
done();
}
});
......@@ -192,8 +200,8 @@ describe('FileIOError', function () {
* @tc.name fileio_test_error_008
* @tc.desc Function of API, flags=0o400002. The test file is exist.
*/
it('fileio_test_error_008', 0, function () {
let fpath = nextFileName('fileio_test_error_008');
it('fileio_test_error_008', 0, async function (done) {
let fpath = await nextFileName('fileio_test_error_008');
let txt = randomString(5000);
expect(prepareFile(fpath, txt)).assertTrue();
try {
......@@ -201,8 +209,9 @@ describe('FileIOError', function () {
expect(null).assertFail();
}
catch (err) {
console.log('fileio_test_error_008 has failed for ' + err);
console.info('fileio_test_error_008 has failed for ' + err);
fileio.unlinkSync(fpath);
done();
}
});
......@@ -211,15 +220,16 @@ describe('FileIOError', function () {
* @tc.name fileio_test_error_009
* @tc.desc Function of API, flags=0o10000102. The test file is exist.
*/
it('fileio_test_error_009', 0, function () {
let fpath = nextFileName('fileio_test_error_009');
it('fileio_test_error_009', 0, async function (done) {
let fpath = await nextFileName('fileio_test_error_009');
try {
fileio.openSync(fpath, 0o10000102);
expect(null).assertFail();
}
catch (err) {
console.log('fileio_test_error_009 has failed for ' + err);
console.info('fileio_test_error_009 has failed for ' + err);
expect(isInclude(err.message, 'called with O_CREAT/O_TMPFILE but no mode')).assertTrue();
done();
}
});
......@@ -228,17 +238,18 @@ describe('FileIOError', function () {
* @tc.name fileio_test_error_010
* @tc.desc Function of API, flags=0o200000. Invalid argument.
*/
it('fileio_test_error_010', 0, function () {
let dpath = fileName('fileio_test_error_010d');
it('fileio_test_error_010', 0, async function (done) {
let dpath = await fileName('fileio_test_error_010d');
fileio.mkdirSync(dpath);
try {
fileio.openSync(dpath, 0o200000);
expect(null).assertFail();
}
catch (err) {
console.log('fileio_test_error_010 has failed for ' + err);
console.info('fileio_test_error_010 has failed for ' + err);
expect(isInclude(err.message, 'Invalid argument')).assertTrue();
fileio.rmdirSync(dpath);
done();
}
});
......
......@@ -19,7 +19,7 @@ import featureAbility from '@ohos.ability.featureAbility';
export const FILE_CONTENT = 'hello world';
import {
describe, beforeAll, beforeEach, afterEach, afterAll, it, expect
describe, it, expect
}
from 'deccjsunit/index'
......@@ -80,8 +80,8 @@ export function nextFileName1(testName) {
}
export async function nextFileName(testName) {
let context = featureAbility.getContext();
let data = await context.getFilesDir();
let BASE_PATH = data.substring(0, data.length - 5) + 'cache/';
let data = await context.getCacheDir();
let BASE_PATH = data + '/';
return BASE_PATH + testName + '_' + randomString(testName.length);
}
export async function fileName(testName) {
......@@ -120,10 +120,6 @@ export {
isString,
isBoolean,
describe,
beforeAll,
beforeEach,
afterEach,
afterAll,
it,
expect
};
\ No newline at end of file
......@@ -46,10 +46,10 @@ describe('fileIOTestStream', function () {
expect(ss !== null).assertTrue();
expect(ss.closeSync() !== null).assertTrue();
expect(fileio.unlinkSync(fpath) !== null).assertTrue();
console.log('fileio_test_stream_create_stream_sync_000 is passed!');
console.info('fileio_test_stream_create_stream_sync_000 is passed!');
}
catch (e) {
console.log('fileio_test_stream_create_stream_sync_000 has failed for ' + e);
console.info('fileio_test_stream_create_stream_sync_000 has failed for ' + e);
expect(null).assertFail();
}
});
......@@ -66,7 +66,7 @@ describe('fileIOTestStream', function () {
expect(null).assertFail();
}
catch (e) {
console.log('fileio_test_stream_create_stream_sync_001 has failed for ' + e);
console.info('fileio_test_stream_create_stream_sync_001 has failed for ' + e);
}
});
......@@ -94,7 +94,7 @@ describe('fileIOTestStream', function () {
expect(fileio.unlinkSync(fpath) !== null).assertTrue();
}
catch (e) {
console.log('fileio_test_stream_create_stream_sync_002 has failed for ' + e);
console.info('fileio_test_stream_create_stream_sync_002 has failed for ' + e);
expect(null).assertFail();
}
});
......@@ -113,7 +113,7 @@ describe('fileIOTestStream', function () {
expect(fileio.unlinkSync(fpath) !== null).assertTrue();
}
catch (e) {
console.log('fileio_test_stream_create_stream_sync_003 has failed for ' + e);
console.info('fileio_test_stream_create_stream_sync_003 has failed for ' + e);
expect(null).assertFail();
}
});
......@@ -142,7 +142,7 @@ describe('fileIOTestStream', function () {
expect(fileio.unlinkSync(fpath) !== null).assertTrue();
}
catch (e) {
console.log('fileio_test_stream_create_stream_sync_004 has failed for ' + e);
console.info('fileio_test_stream_create_stream_sync_004 has failed for ' + e);
expect(fileio.unlinkSync(fpath) !== null).assertTrue();
expect(null).assertFail();
}
......@@ -162,7 +162,7 @@ describe('fileIOTestStream', function () {
expect(fileio.unlinkSync(fpath) !== null).assertTrue();
}
catch (e) {
console.log('fileio_test_stream_create_stream_sync_005 has failed for ' + e);
console.info('fileio_test_stream_create_stream_sync_005 has failed for ' + e);
expect(null).assertFail();
}
});
......@@ -182,7 +182,7 @@ describe('fileIOTestStream', function () {
expect(fileio.unlinkSync(fpath) !== null).assertTrue();
}
catch (e) {
console.log('fileio_test_stream_create_stream_sync_006 has failed for ' + e);
console.info('fileio_test_stream_create_stream_sync_006 has failed for ' + e);
expect(null).assertFail();
}
});
......@@ -199,7 +199,7 @@ describe('fileIOTestStream', function () {
expect(null).assertFail();
}
catch (e) {
console.log('fileio_test_stream_create_stream_sync_007 has failed for ' + e);
console.info('fileio_test_stream_create_stream_sync_007 has failed for ' + e);
}
});
......@@ -226,7 +226,7 @@ describe('fileIOTestStream', function () {
expect(fileio.unlinkSync(fpath) !== null).assertTrue();
}
catch (e) {
console.log('fileio_test_stream_create_stream_sync_008 has failed for ' + e);
console.info('fileio_test_stream_create_stream_sync_008 has failed for ' + e);
expect(null).assertFail();
}
});
......@@ -245,7 +245,7 @@ describe('fileIOTestStream', function () {
expect(fileio.unlinkSync(fpath) !== null).assertTrue();
}
catch (e) {
console.log('fileio_test_stream_create_stream_sync_009 has failed for ' + e);
console.info('fileio_test_stream_create_stream_sync_009 has failed for ' + e);
expect(null).assertFail();
}
});
......@@ -273,7 +273,7 @@ describe('fileIOTestStream', function () {
expect(fileio.unlinkSync(fpath) !== null).assertTrue();
}
catch (e) {
console.log('fileio_test_stream_create_stream_sync_010 has failed for ' + e);
console.info('fileio_test_stream_create_stream_sync_010 has failed for ' + e);
expect(null).assertFail();
}
});
......@@ -292,7 +292,7 @@ describe('fileIOTestStream', function () {
expect(fileio.unlinkSync(fpath) !== null).assertTrue();
}
catch (e) {
console.log('fileio_test_stream_create_stream_sync_011 has failed for ' + e);
console.info('fileio_test_stream_create_stream_sync_011 has failed for ' + e);
expect(null).assertFail();
}
});
......@@ -313,7 +313,7 @@ describe('fileIOTestStream', function () {
expect(fileio.unlinkSync(fpath) !== null).assertTrue();
}
catch (e) {
console.log('fileio_test_stream_create_stream_sync_012 has failed for ' + e);
console.info('fileio_test_stream_create_stream_sync_012 has failed for ' + e);
expect(null).assertFail();
}
});
......@@ -330,7 +330,7 @@ describe('fileIOTestStream', function () {
expect(null).assertFail();
}
catch (e) {
console.log('fileio_test_stream_create_stream_sync_013 has failed for ' + e);
console.info('fileio_test_stream_create_stream_sync_013 has failed for ' + e);
}
});
......@@ -358,7 +358,7 @@ describe('fileIOTestStream', function () {
expect(fileio.unlinkSync(fpath) !== null).assertTrue();
}
catch (e) {
console.log('fileio_test_stream_create_stream_sync_014 has failed for ' + e);
console.info('fileio_test_stream_create_stream_sync_014 has failed for ' + e);
expect(null).assertFail();
}
});
......@@ -377,7 +377,7 @@ describe('fileIOTestStream', function () {
expect(fileio.unlinkSync(fpath) !== null).assertTrue();
}
catch (e) {
console.log('fileio_test_stream_create_stream_sync_015 has failed for ' + e);
console.info('fileio_test_stream_create_stream_sync_015 has failed for ' + e);
expect(null).assertFail();
}
});
......@@ -404,10 +404,10 @@ describe('fileIOTestStream', function () {
expect(rlen == text.length + 1).assertTrue();
expect(ss.closeSync() !== null).assertTrue();
expect(fileio.unlinkSync(fpath) !== null).assertTrue();
console.log('fileio_test_stream_create_stream_sync_016 is passed!');
console.info('fileio_test_stream_create_stream_sync_016 is passed!');
}
catch (e) {
console.log('fileio_test_stream_create_stream_sync_016 has failed for ' + e);
console.info('fileio_test_stream_create_stream_sync_016 has failed for ' + e);
expect(null).assertFail();
}
});
......@@ -426,7 +426,7 @@ describe('fileIOTestStream', function () {
expect(fileio.unlinkSync(fpath) !== null).assertTrue();
}
catch (e) {
console.log('fileio_test_stream_create_stream_sync_017 has failed for ' + e);
console.info('fileio_test_stream_create_stream_sync_017 has failed for ' + e);
expect(null).assertFail();
}
});
......@@ -446,7 +446,7 @@ describe('fileIOTestStream', function () {
expect(fileio.unlinkSync(fpath) !== null).assertTrue();
}
catch (e) {
console.log('fileio_test_stream_create_stream_sync_018 has failed for ' + e);
console.info('fileio_test_stream_create_stream_sync_018 has failed for ' + e);
expect(null).assertFail();
}
});
......@@ -463,7 +463,7 @@ describe('fileIOTestStream', function () {
expect(null).assertFail();
}
catch (e) {
console.log('fileio_test_stream_create_stream_sync_019 has failed for ' + e);
console.info('fileio_test_stream_create_stream_sync_019 has failed for ' + e);
}
});
......@@ -490,7 +490,7 @@ describe('fileIOTestStream', function () {
expect(fileio.unlinkSync(fpath) !== null).assertTrue();
}
catch (e) {
console.log('fileio_test_stream_create_stream_sync_020 has failed for ' + e);
console.info('fileio_test_stream_create_stream_sync_020 has failed for ' + e);
expect(null).assertFail();
}
});
......@@ -509,7 +509,7 @@ describe('fileIOTestStream', function () {
expect(fileio.unlinkSync(fpath) !== null).assertTrue();
}
catch (e) {
console.log('fileio_test_stream_create_stream_sync_021 has failed for ' + e);
console.info('fileio_test_stream_create_stream_sync_021 has failed for ' + e);
expect(null).assertFail();
}
});
......@@ -537,7 +537,7 @@ describe('fileIOTestStream', function () {
expect(fileio.unlinkSync(fpath) !== null).assertTrue();
}
catch (e) {
console.log('fileio_test_stream_create_stream_sync_022 has failed for ' + e);
console.info('fileio_test_stream_create_stream_sync_022 has failed for ' + e);
expect(null).assertFail();
}
});
......@@ -556,7 +556,7 @@ describe('fileIOTestStream', function () {
expect(fileio.unlinkSync(fpath) !== null).assertTrue();
}
catch (e) {
console.log('fileio_test_stream_create_stream_sync_023 has failed for ' + e);
console.info('fileio_test_stream_create_stream_sync_023 has failed for ' + e);
expect(null).assertFail();
}
});
......@@ -572,7 +572,7 @@ describe('fileIOTestStream', function () {
expect(null).assertFail();
}
catch (e) {
console.log('fileio_test_stream_create_stream_sync_024 is passed!' + e);
console.info('fileio_test_stream_create_stream_sync_024 is passed!' + e);
}
});
......@@ -589,7 +589,7 @@ describe('fileIOTestStream', function () {
expect(null).assertFail();
}
catch (e) {
console.log('fileio_test_stream_create_stream_sync_025 is passed!' + e);
console.info('fileio_test_stream_create_stream_sync_025 is passed!' + e);
expect(fileio.unlinkSync(fpath) !== null).assertTrue();
}
});
......@@ -615,7 +615,7 @@ describe('fileIOTestStream', function () {
expect(null).assertFail();
}
catch (e) {
console.log('fileio_test_stream_create_stream_sync_026 has failed for ' + e);
console.info('fileio_test_stream_create_stream_sync_026 has failed for ' + e);
}
});
......@@ -631,7 +631,7 @@ describe('fileIOTestStream', function () {
expect(null).assertFail();
}
catch (e) {
console.log('fileio_test_stream_create_stream_sync_027 has failed for ' + e);
console.info('fileio_test_stream_create_stream_sync_027 has failed for ' + e);
}
});
......@@ -656,7 +656,7 @@ describe('fileIOTestStream', function () {
expect(null).assertFail();
}
catch (e) {
console.log('fileio_test_stream_create_stream_sync_028 has failed for ' + e);
console.info('fileio_test_stream_create_stream_sync_028 has failed for ' + e);
}
});
......@@ -672,7 +672,57 @@ describe('fileIOTestStream', function () {
expect(null).assertFail();
}
catch (e) {
console.log('fileio_test_stream_create_stream_sync_029 has failed for ' + e);
console.info('fileio_test_stream_create_stream_sync_029 has failed for ' + e);
}
});
/**
* @tc.number SUB_STORAGE_FileIO_stream_CreateStreamSync_3000
* @tc.name fileio_test_stream_create_stream_sync_030
* @tc.desc Function of API, mode = w+. Test file length is cleared to 0.
*/
it('fileio_test_stream_create_stream_sync_030', 0, async function () {
let fpath = await nextFileName('fileio_test_stream_create_stream_sync_030');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let fd = fileio.openSync(fpath, 0o102, 0o666);
let buf = new ArrayBuffer(4096);
let number = fileio.readSync(fd, buf);
expect(number == 11).assertTrue();
let ss = fileio.createStreamSync(fpath, 'w+');
let num = ss.readSync(buf);
expect(num == 0).assertTrue();
ss.closeSync();
fileio.unlinkSync(fpath);
}
catch (e) {
console.info('fileio_test_stream_create_stream_sync_030 has failed for ' + e);
expect(null).assertFail();
}
});
/**
* @tc.number SUB_STORAGE_FileIO_stream_CreateStreamSync_3100
* @tc.name fileio_test_stream_create_stream_sync_031
* @tc.desc Function of API, mode = w. Test file length is cleared to 0.
*/
it('fileio_test_stream_create_stream_sync_031', 0, async function () {
let fpath = await nextFileName('fileio_test_stream_create_stream_sync_031');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let fd = fileio.openSync(fpath, 0o102, 0o666);
let buf = new ArrayBuffer(4096);
let number = fileio.readSync(fd, buf);
expect(number == 11).assertTrue();
let ss = fileio.createStreamSync(fpath, 'w');
let num = fileio.readSync(fd, buf);
expect(num == 0).assertTrue();
ss.closeSync();
fileio.unlinkSync(fpath);
}
catch (e) {
console.info('fileio_test_stream_create_stream_sync_031 has failed for ' + e);
expect(null).assertFail();
}
});
......@@ -693,7 +743,7 @@ describe('fileIOTestStream', function () {
expect(fileio.unlinkSync(fpath) !== null).assertTrue();
}
catch (e) {
console.log('fileio_test_stream_fdopen_stream_sync_000 has failed for ' + e);
console.info('fileio_test_stream_fdopen_stream_sync_000 has failed for ' + e);
expect(null).assertFail();
}
});
......@@ -711,7 +761,7 @@ describe('fileIOTestStream', function () {
expect(null).assertFail();
}
catch (e) {
console.log('fileio_test_stream_fdopen_stream_sync_001 has failed for ' + e);
console.info('fileio_test_stream_fdopen_stream_sync_001 has failed for ' + e);
}
});
......@@ -742,7 +792,7 @@ describe('fileIOTestStream', function () {
expect(fileio.unlinkSync(fpath) !== null).assertTrue();
}
catch (e) {
console.log('fileio_test_stream_fdopen_stream_sync_002 has failed for ' + e);
console.info('fileio_test_stream_fdopen_stream_sync_002 has failed for ' + e);
expect(null).assertFail();
}
});
......@@ -762,7 +812,7 @@ describe('fileIOTestStream', function () {
expect(fileio.unlinkSync(fpath) !== null).assertTrue();
}
catch (e) {
console.log('fileio_test_stream_fdopen_stream_sync_003 has failed for ' + e);
console.info('fileio_test_stream_fdopen_stream_sync_003 has failed for ' + e);
expect(null).assertFail();
}
});
......@@ -793,7 +843,7 @@ describe('fileIOTestStream', function () {
expect(fileio.unlinkSync(fpath) !== null).assertTrue();
}
catch (e) {
console.log('fileio_test_stream_fdopen_stream_sync_004 has failed for ' + e);
console.info('fileio_test_stream_fdopen_stream_sync_004 has failed for ' + e);
expect(null).assertFail();
}
});
......@@ -813,7 +863,7 @@ describe('fileIOTestStream', function () {
expect(fileio.unlinkSync(fpath) !== null).assertTrue();
}
catch (e) {
console.log('fileio_test_stream_fdopen_stream_sync_005 has failed for ' + e);
console.info('fileio_test_stream_fdopen_stream_sync_005 has failed for ' + e);
expect(null).assertFail();
}
});
......@@ -834,7 +884,7 @@ describe('fileIOTestStream', function () {
expect(fileio.unlinkSync(fpath) !== null).assertTrue();
}
catch (e) {
console.log('fileio_test_stream_fdopen_stream_sync_006 has failed for ' + e);
console.info('fileio_test_stream_fdopen_stream_sync_006 has failed for ' + e);
expect(null).assertFail();
}
});
......@@ -850,7 +900,7 @@ describe('fileIOTestStream', function () {
expect(null).assertFail();
}
catch (e) {
console.log('fileio_test_stream_fdopen_stream_sync_007 has failed for ' + e);
console.info('fileio_test_stream_fdopen_stream_sync_007 has failed for ' + e);
}
});
......@@ -879,7 +929,7 @@ describe('fileIOTestStream', function () {
expect(fileio.unlinkSync(fpath) !== null).assertTrue();
}
catch (e) {
console.log('fileio_test_stream_fdopen_stream_sync_008 has failed for ' + e);
console.info('fileio_test_stream_fdopen_stream_sync_008 has failed for ' + e);
expect(null).assertFail();
}
});
......@@ -899,7 +949,7 @@ describe('fileIOTestStream', function () {
expect(fileio.unlinkSync(fpath) !== null).assertTrue();
}
catch (e) {
console.log('fileio_test_stream_fdopen_stream_sync_009 has failed for ' + e);
console.info('fileio_test_stream_fdopen_stream_sync_009 has failed for ' + e);
expect(null).assertFail();
}
});
......@@ -929,7 +979,7 @@ describe('fileIOTestStream', function () {
expect(fileio.unlinkSync(fpath) !== null).assertTrue();
}
catch (e) {
console.log('fileio_test_stream_fdopen_stream_sync_010 has failed for ' + e);
console.info('fileio_test_stream_fdopen_stream_sync_010 has failed for ' + e);
expect(null).assertFail();
}
});
......@@ -949,7 +999,7 @@ describe('fileIOTestStream', function () {
expect(fileio.unlinkSync(fpath) !== null).assertTrue();
}
catch (e) {
console.log('fileio_test_stream_fdopen_stream_sync_011 has failed for ' + e);
console.info('fileio_test_stream_fdopen_stream_sync_011 has failed for ' + e);
expect(null).assertFail();
}
});
......@@ -971,7 +1021,7 @@ describe('fileIOTestStream', function () {
expect(fileio.unlinkSync(fpath) !== null).assertTrue();
}
catch (e) {
console.log('fileio_test_stream_fdopen_stream_sync_012 has failed for ' + e);
console.info('fileio_test_stream_fdopen_stream_sync_012 has failed for ' + e);
expect(null).assertFail();
}
});
......@@ -987,7 +1037,7 @@ describe('fileIOTestStream', function () {
expect(null).assertFail();
}
catch (e) {
console.log('fileio_test_stream_fdopen_stream_sync_013 has failed for ' + e);
console.info('fileio_test_stream_fdopen_stream_sync_013 has failed for ' + e);
}
});
......@@ -1017,7 +1067,7 @@ describe('fileIOTestStream', function () {
expect(fileio.unlinkSync(fpath) !== null).assertTrue();
}
catch (e) {
console.log('fileio_test_stream_fdopen_stream_sync_014 has failed for ' + e);
console.info('fileio_test_stream_fdopen_stream_sync_014 has failed for ' + e);
expect(null).assertFail();
}
});
......@@ -1037,7 +1087,7 @@ describe('fileIOTestStream', function () {
expect(fileio.unlinkSync(fpath) !== null).assertTrue();
}
catch (e) {
console.log('fileio_test_stream_fdopen_stream_sync_015 has failed for ' + e);
console.info('fileio_test_stream_fdopen_stream_sync_015 has failed for ' + e);
expect(null).assertFail();
}
});
......@@ -1068,7 +1118,7 @@ describe('fileIOTestStream', function () {
expect(fileio.unlinkSync(fpath) !== null).assertTrue();
}
catch (e) {
console.log('fileio_test_stream_fdopen_stream_sync_016 has failed for ' + e);
console.info('fileio_test_stream_fdopen_stream_sync_016 has failed for ' + e);
expect(null).assertFail();
}
});
......@@ -1088,7 +1138,7 @@ describe('fileIOTestStream', function () {
expect(fileio.unlinkSync(fpath) !== null).assertTrue();
}
catch (e) {
console.log('fileio_test_stream_fdopen_stream_sync_017 has failed for ' + e);
console.info('fileio_test_stream_fdopen_stream_sync_017 has failed for ' + e);
expect(null).assertFail();
}
});
......@@ -1109,7 +1159,7 @@ describe('fileIOTestStream', function () {
expect(fileio.unlinkSync(fpath) !== null).assertTrue();
}
catch (e) {
console.log('fileio_test_stream_fdopen_stream_sync_018 has failed for ' + e);
console.info('fileio_test_stream_fdopen_stream_sync_018 has failed for ' + e);
expect(null).assertFail();
}
});
......@@ -1125,7 +1175,7 @@ describe('fileIOTestStream', function () {
expect(null).assertFail();
}
catch (e) {
console.log('fileio_test_stream_fdopen_stream_sync_019 has failed for ' + e);
console.info('fileio_test_stream_fdopen_stream_sync_019 has failed for ' + e);
}
});
......@@ -1154,7 +1204,7 @@ describe('fileIOTestStream', function () {
expect(fileio.unlinkSync(fpath) !== null).assertTrue();
}
catch (e) {
console.log('fileio_test_stream_fdopen_stream_sync_020 has failed for ' + e);
console.info('fileio_test_stream_fdopen_stream_sync_020 has failed for ' + e);
expect(null).assertFail();
}
});
......@@ -1174,7 +1224,7 @@ describe('fileIOTestStream', function () {
expect(fileio.unlinkSync(fpath) !== null).assertTrue();
}
catch (e) {
console.log('fileio_test_stream_fdopen_stream_sync_021 has failed for ' + e);
console.info('fileio_test_stream_fdopen_stream_sync_021 has failed for ' + e);
expect(null).assertFail();
}
});
......@@ -1204,7 +1254,7 @@ describe('fileIOTestStream', function () {
expect(fileio.unlinkSync(fpath) !== null).assertTrue();
}
catch (e) {
console.log('fileio_test_stream_fdopen_stream_sync_022 has failed for ' + e);
console.info('fileio_test_stream_fdopen_stream_sync_022 has failed for ' + e);
expect(null).assertFail();
}
});
......@@ -1224,7 +1274,7 @@ describe('fileIOTestStream', function () {
expect(fileio.unlinkSync(fpath) !== null).assertTrue();
}
catch (e) {
console.log('fileio_test_stream_fdopen_stream_sync_023 has failed for ' + e);
console.info('fileio_test_stream_fdopen_stream_sync_023 has failed for ' + e);
expect(null).assertFail();
}
});
......@@ -1240,7 +1290,7 @@ describe('fileIOTestStream', function () {
expect(null).assertFail();
}
catch (e) {
console.log('---fileio_test_stream_fdopen_stream_sync_024 is passed!' + e);
console.info('---fileio_test_stream_fdopen_stream_sync_024 is passed!' + e);
}
});
......@@ -1258,7 +1308,7 @@ describe('fileIOTestStream', function () {
expect(null).assertFail();
}
catch (e) {
console.log('---fileio_test_stream_fdopen_stream_sync_025 is passed!' + e);
console.info('---fileio_test_stream_fdopen_stream_sync_025 is passed!' + e);
expect(fileio.unlinkSync(fpath) !== null).assertTrue();
}
});
......@@ -1281,7 +1331,7 @@ describe('fileIOTestStream', function () {
expect(fileio.unlinkSync(fpath) !== null).assertTrue();
}
catch (e) {
console.log('fileio_test_stream_read_sync_000 has failed for ' + e);
console.info('fileio_test_stream_read_sync_000 has failed for ' + e);
expect(null).assertFail();
}
});
......@@ -1306,7 +1356,7 @@ describe('fileIOTestStream', function () {
expect(fileio.unlinkSync(fpath) !== null).assertTrue();
}
catch (e) {
console.log('fileio_test_stream_read_sync_001 has failed for ' + e);
console.info('fileio_test_stream_read_sync_001 has failed for ' + e);
expect(null).assertFail();
}
});
......@@ -1331,7 +1381,7 @@ describe('fileIOTestStream', function () {
expect(fileio.unlinkSync(fpath) !== null).assertTrue();
}
catch (e) {
console.log('fileio_test_stream_read_sync_002 has failed for ' + e);
console.info('fileio_test_stream_read_sync_002 has failed for ' + e);
expect(null).assertFail();
}
});
......@@ -1355,7 +1405,7 @@ describe('fileIOTestStream', function () {
expect(fileio.unlinkSync(fpath) !== null).assertTrue();
}
catch (e) {
console.log('fileio_test_stream_read_sync_003 has failed for ' + e);
console.info('fileio_test_stream_read_sync_003 has failed for ' + e);
expect(null).assertFail();
}
});
......@@ -1376,7 +1426,7 @@ describe('fileIOTestStream', function () {
expect(null).assertFail();
}
catch (e) {
console.log('fileio_test_stream_read_sync_004 has failed for ' + e);
console.info('fileio_test_stream_read_sync_004 has failed for ' + e);
expect(ss.closeSync() !== null).assertTrue();
expect(fileio.unlinkSync(fpath) !== null).assertTrue();
}
......@@ -1402,7 +1452,7 @@ describe('fileIOTestStream', function () {
expect(fileio.unlinkSync(fpath) !== null).assertTrue();
}
catch (e) {
console.log('---fileio_test_stream_read_sync_005 has failed for ' + e);
console.info('---fileio_test_stream_read_sync_005 has failed for ' + e);
expect(null).assertFail();
}
});
......@@ -1425,7 +1475,7 @@ describe('fileIOTestStream', function () {
expect(null).assertFail();
}
catch (e) {
console.log('fileio_test_stream_read_sync_006 has failed for ' + e);
console.info('fileio_test_stream_read_sync_006 has failed for ' + e);
expect(ss.closeSync() !== null).assertTrue();
expect(fileio.unlinkSync(fpath) !== null).assertTrue();
}
......@@ -1446,10 +1496,10 @@ describe('fileIOTestStream', function () {
expect(ss.writeSync(text) == text.length).assertTrue();
expect(ss.closeSync() !== null).assertTrue();
expect(fileio.unlinkSync(fpath) !== null).assertTrue();
console.log('---fileio_test_stream_write_sync_000 is passed!');
console.info('---fileio_test_stream_write_sync_000 is passed!');
}
catch (e) {
console.log('fileio_test_stream_write_sync_000 has failed for ' + e);
console.info('fileio_test_stream_write_sync_000 has failed for ' + e);
expect(null).assertFail();
}
});
......@@ -1472,7 +1522,7 @@ describe('fileIOTestStream', function () {
expect(null).assertFail();
}
catch (e) {
console.log('fileio_test_stream_write_sync_001 has failed for ' + e);
console.info('fileio_test_stream_write_sync_001 has failed for ' + e);
expect(ss.closeSync() !== null).assertTrue();
expect(fileio.unlinkSync(fpath) !== null).assertTrue();
}
......@@ -1502,7 +1552,7 @@ describe('fileIOTestStream', function () {
expect(fileio.unlinkSync(fpath) !== null).assertTrue();
}
catch (e) {
console.log('fileio_test_stream_write_sync_002 has failed for ' + e);
console.info('fileio_test_stream_write_sync_002 has failed for ' + e);
expect(null).assertFail();
}
});
......@@ -1531,7 +1581,7 @@ describe('fileIOTestStream', function () {
expect(fileio.unlinkSync(fpath) !== null).assertTrue();
}
catch (e) {
console.log('fileio_test_stream_write_sync_003 has failed for ' + e);
console.info('fileio_test_stream_write_sync_003 has failed for ' + e);
expect(null).assertFail();
}
});
......@@ -1558,7 +1608,7 @@ describe('fileIOTestStream', function () {
expect(fileio.unlinkSync(fpath) !== null).assertTrue();
}
catch (e) {
console.log('fileio_test_stream_write_sync_004 has failed for ' + e);
console.info('fileio_test_stream_write_sync_004 has failed for ' + e);
expect(null).assertFail();
}
});
......@@ -1589,7 +1639,7 @@ describe('fileIOTestStream', function () {
expect(fileio.unlinkSync(fpath) !== null).assertTrue();
}
catch (e) {
console.log('fileio_test_stream_write_sync_005 has failed for ' + e);
console.info('fileio_test_stream_write_sync_005 has failed for ' + e);
expect(fileio.unlinkSync(fpath) !== null).assertTrue();
expect(null).assertFail();
}
......@@ -1621,7 +1671,7 @@ describe('fileIOTestStream', function () {
expect(fileio.unlinkSync(fpath) !== null).assertTrue();
}
catch (e) {
console.log('fileio_test_stream_write_sync_006 has failed for ' + e);
console.info('fileio_test_stream_write_sync_006 has failed for ' + e);
expect(null).assertFail();
}
});
......@@ -1652,7 +1702,7 @@ describe('fileIOTestStream', function () {
expect(fileio.unlinkSync(fpath) !== null).assertTrue();
}
catch (e) {
console.log('fileio_test_stream_write_sync_007 has failed for ' + e);
console.info('fileio_test_stream_write_sync_007 has failed for ' + e);
expect(null).assertFail();
}
});
......@@ -1681,7 +1731,7 @@ describe('fileIOTestStream', function () {
expect(fileio.unlinkSync(fpath) !== null).assertTrue();
}
catch (e) {
console.log('fileio_test_stream_write_sync_008 has failed for ' + e);
console.info('fileio_test_stream_write_sync_008 has failed for ' + e);
expect(null).assertFail();
}
});
......@@ -1702,7 +1752,7 @@ describe('fileIOTestStream', function () {
}
catch (e) {
expect(fileio.unlinkSync(fpath) !== null).assertTrue();
console.log('fileio_test_stream_write_sync_009 has failed for ' + e);
console.info('fileio_test_stream_write_sync_009 has failed for ' + e);
}
});
......@@ -1723,7 +1773,7 @@ describe('fileIOTestStream', function () {
expect(null).assertFail();
}
catch (e) {
console.log('fileio_test_stream_write_sync_010 has failed for ' + e);
console.info('fileio_test_stream_write_sync_010 has failed for ' + e);
expect(ss.closeSync() !== null).assertTrue();
expect(fileio.unlinkSync(fpath) !== null).assertTrue();
}
......@@ -1746,7 +1796,7 @@ describe('fileIOTestStream', function () {
expect(null).assertFail();
}
catch (e) {
console.log('fileio_test_stream_write_sync_011 has failed for ' + e);
console.info('fileio_test_stream_write_sync_011 has failed for ' + e);
expect(ss.closeSync() !== null).assertTrue();
expect(fileio.unlinkSync(fpath) !== null).assertTrue();
}
......@@ -1769,7 +1819,7 @@ describe('fileIOTestStream', function () {
expect(null).assertFail();
}
catch (e) {
console.log('fileio_test_stream_write_sync_012 has failed for ' + e);
console.info('fileio_test_stream_write_sync_012 has failed for ' + e);
expect(ss.closeSync() !== null).assertTrue();
expect(fileio.unlinkSync(fpath) !== null).assertTrue();
}
......@@ -1795,10 +1845,10 @@ describe('fileIOTestStream', function () {
}) == 1).assertTrue();
expect(ss.closeSync() !== null).assertTrue();
expect(fileio.unlinkSync(fpath) !== null).assertTrue();
console.log('---fileio_test_stream_write_sync_013 is passed!');
console.info('---fileio_test_stream_write_sync_013 is passed!');
}
catch (e) {
console.log('fileio_test_stream_write_sync_013 has failed for ' + e);
console.info('fileio_test_stream_write_sync_013 has failed for ' + e);
expect(null).assertFail();
}
});
......@@ -1821,10 +1871,10 @@ describe('fileIOTestStream', function () {
}) == 2).assertTrue();
expect(ss.closeSync() !== null).assertTrue();
expect(fileio.unlinkSync(fpath) !== null).assertTrue();
console.log('---fileio_test_stream_write_sync_014 is passed!');
console.info('---fileio_test_stream_write_sync_014 is passed!');
}
catch (e) {
console.log('fileio_test_stream_write_sync_014 has failed for ' + e);
console.info('fileio_test_stream_write_sync_014 has failed for ' + e);
expect(null).assertFail();
}
});
......@@ -1852,7 +1902,7 @@ describe('fileIOTestStream', function () {
expect(fileio.unlinkSync(fpath) !== null).assertTrue();
}
catch (e) {
console.log('fileio_test_stream_write_read_4k_sync has failed for ' + e);
console.info('fileio_test_stream_write_read_4k_sync has failed for ' + e);
expect(null).assertFail();
}
});
......@@ -1875,7 +1925,7 @@ describe('fileIOTestStream', function () {
expect(fileio.unlinkSync(fpath) !== null).assertTrue();
}
catch (e) {
console.log('fileio_test_stream_flush_sync_001 has failed for ' + e);
console.info('fileio_test_stream_flush_sync_001 has failed for ' + e);
expect(null).assertFail();
}
});
......@@ -1896,7 +1946,7 @@ describe('fileIOTestStream', function () {
expect(null).assertFail();
}
catch (e) {
console.log('fileio_test_stream_flush_sync_001 has failed for ' + e);
console.info('fileio_test_stream_flush_sync_001 has failed for ' + e);
expect(fileio.unlinkSync(fpath) !== null).assertTrue();
}
});
......@@ -1915,7 +1965,7 @@ describe('fileIOTestStream', function () {
expect(fileio.unlinkSync(fpath) !== null).assertTrue();
}
catch (e) {
console.log('fileio_test_stream_close_sync_000 has failed for ' + e);
console.info('fileio_test_stream_close_sync_000 has failed for ' + e);
expect(null).assertFail();
}
});
......@@ -1937,7 +1987,7 @@ describe('fileIOTestStream', function () {
}
catch (e) {
expect(fileio.unlinkSync(fpath) !== null).assertTrue();
console.log('fileio_test_stream_close_sync_001 has failed for ' + e);
console.info('fileio_test_stream_close_sync_001 has failed for ' + e);
}
});
});
......@@ -19,7 +19,7 @@ import featureAbility from '@ohos.ability.featureAbility'
export const FILE_CONTENT = 'hello world';
import {
describe, beforeAll, beforeEach, afterEach, afterAll, it, expect
describe, it, expect
}
from 'deccjsunit/index'
......@@ -51,8 +51,8 @@ export function prepareEmptyFile(fpath) {
export async function nextFileName(testName) {
var context = featureAbility.getContext();
let data = await context.getFilesDir();
let BASE_PATH = data.substring(0, data.length - 5) + 'cache/';
let data = await context.getCacheDir();
let BASE_PATH = data + '/';
return BASE_PATH + testName
}
export async function fileName(testName) {
......@@ -91,10 +91,6 @@ export function randomString(num) {
export {
fileio,
describe,
beforeAll,
beforeEach,
afterEach,
afterAll,
it,
expect
};
\ No newline at end of file
......@@ -17,10 +17,6 @@ import fileio from '@ohos.fileio';
import file from '@system.file';
import {
describe,
beforeAll,
beforeEach,
afterEach,
afterAll,
it,
expect
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册