Best JavaScript code snippet using apimocker
FileIO.test.js
Source:FileIO.test.js  
1/*2 * Copyright (C) 2021 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 at6 *7 *     http://www.apache.org/licenses/LICENSE-2.08 *9 * Unless required by applicable law or agreed to in writing, software10 * 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 and13 * limitations under the License.14 */15import fileio from '@ohos.fileio';16import {17  describe,18  beforeAll,19  beforeEach,20  afterEach,21  afterAll,22  it,23  expect24}25from 'deccjsunit/index'26import {27  FILE_CONTENT,28  prepareFile,29  nextFileName,30  prepareEmptyFile,31  randomString,32  fileName33}34  from './Common'35describe('fileIOTest', function () {36  /**37   * @tc.number SUB_STORAGE_FileIO_open&closesync_000038   * @tc.name fileio_test_open_close_sync_00039   * @tc.desc Function of API, openSync. The test file is exist.40   */41  it('fileio_test_open_close_sync_000', 0, async function () {42    let fpath = await nextFileName('fileio_test_open_close_sync_000');43    try {44      let fd = fileio.openSync(fpath, 0o102, 0o666);45      expect(fd !== null).assertTrue();46      expect(fileio.closeSync(fd) !== null).assertTrue();47      expect(fileio.unlinkSync(fpath) !== null).assertTrue();48    } 49    catch (e) {50      console.log('fileio_test_open_close_sync_000 has failed for ' + e);51      expect(null).assertFail();52    }53  });54  /**55   * @tc.number SUB_STORAGE_FileIO_OpenSync_000056   * @tc.name fileio_test_open_00057   * @tc.desc Function of API, openSync(mode not for value). The test file is exist.58   */59  it('fileio_test_open_000', 0, async function () {60    let fpath = await nextFileName('fileio_test_open_000');61    expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();62    try {63      let fd = fileio.openSync(fpath, 0o202);64      expect(fd !== null).assertTrue();65      expect(fileio.closeSync(fd) !== null).assertTrue();66      expect(fileio.unlinkSync(fpath) !== null).assertTrue();67    } 68    catch (e) {69      console.log('fileio_test_open_000 has failed for ' + e);70      expect(null).assertFail();71    }72  });73  /**74   * @tc.number SUB_STORAGE_FileIO_OpenSync_010075   * @tc.name fileio_test_open_00176   * @tc.desc Function of API, flags=0o100. mode=0o00177   */78  it('fileio_test_open_001', 0, async function () {79    let fpath = await nextFileName('fileio_test_open_001');80    expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();81    try {82      let fd = fileio.openSync(fpath, 0o100, 0o01);83      expect(fd !== null).assertTrue();84      expect(fileio.closeSync(fd) !== null).assertTrue();85      expect(fileio.unlinkSync(fpath) !== null).assertTrue();86    } 87    catch (e) {88      console.log('fileio_test_open_001 has failed for ' + e);89      expect(null).assertFail();90    }91  });92  /**93   * @tc.number SUB_STORAGE_FileIO_OpenSync_020094   * @tc.name fileio_test_open_00295   * @tc.desc Function of API,96   */97  it('fileio_test_open_002', 0, async function () {98    let fpath = await nextFileName('fileio_test_open_002');99    expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();100    try {101      let fd = fileio.openSync(fpath);102      expect(fd !== null).assertTrue();103      expect(fileio.closeSync(fd) !== null).assertTrue();104      expect(fileio.unlinkSync(fpath) !== null).assertTrue();105    } 106    catch (e) {107      console.log('fileio_test_open_002 has failed for ' + e);108      expect(null).assertFail();109    }110  });111  /**112   * @tc.number SUB_STORAGE_FileIO_OpenSync_0300113   * @tc.name fileio_test_open_003114   * @tc.desc Function of API, flags=0o100. mode=0o004115   */116  it('fileio_test_open_003', 0, async function () {117    let fpath = await nextFileName('fileio_test_open_003');118    expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();119    try {120      let fd = fileio.openSync(fpath, 0o100, 0o004);121      expect(fd !== null).assertTrue();122      fileio.writeSync(fd, FILE_CONTENT, {123        encoding: 'utf-8',124        offset: 1,125        length: 1,126      });127      expect(null).assertFail();128    } 129    catch (e) {130      console.log('fileio_test_open_003 has failed for ' + e);131      expect(fileio.unlinkSync(fpath) !== null).assertTrue();132    }133  });134  /**135   * @tc.number SUB_STORAGE_FileIO_OpenSync_0400136   * @tc.name fileio_test_open_004137   * @tc.desc Function of API, flags=0o101. mode=0o002138   */139  it('fileio_test_open_004', 0, async function () {140    let fpath = await nextFileName('fileio_test_open_004');141    expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();142    try {143      let fd = fileio.openSync(fpath, 0o101, 0o002);144      expect(fd !== null).assertTrue();145      fileio.readSync(fd, new ArrayBuffer(4096), {146        offset: 1,147      });148      expect(null).assertFail();149    } 150    catch (e) {151      console.log('fileio_test_open_004 has failed for ' + e);152      expect(fileio.unlinkSync(fpath) !== null).assertTrue();153    }154  });155  /**156   * @tc.number SUB_STORAGE_FileIO_OpenSync_0500157   * @tc.name fileio_test_open_005158   * @tc.desc Function of API, flags=0o102. mode=0o001.159   */160  it('fileio_test_open_005', 0, async function () {161    let fpath = await nextFileName('fileio_test_open_005');162    expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();163    try {164      let fd = fileio.openSync(fpath, 0o102, 0o001);165      expect(fd !== null).assertTrue();166      let wri = fileio.writeSync(fd, FILE_CONTENT, {167        encoding: 'utf-8',168        offset: 1,169        length: 1,170      });171      expect(wri !== null).assertTrue();172      let red = fileio.readSync(fd, new ArrayBuffer(4096), {173        offset: 1,174      });175      expect(red !== null).assertTrue();176      expect(fileio.closeSync(fd) !== null).assertTrue();177      expect(fileio.unlinkSync(fpath) !== null).assertTrue();178    } 179    catch (e) {180      console.log('fileio_test_open_005 has failed for ' + e);181      expect(null).assertFail();182    }183  });184  /**185   * @tc.number SUB_STORAGE_FileIO_OpenSync_0600186   * @tc.name fileio_test_open_006187   * @tc.desc Function of API, flags=0o200. mode=0o700188   */189  it('fileio_test_open_006', 0, async function () {190    let fpath = await nextFileName('fileio_test_open_006');191    expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();192    try {193      fileio.openSync(fpath, 0o200, 0o700);194      expect(null).assertFail();195    } 196    catch (e) {197      expect(fileio.unlinkSync(fpath) !== null).assertTrue();198    }199  });200  /**201   * @tc.number SUB_STORAGE_FileIO_OpenSync_0700202   * @tc.name fileio_test_open_007203   * @tc.desc Function of API, flags=0o302. mode=0o700.204   */205  it('fileio_test_open_007', 0, async function () {206    let fpath = await nextFileName('fileio_test_open_007');207    try {208      let fd = fileio.openSync(fpath, 0o302, 0o700);209      expect(fd !== null).assertTrue();210      let wri = fileio.writeSync(fd, FILE_CONTENT, {211        encoding: 'utf-8',212        offset: 1,213        length: 1,214      });215      expect(wri !== null).assertTrue();216      let red = fileio.readSync(fd, new ArrayBuffer(4096), {217        offset: 1,218      });219      expect(red !== null).assertTrue();220      expect(fileio.closeSync(fd) !== null).assertTrue();221      expect(fileio.unlinkSync(fpath) !== null).assertTrue();222    } 223    catch (e) {224      console.log('fileio_test_open_007 has failed for ' + e);225      expect(null).assertFail();226    }227  });228  /**229   * @tc.number SUB_STORAGE_FileIO_OpenSync_0800230   * @tc.name fileio_test_open_008231   * @tc.desc Function of API, flags=0o102. mode=0o700232   */233  it('fileio_test_open_008', 0, async function () {234    let fpath = await nextFileName('fileio_test_open_008');235    try {236      let fd = fileio.openSync(fpath, 0o102, 0o700);237      expect(fd !== null).assertTrue();238      let wri = fileio.writeSync(fd, FILE_CONTENT, {239        encoding: 'utf-8',240        offset: 1,241        length: 1,242      });243      expect(wri !== null).assertTrue();244      let red = fileio.readSync(fd, new ArrayBuffer(4096), {245        offset: 1,246      });247      expect(red !== null).assertTrue();248      expect(fileio.closeSync(fd) !== null).assertTrue();249      expect(fileio.unlinkSync(fpath) !== null).assertTrue();250    } 251    catch (e) {252      console.log('fileio_test_open_008 has failed for ' + e);253      expect(null).assertFail();254    }255  });256  /**257   * @tc.number SUB_STORAGE_FileIO_OpenSync_0900258   * @tc.name fileio_test_open_009259   * @tc.desc Function of API, flags=0o302.260   */261  it('fileio_test_open_009', 0, async function () {262    let fpath = await nextFileName('fileio_test_open_009');263    try {264      fileio.openSync(fpath, 0o302);265      expect(null).assertFail();266    } 267    catch (e) {268      console.log('fileio_test_open_009 has failed for ' + e);269    }270  });271  /**272   * @tc.number SUB_STORAGE_FileIO_OpenSync_1000273   * @tc.name fileio_test_open_010274   * @tc.desc Function of API, flags=0o402.275   */276  it('fileio_test_open_010', 0, async function () {277    let fpath = await nextFileName('fileio_test_open_010');278    expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();279    try {280      let fd = fileio.openSync(fpath, 0o402);281      expect(fd !== null).assertTrue();282      let wri = fileio.writeSync(fd, FILE_CONTENT, {283        encoding: 'utf-8',284        offset: 1,285        length: 1,286      });287      expect(wri !== null).assertTrue();288      let red = fileio.readSync(fd, new ArrayBuffer(4096), {289        offset: 1,290      });291      expect(red !== null).assertTrue();292      expect(fileio.closeSync(fd) !== null).assertTrue();293      expect(fileio.unlinkSync(fpath) !== null).assertTrue();294    } 295    catch (e) {296      console.log('fileio_test_open_010 has failed for ' + e);297      expect(null).assertFail();298    }299  });300  /**301   * @tc.number SUB_STORAGE_FileIO_OpenSync_1100302   * @tc.name fileio_test_open_011303   * @tc.desc Function of API, flags=0o1000.304   */305  it('fileio_test_open_011', 0, async function () {306    let fpath = await nextFileName('fileio_test_open_011');307    expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();308    try {309      let fd = fileio.openSync(fpath, 0o1000);310      expect(fd !== null).assertTrue();311      let red = fileio.readSync(fd, new ArrayBuffer(4096), {312        offset: 1,313      });314      expect(red !== null).assertTrue();315      expect(fileio.closeSync(fd) !== null).assertTrue();316      expect(fileio.unlinkSync(fpath) !== null).assertTrue();317    } 318    catch (e) {319      console.log('fileio_test_open_011 has failed for ' + e);320      expect(null).assertFail();321    }322  });323  /**324   * @tc.number SUB_STORAGE_FileIO_OpenSync_1200325   * @tc.name fileio_test_open_012326   * @tc.desc Function of API, flags=0o1001.327   */328  it('fileio_test_open_012', 0, async function () {329    let fpath = await nextFileName('fileio_test_open_012');330    expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();331    try {332      let fd = fileio.openSync(fpath, 0o1001);333      expect(fd !== null).assertTrue();334      fileio.readSync(fd, new ArrayBuffer(4096), {335        offset: 1,336      });337      expect(null).assertFail();338    } 339    catch (e) {340      console.log('fileio_test_open_012 has failed for ' + e);341      expect(fileio.unlinkSync(fpath) !== null).assertTrue();342    }343  });344  /**345   * @tc.number SUB_STORAGE_FileIO_OpenSync_1300346   * @tc.name fileio_test_open_013347   * @tc.desc Function of API, flags=0o2002.348   */349  it('fileio_test_open_013', 0, async function () {350    let fpath = await nextFileName('fileio_test_open_013');351    expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();352    try {353      let fd = fileio.openSync(fpath, 0o2002);354      expect(fd !== null).assertTrue();355      let wri = fileio.writeSync(fd, 'hello', {356        encoding: 'utf-8',357        offset: 1,358        length: 1,359      });360      expect(wri !== null).assertTrue();361      let red = fileio.readSync(fd, new ArrayBuffer(4096), {362        offset: 1,363      });364      expect(red !== null).assertTrue();365      expect(fileio.closeSync(fd) !== null).assertTrue();366      expect(fileio.unlinkSync(fpath) !== null).assertTrue();367    } 368    catch (e) {369      console.log('fileio_test_open_013 has failed for ' + e);370      expect(null).assertFail();371    }372  });373  /**374   * @tc.number SUB_STORAGE_FileIO_OpenSync_1400375   * @tc.name fileio_test_open_014376   * @tc.desc Function of API, flags=0o4002.377   */378  it('fileio_test_open_014', 0, async function (done) {379    let fpath = await nextFileName('fileio_test_open_014');380    expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();381    try {382      let fd = fileio.openSync(fpath, 0o4002);383      expect(fd !== null).assertTrue();384      let fd2 = fileio.openSync(fpath, 0o4002);385      expect(fd2 !== null).assertTrue();386      expect(fileio.closeSync(fd) !== null).assertTrue();387      expect(fileio.closeSync(fd2) !== null).assertTrue();388      expect(fileio.unlinkSync(fpath) !== null).assertTrue();389      done();390    } 391    catch (e) {392      console.log('fileio_test_open_014 has failed for ' + e);393      expect(null).assertFail();394    }395  });396  /**397   * @tc.number SUB_STORAGE_FileIO_OpenSync_1500398   * @tc.name fileio_test_open_015399   * @tc.desc Function of API, flags=0o20002.400   */401  it('fileio_test_open_015', 0, async function () {402    let fpath = await nextFileName('fileio_test_open_015');403    expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();404    try {405      let fd = fileio.openSync(fpath, 0o20002);406      expect(fd !== null).assertTrue();407      expect(fileio.closeSync(fd) !== null).assertTrue();408      expect(fileio.unlinkSync(fpath) !== null).assertTrue();409    } 410    catch (e) {411      console.log('fileio_test_open_015 has failed for ' + e);412      expect(null).assertFail();413    }414  });415  /**416   * @tc.number SUB_STORAGE_FileIO_OpenSync_1600417   * @tc.name fileio_test_open_016418   * @tc.desc Function of API, flags=0o10002.419   */420  it('fileio_test_open_016', 0, async function () {421    let fpath = await nextFileName('fileio_test_open_016');422    expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();423    try {424      let fd = fileio.openSync(fpath, 0o10002);425      expect(fd !== null).assertTrue();426      expect(fileio.closeSync(fd) !== null).assertTrue();427      expect(fileio.unlinkSync(fpath) !== null).assertTrue();428    } 429    catch (e) {430      console.log('fileio_test_open_016 has failed for ' + e);431      expect(null).assertFail();432    }433  });434  /**435   * @tc.number SUB_STORAGE_FileIO_OpenSync_1700436   * @tc.name fileio_test_open_017437   * @tc.desc Function of API, flags=0o4010002.438   */439  it('fileio_test_open_017', 0, async function () {440    let fpath = await nextFileName('fileio_test_open_017');441    expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();442    try {443      let fd = fileio.openSync(fpath, 0o4010002);444      expect(fd !== null).assertTrue();445      expect(fileio.closeSync(fd) !== null).assertTrue();446      expect(fileio.unlinkSync(fpath) !== null).assertTrue();447    } 448    catch (e) {449      console.log('fileio_test_open_017 has failed for ' + e);450      expect(null).assertFail();451    }452  });453  /**454   * @tc.number SUB_STORAGE_FileIO_OpenSync_1800455   * @tc.name fileio_test_open_018456   * @tc.desc Function of API, flags=0o100002.457   */458  it('fileio_test_open_018', 0, async function () {459    let fpath = await nextFileName('fileio_test_open_018');460    expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();461    try {462      let fd = fileio.openSync(fpath, 0o100002);463      expect(fd !== null).assertTrue();464      expect(fileio.closeSync(fd) !== null).assertTrue();465      expect(fileio.unlinkSync(fpath) !== null).assertTrue();466    } 467    catch (e) {468      console.log('fileio_test_open_018 has failed for ' + e);469      expect(null).assertFail();470    }471  });472  /**473   * @tc.number SUB_STORAGE_FileIO_OpenSync_1900474   * @tc.name fileio_test_open_019475   * @tc.desc Function of API, flags=0o40002. mode=0o700476   */477  it('fileio_test_open_019', 0, async function () {478    let fpath = await nextFileName('fileio_test_open_019');479    expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();480    try {481      fileio.openSync(fpath, 0o40002, 0o700);482      expect(null).assertFail();483    } 484    catch (e) {485      console.log('fileio_test_open_019 has failed for ' + e);486      expect(fileio.unlinkSync(fpath) !== null).assertTrue();487    }488  });489  /**490   * @tc.number SUB_STORAGE_FileIO_OpenSync_2100491   * @tc.name fileio_test_open_021492   * @tc.desc Function of API, flags=0o2000002.493   */494  it('fileio_test_open_021', 0, async function () {495    let fpath = await nextFileName('fileio_test_open_021');496    expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();497    try {498      let fd = fileio.openSync(fpath, 0o2000002);499      expect(fd !== null).assertTrue();500      expect(fileio.closeSync(fd) == null).assertTrue();501      expect(fileio.unlinkSync(fpath) !== null).assertTrue();502    } 503    catch (e) {504      console.log('fileio_test_open_021 has failed for ' + e);505      expect(null).assertFail();506    }507  });508  /**509   * @tc.number SUB_STORAGE_FileIO_OpenSync_2200510   * @tc.name fileio_test_open_022511   * @tc.desc Function of API, flags=0o200002.512   */513  it('fileio_test_open_022', 0, async function () {514    let fpath = await nextFileName('fileio_test_open_022');515    expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();516    try {517      let fd = fileio.openSync(fpath, 0o200002);518      expect(fd !== null).assertTrue();519      expect(fileio.closeSync(fd) !== null).assertTrue();520      expect(fileio.unlinkSync(fpath) !== null).assertTrue();521    } 522    catch (e) {523      console.log('fileio_test_open_022 has failed for ' + e);524      expect(null).assertFail();525    }526  });527  /**528   * @tc.number SUB_STORAGE_FileIO_OpenSync_2300529   * @tc.name fileio_test_open_023530   * @tc.desc Function of API, flags=0o400002.531   */532  it('fileio_test_open_023', 0, async function () {533    let fpath = await nextFileName('fileio_test_open_023');534    expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();535    try {536      let fd = fileio.openSync(fpath, 0o400002);537      expect(fd !== null).assertTrue();538      expect(fileio.closeSync(fd) !== null).assertTrue();539      expect(fileio.unlinkSync(fpath) !== null).assertTrue();540    } 541    catch (e) {542      console.log('fileio_test_open_023 has failed for ' + e);543      expect(null).assertFail();544    }545  });546  /**547   * @tc.number SUB_STORAGE_FileIO_OpenSync_2400548   * @tc.name fileio_test_open_024549   * @tc.desc Function of API, flags=0o1000002.mode=0o700550   */551  it('fileio_test_open_024', 0, async function () {552    let fpath = await nextFileName('fileio_test_open_024');553    expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();554    try {555      let fd = fileio.openSync(fpath, 0o1000002, 0o700);556      expect(fd !== null).assertTrue();557      expect(fileio.closeSync(fd) !== null).assertTrue();558      expect(fileio.unlinkSync(fpath) !== null).assertTrue();559    }560    catch (e) {561      console.log('fileio_test_open_024 has failed for ' + e);562      expect(null).assertFail();563    }564  });565  /**566   * @tc.number SUB_STORAGE_FileIO_OpenSync_2500567   * @tc.name fileio_test_open_025568   * @tc.desc Function of API, flags=0o10000002.569   */570  it('fileio_test_open_025', 0, async function () {571    let fpath = await nextFileName('fileio_test_open_025');572    expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();573    try {574      let fd = fileio.openSync(fpath, 0o10000002);575      expect(fd !== null).assertTrue();576      expect(fileio.closeSync(fd) !== null).assertTrue();577      expect(fileio.unlinkSync(fpath) !== null).assertTrue();578    }579    catch (e) {580      console.log('fileio_test_open_025 has failed for ' + e);581      expect(null).assertFail();582    }583  });584  /**585   * @tc.number SUB_STORAGE_FileIO_OpenSync_2600586   * @tc.name fileio_test_open_026587   * @tc.desc Function of API,flags=0o002.mode=0o700588   */589  it('fileio_test_open_026', 0, async function () {590    let fpath = await nextFileName('fileio_test_open_026');591    expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();592    try {593      let fd = fileio.openSync(fpath, 0o002, 0o700);594      expect(fd !== null).assertTrue();595      expect(fileio.closeSync(fd) !== null).assertTrue();596      expect(fileio.unlinkSync(fpath) !== null).assertTrue();597    } 598    catch (e) {599      console.log('fileio_test_open_026 has failed for ' + e);600      expect(null).assertFail();601    }602  });603  /**604   * @tc.number SUB_STORAGE_FileIO_OpenSync_2700605   * @tc.name fileio_test_open_027606   * @tc.desc Function of API, flags=0o002.mode=0o400607   */608  it('fileio_test_open_027', 0, async function () {609    let fpath = await nextFileName('fileio_test_open_027');610    expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();611    try {612      let fd = fileio.openSync(fpath, 0o002, 0o400);613      expect(fd !== null).assertTrue();614      let red = fileio.readSync(fd, new ArrayBuffer(4096), {615        offset: 1,616      });617      expect(red !== null).assertTrue();618      fileio.writeSync(fd, 'hello', {619        encoding: 'utf-8',620        offset: 1,621        length: 1,622      });623      expect(null).assertFail();624    } 625    catch (e) {626      expect(fileio.unlinkSync(fpath) !== null).assertTrue();627    }628  });629  /**630   * @tc.number SUB_STORAGE_FileIO_OpenSync_2800631   * @tc.name fileio_test_open_028632   * @tc.desc Function of API, flags=0o002.mode=0o200633   */634  it('fileio_test_open_028', 0, async function () {635    let fpath = await nextFileName('fileio_test_open_028');636    expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();637    try {638      let fd = fileio.openSync(fpath, 0o002, 0o200);639      expect(fd !== null).assertTrue();640      let wri = fileio.writeSync(fd, 'hello', {641        encoding: 'utf-8',642        offset: 1,643        length: 1,644      });645      expect(wri !== null).assertTrue();646      fileio.readSync(fd, new ArrayBuffer(4096), {647        offset: 1,648      });649      expect(null).assertFail();650    } 651    catch (e) {652      expect(fileio.unlinkSync(fpath) !== null).assertTrue();653    }654  });655  /**656   * @tc.number SUB_STORAGE_FileIO_OpenSync_2900657   * @tc.name fileio_test_open_029658   * @tc.desc Function of API, flags=0o002.mode=0o100659   */660  it('fileio_test_open_029', 0, async function () {661    let fpath = await nextFileName('fileio_test_open_029');662    expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();663    try {664      let fd = fileio.openSync(fpath, 0o002, 0o100);665      expect(fd !== null).assertTrue();666      expect(fileio.closeSync(fd) !== null).assertTrue();667      expect(fileio.unlinkSync(fpath) !== null).assertTrue();668    } 669    catch (e) {670      console.log('fileio_test_open_029 has failed for ' + e);671      expect(null).assertFail();672    }673  });674  /**675   * @tc.number SUB_STORAGE_FileIO_OpenSync_3000676   * @tc.name fileio_test_open_030677   * @tc.desc Function of API,  flags=0o002.mode=0o070678   */679  it('fileio_test_open_030', 0, async function () {680    let fpath = await nextFileName('fileio_test_open_030');681    expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();682    try {683      let fd = fileio.openSync(fpath, 0o002, 0o070);684      expect(fd !== null).assertTrue();685      let wri = fileio.writeSync(fd, 'hello', {686        encoding: 'utf-8',687        offset: 1,688        length: 1,689      });690      expect(wri !== null).assertTrue();691      let red = fileio.readSync(fd, new ArrayBuffer(4096), {692        offset: 1,693      });694      expect(red !== null).assertTrue();695      expect(fileio.closeSync(fd) !== null).assertTrue();696      expect(fileio.unlinkSync(fpath) !== null).assertTrue();697    } 698    catch (e) {699      console.log('fileio_test_open_030 has failed for ' + e);700      expect(null).assertFail();701    }702  });703  /**704   * @tc.number SUB_STORAGE_FileIO_OpenSync_3100705   * @tc.name fileio_test_open_031706   * @tc.desc Function of API, flags=0o002.mode=0o040707   */708  it('fileio_test_open_031', 0, async function () {709    let fpath = await nextFileName('fileio_test_open_031');710    expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();711    try {712      let fd = fileio.openSync(fpath, 0o002, 0o040);713      expect(fd !== null).assertTrue();714      let red = fileio.readSync(fd, new ArrayBuffer(4096), {715        offset: 1,716      });717      expect(red !== null).assertTrue();718      fileio.writeSync(fd, 'hello', {719        encoding: 'utf-8',720        offset: 1,721        length: 1,722      });723      expect(null).assertFail();724    } 725    catch (e) {726      expect(fileio.unlinkSync(fpath) !== null).assertTrue();727    }728  });729  /**730   * @tc.number SUB_STORAGE_FileIO_OpenSync_3200731   * @tc.name fileio_test_open_032732   * @tc.desc Function of API, flags=0o002.mode=0o020733   */734  it('fileio_test_open_032', 0, async function () {735    let fpath = await nextFileName('fileio_test_open_032');736    expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();737    try {738      let fd = fileio.openSync(fpath, 0o002, 0o020);739      expect(fd !== null).assertTrue();740      let wri = fileio.writeSync(fd, 'hello', {741        encoding: 'utf-8',742        offset: 1,743        length: 1,744      });745      expect(wri !== null).assertTrue();746      fileio.readSync(fd, new ArrayBuffer(4096), {747        offset: 1,748      });749      expect(null).assertFail();750    } 751    catch (e) {752      expect(fileio.unlinkSync(fpath) !== null).assertTrue();753    }754  });755  /**756   * @tc.number SUB_STORAGE_FileIO_OpenSync_3300757   * @tc.name fileio_test_open_033758   * @tc.desc Function of API, flags=0o002.mode=0o010759   */760  it('fileio_test_open_033', 0, async function () {761    let fpath = await nextFileName('fileio_test_open_033');762    expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();763    try {764      let fd = fileio.openSync(fpath, 0o002, 0o010);765      expect(fd !== null).assertTrue();766      expect(fileio.closeSync(fd) !== null).assertTrue();767      expect(fileio.unlinkSync(fpath) !== null).assertTrue();768    } 769    catch (e) {770      console.log('fileio_test_open_033 has failed for ' + e);771      expect(null).assertFail();772    }773  });774  /**775   * @tc.number SUB_STORAGE_FileIO_OpenSync_3400776   * @tc.name fileio_test_open_034777   * @tc.desc Function of API, flags=0o002.mode=0o007778   */779  it('fileio_test_open_034', 0, async function () {780    let fpath = await nextFileName('fileio_test_open_034');781    expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();782    try {783      let fd = fileio.openSync(fpath, 0o002, 0o007);784      expect(fd !== null).assertTrue();785      let ret = fileio.readSync(fd, new ArrayBuffer(4096), {786        offset: 1,787      });788      expect(ret !== null).assertTrue();789      let wri = fileio.writeSync(fd, 'hello', {790        encoding: 'utf-8',791        offset: 1,792        length: 1,793      });794      expect(wri !== null).assertTrue();795      expect(fileio.closeSync(fd) !== null).assertTrue();796      expect(fileio.unlinkSync(fpath) !== null).assertTrue();797    } 798    catch (e) {799      console.log('fileio_test_open_034 has failed for ' + e);800      expect(null).assertFail();801    }802  });803  /**804   * @tc.number SUB_STORAGE_FileIO_OpenSync_3500805   * @tc.name fileio_test_open_035806   * @tc.desc Function of API, flags=0o002.mode=0o004807   */808  it('fileio_test_open_035', 0, async function () {809    let fpath = await nextFileName('fileio_test_open_035');810    expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();811    try {812      let fd = fileio.openSync(fpath, 0o002, 0o004);813      expect(fd !== null).assertTrue();814      let ret = fileio.readSync(fd, new ArrayBuffer(4096), {815        offset: 1,816      });817      expect(ret !== null).assertTrue();818      fileio.writeSync(fd, 'hello', {819        encoding: 'utf-8',820        offset: 1,821        length: 1,822      });823      expect(null).assertFail();824    } 825    catch (e) {826      expect(fileio.unlinkSync(fpath) !== null).assertTrue();827    }828  });829  /**830   * @tc.number SUB_STORAGE_FileIO_OpenSync_3600831   * @tc.name fileio_test_open_036832   * @tc.desc Function of API, flags=0o002.mode=0o002833   */834  it('fileio_test_open_036', 0, async function () {835    let fpath = await nextFileName('fileio_test_open_036');836    expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();837    try {838      let fd = fileio.openSync(fpath, 0o002, 0o002);839      expect(fd !== null).assertTrue();840      let wri = fileio.writeSync(fd, 'hello', {841        encoding: 'utf-8',842        offset: 1,843        length: 1,844      });845      expect(wri !== null).assertTrue();846      fileio.readSync(fd, new ArrayBuffer(4096), {847        offset: 1,848      });849      expect(null).assertFail();850    } 851    catch (e) {852      expect(fileio.unlinkSync(fpath) !== null).assertTrue();853    }854  });855  /**856   * @tc.number SUB_STORAGE_FileIO_OpenSync_3700857   * @tc.name fileio_test_open_037858   * @tc.desc Function of API, flags=0o002.mode=0o001859   */860  it('fileio_test_open_037', 0, async function () {861    let fpath = await nextFileName('fileio_test_open_037');862    expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();863    try {864      let fd = fileio.openSync(fpath, 0o002, 0o001);865      expect(fileio.closeSync(fd) !== null).assertTrue();866      expect(fileio.unlinkSync(fpath) !== null).assertTrue();867    } 868    catch (e) {869      console.log('fileio_test_open_037 has failed for ' + e);870      expect(null).assertFail();871    }872  });873  /**874   * @tc.number SUB_STORAGE_FileIO_OpenSync_3800875   * @tc.name fileio_test_open_038876   * @tc.desc Function of API, flags=0o102.mode=0o700877   */878  it('fileio_test_open_038', 0, async function () {879    let txt = randomString(4100);880    let fpath = await nextFileName(txt);881    try {882      let fd = fileio.openSync(fpath, 0o102, 0o700);883      expect(null).assertFail();884    } 885    catch (e) {886      console.log('fileio_test_open_038 has failed for ' + e);887    }888  });889  /**890   * @tc.number SUB_STORAGE_FileIO_OpenSync_0100891   * @tc.name fileio_test_open_sync_001892   * @tc.desc Function of API, openSync(flags=0o200). The test file is exist.893   */894  it('fileio_test_open_sync_001', 0, async function () {895    let fpath = await nextFileName('fileio_test_open_sync_001');896    expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();897    try {898      let fd = fileio.openSync(fpath, 0o200);899      expect(fd !== null).assertTrue();900      expect(fileio.closeSync(fd) !== null).assertTrue();901      expect(fileio.unlinkSync(fpath) !== null).assertTrue();902    } 903    catch (e) {904      console.log('fileio_test_open_sync_001 has failed for ' + e);905      expect(null).assertFail();906    }907  });908  /**909   * @tc.number SUB_STORAGE_FileIO_OpenSync_0200910   * @tc.name fileio_test_open_sync_002911   * @tc.desc Function of API, openSync(flags=0o201). The test file is exist.912   */913  it('fileio_test_open_sync_002', 0, async function () {914    let fpath = await nextFileName('fileio_test_open_sync_002');915    expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();916    try {917      let fd = fileio.openSync(fpath, 0o201);918      expect(fd !== null).assertTrue();919      expect(fileio.closeSync(fd) !== null).assertTrue();920      expect(fileio.unlinkSync(fpath) !== null).assertTrue();921    } 922    catch (e) {923      console.log('fileio_test_open_sync_002 has failed for ' + e);924      expect(null).assertFail();925    }926  });927  /**928   * @tc.number SUB_STORAGE_FileIO_OpenSync_0300929   * @tc.name fileio_test_open_sync_003930   * @tc.desc Function of API, openSync(flags=0o202). The test file is exist.931   */932  it('fileio_test_open_sync_003', 0, async function () {933    let fpath = await nextFileName('fileio_test_open_sync_003');934    expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();935    try {936      let fd = fileio.openSync(fpath, 0o202);937      expect(fd !== null).assertTrue();938      expect(fileio.closeSync(fd) !== null).assertTrue();939      expect(fileio.unlinkSync(fpath) !== null).assertTrue();940    } 941    catch (e) {942      console.log('fileio_test_open_sync_003 has failed for ' + e);943      expect(null).assertFail();944    }945  });946  /**947   * @tc.number SUB_STORAGE_FileIO_OpenSync_0400948   * @tc.name fileio_test_open_sync_004949   * @tc.desc Function of API, openSync(flags=0o102, mode=0o777). The test file is not exist.950   */951  it('fileio_test_open_sync_004', 0, async function () {952    let fpath = await nextFileName('fileio_test_open_sync_004');953    try {954      let fd = fileio.openSync(fpath, 0o102, 0o777);955      expect(fd !== null).assertTrue();956      expect(fileio.closeSync(fd) !== null).assertTrue();957      expect(fileio.unlinkSync(fpath) !== null).assertTrue();958    } 959    catch (e) {960      console.log('fileio_test_open_sync_004 has failed for ' + e);961      expect(null).assertFail();962    }963  });964  /**965   * @tc.number SUB_STORAGE_FileIO_OpenSync_0500966   * @tc.name fileio_test_open_sync_005967   * @tc.desc Function of API, openSync(flags not for value, mode not for value).968   */969  it('fileio_test_open_sync_005', 0, async function () {970    let dpath = await nextFileName('fileio_test_open_sync_005') + 'd'971    try {972      expect(fileio.mkdirSync(dpath) !== null).assertTrue();973      let fd = fileio.openSync(dpath);974      expect(fd !== null).assertTrue();975      expect(fileio.closeSync(fd) !== null).assertTrue();976      expect(fileio.rmdirSync(dpath) !== null).assertTrue();977    } 978    catch (e) {979      console.log('fileio_test_open_sync_005 has failed for ' + e);980      expect(null).assertFail();981    }982  });983  /**984   * @tc.number SUB_STORAGE_FileIO_OpenSync_0600985   * @tc.name fileio_test_open_sync_006986   * @tc.desc Function of API, openSync(flags=0o1, illegal parameter).987   */988  it('fileio_test_open_sync_006', 0, async function () {989    let dpath = await nextFileName('fileio_test_open_sync_006') + 'd'990    try {991      expect(fileio.mkdirSync(dpath) !== null).assertTrue();992      fileio.openSync(dpath, 0o1);993      expect(null).assertFail();994    } 995    catch (e) {996      console.log('fileio_test_open_sync_006 has failed for ' + e);997      fileio.rmdirSync(dpath);998    }999  });1000  /**1001   * @tc.number SUB_STORAGE_FileIO_OpenSync_07001002   * @tc.name fileio_test_open_sync_0071003   * @tc.desc Function of API, openSync(fpath too long).1004   */1005  it('fileio_test_open_sync_007', 0, async function () {1006    let dpath = await nextFileName('fileio_open1');1007    fileio.mkdirSync(dpath);1008    try {1009      for (let i = 0; i < 16; i++) {1010        if (i == 15) {1011          let fpath = dpath + '/f' + randomString(248);1012          fileio.openSync(fpath, 0o102, 0o777);1013        } else {1014          dpath = dpath + '/d' + randomString(248);1015          fileio.mkdirSync(dpath);1016        }1017      }1018      expect(null).assertFail();1019    } 1020    catch (e) {1021      console.log('fileio_test_open_sync_007 has failed for ' + e);1022    }1023  });1024  /**1025   * @tc.number SUB_STORAGE_FileIO_OpenSync_08001026   * @tc.name fileio_test_open_sync_0081027   * @tc.desc Function of API, openSync(filename too long).1028   */1029  it('fileio_test_open_sync_008', 0, async function () {1030    let fpath = await nextFileName(randomString(256));1031    try {1032      fileio.openSync(fpath, 0o102, 0o777);1033      expect(null).assertFail();1034    } 1035    catch (e) {1036      console.log('fileio_test_open_sync_008 has failed for ' + e);1037    }1038  });1039  /**1040   * @tc.number SUB_STORAGE_FileIO_OpenSync_09001041   * @tc.name fileio_test_open_sync_0091042   * @tc.desc Function of API, openSync(dir layers too long).1043   */1044  it('fileio_test_open_sync_009', 0, async function () {1045    let dpath = await nextFileName('prop1');1046    fileio.mkdirSync(dpath);1047    try {1048      for (let i = 0; i < 113; i++) {1049        if (i == 112) {1050          let fpath = dpath + '/f' + i1051          fileio.openSync(fpath, 0o102, 0o777);1052        } else {1053          dpath = dpath + '/' + i1054          fileio.mkdirSync(dpath);1055        }1056      }1057      expect(null).assertFail();1058    } 1059    catch (e) {1060      console.log('fileio_test_open_sync_009 has failed for ' + e);1061    }1062  });1063  /**1064   * @tc.number SUB_STORAGE_FileIO_OpenSync_10001065   * @tc.name fileio_test_open_sync_0101066   * @tc.desc Function of API, openSync(filename has special characters).1067   */1068  it('fileio_test_open_sync_010', 0, async function () {1069    let fpath = await nextFileName('?*:<>/|');1070    try {1071      fileio.openSync(fpath, 0o102, 0o777);1072      expect(null).assertFail();1073    } 1074    catch (e) {1075      console.log('fileio_test_open_sync_010 has failed for ' + e);1076    }1077  });1078  /**1079   * @tc.number SUB_STORAGE_FileIO_CloseSync_00001080   * @tc.name fileio_test_close_sync_0001081   * @tc.desc Function of API, close. The test file is not exist.1082   */1083  it('fileio_test_close_sync_000', 0, async function () {1084    let fpath = await nextFileName('fileio_test_chmod_sync_000');1085    try {1086      fileio.closeSync(fpath);1087      expect(null).assertFail();1088    } 1089    catch (e) {1090      console.log('fileio_test_close_sync_000 has failed for ' + e);1091    }1092  });1093  /**1094   * @tc.number SUB_STORAGE_FileIO_CloseSync_01001095   * @tc.name fileio_test_close_sync_0011096   * @tc.desc Function of API, close(fpath=vaild value). The test file is not exist.1097   */1098  it('fileio_test_close_sync_001', 0, async function () {1099    try {1100      fileio.closeSync(-1);1101      expect(null).assertFail();1102    } 1103    catch (e) {1104      console.log('fileio_test_close_sync_001 has failed for ' + e);1105    }1106  });1107  /**1108   * @tc.number SUB_STORAGE_FileIO_AccessSync_00001109   * @tc.name fileio_test_access_sync_0001110   * @tc.desc Function of API,access. The test file is exist.1111   */1112  it('fileio_test_access_sync_000', 0, async function () {1113    let fpath = await nextFileName('fileio_test_access_sync_000');1114    expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();1115    try {1116      expect(fileio.accessSync(fpath) !== null).assertTrue();1117      expect(fileio.unlinkSync(fpath) !== null).assertTrue();1118    } 1119    catch (e) {1120      console.log('fileio_test_access_sync_000 has failed for ' + e);1121      expect(null).assertFail();1122    }1123  });1124  /**1125   * @tc.number SUB_STORAGE_FileIO_AccessSync_01001126   * @tc.name fileio_test_access_sync_0011127   * @tc.desc Function of API, launch via fileio. The test file is not exist.1128   */1129  it('fileio_test_access_sync_001', 0, async function () {1130    try {1131      fileio.accessSync(1);1132      expect(null).assertFail();1133    } 1134    catch (e) {1135      console.log('fileio_test_access_sync_001 has failed for ' + e);1136    }1137  });1138  /**1139   * @tc.number SUB_STORAGE_FileIO_AccessSync_02001140   * @tc.name fileio_test_access_sync_0021141   * @tc.desc Function of API, access. The test file is not exist.1142   */1143  it('fileio_test_access_sync_002', 0, async function () {1144    let fpath = await nextFileName('fileIOTest');1145    try {1146      fileio.accessSync(fpath);1147      expect(null).assertFail();1148    } 1149    catch (e) {1150      console.log('fileio_test_access_sync_002 has failed for ' + e);1151    }1152  });1153  /**1154   * @tc.number SUB_STORAGE_FileIO_AccessSync_03001155   * @tc.name fileio_test_access_sync_0031156   * @tc.desc Function of API, access(mode=1). The test file is exist and have the authority.1157   */1158  it('fileio_test_access_sync_003', 0, async function () {1159    let fpath = await nextFileName('fileio_test_access_sync_004');1160    expect(prepareEmptyFile(fpath)).assertTrue();1161    try {1162      let fd = fileio.accessSync(fpath);1163      console.log(fd);1164      expect(fileio.accessSync(fpath, 1) !== null).assertTrue();1165      expect(fileio.unlinkSync(fpath) !== null).assertTrue();1166    } 1167    catch (e) {1168      console.log('fileio_test_access_sync_004 has failed for ' + e);1169      expect(null).assertFail();1170    }1171  });1172  /**1173   * @tc.number SUB_STORAGE_FileIO_AccessSync_04001174   * @tc.name fileio_test_access_sync_0041175   * @tc.desc Function of API, access(mode=2). The test file is exist and have the authority.1176   */1177  it('fileio_test_access_sync_004', 0, async function () {1178    let fpath = await nextFileName('fileio_test_access_sync_004');1179    expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();1180    try {1181      let fd = fileio.accessSync(fpath);1182      expect(fd !== null).assertTrue();1183      expect(fileio.accessSync(fpath, 2) !== null).assertTrue();1184      expect(fileio.unlinkSync(fpath) !== null).assertTrue();1185    } 1186    catch (e) {1187      console.log('fileio_test_access_sync_004 has failed for ' + e);1188      expect(null).assertFail();1189    }1190  });1191  /**1192   * @tc.number SUB_STORAGE_FileIO_AccessSync_05001193   * @tc.name fileio_test_access_sync_0051194   * @tc.desc Function of API, access(fpath=dir address). The test dir is exist.1195   */1196  it('fileio_test_access_sync_005', 0, async function () {1197    let dpath = await nextFileName('fileio_test_access_sync_005') + 'd'1198    try {1199      expect(fileio.mkdirSync(dpath) !== null).assertTrue();1200      let fd = fileio.accessSync(dpath);1201      expect(fd == undefined).assertTrue();1202      expect(fileio.rmdirSync(dpath) !== null).assertTrue();1203    } 1204    catch (e) {1205      console.log('fileio_test_access_sync_005 has failed for ' + e);1206      expect(null).assertFail();1207    }1208  });1209  /**1210   * @tc.number SUB_STORAGE_FileIO_AccessSync_06001211   * @tc.name fileio_test_access_sync_0061212   * @tc.desc Function of API, access(fpath=dir address). The test dir is not exist.1213   */1214  it('fileio_test_access_sync_006', 0, async function () {1215    let dpath = await nextFileName('fileio_test_access_sync_006') + 'd'1216    try {1217      fileio.accessSync(dpath);1218      expect(null).assertFail();1219    } 1220    catch (e) {1221      console.log('fileio_test_access_sync_006 has failed for ' + e);1222    }1223  });1224  /**1225   * @tc.number SUB_STORAGE_FileIO_AccessSync_07001226   * @tc.name fileio_test_access_sync_0071227   * @tc.desc Function of API, access(mode=4).1228   */1229  it('fileio_test_access_sync_007', 0, async function () {1230    let fpath = await nextFileName('fileio_test_access_sync_007');1231    expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();1232    try {1233      let fd = fileio.accessSync(fpath);1234      expect(fd !== null).assertTrue();1235      expect(fileio.accessSync(fpath, 4) !== null).assertTrue();1236      expect(fileio.unlinkSync(fpath) !== null).assertTrue();1237    } 1238    catch (e) {1239      console.log('fileio_test_access_sync_007 has failed for ' + e);1240      expect(null).assertFail();1241    }1242  });1243  /**1244   * @tc.number SUB_STORAGE_FileIO_UnlinkSync_00001245   * @tc.name fileio_test_unlink_sync_0001246   * @tc.desc Function of API,unlinkSync. The test file is exist.1247   */1248  it('fileio_test_unlink_sync_000', 0, async function () {1249    let fpath = await nextFileName('fileio_test_unlink_sync_000');1250    expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();1251    try {1252      expect(fileio.unlinkSync(fpath) !== null);1253    } 1254    catch (e) {1255      console.log('fileio_test_unlink_sync_000 has failed for ' + e);1256      expect(null).assertFail();1257    }1258  });1259  /**1260   * @tc.number SUB_STORAGE_FileIO_UnlinkSync_01001261   * @tc.name fileio_test_unlink_sync_0011262   * @tc.desc Function of API, no parameter.1263   */1264  it('fileio_test_unlink_sync_001', 0, async function () {1265    try {1266      fileio.unlinkSync(1);1267      expect(null).assertFail();1268    } 1269    catch (e) {1270      console.log('fileio_test_unlink_sync_002 has failed for ' + e);1271    }1272  });1273  /**1274   * @tc.number SUB_STORAGE_FileIO_UnlinkSync_02001275   * @tc.name fileio_test_unlink_sync_0021276   * @tc.desc Function of API, invalid parameter1277   */1278  it('fileio_test_unlink_sync_002', 0, async function () {1279    let fpath = await nextFileName('fileIOTest');1280    try {1281      fileio.unlinkSync(fpath);1282      expect(null).assertFail();1283    } 1284    catch (e) {1285      console.log('fileio_test_unlink_sync_002 has failed for ' + e);1286    }1287  });1288  /**1289   * @tc.number SUB_STORAGE_FileIO_WriteSync_00001290   * @tc.name fileio_test_write_sync_0001291   * @tc.desc Function of API, writeSync.1292   */1293  it('fileio_test_write_sync_000', 0, async function () {1294    let fpath = await nextFileName('fileio_test_write_sync_000');1295    try {1296      let fd = fileio.openSync(fpath, 0o102, 0o666);1297      let res = fileio.writeSync(fd, FILE_CONTENT);1298      expect(typeof(res) == 'number').assertTrue();1299      expect(fileio.closeSync(fd) !== null).assertTrue();1300      expect(fileio.unlinkSync(fpath) !== null).assertTrue();1301    } 1302    catch (e) {1303      console.log('fileio_test_write_sync_000 has failed for ' + e);1304      expect(null).assertFail();1305    }1306  });1307  /**1308   * @tc.number SUB_STORAGE_FileIO_WriteSync_01001309   * @tc.name fileio_test_write_sync_0011310   * @tc.desc Function of API, encoding=UTF-8.1311   */1312  it('fileio_test_write_sync_001', 0, async function () {1313    let fpath = await nextFileName('fileio_test_write_sync_001');1314    try {1315      let fd = fileio.openSync(fpath, 0o102, 0o666);1316      let res = fileio.writeSync(fd, FILE_CONTENT, {1317        encoding: 'utf-8',1318      });1319      expect(typeof(res) == 'number').assertTrue();1320      expect(fileio.closeSync(fd) !== null).assertTrue();1321      expect(fileio.unlinkSync(fpath) !== null).assertTrue();1322    } 1323    catch (e) {1324      console.log('fileio_test_write_sync_001 has failed for ' + e);1325      expect(null).assertFail();1326    }1327  });1328  /**1329   * @tc.number SUB_STORAGE_FileIO_WriteSync_02001330   * @tc.name fileio_test_write_sync_0021331   * @tc.desc Function of API, offset=1.1332   */1333  it('fileio_test_write_sync_002', 0, async function () {1334    let fpath = await nextFileName('fileio_test_write_sync_002');1335    let text = '0123456789abcdefg';1336    try {1337      let fd = fileio.openSync(fpath, 0o102, 0o666);1338      expect(fileio.writeSync(fd, text, {1339        offset: 1,1340      }) == text.length - 1).assertTrue();1341      expect(fileio.closeSync(fd) !== null).assertTrue();1342      expect(fileio.unlinkSync(fpath) !== null).assertTrue();1343    } 1344    catch (e) {1345      console.log('fileio_test_write_sync_002 has failed for ' + e);1346      expect(null).assertFail();1347    }1348  });1349  /**1350   * @tc.number SUB_STORAGE_FileIO_WriteSync_03001351   * @tc.name fileio_test_write_sync_0031352   * @tc.desc Function of API, length = - 1.1353   */1354  it('fileio_test_write_sync_003', 0, async function () {1355    let fpath = await nextFileName('fileio_test_write_sync_003');1356    try {1357      let fd = fileio.openSync(fpath, 0o102, 0o666);1358      expect(fileio.writeSync(fd, FILE_CONTENT, {1359        length: FILE_CONTENT.length - 1,1360      }) == (FILE_CONTENT.length - 1)).assertTrue();1361      expect(fileio.closeSync(fd) !== null).assertTrue();1362      expect(fileio.unlinkSync(fpath) !== null).assertTrue();1363    } 1364    catch (e) {1365      console.log('fileio_test_write_sync_003 has failed for ' + e);1366      expect(null).assertFail();1367    }1368  });1369  /**1370   * @tc.number SUB_STORAGE_FileIO_WriteSync_04001371   * @tc.name fileio_test_write_sync_0041372   * @tc.desc Function of API, length = 1, offset = 1.1373   */1374  it('fileio_test_write_sync_004', 0, async function () {1375    let fpath = await nextFileName('fileio_test_write_sync_004');1376    try {1377      let fd = fileio.openSync(fpath, 0o102, 0o666);1378      let res = fileio.writeSync(fd, FILE_CONTENT, {1379        offset: 1,1380        length: 1,1381      });1382      expect(typeof(res) == 'number').assertTrue();1383      expect(fileio.closeSync(fd) !== null).assertTrue();1384      expect(fileio.unlinkSync(fpath) !== null).assertTrue();1385    } 1386    catch (e) {1387      console.log('fileio_test_write_sync_004 has failed for ' + e);1388      expect(null).assertFail();1389    }1390  });1391  /**1392   * @tc.number SUB_STORAGE_FileIO_WriteSync_05001393   * @tc.name fileio_test_write_sync_0051394   * @tc.desc Function of API, invalid offset.1395   */1396  it('fileio_test_write_sync_005', 0, async function () {1397    let fpath = await nextFileName('fileio_test_write_sync_005');1398    const invalidOffset = 9991399    let fd1400    try {1401      fd = fileio.openSync(fpath, 0o102, 0o666);1402      expect(fd).assertInstanceOf('Number');1403      expect(fileio.writeSync(fd, FILE_CONTENT, {1404        offset: invalidOffset,1405      }) == 1).assertTrue();1406      expect(null).assertFail();1407    } 1408    catch (e) {1409      expect(fileio.closeSync(fd) !== null).assertTrue();1410      expect(fileio.unlinkSync(fpath) !== null).assertTrue();1411    }1412  });1413  /**1414   * @tc.number SUB_STORAGE_FileIO_WriteSync_06001415   * @tc.name fileio_test_write_sync_0061416   * @tc.desc Function of API, invalid length.1417   */1418  it('fileio_test_write_sync_006', 0, async function () {1419    let fpath = await nextFileName('fileio_test_write_sync_006');1420    const invalidLength = 9991421    let fd1422    try {1423      fd = fileio.openSync(fpath, 0o102, 0o666);1424      expect(fd).assertInstanceOf('Number');1425      expect(fileio.writeSync(fd, FILE_CONTENT, {1426        length: invalidLength,1427      }) == 1);1428      expect(null).assertFail();1429    } 1430    catch (e) {1431      expect(fileio.closeSync(fd) !== null).assertTrue();1432      expect(fileio.unlinkSync(fpath) !== null).assertTrue();1433    }1434  });1435  /**1436   * @tc.number SUB_STORAGE_FileIO_WriteSync_07001437   * @tc.name fileio_test_write_sync_0071438   * @tc.desc Function of API, no parameter.1439   */1440  it('fileio_test_write_sync_007', 0, async function () {1441    try {1442      fileio.writeSync(1, 1);1443      expect(null).assertFail();1444    } 1445    catch (e) {1446      console.log('fileio_test_write_sync_007 has failed for ' + e);1447    }1448  });1449  /**1450   * @tc.number SUB_STORAGE_FileIO_WriteSync_08001451   * @tc.name fileio_test_write_sync_0081452   * @tc.desc Function of API, invalid parameter.1453   */1454  it('fileio_test_write_sync_008', 0, async function () {1455    try {1456      console.log(fileio.writeSync(-1, FILE_CONTENT));1457      expect(null).assertFail();1458    } 1459    catch (e) {1460      console.log('fileio_test_write_sync_008 has failed for ' + e);1461    }1462  });1463  /**1464   * @tc.number SUB_STORAGE_FileIO_WriteSync_09001465   * @tc.name fileio_test_write_sync_0091466   * @tc.desc Function of API, Set all parameters.1467   */1468  it('fileio_test_write_sync_009', 0, async function () {1469    let fpath = await nextFileName('fileio_test_write_sync_009');1470    try {1471      let fd = fileio.openSync(fpath, 0o102, 0o666);1472      let res = fileio.writeSync(fd, FILE_CONTENT, {1473        encoding: 'utf-8',1474        position: 0,1475        offset: 1,1476        length: 1,1477      });1478      expect(typeof(res) == 'number').assertTrue();1479      expect(fileio.closeSync(fd) !== null).assertTrue();1480      expect(fileio.unlinkSync(fpath) !== null).assertTrue();1481    } 1482    catch (e) {1483      console.log('fileio_test_write_sync_009 has failed for ' + e);1484      expect(null).assertFail();1485    }1486  });1487  /**1488   * @tc.number SUB_STORAGE_FileIO_WriteSync_10001489   * @tc.name fileio_test_write_sync_0101490   * @tc.desc Function of API, encoding=gb2312.1491   */1492  it('fileio_test_write_sync_010', 0, async function () {1493    let fpath = await nextFileName('fileio_test_write_sync_010');1494    let fd = fileio.openSync(fpath, 0o102, 0o666);1495    try {1496      fileio.writeSync(fd, FILE_CONTENT, {1497        encoding: 'gb2312',1498      });1499      expect(null).assertFail();1500    } 1501    catch (e) {1502      console.log('fileio_test_write_sync_010 has failed for ' + e);1503      expect(fileio.closeSync(fd) !== null).assertTrue();1504      expect(fileio.unlinkSync(fpath) !== null).assertTrue();1505    }1506  });1507  /**1508   * @tc.number SUB_STORAGE_FileIO_ReadSync_01001509   * @tc.name fileio_test_read_sync_0011510   * @tc.desc Function of API, offset = 1.1511   */1512  it('fileio_test_read_sync_001', 0, async function () {1513    let bufLen = 51514    expect(FILE_CONTENT.length > bufLen).assertTrue();1515    let fpath = await nextFileName('fileio_test_read_sync_001');1516    expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();1517    try {1518      let fd = fileio.openSync(fpath, 0o2);1519      let len = fileio.readSync(fd, new ArrayBuffer(bufLen), {1520      offset: 1,1521      });1522      expect(len == bufLen - 1).assertTrue();1523      expect(fileio.closeSync(fd) !== null).assertTrue();1524      expect(fileio.unlinkSync(fpath) !== null).assertTrue();1525    } 1526    catch (e) {1527      console.log('fileio_test_read_sync_001 has failed for ' + e);1528      expect(null).assertFail();1529    }1530  });1531  /**1532   * @tc.number SUB_STORAGE_FileIO_ReadSync_02001533   * @tc.name fileio_test_read_sync_0021534   * @tc.desc Function of API, length = 1.1535   */1536  it('fileio_test_read_sync_002', 0, async function () {1537    let fpath = await nextFileName('fileio_test_read_sync_002');1538    expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();1539    try {1540      let fd = fileio.openSync(fpath, 0o2);1541      let len = fileio.readSync(fd, new ArrayBuffer(4096), {1542        length: 1,1543      });1544      expect(len == 1).assertTrue();1545      expect(fileio.closeSync(fd) !== null).assertTrue();1546      expect(fileio.unlinkSync(fpath) !== null).assertTrue();1547    } 1548    catch (e) {1549      console.log('fileio_test_read_sync_002 has failed for ' + e);1550      expect(null).assertFail();1551    }1552  });1553  /**1554   * @tc.number SUB_STORAGE_FileIO_ReadSync_03001555   * @tc.name fileio_test_read_sync_0031556   * @tc.desc Function of API, invalid offset1557   */1558  it('fileio_test_read_sync_003', 0, async function () {1559    let fd1560    const invalidOffset = 999991561    let fpath = await nextFileName('fileio_test_read_sync_003');1562    expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();1563    try {1564      fd = fileio.openSync(fpath, 0o2);1565      fileio.readSync(fd, new ArrayBuffer(4096), {1566        offset: invalidOffset,1567      });1568      expect(null).assertFail();1569    } 1570    catch (e) {1571      expect(fileio.closeSync(fd) !== null).assertTrue();1572      expect(fileio.unlinkSync(fpath) !== null).assertTrue();1573      console.log('fileio_test_read_sync_003 has failed for ' + e);1574    }1575  });1576  /**1577   * @tc.number SUB_STORAGE_FileIO_ReadSync_03001578   * @tc.name fileio_test_read_sync_0041579   * @tc.desc Function of API, invalid length.1580   */1581  it('fileio_test_read_sync_004', 0, async function () {1582    let fd1583    const invalidLength = 99991584    let fpath = await nextFileName('fileio_test_read_sync_004');1585    expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();1586    try {1587      fd = fileio.openSync(fpath, 0o2);1588      fileio.readSync(fd, new ArrayBuffer(4096), {1589        length: invalidLength,1590      });1591      expect(null).assertFail();1592    } 1593    catch (e) {1594      expect(fileio.closeSync(fd) !== null).assertTrue();1595      expect(fileio.unlinkSync(fpath) !== null).assertTrue();1596      console.log('fileio_test_read_sync_004 has failed for ' + e);1597    }1598  });1599  /**1600   * @tc.number SUB_STORAGE_FileIO_ReadSync_05001601   * @tc.name fileio_test_read_sync_0051602   * @tc.desc Function of API, fpatch = -1.1603   */1604  it('fileio_test_read_sync_005', 0, async function () {1605    try {1606      fileio.readSync(-1, new ArrayBuffer(4096));1607      expect(null).assertFail();1608    } 1609    catch (e) {1610      console.log('fileio_test_read_sync_005 has failed for ' + e);1611    }1612  });1613  /**1614   * @tc.number SUB_STORAGE_FileIO_ReadSync_06001615   * @tc.name fileio_test_read_sync_0061616   * @tc.desc Function of API, offset & length & position = 1.1617   */1618  it('fileio_test_read_sync_006', 0, async function () {1619    let fpath = await nextFileName('fileio_test_read_sync_006');1620    expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();1621    try {1622      let fd = fileio.openSync(fpath, 0o2);1623      let len = fileio.readSync(fd, new ArrayBuffer(4096), {1624        position: 1,1625      });1626      expect(len == FILE_CONTENT.length - 1);1627      expect(fileio.closeSync(fd) !== null).assertTrue();1628      expect(fileio.unlinkSync(fpath) !== null).assertTrue();1629    } 1630    catch (e) {1631      console.log('fileio_test_read_sync_006 has failed for ' + e);1632      expect(null).assertFail();1633    }1634  });1635  /**1636   * @tc.number SUB_STORAGE_FileIO_ReadSync_07001637   * @tc.name fileio_test_read_sync_0071638   * @tc.desc Function of API, invalid position.1639   */1640  it('fileio_test_read_sync_007', 0, async function () {1641    let fpath = await nextFileName('fileio_test_read_sync_007');1642    expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();1643    try {1644      let fd = fileio.openSync(fpath, 0o2);1645      let invalidPos = FILE_CONTENT.length;1646      let len = fileio.readSync(fd, new ArrayBuffer(4096), {1647        position: invalidPos,1648      });1649      expect(fileio.closeSync(fd) !== null).assertTrue();1650      expect(fileio.unlinkSync(fpath) !== null).assertTrue();1651    } 1652    catch (e) {1653      console.log('fileio_test_read_sync_007 has failed for ' + e);1654      expect(null).assertFail();1655    }1656  });1657  /**1658   * @tc.number SUB_STORAGE_FileIO_ReadSync_08001659   * @tc.name fileio_test_read_sync_0081660   * @tc.desc Function of API, Enter all parameters correctly.1661   */1662  it('fileio_test_read_sync_008', 0, async function () {1663    let fpath = await nextFileName('fileio_test_read_sync_008');1664    expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();1665    try {1666      let fd = fileio.openSync(fpath, 0o2);1667      let len = fileio.readSync(fd, new ArrayBuffer(4096), {1668        position: 1,1669        offset: 1,1670        length: 1,1671      });1672      expect(len == 1).assertTrue();1673      expect(fileio.closeSync(fd) !== null).assertTrue();1674      expect(fileio.unlinkSync(fpath) !== null).assertTrue();1675    } 1676    catch (e) {1677      console.log('fileio_test_read_sync_008 has failed for ' + e);1678      expect(null).assertFail();1679    }1680  });1681  /**1682   * @tc.number SUB_STORAGE_FileIO_ReadSync_09001683   * @tc.name fileio_test_read_sync_0091684   * @tc.desc Function of API, Set offset and length.1685   */1686  it('fileio_test_read_sync_009', 0, async function () {1687    let fpath = await nextFileName('fileio_test_read_sync_009');1688    expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();1689    try {1690      let fd = fileio.openSync(fpath, 0o2);1691      let len = fileio.readSync(fd, new ArrayBuffer(4096), {1692        offset: 1,1693        length: 1,1694      });1695      expect(len == 1).assertTrue();1696      expect(fileio.closeSync(fd) !== null).assertTrue();1697      expect(fileio.unlinkSync(fpath) !== null).assertTrue();1698    } 1699    catch (e) {1700      console.log('fileio_test_read_sync_009 has failed for ' + e);1701      expect(null).assertFail();1702    }1703  });1704  /**1705   * @tc.number SUB_STORAGE_FileIO_ReadSync_10001706   * @tc.name fileio_test_read_sync_0101707   * @tc.desc Function of API, Set error parameters (options).1708   */1709  it('fileio_test_read_sync_010', 0, async function () {1710    let fpath = await nextFileName('fileio_test_read_sync_010');1711    expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();1712    let fd;1713    try {1714      fd = fileio.openSync(fpath, 0o2);1715      fileio.readSync(fd, new ArrayBuffer(4096), {1716        position: 1,1717        offset: 1,1718        length: 1,1719      });1720      expect(null).assertFail();1721    } 1722    catch (e) {1723      console.log('fileio_test_read_sync_010 has failed for ' + e);1724      expect(fileio.closeSync(fd) !== null).assertTrue();1725      expect(fileio.unlinkSync(fpath) !== null).assertTrue();1726    }1727  });1728  /**1729   * @tc.number SUB_STORAGE_FileIO_ChmodSync_00001730   * @tc.name fileio_test_chmod_sync_0001731   * @tc.desc Function of API, mode=0o6601732   */1733  it('fileio_test_chmod_sync_000', 0, async function () {1734    let fpath = await nextFileName('fileio_test_chmod_sync_000');1735    expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();1736    try {1737      expect(fileio.chmodSync(fpath, 0o660) !== null).assertTrue();1738      expect((fileio.statSync(fpath).mode & 0o777) == 0o660).assertTrue();1739      expect(fileio.unlinkSync(fpath) !== null).assertTrue();1740    } 1741    catch (e) {1742      console.log('fileio_test_chmod_sync_000 has failed for ' + e);1743      expect(null).assertFail();1744    }1745  });1746  /**1747   * @tc.number SUB_STORAGE_FileIO_ChmodSync_01001748   * @tc.name fileio_test_chmod_sync_0011749   * @tc.desc Function of API, mode=0o4601750   */1751  it('fileio_test_chmod_sync_001', 0, async function () {1752    let fpath = await nextFileName('fileio_test_chmod_sync_001');1753    expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();1754    try {1755      expect(fileio.chmodSync(fpath, 0o460) !== null).assertTrue();1756      expect((fileio.statSync(fpath).mode & 0o777) == 0o460).assertTrue();1757      expect(fileio.unlinkSync(fpath) !== null).assertTrue();1758    } 1759    catch (e) {1760      console.log('fileio_test_chmod_sync_001 has failed for ' + e);1761      expect(null).assertFail();1762    }1763  });1764  /**1765   * @tc.number SUB_STORAGE_FileIO_ChmodSync_02001766   * @tc.name fileio_test_chmod_sync_0021767   * @tc.desc Function of API, mode=0o260. The test file is exist.1768   */1769  it('fileio_test_chmod_sync_002', 0, async function () {1770    let fpath = await nextFileName('fileio_test_chmod_sync_002');1771    expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();1772    try {1773      expect(fileio.chmodSync(fpath, 0o260) !== null).assertTrue();1774      expect((fileio.statSync(fpath).mode & 0o777) == 0o260).assertTrue();1775      expect(fileio.unlinkSync(fpath) !== null).assertTrue();1776    } 1777    catch (e) {1778      console.log('fileio_test_chmod_sync_002 has failed for ' + e);1779      expect(null).assertFail();1780    }1781  });1782  /**1783   * @tc.number SUB_STORAGE_FileIO_ChmodSync_03001784   * @tc.name fileio_test_chmod_sync_0031785   * @tc.desc Function of API, chmodSync. The test file is not exist.1786   */1787  it('fileio_test_chmod_sync_003', 0, async function () {1788    let fpath = await nextFileName('fileio_test_chmod_sync_003');1789    try {1790      fileio.chmodSync(fpath, 0o260);1791      expect(null).assertFail();1792    } 1793    catch (e) {1794      console.log('fileio_test_chmod_sync_003 has failed for ' + e);1795    }1796  });1797  /**1798   * @tc.number SUB_STORAGE_FileIO_ChmodSync_04001799   * @tc.name fileio_test_chmod_sync_0041800   * @tc.desc Function of API, fpatch=dir address. The test dir is exist.1801   */1802  it('fileio_test_chmod_sync_004', 0, async function () {1803    let dpath = await nextFileName('fileio_test_chmod_sync_004');1804    try {1805      expect(fileio.mkdirSync(dpath, 0o777) !== null).assertTrue();1806      expect(fileio.chmodSync(dpath, 0o660) !== null).assertTrue();1807      expect((fileio.statSync(dpath).mode & 0o777) == 0o660).assertTrue();1808      expect(fileio.rmdirSync(dpath) !== null).assertTrue();1809    } 1810    catch (e) {1811      console.log('fileio_test_chmod_sync_000 has failed for ' + e);1812      expect(null).assertFail();1813    }1814  });1815  /**1816   * @tc.number SUB_STORAGE_FileIO_ChmodSync_05001817   * @tc.name fileio_test_chmod_sync_0051818   * @tc.desc Function of API, fpatch=dir address. The test dir is not exist.1819   */1820  it('fileio_test_chmod_sync_005', 0, async function () {1821    let dpath;1822    try {1823      fileio.chmodSync(dpath, 0o660);1824      expect(null).assertFail();1825    } 1826    catch (e) {1827      console.log('fileio_test_chmod_sync_005 has failed for ' + e);1828    }1829  });1830  /**1831   * @tc.number SUB_STORAGE_FileIO_ChmodSync_06001832   * @tc.name fileio_test_chmod_sync_0061833   * @tc.desc Function of API, mode=0o700. The test file is exist.1834   */1835  it('fileio_test_chmod_sync_006', 0, async function () {1836    let fpath = await nextFileName('fileio_test_chmod_sync_006');1837    expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();1838    try {1839      expect(fileio.chmodSync(fpath, 0o700) !== null).assertTrue();1840      expect((fileio.statSync(fpath).mode & 0o777) == 0o700).assertTrue();1841      expect(fileio.unlinkSync(fpath) !== null).assertTrue();1842    } 1843    catch (e) {1844      console.log('fileio_test_chmod_sync_006 has failed for ' + e);1845      expect(null).assertFail();1846    }1847  });1848  /**1849   * @tc.number SUB_STORAGE_FileIO_ChmodSync_07001850   * @tc.name fileio_test_chmod_sync_0071851   * @tc.desc Function of API, mode=0o400. The test file is exist.1852   */1853  it('fileio_test_chmod_sync_007', 0, async function () {1854    let fpath = await nextFileName('fileio_test_chmod_sync_007');1855    expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();1856    try {1857      expect(fileio.chmodSync(fpath, 0o400) !== null).assertTrue();1858      expect((fileio.statSync(fpath).mode & 0o777) == 0o400).assertTrue();1859      expect(fileio.unlinkSync(fpath) !== null).assertTrue();1860    } 1861    catch (e) {1862      console.log('fileio_test_chmod_sync_002 has failed for ' + e);1863      expect(null).assertFail();1864    }1865  });1866  /**1867   * @tc.number SUB_STORAGE_FileIO_ChmodSync_08001868   * @tc.name fileio_test_chmod_sync_0081869   * @tc.desc Function of API, mode=0o200. The test file is exist.1870   */1871  it('fileio_test_chmod_sync_008', 0, async function () {1872    let fpath = await nextFileName('fileio_test_chmod_sync_008');1873    expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();1874    try {1875      expect(fileio.chmodSync(fpath, 0o200) !== null).assertTrue();1876      expect((fileio.statSync(fpath).mode & 0o777) == 0o200).assertTrue();1877      expect(fileio.unlinkSync(fpath) !== null).assertTrue();1878    } 1879    catch (e) {1880      console.log('fileio_test_chmod_sync_008 has failed for ' + e);1881      expect(null).assertFail();1882    }1883  });1884  /**1885   * @tc.number SUB_STORAGE_FileIO_ChmodSync_09001886   * @tc.name fileio_test_chmod_sync_0091887   * @tc.desc Function of API, mode=0o100. The test file is exist.1888   */1889  it('fileio_test_chmod_sync_009', 0, async function () {1890    let fpath = await nextFileName('fileio_test_chmod_sync_009');1891    expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();1892    try {1893      expect(fileio.chmodSync(fpath, 0o100) !== null).assertTrue();1894      expect((fileio.statSync(fpath).mode & 0o777) == 0o100).assertTrue();1895      expect(fileio.unlinkSync(fpath) !== null).assertTrue();1896    } 1897    catch (e) {1898      console.log('fileio_test_chmod_sync_009 has failed for ' + e);1899      expect(null).assertFail();1900    }1901  });1902  /**1903   * @tc.number SUB_STORAGE_FileIO_ChmodSync_01001904   * @tc.name fileio_test_chmod_sync_0101905   * @tc.desc Function of API, mode=0o070. The test file is exist.1906   */1907  it('fileio_test_chmod_sync_010', 0, async function () {1908    let fpath = await nextFileName('fileio_test_chmod_sync_010');1909    expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();1910    try {1911      expect(fileio.chmodSync(fpath, 0o070) !== null).assertTrue();1912      expect((fileio.statSync(fpath).mode & 0o777) == 0o070).assertTrue();1913      expect(fileio.unlinkSync(fpath) !== null).assertTrue();1914    } 1915    catch (e) {1916      console.log('fileio_test_chmod_sync_010 has failed for ' + e);1917      expect(null).assertFail();1918    }1919  });1920  /**1921   * @tc.number SUB_STORAGE_FileIO_ChmodSync_01101922   * @tc.name fileio_test_chmod_sync_0111923   * @tc.desc Function of API, mode=0o040. The test file is exist.1924   */1925  it('fileio_test_chmod_sync_011', 0, async function () {1926    let fpath = await nextFileName('fileio_test_chmod_sync_011');1927    expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();1928    try {1929      expect(fileio.chmodSync(fpath, 0o040) !== null).assertTrue();1930      expect((fileio.statSync(fpath).mode & 0o777) == 0o040).assertTrue();1931      expect(fileio.unlinkSync(fpath) !== null).assertTrue();1932    } 1933    catch (e) {1934      console.log('fileio_test_chmod_sync_011 has failed for ' + e);1935      expect(null).assertFail();1936    }1937  });1938  /**1939   * @tc.number SUB_STORAGE_FileIO_ChmodSync_01201940   * @tc.name fileio_test_chmod_sync_0121941   * @tc.desc Function of API, mode=0o020. The test file is exist.1942   */1943  it('fileio_test_chmod_sync_012', 0, async function () {1944    let fpath = await nextFileName('fileio_test_chmod_sync_012');1945    expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();1946    try {1947      expect(fileio.chmodSync(fpath, 0o020) !== null).assertTrue();1948      expect((fileio.statSync(fpath).mode & 0o777) == 0o020).assertTrue();1949      expect(fileio.unlinkSync(fpath) !== null).assertTrue();1950    } 1951    catch (e) {1952      console.log('fileio_test_chmod_sync_012 has failed for ' + e);1953      expect(null).assertFail();1954    }1955  });1956  /**1957   * @tc.number SUB_STORAGE_FileIO_ChmodSync_01301958   * @tc.name fileio_test_chmod_sync_0131959   * @tc.desc Function of API, mode=0o010. The test file is exist.1960   */1961  it('fileio_test_chmod_sync_013', 0, async function () {1962    let fpath = await nextFileName('fileio_test_chmod_sync_013');1963    expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();1964    try {1965      expect(fileio.chmodSync(fpath, 0o010) !== null).assertTrue();1966      expect((fileio.statSync(fpath).mode & 0o777) == 0o010).assertTrue();1967      expect(fileio.unlinkSync(fpath) !== null).assertTrue();1968    } 1969    catch (e) {1970      console.log('fileio_test_chmod_sync_013 has failed for ' + e);1971      expect(null).assertFail();1972    }1973  });1974  /**1975   * @tc.number SUB_STORAGE_FileIO_ChmodSync_01401976   * @tc.name fileio_test_chmod_sync_0141977   * @tc.desc Function of API, mode=0o007. The test file is exist.1978   */1979  it('fileio_test_chmod_sync_014', 0, async function () {1980    let fpath = await nextFileName('fileio_test_chmod_sync_014');1981    expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();1982    try {1983      expect(fileio.chmodSync(fpath, 0o007) !== null).assertTrue();1984      expect((fileio.statSync(fpath).mode & 0o777) == 0o007).assertTrue();1985      expect(fileio.unlinkSync(fpath) !== null).assertTrue();1986    } 1987    catch (e) {1988      console.log('fileio_test_chmod_sync_014 has failed for ' + e);1989      expect(null).assertFail();1990    }1991  });1992  /**1993   * @tc.number SUB_STORAGE_FileIO_ChmodSync_01501994   * @tc.name fileio_test_chmod_sync_0151995   * @tc.desc Function of API, mode=0o700. The test file is exist.1996   */1997  it('fileio_test_chmod_sync_015', 0, async function () {1998    let fpath = await nextFileName('fileio_test_chmod_sync_015');1999    expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();2000    try {2001      expect(fileio.chmodSync(fpath, 0o004) !== null).assertTrue();2002      expect((fileio.statSync(fpath).mode & 0o777) == 0o004).assertTrue();2003      expect(fileio.unlinkSync(fpath) !== null).assertTrue();2004    } 2005    catch (e) {2006      console.log('fileio_test_chmod_sync_015 has failed for ' + e);2007      expect(null).assertFail();2008    }2009  });2010  /**2011   * @tc.number SUB_STORAGE_FileIO_ChmodSync_01602012   * @tc.name fileio_test_chmod_sync_0162013   * @tc.desc Function of API, mode=0o002. The test file is exist.2014   */2015  it('fileio_test_chmod_sync_016', 0, async function () {2016    let fpath = await nextFileName('fileio_test_chmod_sync_016');2017    expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();2018    try {2019      expect(fileio.chmodSync(fpath, 0o002) !== null).assertTrue();2020      expect((fileio.statSync(fpath).mode & 0o777) == 0o002).assertTrue();2021      expect(fileio.unlinkSync(fpath) !== null).assertTrue();2022    } 2023    catch (e) {2024      console.log('fileio_test_chmod_sync_016 has failed for ' + e);2025      expect(null).assertFail();2026    }2027  });2028  /**2029   * @tc.number SUB_STORAGE_FileIO_ChmodSync_01702030   * @tc.name fileio_test_chmod_sync_0172031   * @tc.desc Function of API, mode=0o001. The test file is exist.2032   */2033  it('fileio_test_chmod_sync_017', 0, async function () {2034    let fpath = await nextFileName('fileio_test_chmod_sync_017');2035    expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();2036    try {2037      expect(fileio.chmodSync(fpath, 0o001) !== null).assertTrue();2038      expect((fileio.statSync(fpath).mode & 0o777) == 0o001).assertTrue();2039      expect(fileio.unlinkSync(fpath) !== null).assertTrue();2040    } 2041    catch (e) {2042      console.log('fileio_test_chmod_sync_017 has failed for ' + e);2043      expect(null).assertFail();2044    }2045  });2046  /**2047   * @tc.number SUB_STORAGE_FileIO_copyFileSync_00002048   * @tc.name fileio_test_copy_file_sync_0002049   * @tc.desc Function of API, copy. fpatch is vaild, fpathTarget is vaild, same path, file not same.2050   */2051  it('fileio_test_copy_file_sync_000', 0, async function () {2052    let fpath = await nextFileName('fileio_test_copy_file_sync_000');2053    let fpathTarget = fpath + 'tgt'2054    expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();2055    try {2056      expect(fileio.copyFileSync(fpath, fpathTarget) !== null).assertTrue();2057      expect(fileio.unlinkSync(fpath) !== null).assertTrue();2058      expect(fileio.unlinkSync(fpathTarget) !== null).assertTrue();2059    } 2060    catch (e) {2061      console.log('fileio_test_copy_file_sync_000 has failed for ' + e);2062      expect(null).assertFail();2063    }2064  });2065  /**2066   * @tc.number SUB_STORAGE_FileIO_copyFileSync_01002067   * @tc.name fileio_test_copy_file_sync_0012068   * @tc.desc Function of API, copy. fpatch is invalid, fpathTarget is vaild, same path, file not same.2069   */2070  it('fileio_test_copy_file_sync_001', 0, async function () {2071    let fpath = await nextFileName('fileio_test_copy_file_sync_001') + 'd'2072    let fpathTarget = fpath + 'tgt'2073    try {2074      fileio.copyFileSync(fpath, fpathTarget);2075      expect(null).assertFail();2076    } 2077    catch (e) {2078      console.log('fileio_test_copy_file_sync_001 has failed for ' + e);2079    }2080  });2081  /**2082   * @tc.number SUB_STORAGE_FileIO_copyFileSync_02002083   * @tc.name fileio_test_copy_file_sync_0022084   * @tc.desc Function of API, copy. fpatch is vaild, fpathTarget is invalid.2085   */2086  it('fileio_test_copy_file_sync_002', 0, async function () {2087    let fpath = await nextFileName('fileio_test_copy_file_sync_002');2088    try {2089      fileio.copyFileSync(fpath, 0);2090      expect(null).assertFail();2091    } 2092    catch (e) {2093      console.log('fileio_test_copy_file_sync_002 has failed for ' + e);2094    }2095  });2096  /**2097   * @tc.number SUB_STORAGE_FileIO_copyFileSync_03002098   * @tc.name fileio_test_copy_file_sync_0032099   * @tc.desc Function of API, copy. fpatch is vaild, fpathTarget is vaild, path not same, file not same.2100   */2101  it('fileio_test_copy_file_sync_003', 0, async function () {2102    let fpath = await nextFileName('fileio_test_copy_file_sync_003');2103    let fpathTarget = fpath + 'f1'2104    expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();2105    try {2106      expect(fileio.copyFileSync(fpath, fpathTarget) !== null).assertTrue();2107      expect(fileio.unlinkSync(fpath) !== null).assertTrue();2108      expect(fileio.unlinkSync(fpathTarget) !== null).assertTrue();2109    } 2110    catch (e) {2111      console.log('fileio_test_copy_file_sync_003 has failed for ' + e);2112      expect(null).assertFail();2113    }2114  });2115  /**2116   * @tc.number SUB_STORAGE_FileIO_copyFileSync_04002117   * @tc.name fileio_test_copy_file_sync_0042118   * @tc.desc Function of API, copy. fpatch is vaild, fpathTarget is vaild, path not same, file not same.2119   */2120  it('fileio_test_copy_file_sync_004', 0, async function () {2121    let fpath = await nextFileName('fileio_test_copy_file_sync_004');2122    let fpathTarget = await fileName('fileio_test_copy_file_sync_004');2123    expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();2124    try {2125      expect(fileio.copyFileSync(fpath, fpathTarget) !== null).assertTrue();2126      expect(fileio.unlinkSync(fpath) !== null).assertTrue();2127      expect(fileio.unlinkSync(fpathTarget) !== null).assertTrue();2128    } 2129    catch (e) {2130      console.log('fileio_test_copy_file_sync_004 has failed for ' + e);2131      expect(null).assertFail();2132    }2133  });2134  /**2135   * @tc.number SUB_STORAGE_FileIO_copyFileSync_05002136   * @tc.name fileio_test_copy_file_sync_0052137   * @tc.desc Function of API, copy. fpatch is vaild, fpathTarget is vaild, path not same, file not same.2138   */2139  it('fileio_test_copy_file_sync_005', 0, async function () {2140    let fpath = await nextFileName('fileio_test_copy_file_sync_005');2141    let fpathTarget = fpath2142    expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();2143    try {2144      expect(fileio.copyFileSync(fpath, fpathTarget) !== null).assertTrue();2145      expect(fileio.unlinkSync(fpath) !== null).assertTrue();2146    } 2147    catch (e) {2148      console.log('fileio_test_copy_file_sync_005 has failed for ' + e);2149      expect(null).assertFail();2150    }2151  });2152  /**2153   * @tc.number SUB_STORAGE_FileIO_copyFileSync_06002154   * @tc.name fileio_test_copy_file_sync_0062155   * @tc.desc Function of API, copy. fpathTarget is invalid.2156   */2157  it('fileio_test_copy_file_sync_006', 0, async function () {2158    let fpath = await nextFileName('fileio_test_copy_file_sync_006');2159    let fpathTarget = fpath + 'tgt'2160    try {2161      fileio.copyFileSync(fpath, fpathTarget);2162      expect(null).assertFail();2163    } 2164    catch (e) {2165      console.log('fileio_test_copy_file_sync_006 has failed for ' + e);2166    }2167  });2168  /**2169   * @tc.number SUB_STORAGE_FileIO_copyFileSync_07002170   * @tc.name fileio_test_copy_file_sync_0072171   * @tc.desc Function of API, copy. fpatch is invalid, fpathTarget is invalid.2172   */2173  it('fileio_test_copy_file_sync_007', 0, async function () {2174    try {2175      fileio.copyFileSync(1, 1);2176      expect(null).assertFail();2177    } 2178    catch (e) {2179      console.log('fileio_test_copy_file_sync_007 has failed for ' + e);2180    }2181  });2182  /**2183   * @tc.number SUB_STORAGE_FileIO_copyFileSync_08002184   * @tc.name fileio_test_copy_file_sync_0082185   * @tc.desc Function of API, parameter more than 4096.2186   */2187  it('fileio_test_copy_file_sync_008', 0, async function () {2188    let fpath = await nextFileName('fileio_test_copy_file_sync_008');2189    fileio.openSync(fpath, 0o102, 0o777);2190    let dpath = await nextFileName('fileio_copy1');2191    fileio.mkdirSync(dpath);2192    try {2193      for (let i = 0; i < 16; i++) {2194        if (i == 15) {2195          let fpathTarget = dpath + '/f' + randomString(248);2196          fileio.copyFileSync(fpath, fpathTarget);2197        } else {2198          dpath = dpath + '/d' + randomString(248);2199          fileio.mkdirSync(dpath);2200        }2201      }2202      expect(null).assertFail();2203    } 2204    catch (e) {2205      console.log('fileio_test_copy_file_sync_008 has failed for ' + e);2206    }2207  });2208  /**2209   * @tc.number SUB_STORAGE_FileIO_copyFileSync_09002210   * @tc.name fileio_test_copy_file_sync_0092211   * @tc.desc Function of API, filename is too long.2212   */2213  it('fileio_test_copy_file_sync_009', 0, async function () {2214    let fpath = await nextFileName('fileio_test_copy_file_sync_009');2215    fileio.openSync(fpath, 0o102, 0o777);2216    let fpathTarget = await nextFileName(randomString(256));2217    try {2218      fileio.copyFileSync(fpath, fpathTarget);2219      expect(null).assertFail();2220    } 2221    catch (e) {2222      fileio.unlinkSync(fpath);2223      console.log('fileio_test_copy_file_sync_009 has failed for ' + e);2224    }2225  });2226  /**2227   * @tc.number SUB_STORAGE_FileIO_copyFileSync_10002228   * @tc.name fileio_test_copy_file_sync_0102229   * @tc.desc Function of API, dir layers too long2230   */2231  it('fileio_test_copy_file_sync_010', 0, async function () {2232    let fpath = await nextFileName('fileio_test_copy_file_sync_010');2233    fileio.openSync(fpath, 0o102, 0o777);2234    let dpath = await nextFileName('prop');2235    fileio.mkdirSync(dpath);2236    try {2237      for (let i = 0; i < 113; i++) {2238        if (i == 112) {2239          let fpathTarget = dpath + '/f' + i2240          fileio.copyFileSync(fpath, fpathTarget);2241        } else {2242          dpath = dpath + '/' + i2243          fileio.mkdirSync(dpath);2244        }2245      }2246      expect(null).assertFail();2247    } 2248    catch (e) {2249      fileio.unlinkSync(fpath);2250    }2251  });2252  /**2253   * @tc.number SUB_STORAGE_FileIO_copyFileSync_11002254   * @tc.name fileio_test_copy_file_sync_0112255   * @tc.desc Function of API, special parameter.2256   */2257  it('fileio_test_copy_file_sync_011', 0, async function () {2258    let fpath = await nextFileName('fileio_test_copy_file_sync_011');2259    fileio.openSync(fpath, 0o102, 0o777);2260    let fpathTarget = await nextFileName('?*:<>/|');2261    try {2262      fileio.copyFileSync(fpath, fpathTarget);2263      expect(null).assertFail();2264    } 2265    catch (e) {2266      fileio.unlinkSync(fpath);2267      console.log('fileio_test_copy_file_sync_011 has failed for ' + e);2268    }2269  });2270  /**2271   * @tc.number SUB_STORAGE_FileIO_copyFileSync_12002272   * @tc.name fileio_test_copy_file_sync_0122273   * @tc.desc Function of API, copy. fpatch is vaild, fpathTarget is vaild, same path, file not same, mode is 0.2274   */2275  it('fileio_test_copy_file_sync_012', 0, async function () {2276    let fpath = await nextFileName('fileio_test_copy_file_sync_012');2277    let fpathTarget = fpath + 'tgt'2278    expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();2279    try {2280      expect(fileio.copyFileSync(fpath, fpathTarget, 0) !== null).assertTrue();2281      expect(fileio.unlinkSync(fpath) !== null).assertTrue();2282      expect(fileio.unlinkSync(fpathTarget) !== null).assertTrue();2283    } 2284    catch (e) {2285      console.log('fileio_test_copy_file_sync_012 has failed for ' + e);2286      expect(null).assertFail();2287    }2288  });2289  /**2290   * @tc.number SUB_STORAGE_FileIO_truncateSync_00002291   * @tc.name fileio_test_truncate_sync_0002292   * @tc.desc Function of API, truncateSync.2293   */2294  it('fileio_test_truncate_sync_000', 0, async function () {2295    let fpath = await nextFileName('fileio_test_truncate_sync_000');2296    expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();2297    try {2298      expect(fileio.truncateSync(fpath, 10) !== null).assertTrue();2299      expect(fileio.statSync(fpath).size == 10).assertTrue();2300      expect(fileio.unlinkSync(fpath) !== null).assertTrue();2301    } 2302    catch (e) {2303      console.log('fileio_test_truncate_sync_000 has failed for ' + e);2304      expect(null).assertFail();2305    }2306  });2307  /**2308   * @tc.number SUB_STORAGE_FileIO_truncateSync_01002309   * @tc.name fileio_test_truncate_sync_0012310   * @tc.desc Function of API, no value for parameter.2311   */2312  it('fileio_test_truncate_sync_001', 0, async function () {2313    try {2314      fileio.truncateSync();2315      expect(null).assertFail();2316    } 2317    catch (e) {2318      console.log('fileio_test_truncate_sync_001 has failed for ' + e);2319    }2320  });2321  /**2322   * @tc.number SUB_STORAGE_FileIO_truncateSync_02002323   * @tc.name fileio_test_truncate_sync_0022324   * @tc.desc Function of API, no invalid parameter.2325   */2326  it('fileio_test_truncate_sync_002', 0, async function () {2327    let fpath = await nextFileName('fileio_test_truncate_sync_001');2328    try {2329      fileio.truncateSync(fpath);2330      expect(null).assertFail();2331    } 2332    catch (e) {2333      console.log('fileio_test_truncate_sync_002 has failed for ' + e);2334    }2335  });2336  /**2337   * @tc.number SUB_STORAGE_FileIO_truncateSync_03002338   * @tc.name fileio_test_truncate_sync_0032339   * @tc.desc Function of API, .2340   */2341  it('fileio_test_truncate_sync_003', 0, async function () {2342    let fpath = await nextFileName('fileio_test_truncate_sync_003');2343    try {2344      fileio.truncateSync(fpath, -1);2345      expect(null).assertFail();2346    } 2347    catch (e) {2348      console.log('fileio_test_truncate_sync_003 has failed for ' + e);2349    }2350  });2351  /**2352   * @tc.number SUB_STORAGE_FileIO_RenameSync_00002353   * @tc.name fileio_test_rename_sync_0002354   * @tc.desc Function of API, renameSync. The test file is exist,2355   * fpathTarget is not same with fpatch, file name are same.2356   */2357  it('fileio_test_rename_sync_000', 0, async function () {2358    let fpath = await nextFileName('fileio_test_rename_sync_000');2359    let fpathTarget = fpath + 'tgt'2360    expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();2361    try {2362      expect(fileio.renameSync(fpath, fpathTarget) !== null).assertTrue();2363      expect(fileio.accessSync(fpathTarget) !== null).assertTrue();2364      expect(fileio.unlinkSync(fpathTarget) !== null).assertTrue();2365    } 2366    catch (e) {2367      console.log('fileio_test_rename_sync_000 has failed for ' + e);2368      expect(null).assertFail();2369    }2370  });2371  /**2372   * @tc.number SUB_STORAGE_FileIO_RenameSync_01002373   * @tc.name fileio_test_rename_sync_0012374   * @tc.desc Function of API, renameSync. The test file is not exist, 2375   * fpathTarget is not same with fpatch, file name are same.2376   */2377  it('fileio_test_rename_sync_001', 0, async function () {2378    let fpath = await nextFileName('fileio_test_rename_sync_001');2379    let fpathTarget = fpath + 'tgt'2380    try {2381      fileio.renameSync(fpath, fpathTarget);2382      expect(null).assertFail();2383    } 2384    catch (e) {2385      console.log('fileio_test_rename_sync_001 has failed for ' + e);2386    }2387  });2388  /**2389   * @tc.number SUB_STORAGE_FileIO_RenameSync_02002390   * @tc.name fileio_test_rename_sync_0022391   * @tc.desc Function of API, renameSync. The test file is exist, fpathTarget is invalid.2392   */2393  it('fileio_test_rename_sync_002', 0, async function () {2394    let fpath = await nextFileName('fileio_test_rename_sync_002');2395    expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();2396    try {2397      fileio.renameSync(fpath, '/');2398      expect(null).assertFail();2399    } 2400    catch (e) {2401      expect(fileio.unlinkSync(fpath) !== null).assertTrue();2402      console.log('fileio_test_rename_sync_002 has failed for ' + e);2403    }2404  });2405  /**2406   * @tc.number SUB_STORAGE_FileIO_RenameSync_03002407   * @tc.name fileio_test_rename_sync_0032408   * @tc.desc Function of API, renameSync. The test file is not exist, fpathTarget is same with fpatch, file name are same.2409   */2410  it('fileio_test_rename_sync_003', 0, async function () {2411    let fpath = await nextFileName('fileio_test_rename_sync_003');2412    expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();2413    try {2414      console.log('fileio_test_rename_sync_003 Test start');2415      fileio.renameSync(fpath, fpath);2416      expect(null).assertFail();2417    } 2418    catch (e) {2419      expect(fileio.unlinkSync(fpath) !== null).assertTrue();2420    }2421  });2422  /**2423   * @tc.number SUB_STORAGE_FileIO_RenameSync_04002424   * @tc.name fileio_test_rename_sync_0042425   * @tc.desc Function of API, no fpath parameter.2426   */2427  it('fileio_test_rename_sync_004', 0, async function () {2428    try {2429      fileio.renameSync(1, 1);2430      expect(null).assertFail();2431    } 2432    catch (e) {2433      console.log('fileio_test_rename_sync_004 pass. ' + e);2434    }2435  });2436  /**2437   * @tc.number SUB_STORAGE_FileIO_RenameSync_05002438   * @tc.name fileio_test_rename_sync_0052439   * @tc.desc Function of API, no fpathTarget parameter.2440   */2441  it('fileio_test_rename_sync_005', 0, async function () {2442    let fpath = await nextFileName('fileio_test_rename_sync_005');2443    expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();2444    try {2445      fileio.renameSync(fpath, 1);2446      expect(null).assertFail();2447    } 2448    catch (e) {2449      expect(fileio.unlinkSync(fpath) !== null).assertTrue();2450      console.log('fileio_test_rename_sync_005 pass. ' + e);2451    }2452  });2453  /**2454   * @tc.number SUB_STORAGE_FileIO_RenameSync_06002455   * @tc.name fileio_test_rename_sync_0062456   * @tc.desc Function of API, rename dir.2457   */2458  it('fileio_test_rename_sync_006', 0, async function () {2459    let dpath = await nextFileName('fileio_test_rename_sync_006') + 'd'2460    let dpathTarget = await nextFileName('fileio_test_rename_sync_006-1') + 'd'2461    try {2462      expect(fileio.mkdirSync(dpath) !== null).assertTrue();2463      expect(fileio.renameSync(dpath, dpathTarget) == undefined).assertTrue();2464      expect(fileio.accessSync(dpathTarget) !== null).assertTrue();2465      expect(fileio.rmdirSync(dpathTarget) !== null).assertTrue();2466    } 2467    catch (e) {2468      console.log('fileio_test_rename_sync_006 has failed for ' + e);2469      expect(null).assertFail();2470    }2471  });2472  /**2473   * @tc.number SUB_STORAGE_FileIO_RenameSync_07002474   * @tc.name fileio_test_rename_sync_0072475   * @tc.desc Function of API, dir not exist. The test dir is not exist.2476   */2477  it('fileio_test_rename_sync_007', 0, async function () {2478    let dpath = await nextFileName('fileio_test_rename_sync_007') + 'd'2479    let dpathTarget = await nextFileName('fileio_test_rename_sync_007-1') + 'd'2480    try {2481      fileio.renameSync(dpath, dpathTarget);2482      expect(null).assertFail();2483    } 2484    catch (e) {2485      console.log('fileio_test_rename_sync_007 has failed for ' + e);2486    }2487  });2488  /**2489   * @tc.number SUB_STORAGE_FileIO_RenameSync_08002490   * @tc.name fileio_test_rename_sync_0082491   * @tc.desc Function of API, fpathTarget not exist. fpathTarget not exist.2492   */2493  it('fileio_test_rename_sync_008', 0, async function () {2494    let dpath = await nextFileName('fileio_test_rename_sync_008') + 'd'2495    let dpathTarget = '/data/accounts/account_0/appdata/aaa/bbb/fileio_test_rename_sync_008-1d'2496    try {2497      expect(fileio.mkdirSync(dpath) !== null).assertTrue();2498      fileio.renameSync(dpath, dpathTarget);2499      expect(null).assertFail();2500    } 2501    catch (e) {2502      expect(fileio.rmdirSync(dpath) !== null).assertTrue();2503      console.log('fileio_test_rename_sync_008 has failed for ' + e);2504    }2505  });2506  /**2507   * @tc.number SUB_STORAGE_FileIO_RenameSync_09002508   * @tc.name fileio_test_rename_sync_0092509   * @tc.desc Function of API, fpath is same with fpathTarget. fpath is same with fpathTarget.2510   */2511  it('fileio_test_rename_sync_009', 0, async function () {2512    let dpath = await nextFileName('fileio_test_rename_sync_009') + 'd'2513    try {2514      expect(fileio.mkdirSync(dpath) !== null).assertTrue();2515      let result = fileio.renameSync(dpath, dpath);2516      expect(result === undefined).assertTrue();2517      expect(fileio.accessSync(dpath) !== null).assertTrue();2518      expect(fileio.rmdirSync(dpath) !== null).assertTrue();2519    } 2520    catch (e) {2521      console.log('fileio_test_rename_sync_009 has failed for ' + e);2522      expect(null).assertFail();2523    }2524  });2525  /**2526   * @tc.number SUB_STORAGE_FileIO_FchmodSync_00002527   * @tc.name fileio_test_fchmod_sync_0002528   * @tc.desc Function of API, fchmodSync(mode=0o660). The test file is exist.2529   */2530  it('fileio_test_fchmod_sync_000', 0, async function () {2531    let fpath = await nextFileName('fileio_test_fchmod_sync_000');2532    expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();2533    try {2534      let fd = fileio.openSync(fpath);2535      expect(fileio.fchmodSync(fd, 0o660) !== null).assertTrue();2536      expect((fileio.statSync(fpath).mode & 0o777) == 0o660).assertTrue();2537      expect(fileio.unlinkSync(fpath) !== null).assertTrue();2538    } 2539    catch (e) {2540      console.log('fileio_test_fchmod_sync_000 has failed for ' + e);2541      expect(null).assertFail();2542    }2543  });2544  /**2545   * @tc.number SUB_STORAGE_FileIO_FchmodSync_01002546   * @tc.name fileio_test_fchmod_sync_0012547   * @tc.desc Function of API, fchmodSync(mode=0o460). The test file is exist.2548   */2549  it('fileio_test_fchmod_sync_001', 0, async function () {2550    let fpath = await nextFileName('fileio_test_fchmod_sync_001');2551    expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();2552    try {2553      let fd = fileio.openSync(fpath);2554      expect(fileio.fchmodSync(fd, 0o460) !== null).assertTrue();2555      expect((fileio.statSync(fpath).mode & 0o777) == 0o460).assertTrue();2556      expect(fileio.unlinkSync(fpath) !== null).assertTrue();2557    } 2558    catch (e) {2559      console.log('fileio_test_fchmod_sync_001 has failed for ' + e);2560      expect(null).assertFail();2561    }2562  });2563  /**2564   * @tc.number SUB_STORAGE_FileIO_FchmodSync_02002565   * @tc.name fileio_test_fchmod_sync_0022566   * @tc.desc Function of API, fchmodSync(mode=0o260). The test file is exist.2567   */2568  it('fileio_test_fchmod_sync_002', 0, async function () {2569    let fpath = await nextFileName('fileio_test_fchmod_sync_002');2570    expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();2571    try {2572      let fd = fileio.openSync(fpath);2573      expect(fileio.fchmodSync(fd, 0o260) !== null).assertTrue();2574      expect((fileio.statSync(fpath).mode & 0o777) == 0o260).assertTrue();2575      expect(fileio.unlinkSync(fpath) !== null).assertTrue();2576    } 2577    catch (e) {2578      console.log('fileio_test_fchmod_sync_002 has failed for ' + e);2579      expect(null).assertFail();2580    }2581  });2582  /**2583   * @tc.number SUB_STORAGE_FileIO_FchmodSync_03002584   * @tc.name fileio_test_fchmod_sync_0032585   * @tc.desc Function of API, file not exist. The test file is not exist.2586   */2587  it('fileio_test_fchmod_sync_003', 0, async function () {2588    let fpath = await nextFileName('fileio_test_fchmod_sync_003');2589    try {2590      expect(fileio.fchmodSync(fpath, 0o660) !== null).assertTrue();2591      expect(null).assertFail();2592    } 2593    catch (e) {2594      console.log('fileio_test_fchmod_sync_003 has failed for ' + e);2595    }2596  });2597  /**2598   * @tc.number SUB_STORAGE_FileIO_FchmodSync_04002599   * @tc.name fileio_test_fchmod_sync_0042600   * @tc.desc Function of API, mode is invalid. The test file is exist.2601   */2602  it('fileio_test_fchmod_sync_004', 0, async function () {2603    let fpath = await nextFileName('fileio_test_fchmod_sync_004');2604    expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();2605    try {2606      let fd = fileio.openSync(fpath);2607      expect(fileio.fchmodSync(fd, 2222222222222) !== null).assertTrue();2608      expect(fileio.unlinkSync(fpath) !== null).assertTrue();2609    } 2610    catch (e) {2611      console.log('fileio_test_fchmod_sync_004 has failed for A' + e);2612      expect(null).assertFail();2613    }2614  });2615  /**2616   * @tc.number SUB_STORAGE_FileIO_FchmodSync_05002617   * @tc.name fileio_test_fchmod_sync_0052618   * @tc.desc Function of API, fpath = dir. The test dir is exist.2619   */2620  it('fileio_test_fchmod_sync_005', 0, async function () {2621    let dpath = await nextFileName('fileio_test_fchmod_sync_005') + 'd'2622    try {2623      expect(fileio.mkdirSync(dpath, 0o777) !== null).assertTrue();2624      let fd = fileio.openSync(dpath);2625      console.log(fd);2626      expect(fileio.fchmodSync(fd, 0o660) !== null).assertTrue();2627      expect(fileio.rmdirSync(dpath) !== null).assertTrue();2628    } 2629    catch (e) {2630      console.log('fileio_test_fchmod_sync_005 has failed for ' + e);2631      expect(null).assertFail();2632    }2633  });2634  /**2635   * @tc.number SUB_STORAGE_FileIO_FchmodSync_06002636   * @tc.name fileio_test_fchmod_sync_0062637   * @tc.desc Function of API, fpatch = dir. The test dir is not exist.2638   */2639  it('fileio_test_fchmod_sync_006', 0, async function () {2640    let dpath;2641    try {2642      fileio.fchmodSync(dpath, 0o660);2643      expect(null).assertFail();2644    } 2645    catch (e) {2646      console.log('fileio_test_fchmod_sync_006 has failed for ' + e);2647    }2648  });2649  /**2650   * @tc.number SUB_STORAGE_FileIO_FchmodSync_07002651   * @tc.name fileio_test_fchmod_sync_0072652   * @tc.desc Function of API, fchmodSync(mode=0o460). The test file is exist.2653   */2654  it('fileio_test_fchmod_sync_007', 0, async function () {2655    let fpath = await nextFileName('fileio_test_fchmod_sync_007');2656    expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();2657    try {2658      let fd = fileio.openSync(fpath);2659      expect(fileio.fchmodSync(fd, 0o700) !== null).assertTrue();2660      expect((fileio.statSync(fpath).mode & 0o777) == 0o700).assertTrue();2661      expect(fileio.unlinkSync(fpath) !== null).assertTrue();2662    } 2663    catch (e) {2664      console.log('fileio_test_fchmod_sync_007 has failed for ' + e);2665      expect(null).assertFail();2666    }2667  });2668  /**2669   * @tc.number SUB_STORAGE_FileIO_FchmodSync_08002670   * @tc.name fileio_test_fchmod_sync_0082671   * @tc.desc Function of API, fchmodSync(mode=0o400). The test file is exist.2672   */2673  it('fileio_test_fchmod_sync_008', 0, async function () {2674    let fpath = await nextFileName('fileio_test_fchmod_sync_008');2675    expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();2676    try {2677      let fd = fileio.openSync(fpath);2678      expect(fileio.fchmodSync(fd, 0o400) !== null).assertTrue();2679      expect((fileio.statSync(fpath).mode & 0o777) == 0o400).assertTrue();2680      expect(fileio.unlinkSync(fpath) !== null).assertTrue();2681    } 2682    catch (e) {2683      console.log('fileio_test_fchmod_sync_008 has failed for ' + e);2684      expect(null).assertFail();2685    }2686  });2687  /**2688   * @tc.number SUB_STORAGE_FileIO_FchmodSync_09002689   * @tc.name fileio_test_fchmod_sync_0092690   * @tc.desc Function of API, fchmodSync(mode=0o200). The test file is exist.2691   */2692  it('fileio_test_fchmod_sync_009', 0, async function () {2693    let fpath = await nextFileName('fileio_test_fchmod_sync_009');2694    expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();2695    try {2696      let fd = fileio.openSync(fpath);2697      expect(fileio.fchmodSync(fd, 0o200) !== null).assertTrue();2698      expect((fileio.statSync(fpath).mode & 0o777) == 0o200).assertTrue();2699      expect(fileio.unlinkSync(fpath) !== null).assertTrue();2700    } 2701    catch (e) {2702      console.log('fileio_test_fchmod_sync_009 has failed for ' + e);2703      expect(null).assertFail();2704    }2705  });2706  /**2707   * @tc.number SUB_STORAGE_FileIO_FchmodSync_01002708   * @tc.name fileio_test_fchmod_sync_0102709   * @tc.desc Function of API, fchmodSync(mode=0o100). The test file is exist.2710   */2711  it('fileio_test_fchmod_sync_010', 0, async function () {2712    let fpath = await nextFileName('fileio_test_fchmod_sync_010');2713    expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();2714    try {2715      let fd = fileio.openSync(fpath);2716      expect(fileio.fchmodSync(fd, 0o100) !== null).assertTrue();2717      expect((fileio.statSync(fpath).mode & 0o777) == 0o100).assertTrue();2718      expect(fileio.unlinkSync(fpath) !== null).assertTrue();2719    } 2720    catch (e) {2721      console.log('fileio_test_fchmod_sync_010 has failed for ' + e);2722      expect(null).assertFail();2723    }2724  });2725  /**2726   * @tc.number SUB_STORAGE_FileIO_FchmodSync_01102727   * @tc.name fileio_test_fchmod_sync_0112728   * @tc.desc Function of API, fchmodSync(mode=0o070). The test file is exist.2729   */2730  it('fileio_test_fchmod_sync_011', 0, async function () {2731    let fpath = await nextFileName('fileio_test_fchmod_sync_011');2732    expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();2733    try {2734      let fd = fileio.openSync(fpath);2735      expect(fileio.fchmodSync(fd, 0o070) !== null).assertTrue();2736      expect((fileio.statSync(fpath).mode & 0o777) == 0o070).assertTrue();2737      expect(fileio.unlinkSync(fpath) !== null).assertTrue();2738    } 2739    catch (e) {2740      console.log('fileio_test_fchmod_sync_011 has failed for ' + e);2741      expect(null).assertFail();2742    }2743  });2744  /**2745   * @tc.number SUB_STORAGE_FileIO_FchmodSync_01202746   * @tc.name fileio_test_fchmod_sync_0122747   * @tc.desc Function of API, fchmodSync(mode=0o040). The test file is exist.2748   */2749  it('fileio_test_fchmod_sync_012', 0, async function () {2750    let fpath = await nextFileName('fileio_test_fchmod_sync_012');2751    expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();2752    try {2753      let fd = fileio.openSync(fpath);2754      expect(fileio.fchmodSync(fd, 0o040) !== null).assertTrue();2755      expect((fileio.statSync(fpath).mode & 0o777) == 0o040).assertTrue();2756      expect(fileio.unlinkSync(fpath) !== null).assertTrue();2757    } 2758    catch (e) {2759      console.log('fileio_test_fchmod_sync_012 has failed for ' + e);2760      expect(null).assertFail();2761    }2762  });2763  /**2764   * @tc.number SUB_STORAGE_FileIO_FchmodSync_01302765   * @tc.name fileio_test_fchmod_sync_0132766   * @tc.desc Function of API, fchmodSync(mode=0o020). The test file is exist.2767   */2768  it('fileio_test_fchmod_sync_013', 0, async function () {2769    let fpath = await nextFileName('fileio_test_fchmod_sync_013');2770    expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();2771    try {2772      let fd = fileio.openSync(fpath);2773      expect(fileio.fchmodSync(fd, 0o020) !== null).assertTrue();2774      expect((fileio.statSync(fpath).mode & 0o777) == 0o020).assertTrue();2775      expect(fileio.unlinkSync(fpath) !== null).assertTrue();2776    } 2777    catch (e) {2778      console.log('fileio_test_fchmod_sync_013 has failed for ' + e);2779      expect(null).assertFail();2780    }2781  });2782  /**2783   * @tc.number SUB_STORAGE_FileIO_FchmodSync_01402784   * @tc.name fileio_test_fchmod_sync_0142785   * @tc.desc Function of API, fchmodSync(mode=0o010). The test file is exist.2786   */2787  it('fileio_test_fchmod_sync_014', 0, async function () {2788    let fpath = await nextFileName('fileio_test_fchmod_sync_014');2789    expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();2790    try {2791      let fd = fileio.openSync(fpath);2792      expect(fileio.fchmodSync(fd, 0o010) !== null).assertTrue();2793      expect((fileio.statSync(fpath).mode & 0o777) == 0o010).assertTrue();2794      expect(fileio.unlinkSync(fpath) !== null).assertTrue();2795    } 2796    catch (e) {2797      console.log('fileio_test_fchmod_sync_014 has failed for ' + e);2798      expect(null).assertFail();2799    }2800  });2801  /**2802   * @tc.number SUB_STORAGE_FileIO_FchmodSync_01502803   * @tc.name fileio_test_fchmod_sync_0152804   * @tc.desc Function of API, fchmodSync(mode=0o007). The test file is exist.2805   */2806  it('fileio_test_fchmod_sync_015', 0, async function () {2807    let fpath = await nextFileName('fileio_test_fchmod_sync_015');2808    expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();2809    try {2810      let fd = fileio.openSync(fpath);2811      expect(fileio.fchmodSync(fd, 0o007) !== null).assertTrue();2812      expect((fileio.statSync(fpath).mode & 0o777) == 0o007).assertTrue();2813      expect(fileio.unlinkSync(fpath) !== null).assertTrue();2814    } 2815    catch (e) {2816      console.log('fileio_test_fchmod_sync_015 has failed for ' + e);2817      expect(null).assertFail();2818    }2819  });2820  /**2821   * @tc.number SUB_STORAGE_FileIO_FchmodSync_01602822   * @tc.name fileio_test_fchmod_sync_0162823   * @tc.desc Function of API, fchmodSync(mode=0o004). The test file is exist.2824   */2825  it('fileio_test_fchmod_sync_016', 0, async function () {2826    let fpath = await nextFileName('fileio_test_fchmod_sync_016');2827    expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();2828    try {2829      let fd = fileio.openSync(fpath);2830      expect(fileio.fchmodSync(fd, 0o004) !== null).assertTrue();2831      expect((fileio.statSync(fpath).mode & 0o777) == 0o004).assertTrue();2832      expect(fileio.unlinkSync(fpath) !== null).assertTrue();2833    } 2834    catch (e) {2835      console.log('fileio_test_fchmod_sync_016 has failed for ' + e);2836      expect(null).assertFail();2837    }2838  });2839  /**2840   * @tc.number SUB_STORAGE_FileIO_FchmodSync_01702841   * @tc.name fileio_test_fchmod_sync_0172842   * @tc.desc Function of API, fchmodSync(mode=0o002). The test file is exist.2843   */2844  it('fileio_test_fchmod_sync_017', 0, async function () {2845    let fpath = await nextFileName('fileio_test_fchmod_sync_017');2846    expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();2847    try {2848      let fd = fileio.openSync(fpath);2849      expect(fileio.fchmodSync(fd, 0o002) !== null).assertTrue();2850      expect((fileio.statSync(fpath).mode & 0o777) == 0o002).assertTrue();2851      expect(fileio.unlinkSync(fpath) !== null).assertTrue();2852    } 2853    catch (e) {2854      console.log('fileio_test_fchmod_sync_017 has failed for ' + e);2855      expect(null).assertFail();2856    }2857  });2858  /**2859   * @tc.number SUB_STORAGE_FileIO_FchmodSync_01802860   * @tc.name fileio_test_fchmod_sync_0182861   * @tc.desc Function of API, fchmodSync(mode=0o001). The test file is exist.2862   */2863  it('fileio_test_fchmod_sync_018', 0, async function () {2864    let fpath = await nextFileName('fileio_test_fchmod_sync_018');2865    expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();2866    try {2867      let fd = fileio.openSync(fpath);2868      expect(fileio.fchmodSync(fd, 0o001) !== null).assertTrue();2869      expect((fileio.statSync(fpath).mode & 0o777) == 0o001).assertTrue();2870      expect(fileio.unlinkSync(fpath) !== null).assertTrue();2871    } 2872    catch (e) {2873      console.log('fileio_test_fchmod_sync_018 has failed for ' + e);2874      expect(null).assertFail();2875    }2876  });2877  /**2878   * @tc.number SUB_STORAGE_FileIO_FtruncateSync_00002879   * @tc.name fileio_test_ftruncate_sync_0002880   * @tc.desc Function of API, ftruncateSync. The test file is exist.2881   */2882  it('fileio_test_ftruncate_sync_000', 0, async function () {2883    let fpath = await nextFileName('fileio_test_ftruncate_sync_000');2884    expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();2885    try {2886      let fd = fileio.openSync(fpath, 0o2);2887      expect(fileio.ftruncateSync(fd, 10) !== null).assertTrue();2888      expect(fileio.statSync(fpath).size == 10).assertTrue();2889      expect(fileio.unlinkSync(fpath) !== null).assertTrue();2890    } 2891    catch (e) {2892      console.log('fileio_test_ftruncate_sync_000 has failed for ' + e);2893      expect(null).assertFail();2894    }2895  });2896  /**2897   * @tc.number SUB_STORAGE_FileIO_FtruncateSync_01002898   * @tc.name fileio_test_ftruncate_sync_0012899   * @tc.desc Function of API, len not for value. The test file is exist.2900   */2901  it('fileio_test_ftruncate_sync_001', 0, async function () {2902    let fpath = await nextFileName('fileio_test_ftruncate_sync_001');2903    expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();2904    try {2905      let fd = fileio.openSync(fpath, 0o2);2906      expect(fileio.ftruncateSync(fd) !== null).assertTrue();2907      expect(fileio.closeSync(fd) !== null).assertTrue();2908      expect(fileio.unlinkSync(fpath) !== null).assertTrue();2909    } 2910    catch (e) {2911      console.log('fileio_test_ftruncate_sync_001 has failed for ' + e);2912      expect(null).assertFail();2913    }2914  });2915  /**2916   * @tc.number SUB_STORAGE_FileIO_FtruncateSync_02002917   * @tc.name fileio_test_ftruncate_sync_0022918   * @tc.desc Function of API, invalid parameter. The test file is not exist.2919   */2920  it('fileio_test_ftruncate_sync_002', 0, async function () {2921    try {2922      fileio.ftruncateSync(1);2923      expect(null).assertFail();2924    } 2925    catch (e) {2926      console.log('fileio_test_ftruncate_sync_002 has failed for ' + e);2927    }2928  });2929  /**2930   * @tc.number SUB_STORAGE_FileIO_FtruncateSync_03002931   * @tc.name fileio_test_ftruncate_sync_0032932   * @tc.desc Function of API, invalid parameter. The test file is not exist.2933   */2934  it('fileio_test_ftruncate_sync_003', 0, async function () {2935    try {2936      fileio.ftruncateSync(-1);2937      expect(null).assertFail();2938    } 2939    catch (e) {2940      console.log('fileio_test_ftruncate_sync_003 has failed for ' + e);2941    }2942  });2943  /**2944   * @tc.number SUB_STORAGE_FileIO_FtruncateSync_04002945   * @tc.name fileio_test_ftruncate_sync_0042946   * @tc.desc Function of API, Parameter exception(len = -1).2947   */2948  it('fileio_test_ftruncate_sync_004', 0, async function () {2949    let fpath = await nextFileName('fileio_test_ftruncate_sync_004');2950    expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();2951    try {2952      let fd = fileio.openSync(fpath, 0o2);2953      expect(fileio.ftruncateSync(fd, -1) !== null).assertTrue();2954      expect(null).assertFail();2955    } 2956    catch (e) {2957      console.log('fileio_test_ftruncate_sync_004 has failed for ' + e);2958    }2959  });2960  /**2961   * @tc.number SUB_STORAGE_FileIO_FsyncSync_00002962   * @tc.name fileio_test_fsync_sync_0002963   * @tc.desc Function of API, fsyneSync.2964   */2965  it('fileio_test_fsync_sync_000', 0, async function () {2966    let fpath = await nextFileName('fileio_test_fsync_sync_000');2967    expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();2968    try {2969      let fd = fileio.openSync(fpath, 0o2);2970      expect(fileio.fsyncSync(fd) !== null).assertTrue();2971      expect(fileio.closeSync(fd) !== null).assertTrue();2972      expect(fileio.unlinkSync(fpath) !== null).assertTrue();2973    } 2974    catch (e) {2975      console.log('fileio_test_fsync_sync_000 has failed for ' + e);2976      expect(null).assertFail();2977    }2978  });2979  /**2980   * @tc.number SUB_STORAGE_FileIO_FsyncSync_01002981   * @tc.name fileio_test_fsync_sync_0012982   * @tc.desc Function of API, no value of parameter.2983   */2984  it('fileio_test_fsync_sync_001', 0, async function () {2985    try {2986      fileio.fsyncSync(1);2987      expect(null).assertFail();2988    } 2989    catch (e) {2990      console.log('fileio_test_fsync_sync_001 has failed for ' + e);2991    }2992  });2993  /**2994   * @tc.number SUB_STORAGE_FileIO_FsyncSync_02002995   * @tc.name fileio_test_fsync_sync_0022996   * @tc.desc Function of API, invalid parameter.2997   */2998  it('fileio_test_fsync_sync_002', 0, async function () {2999    try {3000      fileio.fsyncSync(-1);3001      expect(null).assertFail();3002    } 3003    catch (e) {3004      console.log('fileio_test_fsync_sync_002 has failed for ' + e);3005    }3006  });3007  /**3008   * @tc.number SUB_STORAGE_FileIO_MkdirSync_RmdirSync_00003009   * @tc.name fileio_test_mkdir_sync_rmdir_sync_0003010   * @tc.desc Sync to mkdir and rmdir.3011   */3012  it('fileio_test_mkdir_sync_rmdir_sync_000', 0, async function () {3013    let dpath = await nextFileName('fileio_test_fsync_sync_000') + 'd'3014    try {3015      expect(fileio.mkdirSync(dpath) !== null).assertTrue();3016      expect(fileio.rmdirSync(dpath) !== null).assertTrue();3017    } 3018    catch (e) {3019      console.log('fileio_test_mkdir_sync_rmdir_sync_000 has failed for ' + e);3020      expect(null).assertFail();3021    }3022  });3023  /**3024   * @tc.number SUB_STORAGE_FileIO_MkdirSync_RmdirSync_01003025   * @tc.name fileio_test_mkdir_sync_rmdir_sync_0013026   * @tc.desc Sync to mkdir and rmdir. mkdirSync(mode=0o660).3027   */3028  it('fileio_test_mkdir_sync_rmdir_sync_001', 0, async function () {3029    let dpath = await nextFileName('fileio_test_mkdir_sync_rmdir_sync_001') + 'd'3030    try {3031      expect(fileio.mkdirSync(dpath, 0o660) !== null).assertTrue();3032      expect(fileio.rmdirSync(dpath) !== null).assertTrue();3033    } 3034    catch (e) {3035      console.log('fileio_test_mkdir_sync_rmdir_sync_001 has failed for ' + e);3036      expect(null).assertFail();3037    }3038  });3039  /**3040   * @tc.number SUB_STORAGE_FileIO_MkdirSync_RmdirSync_02003041   * @tc.name fileio_test_mkdir_sync_rmdir_sync_0023042   * @tc.desc Sync to mkdir and rmdir. mkdirSync(mode=0o460).3043   */3044  it('fileio_test_mkdir_sync_rmdir_sync_002', 0, async function () {3045    let dpath = await nextFileName('fileio_test_mkdir_sync_rmdir_sync_002') + 'd'3046    try {3047      expect(fileio.mkdirSync(dpath, 0o460) !== null).assertTrue();3048      expect(fileio.rmdirSync(dpath) !== null).assertTrue();3049    } 3050    catch (e) {3051      console.log('fileio_test_mkdir_sync_rmdir_sync_002 has failed for ' + e);3052      expect(null).assertFail();3053    }3054  });3055  /**3056   * @tc.number SUB_STORAGE_FileIO_MkdirSync_RmdirSync_03003057   * @tc.name fileio_test_mkdir_sync_rmdir_sync_0033058   * @tc.desc Sync to mkdir and rmdir. mkdirSync(mode=0o260).3059   */3060  it('fileio_test_mkdir_sync_rmdir_sync_003', 0, async function () {3061    let dpath = await nextFileName('fileio_test_mkdir_sync_rmdir_sync_003') + 'd'3062    try {3063      expect(fileio.mkdirSync(dpath, 0o260) !== null).assertTrue();3064      expect(fileio.rmdirSync(dpath) !== null).assertTrue();3065    } 3066    catch (e) {3067      console.log('fileio_test_mkdir_sync_rmdir_sync_003 has failed for ' + e);3068      expect(null).assertFail();3069    }3070  });3071  /**3072   * @tc.number SUB_STORAGE_FileIO_MkdirSync_RmdirSync_04003073   * @tc.name fileio_test_mkdir_sync_rmdir_sync_0043074   * @tc.desc Function of API, invalid parameter. The test file is not exist.3075   */3076  it('fileio_test_mkdir_sync_rmdir_sync_004', 0, async function () {3077    try {3078      expect(fileio.mkdirSync(1) !== null);3079      expect(null).assertFail();3080    } 3081    catch (e) {3082      console.log('fileio_test_fsync_sync_004 has failed for ' + e);3083    }3084  });3085  /**3086   * @tc.number SUB_STORAGE_FileIO_MkdirSync_RmdirSync_05003087   * @tc.name fileio_test_mkdir_sync_rmdir_sync_0053088   * @tc.desc Function of API, invalid parameter. The test file is not exist.3089   */3090  it('fileio_test_mkdir_sync_rmdir_sync_005', 0, async function () {3091    try {3092      expect(fileio.mkdirSync('/', 1) !== null).assertTrue();3093      expect(null).assertFail();3094    } 3095    catch (e) {3096      console.log('fileio_test_fsync_sync_005 has failed for ' + e);3097    }3098  });3099  /**3100   * @tc.number SUB_STORAGE_FileIO_MkdirSync_RmdirSync_06003101   * @tc.name fileio_test_mkdir_sync_rmdir_sync_0063102   * @tc.desc Sync to mkdir and rmdir. mkdirSync(mode=0o700).3103   */3104  it('fileio_test_mkdir_sync_rmdir_sync_006', 0, async function () {3105    let dpath = await nextFileName('fileio_test_mkdir_sync_rmdir_sync_006') + 'd'3106    try {3107      expect(fileio.mkdirSync(dpath, 0o700) !== null).assertTrue();3108      expect(fileio.rmdirSync(dpath) !== null).assertTrue();3109    } 3110    catch (e) {3111      console.log('fileio_test_mkdir_sync_rmdir_sync_006 has failed for ' + e);3112      expect(null).assertFail();3113    }3114  });3115  /**3116   * @tc.number SUB_STORAGE_FileIO_MkdirSync_RmdirSync_07003117   * @tc.name fileio_test_mkdir_sync_rmdir_sync_0073118   * @tc.desc Sync to mkdir and rmdir. mkdirSync(mode=0o400).3119   */3120  it('fileio_test_mkdir_sync_rmdir_sync_007', 0, async function () {3121    let dpath = await nextFileName('fileio_test_mkdir_sync_rmdir_sync_007') + 'd'3122    try {3123      expect(fileio.mkdirSync(dpath, 0o400) !== null).assertTrue();3124      expect(fileio.rmdirSync(dpath) !== null).assertTrue();3125    } 3126    catch (e) {3127      console.log('fileio_test_mkdir_sync_rmdir_sync_007 has failed for ' + e);3128      expect(null).assertFail();3129    }3130  });3131  /**3132   * @tc.number SUB_STORAGE_FileIO_MkdirSync_RmdirSync_08003133   * @tc.name fileio_test_mkdir_sync_rmdir_sync_0083134   * @tc.desc Sync to mkdir and rmdir. mkdirSync(mode=0o200).3135   */3136  it('fileio_test_mkdir_sync_rmdir_sync_008', 0, async function () {3137    let dpath = await nextFileName('fileio_test_mkdir_sync_rmdir_sync_008') + 'd'3138    try {3139      expect(fileio.mkdirSync(dpath, 0o200) !== null).assertTrue();3140      expect(fileio.rmdirSync(dpath) !== null).assertTrue();3141    } 3142    catch (e) {3143      console.log('fileio_test_mkdir_sync_rmdir_sync_008 has failed for ' + e);3144      expect(null).assertFail();3145    }3146  });3147  /**3148   * @tc.number SUB_STORAGE_FileIO_MkdirSync_RmdirSync_09003149   * @tc.name fileio_test_mkdir_sync_rmdir_sync_0093150   * @tc.desc Sync to mkdir and rmdir. mkdirSync(mode=0o100).3151   */3152  it('fileio_test_mkdir_sync_rmdir_sync_009', 0, async function () {3153    let dpath = await nextFileName('fileio_test_mkdir_sync_rmdir_sync_009') + 'd'3154    try {3155      expect(fileio.mkdirSync(dpath, 0o100) !== null).assertTrue();3156      expect(fileio.rmdirSync(dpath) !== null).assertTrue();3157    } 3158    catch (e) {3159      console.log('fileio_test_mkdir_sync_rmdir_sync_009 has failed for ' + e);3160      expect(null).assertFail();3161    }3162  });3163  /**3164   * @tc.number SUB_STORAGE_FileIO_MkdirSync_RmdirSync_10003165   * @tc.name fileio_test_mkdir_sync_rmdir_sync_0103166   * @tc.desc Sync to mkdir and rmdir. mkdirSync(mode=0o070).3167   */3168  it('fileio_test_mkdir_sync_rmdir_sync_010', 0, async function () {3169    let dpath = await nextFileName('fileio_test_mkdir_sync_rmdir_sync_010') + 'd';3170    try {3171      expect(fileio.mkdirSync(dpath, 0o070) !== null).assertTrue();3172      expect(fileio.rmdirSync(dpath) !== null).assertTrue();3173    } 3174    catch (e) {3175      console.log('fileio_test_mkdir_sync_rmdir_sync_010 has failed for ' + e);3176      expect(null).assertFail();3177    }3178  });3179  /**3180   * @tc.number SUB_STORAGE_FileIO_MkdirSync_RmdirSync_11003181   * @tc.name fileio_test_mkdir_sync_rmdir_sync_0113182   * @tc.desc Sync to mkdir and rmdir. mkdirSync(mode=0o040).3183   */3184  it('fileio_test_mkdir_sync_rmdir_sync_011', 0, async function () {3185    let dpath = await nextFileName('fileio_test_mkdir_sync_rmdir_sync_011') + 'd';3186    try {3187      expect(fileio.mkdirSync(dpath, 0o040) !== null).assertTrue();3188      expect(fileio.rmdirSync(dpath) !== null).assertTrue();3189    } 3190    catch (e) {3191      console.log('fileio_test_mkdir_sync_rmdir_sync_011 has failed for ' + e);3192      expect(null).assertFail();3193    }3194  });3195  /**3196   * @tc.number SUB_STORAGE_FileIO_MkdirSync_RmdirSync_12003197   * @tc.name fileio_test_mkdir_sync_rmdir_sync_0123198   * @tc.desc Sync to mkdir and rmdir. mkdirSync(mode=0o020).3199   */3200  it('fileio_test_mkdir_sync_rmdir_sync_012', 0, async function () {3201    let dpath = await nextFileName('fileio_test_mkdir_sync_rmdir_sync_012') + 'd';3202    try {3203      expect(fileio.mkdirSync(dpath, 0o020) !== null).assertTrue();3204      expect(fileio.rmdirSync(dpath) !== null).assertTrue();3205    } 3206    catch (e) {3207      console.log('fileio_test_mkdir_sync_rmdir_sync_012 has failed for ' + e);3208      expect(null).assertFail();3209    }3210  });3211  /**3212   * @tc.number SUB_STORAGE_FileIO_MkdirSync_RmdirSync_13003213   * @tc.name fileio_test_mkdir_sync_rmdir_sync_0133214   * @tc.desc Sync to mkdir and rmdir. mkdirSync(mode=0o010).3215   */3216  it('fileio_test_mkdir_sync_rmdir_sync_013', 0, async function () {3217    let dpath = await nextFileName('fileio_test_mkdir_sync_rmdir_sync_013') + 'd';3218    try {3219      expect(fileio.mkdirSync(dpath, 0o010) !== null).assertTrue();3220      expect(fileio.rmdirSync(dpath) !== null).assertTrue();3221    } 3222    catch (e) {3223      console.log('fileio_test_mkdir_sync_rmdir_sync_013 has failed for ' + e);3224      expect(null).assertFail();3225    }3226  });3227  /**3228   * @tc.number SUB_STORAGE_FileIO_MkdirSync_RmdirSync_14003229   * @tc.name fileio_test_mkdir_sync_rmdir_sync_0143230   * @tc.desc Sync to mkdir and rmdir. mkdirSync(mode=0o007).3231   */3232  it('fileio_test_mkdir_sync_rmdir_sync_014', 0, async function () {3233    let dpath = await nextFileName('fileio_test_mkdir_sync_rmdir_sync_014') + 'd';3234    try {3235      expect(fileio.mkdirSync(dpath, 0o007) !== null).assertTrue();3236      expect(fileio.rmdirSync(dpath) !== null).assertTrue();3237    } 3238    catch (e) {3239      console.log('fileio_test_mkdir_sync_rmdir_sync_014 has failed for ' + e);3240      expect(null).assertFail();3241    }3242  });3243  /**3244   * @tc.number SUB_STORAGE_FileIO_MkdirSync_RmdirSync_15003245   * @tc.name fileio_test_mkdir_sync_rmdir_sync_0153246   * @tc.desc Sync to mkdir and rmdir. mkdirSync(mode=0o004).3247   */3248  it('fileio_test_mkdir_sync_rmdir_sync_015', 0, async function () {3249    let dpath = await nextFileName('fileio_test_mkdir_sync_rmdir_sync_015') + 'd';3250    try {3251      expect(fileio.mkdirSync(dpath, 0o004) !== null).assertTrue();3252      expect(fileio.rmdirSync(dpath) !== null).assertTrue();3253    } 3254    catch (e) {3255      console.log('fileio_test_mkdir_sync_rmdir_sync_015 has failed for ' + e);3256      expect(null).assertFail();3257    }3258  });3259  /**3260   * @tc.number SUB_STORAGE_FileIO_MkdirSync_RmdirSync_16003261   * @tc.name fileio_test_mkdir_sync_rmdir_sync_0163262   * @tc.desc Sync to mkdir and rmdir. mkdirSync(mode=0o002).3263   */3264  it('fileio_test_mkdir_sync_rmdir_sync_016', 0, async function () {3265    let dpath = await nextFileName('fileio_test_mkdir_sync_rmdir_sync_016') + 'd';3266    try {3267      expect(fileio.mkdirSync(dpath, 0o002) !== null).assertTrue();3268      expect(fileio.rmdirSync(dpath) !== null).assertTrue();3269    } 3270    catch (e) {3271      console.log('fileio_test_mkdir_sync_rmdir_sync_016 has failed for ' + e);3272      expect(null).assertFail();3273    }3274  });3275  /**3276   * @tc.number SUB_STORAGE_FileIO_MkdirSync_RmdirSync_17003277   * @tc.name fileio_test_mkdir_sync_rmdir_sync_0173278   * @tc.desc Sync to mkdir and rmdir. mkdirSync(mode=0o001).3279   */3280  it('fileio_test_mkdir_sync_rmdir_sync_017', 0, async function () {3281    let dpath = await nextFileName('fileio_test_mkdir_sync_rmdir_sync_017') + 'd';3282    try {3283      expect(fileio.mkdirSync(dpath, 0o001) !== null).assertTrue();3284      expect(fileio.rmdirSync(dpath) !== null).assertTrue();3285    } 3286    catch (e) {3287      console.log('fileio_test_mkdir_sync_rmdir_sync_017 has failed for ' + e);3288      expect(null).assertFail();3289    }3290  });3291  /**3292   * @tc.number SUB_STORAGE_FileIO_FstatSync_00003293   * @tc.name fileio_test_fstat_sync_0003294   * @tc.desc Function of API, fstatSync. The test file is exist.3295   */3296  it('fileio_test_fstat_sync_000', 0, async function () {3297    let fpath = await nextFileName('fileio_test_fstat_sync_000');3298    expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();3299    try {3300      let fd = fileio.openSync(fpath, 0o2);3301      let stat = fileio.fstatSync(fd);3302      expect(stat !== null).assertTrue();3303      expect(fileio.closeSync(fd) !== null).assertTrue();3304      expect(fileio.unlinkSync(fpath) !== null).assertTrue();3305    } 3306    catch (e) {3307      console.log('fileio_test_fstat_sync_000 has failed for ' + e);3308      expect(null).assertFail();3309    }3310  });3311  /**3312   * @tc.number SUB_STORAGE_FileIO_FstatSync_01003313   * @tc.name fileio_test_fstat_sync_0013314   * @tc.desc Function of API, fstatSync, fd = -1. The test file is not exist.3315   */3316  it('fileio_test_fstat_sync_001', 0, async function () {3317    try {3318      expect(fileio.fstatSync(1) !== null).assertTrue();3319      expect(null).assertFail();3320    } 3321    catch (e) {3322      console.log('fileio_test_fstat_sync_001 has failed for ' + e);3323    }3324  });3325  /**3326   * @tc.number SUB_STORAGE_FileIO_FstatSync_02003327   * @tc.name fileio_test_fstat_sync_0023328   * @tc.desc Function of API, fstatSync, fd = 1. The test file is not exist.3329   */3330  it('fileio_test_fstat_sync_002', 0, async function () {3331    try {3332      expect(fileio.fstatSync(1) !== null).assertTrue();3333      expect(null).assertFail();3334    } 3335    catch (e) {3336      console.log('fileio_test_fstat_sync_002 has failed for ' + e);3337    }3338  });3339  /**3340   * @tc.number SUB_STORAGE_FileIO_FstatSync_03003341   * @tc.name fileio_test_fstat_sync_0033342   * @tc.desc Function of API, fstatSync, vaild fd. The test file is exist.3343   */3344  it('fileio_test_fstat_sync_003', 0, async function () {3345    let dpath = await nextFileName('fileio_test_fstat_sync_003') + 'd'3346    try {3347      expect(fileio.mkdirSync(dpath) !== null).assertTrue();3348      let fd = fileio.openSync(dpath);3349      expect(fd !== null).assertTrue();3350      let stat = fileio.fstatSync(fd);3351      expect(stat !== null).assertTrue();3352      expect(fileio.closeSync(fd) !== null).assertTrue();3353      expect(fileio.rmdirSync(dpath) !== null).assertTrue();3354    } 3355    catch (e) {3356      console.log('fileio_test_fstat_sync_003 has failed for ' + e);3357      expect(null).assertFail();3358    }3359  });3360  /**3361   * @tc.number SUB_STORAGE_FileIO_ChownSync_00003362   * @tc.name fileio_test_chown_sync_0003363   * @tc.desc Function of API, chownSync. The test file is exist.3364   */3365  it('fileio_test_chown_sync_000', 0, async function () {3366    let fpath = await nextFileName('fileio_test_chown_sync_000');3367    expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();3368    let stat = fileio.statSync(fpath);3369    let UID = stat.uid3370    let GID = stat.gid3371    try {3372      expect(fileio.chownSync(fpath, UID, GID) !== null).assertTrue();3373      expect(fileio.unlinkSync(fpath) !== null).assertTrue();3374    } 3375    catch (e) {3376      console.log('fileio_test_chown_sync_000 has failed for ' + e);3377      expect(null).assertFail();3378    }3379  });3380  /**3381   * @tc.number SUB_STORAGE_FileIO_ChownSync_01003382   * @tc.name fileio_test_chown_sync_0013383   * @tc.desc Function of API, chownSync. The test file is not exist.3384   */3385  it('fileio_test_chown_sync_001', 0, async function () {3386    let fpath = await nextFileName('fileio_test_chown_sync_001');3387    let fpathc = await nextFileName('fileio_test_chown_sync_001_1');3388    expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();3389    let stat = fileio.statSync(fpath);3390    let UID = stat.uid3391    let GID = stat.gid3392    try {3393      expect(fileio.chownSync(fpathc, UID, GID));3394      expect(null).assertFail();3395    } 3396    catch (e) {3397      console.log('fileio_test_chown_sync_001 has failed for ' + e);3398      expect(fileio.unlinkSync(fpath) !== null).assertTrue();3399    }3400  });3401  /**3402   * @tc.number SUB_STORAGE_FileIO_ChownSync_02003403   * @tc.name fileio_test_chown_sync_0023404   * @tc.desc Function of API, invalid fd. The test file is not exist.3405   */3406  it('fileio_test_chown_sync_002', 0, async function () {3407    let fpath = await nextFileName('fileio_test_chown_sync_002');3408    expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();3409    try {3410      expect(fileio.chownSync(fpath, 0, 0));3411      expect(null).assertFail();3412    } 3413    catch (e) {3414      console.log('fileio_test_chown_sync_002 has failed for ' + e);3415      expect(fileio.unlinkSync(fpath) !== null).assertTrue();3416    }3417  });3418  /**3419   * @tc.number SUB_STORAGE_FileIO_FchownSync_00003420   * @tc.name fileio_test_fchown_sync_0003421   * @tc.desc Function of API, fchownSync. The test file is exist.3422   */3423  it('fileio_test_fchown_sync_000', 0, async function () {3424    let fpath = await nextFileName('fileio_test_fchown_sync_000');3425    expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();3426    let stat = fileio.statSync(fpath);3427    let UID = stat.uid3428    let GID = stat.gid3429    try {3430      let fd = fileio.openSync(fpath);3431      expect(fileio.fchownSync(fd, UID, GID) !== null).assertTrue();3432      expect(fileio.closeSync(fd) !== null).assertTrue();3433      expect(fileio.unlinkSync(fpath) !== null).assertTrue();3434    } 3435    catch (e) {3436      console.log('fileio_test_fchown_sync_000 has failed for ' + e);3437      expect(null).assertFail();3438    }3439  });3440  /**3441   * @tc.number SUB_STORAGE_FileIO_FchownSync_01003442   * @tc.name fileio_test_fchown_sync_0013443   * @tc.desc Function of API, fchownSync. The test file is not exist.3444   */3445  it('fileio_test_fchown_sync_001', 0, async function () {3446    let fpath = await nextFileName('fileio_test_fchown_sync_001');3447    expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();3448    let stat = fileio.statSync(fpath);3449    let UID = stat.uid3450    let GID = stat.gid3451    try {3452      expect(fileio.fchownSync(-1, UID, GID));3453      expect(null).assertFail();3454    } 3455    catch (e) {3456      expect(fileio.unlinkSync(fpath) !== null).assertTrue();3457      console.log('fileio_test_fchown_sync_001 has failed for ' + e);3458    }3459  });3460  /**3461   * @tc.number SUB_STORAGE_FileIO_FchownSync_02003462   * @tc.name fileio_test_fchown_sync_0023463   * @tc.desc Function of API, fchownSync, wrong owner. The test file is exist.3464   */3465  it('fileio_test_fchown_sync_002', 0, async function () {3466    let fpath = await nextFileName('fileio_test_fchown_sync_002');3467    expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();3468    let stat = fileio.statSync(fpath);3469    let fd;3470    let GID = stat.gid3471    try {3472      let fd = fileio.openSync(fpath);3473      fileio.fchownSync(fd, cc, GID);3474      expect(null).assertFail();3475    } 3476    catch (e) {3477      expect(fileio.unlinkSync(fpath) !== null).assertTrue();3478      console.log('fileio_test_fchown_sync_002 has failed for ' + e);3479    }3480  });3481  /**3482   * @tc.number SUB_STORAGE_FileIO_FchownSync_03003483   * @tc.name fileio_test_fchown_sync_0033484   * @tc.desc Function of API, fchownSync, wrong group. The test file is exist.3485   */3486  it('fileio_test_fchown_sync_003', 0, async function () {3487    let fpath = await nextFileName('fileio_test_fchown_sync_003');3488    expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();3489    let stat = fileio.statSync(fpath);3490    let UID = stat.uid;3491    let fd;3492    try {3493      fd = fileio.openSync(fpath, 0o2);3494      expect(fileio.fchownSync(fd, UID, 0));3495      expect(null).assertFail();3496    } 3497    catch (e) {3498      expect(fileio.closeSync(fd) !== null).assertTrue();3499      expect(fileio.unlinkSync(fpath) !== null).assertTrue();3500      console.log('fileio_test_fchown_sync_003 has failed for ' + e);3501    }3502  });3503  /**3504   * @tc.number SUB_STORAGE_FileIO_FchownSync_04003505   * @tc.name fileio_test_fchown_sync_0043506   * @tc.desc Function of API, fchownSync, no value of fd. The test file is exist.3507   */3508  it('fileio_test_fchown_sync_004', 0, async function () {3509    let fpath = await nextFileName('fileio_test_fchown_sync_004');3510    expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();3511    let stat = fileio.statSync(fpath);3512    let UID = stat.uid3513    let GID = stat.gid3514    let fd = null3515    try {3516      expect(fileio.fchownSync(fd, UID, GID));3517      expect(null).assertFail();3518    } 3519    catch (e) {3520      expect(fileio.unlinkSync(fpath) !== null).assertTrue();3521      console.log('fileio_test_fchown_sync_004 has failed for ' + e);3522    }3523  });3524  /**3525   * @tc.number SUB_STORAGE_FileIO_FchownSync_05003526   * @tc.name fileio_test_fchown_sync_0053527   * @tc.desc Function of API, fchownSync, no value of owner. The test file is exist.3528   */3529  it('fileio_test_fchown_sync_005', 0, async function () {3530    let fpath = await nextFileName('fileio_test_fchown_sync_005');3531    expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();3532    let stat = fileio.statSync(fpath);3533    let UID = null3534    let GID = stat.gid3535    let fd;3536    try {3537      fd = fileio.openSync(fpath);3538      expect(fileio.fchownSync(fd, UID, GID));3539      expect(null).assertFail();3540    } 3541    catch (e) {3542      expect(fileio.closeSync(fd) !== null).assertTrue();3543      expect(fileio.unlinkSync(fpath) !== null).assertTrue();3544      console.log('fileio_test_fchown_sync_005 has failed for ' + e);3545    }3546  });3547  /**3548   * @tc.number SUB_STORAGE_FileIO_FchownSync_06003549   * @tc.name fileio_test_fchown_sync_0063550   * @tc.desc Function of API, fchownSync, no value of group. The test file is exist.3551   */3552  it('fileio_test_fchown_sync_006', 0, async function () {3553    let fpath = await nextFileName('fileio_test_fchown_sync_006');3554    expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();3555    let stat = fileio.statSync(fpath);3556    let UID = stat.uid;3557    let fd;3558    try {3559      fd = fileio.openSync(fpath);3560      fileio.fchownSync(fd, UID, 0);3561      expect(null).assertFail();3562    } 3563    catch (e) {3564      expect(fileio.closeSync(fd) !== null).assertTrue();3565      expect(fileio.unlinkSync(fpath) !== null).assertTrue();3566      console.log('fileio_test_fchown_sync_006 has failed for ' + e);3567    }3568  });3569  /**3570   * @tc.number SUB_STORAGE_FileIO_FchownSync_07003571   * @tc.name fileio_test_fchown_sync_0073572   * @tc.desc Function of API, fchownSync, no value of GID,UID. The test file is exist.3573   */3574  it('fileio_test_fchown_sync_007', 0, async function () {3575    let fpath = await nextFileName('fileio_test_fchown_sync_007');3576    expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();3577    let fd;3578    try {3579      fd = fileio.openSync(fpath, 0o2);3580      fileio.fchownSync(fd, 0, 0);3581      expect(null).assertFail();3582    } 3583    catch (e) {3584      expect(fileio.closeSync(fd) !== null).assertTrue();3585      expect(fileio.unlinkSync(fpath) !== null).assertTrue();3586      console.log('fileio_test_fchown_sync_007 has failed for ' + e);3587    }3588  });3589  /**3590   * @tc.number SUB_STORAGE_FileIO_prop_write_open_read_4k_sync3591   * @tc.name fileio_test_prop_write_open_read_4k_sync3592   * @tc.desc Sync to write & open & read 4K file.3593   */3594  it('fileio_test_prop_write_open_read_4k_sync', 0, async function () {3595    let fpath = await nextFileName('fileio_test_prop_write_open_read_4k_sync');3596    try {3597      let fd = fileio.openSync(fpath, 0o102, 0o777);3598      expect(fd !== null).assertTrue();3599      expect(fileio.writeSync(fd, randomString(4096)) !== null).assertTrue();3600      expect(fileio.closeSync(fd) !== null).assertTrue();3601      let fd1 = fileio.openSync(fpath, 0o2);3602      let rlen = fileio.readSync(fd1, new ArrayBuffer(4096));3603      expect(rlen == 4096).assertTrue();3604      expect(fileio.closeSync(fd1) !== null).assertTrue();3605      expect(fileio.unlinkSync(fpath) !== null).assertTrue();3606    } 3607    catch (e) {3608      console.log('fileio_test_prop_write_open_read_4k_sync has failed for ' + e);3609      expect(null).assertFail();3610    }3611  });3612  /**3613   * @tc.number SUB_STORAGE_FileIO_prop_write_open_read_4k_sync3614   * @tc.name fileio_test_prop_copyFile_4k_sync3615   * @tc.desc Sync to copy 4K file.3616   */3617  it('fileio_test_prop_copyFile_4k_sync', 0, async function () {3618    let fpath = await nextFileName('fileio_test_prop_copyFile_4k_sync');3619    let fpath1 = await fileName('fileio_test_prop_copyFile_4k_1_sync');3620    try {3621      let fd = fileio.openSync(fpath, 0o102, 0o777);3622      expect(fd !== null).assertTrue();3623      expect(fileio.writeSync(fd, randomString(4096)) !== null).assertTrue();3624      expect(fileio.closeSync(fd) !== null).assertTrue();3625      expect(fileio.copyFileSync(fpath, fpath1) !== null).assertTrue();3626      expect(fileio.unlinkSync(fpath) !== null).assertTrue();3627      expect(fileio.unlinkSync(fpath1) !== null).assertTrue();3628    } 3629    catch (e) {3630      console.log('fileio_test_prop_copyFile_4k_sync has failed for ' + e);3631      expect(null).assertFail();3632    }3633  });...FileIOStream.test.js
Source:FileIOStream.test.js  
1/*2 * Copyright (C) 2021 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 at6 *7 *     http://www.apache.org/licenses/LICENSE-2.08 *9 * Unless required by applicable law or agreed to in writing, software10 * 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 and13 * limitations under the License.14 */15import fileio from '@ohos.fileio';16import {17  describe,18  it,19  expect20}21  from 'deccjsunit/index'22import {23  FILE_CONTENT,24  prepareFile,25  fileToReadOnly,26  fileToWriteOnly,27  nextFileName,28  randomString29}30  from './Common'31describe('fileIOTestStream', function () {32  /**33   * @tc.number SUB_STORAGE_FileIO_stream_CreateStreamSync_000034   * @tc.name fileio_test_stream_create_stream_sync_00035   * @tc.desc Function of API, mode = r. The test file is exist.36   */37  it('fileio_test_stream_create_stream_sync_000', 0, async function () {38    let fpath = await nextFileName('fileio_test_stream_create_stream_sync_000');39    expect(prepareFile(fpath, 'hello')).assertTrue();40    expect(fileToReadOnly(fpath)).assertTrue();41    try {42      let ss = fileio.createStreamSync(fpath, 'r');43      expect(ss !== null).assertTrue();44      expect(ss.closeSync() !== null).assertTrue();45      expect(fileio.unlinkSync(fpath) !== null).assertTrue();46      console.log('fileio_test_stream_create_stream_sync_000 is passed!');47    } 48    catch (e) {49      console.log('fileio_test_stream_create_stream_sync_000 has failed for ' + e);50      expect(null).assertFail();51    }52  });53  /**54   * @tc.number SUB_STORAGE_FileIO_stream_CreateStreamSync_010055   * @tc.name fileio_test_stream_create_stream_sync_00156   * @tc.desc Function of API, mode = r. The test file is not exist.57   */58  it('fileio_test_stream_create_stream_sync_001', 0, async function () {59    let fpath = await nextFileName('fileio_test_stream_create_stream_sync_001');60    try {61      fileio.createStreamSync(fpath, 'r');62      expect(null).assertFail();63    }64    catch (e) {65      console.log('fileio_test_stream_create_stream_sync_001 has failed for ' + e);66    }67  });68  /**69   * @tc.number SUB_STORAGE_FileIO_stream_CreateStreamSync_020070   * @tc.name fileio_test_stream_create_stream_sync_00271   * @tc.desc Function of API, mode = w. The test file is exist.72   */73  it('fileio_test_stream_create_stream_sync_002', 0, async function () {74    let fpath = await nextFileName('fileio_test_stream_create_stream_sync_002');75    expect(prepareFile(fpath, '')).assertTrue();76    expect(fileToWriteOnly(fpath)).assertTrue();77    let text = '0123456789abcdefg';78    try {79      let ss = fileio.createStreamSync(fpath, 'w');80      expect(ss !== null).assertTrue();81      let wlen = ss.writeSync(text);82      expect(wlen !== null).assertTrue();83      expect(ss.closeSync() !== null).assertTrue();84      expect(fileToReadOnly(fpath)).assertTrue();85      ss = fileio.createStreamSync(fpath, 'r');86      let rlen = ss.readSync(new ArrayBuffer(4096));87      expect(rlen == text.length).assertTrue();88      expect(ss.closeSync() !== null).assertTrue();89      expect(fileio.unlinkSync(fpath) !== null).assertTrue();90    } 91    catch (e) {92      console.log('fileio_test_stream_create_stream_sync_002 has failed for ' + e);93      expect(null).assertFail();94    }95  });96  /**97   * @tc.number SUB_STORAGE_FileIO_stream_CreateStreamSync_030098   * @tc.name fileio_test_stream_create_stream_sync_00399   * @tc.desc Function of API, mode = w. The test file is not exist.100   */101  it('fileio_test_stream_create_stream_sync_003', 0, async function () {102    let fpath = await nextFileName('fileio_test_stream_create_stream_sync_003');103    try {104      let ss = fileio.createStreamSync(fpath, 'w');105      expect(ss !== null).assertTrue();106      expect(ss.closeSync() !== null).assertTrue();107      expect(fileio.unlinkSync(fpath) !== null).assertTrue();108    }109    catch (e) {110      console.log('fileio_test_stream_create_stream_sync_003 has failed for ' + e);111      expect(null).assertFail();112    }113  });114  /**115   * @tc.number SUB_STORAGE_FileIO_stream_CreateStreamSync_0400116   * @tc.name fileio_test_stream_create_stream_sync_004117   * @tc.desc Function of API, mode = a. The test file is exist.118   */119  it('fileio_test_stream_create_stream_sync_004', 0, async function () {120    let fpath = await nextFileName('fileio_test_stream_create_stream_sync_004');121    expect(prepareFile(fpath, 'a')).assertTrue();122    expect(fileToWriteOnly(fpath)).assertTrue();123    let text = '0123456789abcdefg';124    try {125      let ss = fileio.createStreamSync(fpath, 'a');126      expect(ss !== null).assertTrue();127      let wlen = ss.writeSync(text);128      expect(wlen !== null).assertTrue();129      expect(ss.closeSync() !== null).assertTrue();130      expect(fileToReadOnly(fpath)).assertTrue();131      ss = fileio.createStreamSync(fpath, 'r');132      let rlen = ss.readSync(new ArrayBuffer(4096));133      expect(rlen == text.length + 1).assertTrue();134      expect(ss.closeSync() !== null).assertTrue();135      expect(fileio.unlinkSync(fpath) !== null).assertTrue();136    } 137    catch (e) {138      console.log('fileio_test_stream_create_stream_sync_004 has failed for ' + e);139      expect(fileio.unlinkSync(fpath) !== null).assertTrue();140      expect(null).assertFail();141    }142  });143  /**144   * @tc.number SUB_STORAGE_FileIO_stream_CreateStreamSync_0500145   * @tc.name fileio_test_stream_create_stream_sync_005146   * @tc.desc Function of API, mode = a. The test file is not exist.147   */148  it('fileio_test_stream_create_stream_sync_005', 0, async function () {149    let fpath = await nextFileName('fileio_test_stream_create_stream_sync_005');150    try {151      let ss = fileio.createStreamSync(fpath, 'a');152      expect(ss !== null).assertTrue();153      expect(ss.closeSync() !== null).assertTrue();154      expect(fileio.unlinkSync(fpath) !== null).assertTrue();155    }156    catch (e) {157      console.log('fileio_test_stream_create_stream_sync_005 has failed for ' + e);158      expect(null).assertFail();159    }160  });161  /**162   * @tc.number SUB_STORAGE_FileIO_stream_CreateStreamSync_0600163   * @tc.name fileio_test_stream_create_stream_sync_006164   * @tc.desc Function of API, mode = r+. The test file is exist.165   */166  it('fileio_test_stream_create_stream_sync_006', 0, async function () {167    let fpath = await nextFileName('fileio_test_stream_create_stream_sync_006');168    expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();169    try {170      let ss = fileio.createStreamSync(fpath, 'r+');171      expect(ss !== null).assertTrue();172      expect(ss.closeSync() !== null).assertTrue();173      expect(fileio.unlinkSync(fpath) !== null).assertTrue();174    } 175    catch (e) {176      console.log('fileio_test_stream_create_stream_sync_006 has failed for ' + e);177      expect(null).assertFail();178    }179  });180  /**181   * @tc.number SUB_STORAGE_FileIO_stream_CreateStreamSync_0700182   * @tc.name fileio_test_stream_create_stream_sync_007183   * @tc.desc Function of API, mode = r+. The test file is not exist.184   */185  it('fileio_test_stream_create_stream_sync_007', 0, async function () {186    let fpath = await nextFileName('fileio_test_stream_create_stream_sync_007');187    try {188      fileio.createStreamSync(fpath, 'r+');189      expect(null).assertFail();190    }191    catch (e) {192      console.log('fileio_test_stream_create_stream_sync_007 has failed for ' + e);193    }194  });195  /**196   * @tc.number SUB_STORAGE_FileIO_stream_CreateStreamSync_0800197   * @tc.name fileio_test_stream_create_stream_sync_008198   * @tc.desc Function of API, mode = w+. The test file is exist.199   */200  it('fileio_test_stream_create_stream_sync_008', 0, async function () {201    let fpath = await nextFileName('fileio_test_stream_create_stream_sync_008');202    expect(prepareFile(fpath, '')).assertTrue();203    let text = '0123456789abcdefg';204    try {205      let ss = fileio.createStreamSync(fpath, 'w+');206      expect(ss !== null).assertTrue();207      let wlen = ss.writeSync(text);208      expect(wlen !== null).assertTrue();209      expect(ss.closeSync() !== null).assertTrue();210      expect(fileToReadOnly(fpath)).assertTrue();211      ss = fileio.createStreamSync(fpath, 'r');212      let rlen = ss.readSync(new ArrayBuffer(4096));213      expect(rlen == text.length).assertTrue();214      expect(ss.closeSync() !== null).assertTrue();215      expect(fileio.unlinkSync(fpath) !== null).assertTrue();216    } 217    catch (e) {218      console.log('fileio_test_stream_create_stream_sync_008 has failed for ' + e);219      expect(null).assertFail();220    }221  });222  /**223   * @tc.number SUB_STORAGE_FileIO_stream_CreateStreamSync_0900224   * @tc.name fileio_test_stream_create_stream_sync_009225   * @tc.desc Function of API, mode = w+. The test file is not exist.226   */227  it('fileio_test_stream_create_stream_sync_009', 0, async function () {228    let fpath = await nextFileName('fileio_test_stream_create_stream_sync_009');229    try {230      let ss = fileio.createStreamSync(fpath, 'w+');231      expect(ss !== null).assertTrue();232      expect(ss.closeSync() !== null).assertTrue();233      expect(fileio.unlinkSync(fpath) !== null).assertTrue();234    }235    catch (e) {236      console.log('fileio_test_stream_create_stream_sync_009 has failed for ' + e);237      expect(null).assertFail();238    }239  });240  /**241   * @tc.number SUB_STORAGE_FileIO_stream_CreateStreamSync_1000242   * @tc.name fileio_test_stream_create_stream_sync_010243   * @tc.desc Function of API, mode = a+. The test file is exist.244   */245  it('fileio_test_stream_create_stream_sync_010', 0, async function () {246    let fpath = await nextFileName('fileio_test_stream_create_stream_sync_010');247    expect(prepareFile(fpath, 'a')).assertTrue();248    let text = '0123456789abcdefg';249    try {250      let ss = fileio.createStreamSync(fpath, 'a+');251      expect(ss !== null).assertTrue();252      let wlen = ss.writeSync(text);253      expect(wlen !== null).assertTrue();254      expect(ss.closeSync() !== null).assertTrue();255      expect(fileToReadOnly(fpath)).assertTrue();256      ss = fileio.createStreamSync(fpath, 'r');257      let rlen = ss.readSync(new ArrayBuffer(4096));258      expect(rlen == text.length + 1).assertTrue();259      expect(ss.closeSync() !== null).assertTrue();260      expect(fileio.unlinkSync(fpath) !== null).assertTrue();261    } 262    catch (e) {263      console.log('fileio_test_stream_create_stream_sync_010 has failed for ' + e);264      expect(null).assertFail();265    }266  });267  /**268   * @tc.number SUB_STORAGE_FileIO_stream_CreateStreamSync_1100269   * @tc.name fileio_test_stream_create_stream_sync_011270   * @tc.desc Function of API, mode = a+. The test file is not exist.271   */272  it('fileio_test_stream_create_stream_sync_011', 0, async function () {273    let fpath = await nextFileName('fileio_test_stream_create_stream_sync_011');274    try {275      let ss = fileio.createStreamSync(fpath, 'a+');276      expect(ss !== null).assertTrue();277      expect(ss.closeSync() !== null).assertTrue();278      expect(fileio.unlinkSync(fpath) !== null).assertTrue();279    }280    catch (e) {281      console.log('fileio_test_stream_create_stream_sync_011 has failed for ' + e);282      expect(null).assertFail();283    }284  });285  /**286   * @tc.number SUB_STORAGE_FileIO_stream_CreateStreamSync_1200287   * @tc.name fileio_test_stream_create_stream_sync_012288   * @tc.desc Function of API, mode = ab. The test file is exist.289   */290  it('fileio_test_stream_create_stream_sync_012', 0, async function () {291    let fpath = await nextFileName('fileio_test_stream_create_stream_sync_012');292    expect(prepareFile(fpath, '')).assertTrue();293    expect(fileToReadOnly(fpath)).assertTrue();294    try {295      let ss = fileio.createStreamSync(fpath, 'rb');296      expect(ss !== null).assertTrue();297      expect(ss.closeSync() !== null).assertTrue();298      expect(fileio.unlinkSync(fpath) !== null).assertTrue();299    } 300    catch (e) {301      console.log('fileio_test_stream_create_stream_sync_012 has failed for ' + e);302      expect(null).assertFail();303    }304  });305  /**306   * @tc.number SUB_STORAGE_FileIO_stream_CreateStreamSync_1300307   * @tc.name fileio_test_stream_create_stream_sync_013308   * @tc.desc Function of API, mode = ab. The test file is not exist.309   */310  it('fileio_test_stream_create_stream_sync_013', 0, async function () {311    let fpath = await nextFileName('fileio_test_stream_create_stream_sync_013');312    try {313      fileio.createStreamSync(fpath, 'rb');314      expect(null).assertFail();315    }316    catch (e) {317      console.log('fileio_test_stream_create_stream_sync_013 has failed for ' + e);318    }319  });320  /**321   * @tc.number SUB_STORAGE_FileIO_stream_CreateStreamSync_1400322   * @tc.name fileio_test_stream_create_stream_sync_014323   * @tc.desc Function of API, mode = wb. The test file is exist.324   */325  it('fileio_test_stream_create_stream_sync_014', 0, async function () {326    let fpath = await nextFileName('fileio_test_stream_create_stream_sync_014');327    expect(prepareFile(fpath, '')).assertTrue();328    expect(fileToWriteOnly(fpath)).assertTrue();329    let text = '0123456789abcdefg';330    try {331      let ss = fileio.createStreamSync(fpath, 'wb');332      expect(ss !== null).assertTrue();333      let wlen = ss.writeSync(text);334      expect(wlen !== null).assertTrue();335      expect(ss.closeSync() !== null).assertTrue();336      expect(fileToReadOnly(fpath)).assertTrue();337      ss = fileio.createStreamSync(fpath, 'r');338      let rlen = ss.readSync(new ArrayBuffer(4096));339      expect(rlen == text.length).assertTrue();340      expect(ss.closeSync() !== null).assertTrue();341      expect(fileio.unlinkSync(fpath) !== null).assertTrue();342    } 343    catch (e) {344      console.log('fileio_test_stream_create_stream_sync_014 has failed for ' + e);345      expect(null).assertFail();346    }347  });348  /**349   * @tc.number SUB_STORAGE_FileIO_stream_CreateStreamSync_1500350   * @tc.name fileio_test_stream_create_stream_sync_015351   * @tc.desc Function of API, mode = wb. The test file is not exist.352   */353  it('fileio_test_stream_create_stream_sync_015', 0, async function () {354    let fpath = await nextFileName('fileio_test_stream_create_stream_sync_015');355    try {356      let ss = fileio.createStreamSync(fpath, 'wb');357      expect(ss !== null).assertTrue();358      expect(ss.closeSync() !== null).assertTrue();359      expect(fileio.unlinkSync(fpath) !== null).assertTrue();360    }361    catch (e) {362      console.log('fileio_test_stream_create_stream_sync_015 has failed for ' + e);363      expect(null).assertFail();364    }365  });366  /**367   * @tc.number SUB_STORAGE_FileIO_stream_CreateStreamSync_1600368   * @tc.name fileio_test_stream_create_stream_sync_016369   * @tc.desc Function of API, mode = ab. The test file is exist.370   */371  it('fileio_test_stream_create_stream_sync_016', 0, async function () {372    let fpath = await nextFileName('fileio_test_stream_create_stream_sync_016');373    expect(prepareFile(fpath, 'a')).assertTrue();374    expect(fileToWriteOnly(fpath)).assertTrue();375    let text = '0123456789abcdefg';376    try {377      let ss = fileio.createStreamSync(fpath, 'ab');378      expect(ss !== null).assertTrue();379      let wlen = ss.writeSync(text);380      expect(wlen !== null).assertTrue();381      expect(ss.closeSync() !== null).assertTrue();382      expect(fileToReadOnly(fpath)).assertTrue();383      ss = fileio.createStreamSync(fpath, 'r');384      let rlen = ss.readSync(new ArrayBuffer(4096));385      expect(rlen == text.length + 1).assertTrue();386      expect(ss.closeSync() !== null).assertTrue();387      expect(fileio.unlinkSync(fpath) !== null).assertTrue();388      console.log('fileio_test_stream_create_stream_sync_016 is passed!');389    } 390    catch (e) {391      console.log('fileio_test_stream_create_stream_sync_016 has failed for ' + e);392      expect(null).assertFail();393    }394  });395  /**396   * @tc.number SUB_STORAGE_FileIO_stream_CreateStreamSync_1700397   * @tc.name fileio_test_stream_create_stream_sync_017398   * @tc.desc Function of API, mode = ab. The test file is not exist.399   */400  it('fileio_test_stream_create_stream_sync_017', 0, async function () {401    let fpath = await nextFileName('fileio_test_stream_create_stream_sync_017');402    try {403      let ss = fileio.createStreamSync(fpath, 'ab');404      expect(ss !== null).assertTrue();405      expect(ss.closeSync() !== null).assertTrue();406      expect(fileio.unlinkSync(fpath) !== null).assertTrue();407    }408    catch (e) {409      console.log('fileio_test_stream_create_stream_sync_017 has failed for ' + e);410      expect(null).assertFail();411    }412  });413  /**414   * @tc.number SUB_STORAGE_FileIO_stream_CreateStreamSync_1800415   * @tc.name fileio_test_stream_create_stream_sync_018416   * @tc.desc Function of API, mode = rb+. The test file is exist.417   */418  it('fileio_test_stream_create_stream_sync_018', 0, async function () {419    let fpath = await nextFileName('fileio_test_stream_create_stream_sync_018');420    expect(prepareFile(fpath, '')).assertTrue();421    try {422      let ss = fileio.createStreamSync(fpath, 'rb+');423      expect(ss !== null).assertTrue();424      expect(ss.closeSync() !== null).assertTrue();425      expect(fileio.unlinkSync(fpath) !== null).assertTrue();426    } 427    catch (e) {428      console.log('fileio_test_stream_create_stream_sync_018 has failed for ' + e);429      expect(null).assertFail();430    }431  });432  /**433   * @tc.number SUB_STORAGE_FileIO_stream_CreateStreamSync_1900434   * @tc.name fileio_test_stream_create_stream_sync_019435   * @tc.desc Function of API, mode = rb+. The test file is not exist.436   */437  it('fileio_test_stream_create_stream_sync_019', 0, async function () {438    let fpath = await nextFileName('fileio_test_stream_create_stream_sync_019');439    try {440      fileio.createStreamSync(fpath, 'rb+');441      expect(null).assertFail();442    }443    catch (e) {444      console.log('fileio_test_stream_create_stream_sync_019 has failed for ' + e);445    }446  });447  /**448   * @tc.number SUB_STORAGE_FileIO_stream_CreateStreamSync_2000449   * @tc.name fileio_test_stream_create_stream_sync_020450   * @tc.desc Function of API, mode = wb+. The test file is exist.451   */452  it('fileio_test_stream_create_stream_sync_020', 0, async function () {453    let fpath = await nextFileName('fileio_test_stream_create_stream_sync_020');454    expect(prepareFile(fpath, '')).assertTrue();455    let text = '0123456789abcdefg';456    try {457      let ss = fileio.createStreamSync(fpath, 'wb+');458      expect(ss !== null).assertTrue();459      let wlen = ss.writeSync(text);460      expect(wlen !== null).assertTrue();461      expect(ss.closeSync() !== null).assertTrue();462      expect(fileToReadOnly(fpath)).assertTrue();463      ss = fileio.createStreamSync(fpath, 'r');464      let rlen = ss.readSync(new ArrayBuffer(4096));465      expect(rlen == text.length).assertTrue();466      expect(ss.closeSync() !== null).assertTrue();467      expect(fileio.unlinkSync(fpath) !== null).assertTrue();468    } 469    catch (e) {470      console.log('fileio_test_stream_create_stream_sync_020 has failed for ' + e);471      expect(null).assertFail();472    }473  });474  /**475   * @tc.number SUB_STORAGE_FileIO_stream_CreateStreamSync_2100476   * @tc.name fileio_test_stream_create_stream_sync_021477   * @tc.desc Function of API, mode = wb+. The test file is not exist.478   */479  it('fileio_test_stream_create_stream_sync_021', 0, async function () {480    let fpath = await nextFileName('fileio_test_stream_create_stream_sync_021');481    try {482      let ss = fileio.createStreamSync(fpath, 'wb+');483      expect(ss !== null).assertTrue();484      expect(ss.closeSync() !== null).assertTrue();485      expect(fileio.unlinkSync(fpath) !== null).assertTrue();486    }487    catch (e) {488      console.log('fileio_test_stream_create_stream_sync_021 has failed for ' + e);489      expect(null).assertFail();490    }491  });492  /**493   * @tc.number SUB_STORAGE_FileIO_stream_CreateStreamSync_2200494   * @tc.name fileio_test_stream_create_stream_sync_022495   * @tc.desc Function of API, mode = ab+. The test file is exist.496   */497  it('fileio_test_stream_create_stream_sync_022', 0, async function () {498    let fpath = await nextFileName('fileio_test_stream_create_stream_sync_022');499    expect(prepareFile(fpath, 'a')).assertTrue();500    let text = '0123456789abcdefg';501    try {502      let ss = fileio.createStreamSync(fpath, 'ab+');503      expect(ss !== null).assertTrue();504      let wlen = ss.writeSync(text);505      expect(wlen !== null).assertTrue();506      expect(ss.closeSync() !== null).assertTrue();507      expect(fileToReadOnly(fpath)).assertTrue();508      ss = fileio.createStreamSync(fpath, 'r');509      let rlen = ss.readSync(new ArrayBuffer(4096));510      expect(rlen == text.length + 1).assertTrue();511      expect(ss.closeSync() !== null).assertTrue();512      expect(fileio.unlinkSync(fpath) !== null).assertTrue();513    } 514    catch (e) {515      console.log('fileio_test_stream_create_stream_sync_022 has failed for ' + e);516      expect(null).assertFail();517    }518  });519  /**520   * @tc.number SUB_STORAGE_FileIO_stream_CreateStreamSync_2300521   * @tc.name fileio_test_stream_create_stream_sync_023522   * @tc.desc Function of API, mode = ab+. The test file is not exist.523   */524  it('fileio_test_stream_create_stream_sync_023', 0, async function () {525    let fpath = await nextFileName('fileio_test_stream_create_stream_sync_023');526    try {527      let ss = fileio.createStreamSync(fpath, 'ab+');528      expect(ss !== null).assertTrue();529      expect(ss.closeSync() !== null).assertTrue();530      expect(fileio.unlinkSync(fpath) !== null).assertTrue();531    }532    catch (e) {533      console.log('fileio_test_stream_create_stream_sync_023 has failed for ' + e);534      expect(null).assertFail();535    }536  });537  /**538   * @tc.number SUB_STORAGE_FileIO_stream_CreateStreamSync_2400539   * @tc.name fileio_test_stream_create_stream_sync_024540   * @tc.desc Function of API, invalid fpath.541   */542  it('fileio_test_stream_create_stream_sync_024', 0, function () {543    try {544      fileio.createStreamSync('', 'r');545      expect(null).assertFail();546    } 547    catch (e) {548      console.log('fileio_test_stream_create_stream_sync_024 is passed!' + e);549    }550  });551  /**552   * @tc.number SUB_STORAGE_FileIO_stream_CreateStreamSync_2500553   * @tc.name fileio_test_stream_create_stream_sync_025554   * @tc.desc Function of API, invalid mode.555   */556  it('fileio_test_stream_create_stream_sync_025', 0, async function () {557    let fpath = await nextFileName('fileio_test_stream_create_stream_sync_025');558    expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();559    try {560      fileio.createStreamSync(fpath, '');561      expect(null).assertFail();562    } 563    catch (e) {564      console.log('fileio_test_stream_create_stream_sync_025 is passed!' + e);565      expect(fileio.unlinkSync(fpath) !== null).assertTrue();566    }567  });568  /**569   * @tc.number SUB_STORAGE_FileIO_stream_CreateStreamSync_2600570   * @tc.name fileio_test_stream_create_stream_sync_026571   * @tc.desc Function of API, fpath too long.572   */573  it('fileio_test_stream_create_stream_sync_026', 0, async function () {574    let dpath = await nextFileName('fileio_stream');575    fileio.mkdirSync(dpath);576    try {577      for (let i = 0; i < 16; i++) {578        if (i == 15) {579          let fpath = dpath + '/f' + randomString(248);580          fileio.createStreamSync(fpath, 'w+');581        } else {582          dpath = dpath + '/d' + randomString(248);583          fileio.mkdirSync(dpath);584        }585      }586      expect(null).assertFail();587    }588    catch (e) {589      console.log('fileio_test_stream_create_stream_sync_026 has failed for ' + e);590    }591  });592  /**593   * @tc.number SUB_STORAGE_FileIO_stream_CreateStreamSync_2700594   * @tc.name fileio_test_stream_create_stream_sync_027595   * @tc.desc Function of API, filename too long.596   */597  it('fileio_test_stream_create_stream_sync_027', 0, async function () {598    let fpath = await nextFileName(randomString(256));599    try {600      fileio.createStreamSync(fpath, 'w+');601      expect(null).assertFail();602    }603    catch (e) {604      console.log('fileio_test_stream_create_stream_sync_027 has failed for ' + e);605    }606  });607  /**608   * @tc.number SUB_STORAGE_FileIO_stream_CreateStreamSync_2800609   * @tc.name fileio_test_stream_create_stream_sync_028610   * @tc.desc Function of API, path too deep.611   */612  it('fileio_test_stream_create_stream_sync_028', 0, async function () {613    let dpath = await nextFileName('stream');614    fileio.mkdirSync(dpath);615    try {616      for (let i = 0; i < 113; i++) {617        if (i == 112) {618          let fpath = dpath + '/f' + i619          fileio.createStreamSync(fpath, 'w+');620        } else {621          dpath = dpath + '/' + i622          fileio.mkdirSync(dpath);623        }624      }625      expect(null).assertFail();626    }627    catch (e) {628      console.log('fileio_test_stream_create_stream_sync_028 has failed for ' + e);629    }630  });631  /**632   * @tc.number SUB_STORAGE_FileIO_stream_CreateStreamSync_2900633   * @tc.name fileio_test_stream_create_stream_sync_029634   * @tc.desc Function of API, special character.635   */636  it('fileio_test_stream_create_stream_sync_029', 0, async function () {637    let fpath = await nextFileName('?*:<>/|');638    try {639      fileio.createStreamSync(fpath, 'w+');640      expect(null).assertFail();641    }642    catch (e) {643      console.log('fileio_test_stream_create_stream_sync_029 has failed for ' + e);644    }645  });646  /**647   * @tc.number SUB_STORAGE_FileIO_stream_FdopenStreamSync_0000648   * @tc.name fileio_test_stream_fdopen_stream_sync_000649   * @tc.desc Function of API, mode=r. The test file is exist.650   */651  it('fileio_test_stream_fdopen_stream_sync_000', 0, async function () {652    let fpath = await nextFileName('fileio_test_stream_fdopen_stream_sync_000');653    expect(prepareFile(fpath, '')).assertTrue();654    expect(fileToReadOnly(fpath)).assertTrue();655    try {656      let fd = fileio.openSync(fpath, 0o0);657      let ss = fileio.fdopenStreamSync(fd, 'r');658      expect(ss !== null).assertTrue();659      expect(ss.closeSync() !== null).assertTrue();660      expect(fileio.unlinkSync(fpath) !== null).assertTrue();661    } 662    catch (e) {663      console.log('fileio_test_stream_fdopen_stream_sync_000 has failed for ' + e);664      expect(null).assertFail();665    }666  });667  /**668   * @tc.number SUB_STORAGE_FileIO_stream_FdopenStreamSync_0100669   * @tc.name fileio_test_stream_fdopen_stream_sync_001670   * @tc.desc Function of API, mode=r. The test file is not exist.671   */672  it('fileio_test_stream_fdopen_stream_sync_001', 0, function () {673    try {674      let fd = -1;675      let mode = 'r+';676      fileio.fdopenStreamSync(fd, mode);677      expect(null).assertFail();678    } 679    catch (e) {680      console.log('fileio_test_stream_fdopen_stream_sync_001 has failed for ' + e);681    }682  });683  /**684   * @tc.number SUB_STORAGE_FileIO_stream_FdopenStreamSync_0200685   * @tc.name fileio_test_stream_fdopen_stream_sync_002686   * @tc.desc Function of API, mode=w. The test file is exist.687   */688  it('fileio_test_stream_fdopen_stream_sync_002', 0, async function () {689    let fpath = await nextFileName('fileio_test_stream_fdopen_stream_sync_002');690    let fd;691    expect(prepareFile(fpath, '')).assertTrue();692    expect(fileToWriteOnly(fpath)).assertTrue();693    let text = '0123456789abcdefg';694    try {695      fd = fileio.openSync(fpath, 0o001);696      expect(fd !== null).assertTrue();697      let ss = fileio.fdopenStreamSync(fd, 'w');698      expect(ss !== null).assertTrue();699      let wlen = ss.writeSync(text);700      expect(wlen !== null).assertTrue();701      expect(ss.closeSync() !== null).assertTrue();702      expect(fileToReadOnly(fpath)).assertTrue();703      ss = fileio.createStreamSync(fpath, 'r');704      let rlen = ss.readSync(new ArrayBuffer(4096));705      expect(rlen == text.length).assertTrue();706      expect(ss.closeSync() !== null).assertTrue();707      expect(fileio.unlinkSync(fpath) !== null).assertTrue();708    } 709    catch (e) {710      console.log('fileio_test_stream_fdopen_stream_sync_002 has failed for ' + e);711      expect(null).assertFail();712    }713  });714  /**715   * @tc.number SUB_STORAGE_FileIO_stream_FdopenStreamSync_0300716   * @tc.name fileio_test_stream_fdopen_stream_sync_003717   * @tc.desc Function of API, mode=w. The test file is not exist.718   */719  it('fileio_test_stream_fdopen_stream_sync_003', 0, async function () {720    let fpath = await nextFileName('fileio_test_stream_fdopen_stream_sync_003');721    try {722      let fd = fileio.openSync(fpath, 0o101, 0o222);723      let ss = fileio.fdopenStreamSync(fd, 'w');724      expect(ss !== null).assertTrue();725      expect(ss.closeSync() !== null).assertTrue();726      expect(fileio.unlinkSync(fpath) !== null).assertTrue();727    }728    catch (e) {729      console.log('fileio_test_stream_fdopen_stream_sync_003 has failed for ' + e);730      expect(null).assertFail();731    }732  });733  /**734   * @tc.number SUB_STORAGE_FileIO_stream_FdopenStreamSync_0400735   * @tc.name fileio_test_stream_fdopen_stream_sync_004736   * @tc.desc Function of API, mode=a. The test file is exist.737   */738  it('fileio_test_stream_fdopen_stream_sync_004', 0, async function () {739    let fpath = await nextFileName('fileio_test_stream_fdopen_stream_sync_004');740    expect(prepareFile(fpath, '1')).assertTrue();741    expect(fileToWriteOnly(fpath)).assertTrue();742    let text = '0123456789abcdefg';743    try {744      let fd = fileio.openSync(fpath, 0o2001);745      expect(fd !== null).assertTrue();746      let ss = fileio.fdopenStreamSync(fd, 'a');747      expect(ss !== null).assertTrue();748      let wlen = ss.writeSync(text);749      expect(wlen !== null).assertTrue();750      expect(ss.closeSync() !== null).assertTrue();751      expect(fileToReadOnly(fpath)).assertTrue();752      ss = fileio.createStreamSync(fpath, 'r');753      let rlen = ss.readSync(new ArrayBuffer(4096));754      expect(rlen == text.length + 1).assertTrue();755      expect(ss.closeSync() !== null).assertTrue();756      expect(fileio.unlinkSync(fpath) !== null).assertTrue();757    } 758    catch (e) {759      console.log('fileio_test_stream_fdopen_stream_sync_004 has failed for ' + e);760      expect(null).assertFail();761    }762  });763  /**764   * @tc.number SUB_STORAGE_FileIO_stream_FdopenStreamSync_0500765   * @tc.name fileio_test_stream_fdopen_stream_sync_005766   * @tc.desc Function of API, mode=a. The test file is not exist.767   */768  it('fileio_test_stream_fdopen_stream_sync_005', 0, async function () {769    let fpath = await nextFileName('fileio_test_stream_fdopen_stream_sync_005');770    try {771      let fd = fileio.openSync(fpath, 0o101, 0o222);772      let ss = fileio.fdopenStreamSync(fd, 'a');773      expect(ss !== null).assertTrue();774      expect(ss.closeSync() !== null).assertTrue();775      expect(fileio.unlinkSync(fpath) !== null).assertTrue();776    }777    catch (e) {778      console.log('fileio_test_stream_fdopen_stream_sync_005 has failed for ' + e);779      expect(null).assertFail();780    }781  });782  /**783   * @tc.number SUB_STORAGE_FileIO_stream_FdopenStreamSync_0600784   * @tc.name fileio_test_stream_fdopen_stream_sync_006785   * @tc.desc Function of API, mode=r+. The test file is exist.786   */787  it('fileio_test_stream_fdopen_stream_sync_006', 0, async function () {788    let fpath = await nextFileName('fileio_test_stream_fdopen_stream_sync_006');789    expect(prepareFile(fpath, '')).assertTrue();790    try {791      let fd = fileio.openSync(fpath, 0o2);792      let ss = fileio.fdopenStreamSync(fd, 'r+');793      expect(ss !== null).assertTrue();794      expect(ss.closeSync() !== null).assertTrue();795      expect(fileio.unlinkSync(fpath) !== null).assertTrue();796    } 797    catch (e) {798      console.log('fileio_test_stream_fdopen_stream_sync_006 has failed for ' + e);799      expect(null).assertFail();800    }801  });802  /**803   * @tc.number SUB_STORAGE_FileIO_stream_FdopenStreamSync_0700804   * @tc.name fileio_test_stream_fdopen_stream_sync_007805   * @tc.desc Function of API, mode=r+. The test file is not exist.806   */807  it('fileio_test_stream_fdopen_stream_sync_007', 0, async function () {808    try {809      fileio.fdopenStreamSync(-1, 'r+');810      expect(null).assertFail();811    } 812    catch (e) {813      console.log('fileio_test_stream_fdopen_stream_sync_007 has failed for ' + e);814    }815  });816  /**817   * @tc.number SUB_STORAGE_FileIO_stream_FdopenStreamSync_0800818   * @tc.name fileio_test_stream_fdopen_stream_sync_008819   * @tc.desc Function of API, mode=w+. The test file is exist.820   */821  it('fileio_test_stream_fdopen_stream_sync_008', 0, async function () {822    let fpath = await nextFileName('fileio_test_stream_fdopen_stream_sync_008');823    expect(prepareFile(fpath, '')).assertTrue();824    let text = '0123456789abcdefg';825    try {826      let fd = fileio.openSync(fpath, 0o2);827      expect(fd !== null).assertTrue();828      let ss = fileio.fdopenStreamSync(fd, 'w+');829      expect(ss !== null).assertTrue();830      let wlen = ss.writeSync(text);831      expect(wlen !== null).assertTrue();832      expect(ss.closeSync() !== null).assertTrue();833      expect(fileToReadOnly(fpath)).assertTrue();834      ss = fileio.createStreamSync(fpath, 'r');835      let rlen = ss.readSync(new ArrayBuffer(4096));836      expect(rlen == text.length).assertTrue();837      expect(ss.closeSync() !== null).assertTrue();838      expect(fileio.unlinkSync(fpath) !== null).assertTrue();839    } 840    catch (e) {841      console.log('fileio_test_stream_fdopen_stream_sync_008 has failed for ' + e);842      expect(null).assertFail();843    }844  });845  /**846   * @tc.number SUB_STORAGE_FileIO_stream_FdopenStreamSync_0900847   * @tc.name fileio_test_stream_fdopen_stream_sync_009848   * @tc.desc Function of API, mode=w+. The test file is not exist.849   */850  it('fileio_test_stream_fdopen_stream_sync_009', 0, async function () {851    let fpath = await nextFileName('fileio_test_stream_fdopen_stream_sync_009');852    try {853      let fd = fileio.openSync(fpath, 0o102, 0o666);854      let ss = fileio.fdopenStreamSync(fd, 'w+');855      expect(ss !== null).assertTrue();856      expect(ss.closeSync() !== null).assertTrue();857      expect(fileio.unlinkSync(fpath) !== null).assertTrue();858    }859    catch (e) {860      console.log('fileio_test_stream_fdopen_stream_sync_009 has failed for ' + e);861      expect(null).assertFail();862    }863  });864  /**865   * @tc.number SUB_STORAGE_FileIO_stream_FdopenStreamSync_1000866   * @tc.name fileio_test_stream_fdopen_stream_sync_010867   * @tc.desc Function of API, mode=a+. The test file is exist.868   */869  it('fileio_test_stream_fdopen_stream_sync_010', 0, async function () {870    let fpath = await nextFileName('fileio_test_stream_fdopen_stream_sync_010');871    expect(prepareFile(fpath, '1')).assertTrue();872    let text = '0123456789abcdefg';873    try {874      let fd = fileio.openSync(fpath, 0o2002);875      expect(fd !== null).assertTrue();876      let ss = fileio.fdopenStreamSync(fd, 'a+');877      expect(ss !== null).assertTrue();878      let wlen = ss.writeSync(text);879      expect(wlen !== null).assertTrue();880      expect(ss.closeSync() !== null).assertTrue();881      expect(fileToReadOnly(fpath)).assertTrue();882      ss = fileio.createStreamSync(fpath, 'r');883      let rlen = ss.readSync(new ArrayBuffer(4096));884      expect(rlen == text.length + 1).assertTrue();885      expect(ss.closeSync() !== null).assertTrue();886      expect(fileio.unlinkSync(fpath) !== null).assertTrue();887    } 888    catch (e) {889      console.log('fileio_test_stream_fdopen_stream_sync_010 has failed for ' + e);890      expect(null).assertFail();891    }892  });893  /**894   * @tc.number SUB_STORAGE_FileIO_stream_FdopenStreamSync_1100895   * @tc.name fileio_test_stream_fdopen_stream_sync_011896   * @tc.desc Function of API, mode=a+. The test file is not exist.897   */898  it('fileio_test_stream_fdopen_stream_sync_011', 0, async function () {899    let fpath = await nextFileName('fileio_test_stream_fdopen_stream_sync_011');900    try {901      let fd = fileio.openSync(fpath, 0o102, 0o666);902      let ss = fileio.fdopenStreamSync(fd, 'a+');903      expect(ss !== null).assertTrue();904      expect(ss.closeSync() !== null).assertTrue();905      expect(fileio.unlinkSync(fpath) !== null).assertTrue();906    }907    catch (e) {908      console.log('fileio_test_stream_fdopen_stream_sync_011 has failed for ' + e);909      expect(null).assertFail();910    }911  });912  /**913   * @tc.number SUB_STORAGE_FileIO_stream_FdopenStreamSync_1200914   * @tc.name fileio_test_stream_fdopen_stream_sync_012915   * @tc.desc Function of API, mode=rb. The test file is exist.916   */917  it('fileio_test_stream_fdopen_stream_sync_012', 0, async function () {918    let fpath = await nextFileName('fileio_test_stream_fdopen_stream_sync_012');919    expect(prepareFile(fpath, '')).assertTrue();920    expect(fileToReadOnly(fpath)).assertTrue();921    try {922      let fd = fileio.openSync(fpath, 0o0);923      let ss = fileio.fdopenStreamSync(fd, 'rb');924      expect(ss !== null).assertTrue();925      expect(ss.closeSync() !== null).assertTrue();926      expect(fileio.unlinkSync(fpath) !== null).assertTrue();927    } 928    catch (e) {929      console.log('fileio_test_stream_fdopen_stream_sync_012 has failed for ' + e);930      expect(null).assertFail();931    }932  });933  /**934   * @tc.number SUB_STORAGE_FileIO_stream_FdopenStreamSync_1300935   * @tc.name fileio_test_stream_fdopen_stream_sync_013936   * @tc.desc Function of API, mode=rb. The test file is not exist.937   */938  it('fileio_test_stream_fdopen_stream_sync_013', 0, async function () {939    try {940      fileio.fdopenStreamSync(-1, 'rb');941      expect(null).assertFail();942    } 943    catch (e) {944      console.log('fileio_test_stream_fdopen_stream_sync_013 has failed for ' + e);945    }946  });947  /**948   * @tc.number SUB_STORAGE_FileIO_stream_FdopenStreamSync_1400949   * @tc.name fileio_test_stream_fdopen_stream_sync_014950   * @tc.desc Function of API, mode=wb. The test file is exist.951   */952  it('fileio_test_stream_fdopen_stream_sync_014', 0, async function () {953    let fpath = await nextFileName('fileio_test_stream_fdopen_stream_sync_014');954    expect(prepareFile(fpath, '')).assertTrue();955    expect(fileToWriteOnly(fpath)).assertTrue();956    let text = '0123456789abcdefg';957    try {958      let fd = fileio.openSync(fpath, 0o001);959      expect(fd !== null).assertTrue();960      let ss = fileio.fdopenStreamSync(fd, 'wb');961      expect(ss !== null).assertTrue();962      let wlen = ss.writeSync(text);963      expect(wlen !== null).assertTrue();964      expect(ss.closeSync() !== null).assertTrue();965      expect(fileToReadOnly(fpath)).assertTrue();966      ss = fileio.createStreamSync(fpath, 'r');967      let rlen = ss.readSync(new ArrayBuffer(4096));968      expect(rlen == text.length).assertTrue();969      expect(ss.closeSync() !== null).assertTrue();970      expect(fileio.unlinkSync(fpath) !== null).assertTrue();971    } 972    catch (e) {973      console.log('fileio_test_stream_fdopen_stream_sync_014 has failed for ' + e);974      expect(null).assertFail();975    }976  });977  /**978   * @tc.number SUB_STORAGE_FileIO_stream_FdopenStreamSync_1500979   * @tc.name fileio_test_stream_fdopen_stream_sync_015980   * @tc.desc Function of API, mode=wb. The test file is not exist.981   */982  it('fileio_test_stream_fdopen_stream_sync_015', 0, async function () {983    let fpath = await nextFileName('fileio_test_stream_fdopen_stream_sync_015');984    try {985      let fd = fileio.openSync(fpath, 0o101, 0o222);986      let ss = fileio.fdopenStreamSync(fd, 'wb');987      expect(ss !== null).assertTrue();988      expect(ss.closeSync() !== null).assertTrue();989      expect(fileio.unlinkSync(fpath) !== null).assertTrue();990    }991    catch (e) {992      console.log('fileio_test_stream_fdopen_stream_sync_015 has failed for ' + e);993      expect(null).assertFail();994    }995  });996  /**997   * @tc.number SUB_STORAGE_FileIO_stream_FdopenStreamSync_1600998   * @tc.name fileio_test_stream_fdopen_stream_sync_016999   * @tc.desc Function of API, mode=ab. The test file is exist.1000   */1001  it('fileio_test_stream_fdopen_stream_sync_016', 0, async function () {1002    let fpath = await nextFileName('fileio_test_stream_fdopen_stream_sync_016');1003    expect(prepareFile(fpath, '1')).assertTrue();1004    expect(fileToWriteOnly(fpath)).assertTrue();1005    let text = '0123456789abcdefg';1006    try {1007      let fd = fileio.openSync(fpath, 0o2001);1008      expect(fd !== null).assertTrue();1009      let ss = fileio.fdopenStreamSync(fd, 'ab');1010      expect(ss !== null).assertTrue();1011      let wlen = ss.writeSync(text);1012      expect(wlen !== null).assertTrue();1013      expect(ss.closeSync() !== null).assertTrue();1014      expect(fileToReadOnly(fpath)).assertTrue();1015      ss = fileio.createStreamSync(fpath, 'r');1016      let rlen = ss.readSync(new ArrayBuffer(4096));1017      expect(rlen == text.length + 1).assertTrue();1018      expect(ss.closeSync() !== null).assertTrue();1019      expect(fileio.unlinkSync(fpath) !== null).assertTrue();1020    } 1021    catch (e) {1022      console.log('fileio_test_stream_fdopen_stream_sync_016 has failed for ' + e);1023      expect(null).assertFail();1024    }1025  });1026  /**1027   * @tc.number SUB_STORAGE_FileIO_stream_FdopenStreamSync_17001028   * @tc.name fileio_test_stream_fdopen_stream_sync_0171029   * @tc.desc Function of API, mode=ab. The test file is not exist.1030   */1031  it('fileio_test_stream_fdopen_stream_sync_017', 0, async function () {1032    let fpath = await nextFileName('fileio_test_stream_fdopen_stream_sync_017');1033    try {1034      let fd = fileio.openSync(fpath, 0o101, 0o222);1035      let ss = fileio.fdopenStreamSync(fd, 'ab');1036      expect(ss !== null).assertTrue();1037      expect(ss.closeSync() !== null).assertTrue();1038      expect(fileio.unlinkSync(fpath) !== null).assertTrue();1039    }1040    catch (e) {1041      console.log('fileio_test_stream_fdopen_stream_sync_017 has failed for ' + e);1042      expect(null).assertFail();1043    }1044  });1045  /**1046   * @tc.number SUB_STORAGE_FileIO_stream_FdopenStreamSync_18001047   * @tc.name fileio_test_stream_fdopen_stream_sync_0181048   * @tc.desc Function of API, mode=rb+. The test file is exist.1049   */1050  it('fileio_test_stream_fdopen_stream_sync_018', 0, async function () {1051    let fpath = await nextFileName('fileio_test_stream_fdopen_stream_sync_018');1052    expect(prepareFile(fpath, '')).assertTrue();1053    try {1054      let fd = fileio.openSync(fpath, 0o2);1055      let ss = fileio.fdopenStreamSync(fd, 'rb+');1056      expect(ss !== null).assertTrue();1057      expect(ss.closeSync() !== null).assertTrue();1058      expect(fileio.unlinkSync(fpath) !== null).assertTrue();1059    } 1060    catch (e) {1061      console.log('fileio_test_stream_fdopen_stream_sync_018 has failed for ' + e);1062      expect(null).assertFail();1063    }1064  });1065  /**1066   * @tc.number SUB_STORAGE_FileIO_stream_FdopenStreamSync_19001067   * @tc.name fileio_test_stream_fdopen_stream_sync_0191068   * @tc.desc Function of API, mode=rb+. The test file is not exist.1069   */1070  it('fileio_test_stream_fdopen_stream_sync_019', 0, async function () {1071    try {1072      fileio.fdopenStreamSync(-1, 'rb+');1073      expect(null).assertFail();1074    } 1075    catch (e) {1076      console.log('fileio_test_stream_fdopen_stream_sync_019 has failed for ' + e);1077    }1078  });1079  /**1080   * @tc.number SUB_STORAGE_FileIO_stream_FdopenStreamSync_20001081   * @tc.name fileio_test_stream_fdopen_stream_sync_0201082   * @tc.desc Function of API, mode=wb+. The test file is exist.1083   */1084  it('fileio_test_stream_fdopen_stream_sync_020', 0, async function () {1085    let fpath = await nextFileName('fileio_test_stream_fdopen_stream_sync_020');1086    expect(prepareFile(fpath, '')).assertTrue();1087    let text = '0123456789abcdefg';1088    try {1089      let fd = fileio.openSync(fpath, 0o002);1090      expect(fd !== null).assertTrue();1091      let ss = fileio.fdopenStreamSync(fd, 'wb+');1092      expect(ss !== null).assertTrue();1093      let wlen = ss.writeSync(text);1094      expect(wlen !== null).assertTrue();1095      expect(ss.closeSync() !== null).assertTrue();1096      expect(fileToReadOnly(fpath)).assertTrue();1097      ss = fileio.createStreamSync(fpath, 'r');1098      let rlen = ss.readSync(new ArrayBuffer(4096));1099      expect(rlen == text.length).assertTrue();1100      expect(ss.closeSync() !== null).assertTrue();1101      expect(fileio.unlinkSync(fpath) !== null).assertTrue();1102    } 1103    catch (e) {1104      console.log('fileio_test_stream_fdopen_stream_sync_020 has failed for ' + e);1105      expect(null).assertFail();1106    }1107  });1108  /**1109   * @tc.number SUB_STORAGE_FileIO_stream_FdopenStreamSync_21001110   * @tc.name fileio_test_stream_fdopen_stream_sync_0211111   * @tc.desc Function of API, mode=wb+. The test file is not exist.1112   */1113  it('fileio_test_stream_fdopen_stream_sync_021', 0, async function () {1114    let fpath = await nextFileName('fileio_test_stream_fdopen_stream_sync_021');1115    try {1116      let fd = fileio.openSync(fpath, 0o102, 0o666);1117      let ss = fileio.fdopenStreamSync(fd, 'wb+');1118      expect(ss !== null).assertTrue();1119      expect(ss.closeSync() !== null).assertTrue();1120      expect(fileio.unlinkSync(fpath) !== null).assertTrue();1121    }1122    catch (e) {1123      console.log('fileio_test_stream_fdopen_stream_sync_021 has failed for ' + e);1124      expect(null).assertFail();1125    }1126  });1127  /**1128   * @tc.number SUB_STORAGE_FileIO_stream_FdopenStreamSync_22001129   * @tc.name fileio_test_stream_fdopen_stream_sync_0221130   * @tc.desc Function of API, mode=ab+. The test file is exist.1131   */1132  it('fileio_test_stream_fdopen_stream_sync_022', 0, async function () {1133    let fpath = await nextFileName('fileio_test_stream_fdopen_stream_sync_022');1134    expect(prepareFile(fpath, '1')).assertTrue();1135    let text = '0123456789abcdefg';1136    try {1137      let fd = fileio.openSync(fpath, 0o2002);1138      expect(fd !== null).assertTrue();1139      let ss = fileio.fdopenStreamSync(fd, 'ab+');1140      expect(ss !== null).assertTrue();1141      let wlen = ss.writeSync(text);1142      expect(wlen !== null).assertTrue();1143      expect(ss.closeSync() !== null).assertTrue();1144      expect(fileToReadOnly(fpath)).assertTrue();1145      ss = fileio.createStreamSync(fpath, 'r');1146      let rlen = ss.readSync(new ArrayBuffer(4096));1147      expect(rlen == text.length + 1).assertTrue();1148      expect(ss.closeSync() !== null).assertTrue();1149      expect(fileio.unlinkSync(fpath) !== null).assertTrue();1150    } 1151    catch (e) {1152      console.log('fileio_test_stream_fdopen_stream_sync_022 has failed for ' + e);1153      expect(null).assertFail();1154    }1155  });1156  /**1157   * @tc.number SUB_STORAGE_FileIO_stream_FdopenStreamSync_23001158   * @tc.name fileio_test_stream_fdopen_stream_sync_0231159   * @tc.desc Function of API, mode=ab+. The test file is not exist.1160   */1161  it('fileio_test_stream_fdopen_stream_sync_023', 0, async function () {1162    let fpath = await nextFileName('fileio_test_stream_fdopen_stream_sync_023');1163    try {1164      let fd = fileio.openSync(fpath, 0o102, 0o666);1165      let ss = fileio.fdopenStreamSync(fd, 'ab+');1166      expect(ss !== null).assertTrue();1167      expect(ss.closeSync() !== null).assertTrue();1168      expect(fileio.unlinkSync(fpath) !== null).assertTrue();1169    }1170    catch (e) {1171      console.log('fileio_test_stream_fdopen_stream_sync_023 has failed for ' + e);1172      expect(null).assertFail();1173    }1174  });1175  /**1176   * @tc.number SUB_STORAGE_FileIO_stream_FdopenStreamSync_24001177   * @tc.name fileio_test_stream_fdopen_stream_sync_0241178   * @tc.desc Function of API, invalid fields. The test file is not exist.1179   */1180  it('fileio_test_stream_fdopen_stream_sync_024', 0, async function () {1181    try {1182      expect(fileio.fdopenStreamSync(null, 'r') == null).assertTrue();1183      expect(null).assertFail();1184    } 1185    catch (e) {1186      console.log('---fileio_test_stream_fdopen_stream_sync_024 is passed!' + e);1187    }1188  });1189  /**1190   * @tc.number SUB_STORAGE_FileIO_stream_FdopenStreamSync_24001191   * @tc.name fileio_test_stream_fdopen_stream_sync_0251192   * @tc.desc Function of API, invalid mode. The test file is exist.1193   */1194  it('fileio_test_stream_fdopen_stream_sync_025', 0, async function () {1195    let fpath = await nextFileName('fileio_test_stream_fdopen_stream_sync_025');1196    expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();1197    try {1198      let fd = fileio.openSync(fpath, 0o2);1199      fileio.fdopenStreamSync(fd, '');1200      expect(null).assertFail();1201    } 1202    catch (e) {1203      console.log('---fileio_test_stream_fdopen_stream_sync_025 is passed!' + e);1204      expect(fileio.unlinkSync(fpath) !== null).assertTrue();1205    }1206  });1207  /**1208   * @tc.number SUB_STORAGE_FileIO_stream_ReadSync_00001209   * @tc.name fileio_test_stream_read_sync_0001210   * @tc.desc Function of API, not set options.1211   */1212  it('fileio_test_stream_read_sync_000', 0, async function () {1213    let fpath = await nextFileName('fileio_test_stream_read_sync_000');1214    let text = '0123456789abcdefg';1215    expect(prepareFile(fpath, text)).assertTrue();1216    try {1217      let ss = fileio.createStreamSync(fpath, 'r+');1218      expect(ss !== null).assertTrue();1219      let len = ss.readSync(new ArrayBuffer(4096));1220      expect(len == text.length).assertTrue();1221      expect(ss.closeSync() !== null).assertTrue();1222      expect(fileio.unlinkSync(fpath) !== null).assertTrue();1223    } 1224    catch (e) {1225      console.log('fileio_test_stream_read_sync_000 has failed for ' + e);1226      expect(null).assertFail();1227    }1228  });1229  /**1230   * @tc.number SUB_STORAGE_FileIO_stream_ReadSync_01001231   * @tc.name fileio_test_stream_read_sync_0011232   * @tc.desc Function of API, position.1233   */1234  it('fileio_test_stream_read_sync_001', 0, async function () {1235    let fpath = await nextFileName('fileio_test_stream_read_sync_001');1236    let text = '0123456789abcdefg';1237    expect(prepareFile(fpath, text)).assertTrue();1238    try {1239      let ss = fileio.createStreamSync(fpath, 'r+');1240      expect(ss !== null).assertTrue();1241      let len = ss.readSync(new ArrayBuffer(4096), {1242        position: 11243      });1244      expect(len == text.length - 1).assertTrue();1245      expect(ss.closeSync() !== null).assertTrue();1246      expect(fileio.unlinkSync(fpath) !== null).assertTrue();1247    } 1248    catch (e) {1249      console.log('fileio_test_stream_read_sync_001 has failed for ' + e);1250      expect(null).assertFail();1251    }1252  });1253  /**1254   * @tc.number SUB_STORAGE_FileIO_stream_ReadSync_02001255   * @tc.name fileio_test_stream_read_sync_0021256   * @tc.desc Function of API, offset.1257   */1258  it('fileio_test_stream_read_sync_002', 0, async function () {1259    let fpath = await nextFileName('fileio_test_stream_read_sync_002');1260    let text = '0123456789abcdefg';1261    expect(prepareFile(fpath, text)).assertTrue();1262    try {1263      let ss = fileio.createStreamSync(fpath, 'r+');1264      expect(ss !== null).assertTrue();1265      let len = ss.readSync(new ArrayBuffer(4096), {1266        offset: 11267      });1268      expect(len == text.length).assertTrue();1269      expect(ss.closeSync() !== null).assertTrue();1270      expect(fileio.unlinkSync(fpath) !== null).assertTrue();1271    } 1272    catch (e) {1273      console.log('fileio_test_stream_read_sync_002 has failed for ' + e);1274      expect(null).assertFail();1275    }1276  });1277  /**1278   * @tc.number SUB_STORAGE_FileIO_stream_ReadSync_03001279   * @tc.name fileio_test_stream_read_sync_0031280   * @tc.desc Function of API, length.1281   */1282  it('fileio_test_stream_read_sync_003', 0, async function () {1283    let fpath = await nextFileName('fileio_test_stream_read_sync_003');1284    expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();1285    try {1286      let ss = fileio.createStreamSync(fpath, 'r+');1287      expect(ss !== null).assertTrue();1288      let len = ss.readSync(new ArrayBuffer(4096), {1289        length: 11290      });1291      expect(len == 1).assertTrue();1292      expect(ss.closeSync() !== null).assertTrue();1293      expect(fileio.unlinkSync(fpath) !== null).assertTrue();1294    } 1295    catch (e) {1296      console.log('fileio_test_stream_read_sync_003 has failed for ' + e);1297      expect(null).assertFail();1298    }1299  });1300  /**1301   * @tc.number SUB_STORAGE_FileIO_stream_ReadSync_04001302   * @tc.name fileio_test_stream_read_sync_0041303   * @tc.desc Function of API, readBuf.1304   */1305  it('fileio_test_stream_read_sync_004', 0, async function () {1306    let fpath = await nextFileName('fileio_test_stream_read_sync_004');1307    expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();1308    try {1309      var ss = fileio.createStreamSync(fpath, 'r+');1310      expect(ss !== null).assertTrue();1311      let len = ss.readSync(null);1312      expect(len == null).assertTrue();1313      expect(null).assertFail();1314    } 1315    catch (e) {1316      console.log('fileio_test_stream_read_sync_004 has failed for ' + e);1317      expect(ss.closeSync() !== null).assertTrue();1318      expect(fileio.unlinkSync(fpath) !== null).assertTrue();1319    }1320  });1321  /**1322   * @tc.number SUB_STORAGE_FileIO_stream_ReadSync_05001323   * @tc.name fileio_test_stream_read_sync_0051324   * @tc.desc Function of API, position = -1.1325   */1326  it('fileio_test_stream_read_sync_005', 0, async function () {1327    let fpath = await nextFileName('fileio_test_stream_read_sync_005');1328    let text = '0123456789abcdefg';1329    expect(prepareFile(fpath, text)).assertTrue();1330    try {1331      var ss = fileio.createStreamSync(fpath, 'r+');1332      expect(ss !== null).assertTrue();1333      let len = ss.readSync(new ArrayBuffer(4096), {1334        position: -11335      });1336      expect(len == text.length).assertTrue();1337      expect(ss.closeSync() !== null).assertTrue();1338      expect(fileio.unlinkSync(fpath) !== null).assertTrue();1339    } 1340    catch (e) {1341      console.log('---fileio_test_stream_read_sync_005 has failed for ' + e);1342      expect(null).assertFail();1343    }1344  });1345  /**1346   * @tc.number SUB_STORAGE_FileIO_stream_ReadSync_06001347   * @tc.name fileio_test_stream_read_sync_0061348   * @tc.desc Function of API, offset.1349   */1350  it('fileio_test_stream_read_sync_006', 0, async function () {1351    let fpath = await nextFileName('fileio_test_stream_read_sync_006');1352    expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();1353    try {1354      var ss = fileio.createStreamSync(fpath, 'r+');1355      expect(ss !== null).assertTrue();1356      let len = ss.readSync(new ArrayBuffer(4096), {1357        offset: -11358     });1359      expect(len == null).assertTrue();1360      expect(null).assertFail();1361    } 1362    catch (e) {1363      console.log('fileio_test_stream_read_sync_006 has failed for ' + e);1364      expect(ss.closeSync() !== null).assertTrue();1365      expect(fileio.unlinkSync(fpath) !== null).assertTrue();1366    }1367  });1368  /**1369   * @tc.number SUB_STORAGE_FileIO_stream_WriteSync_00001370   * @tc.name fileio_test_stream_write_sync_0001371   * @tc.desc Function of API, not set options.1372   */1373  it('fileio_test_stream_write_sync_000', 0, async function () {1374    let fpath = await nextFileName('fileio_test_stream_write_sync_000');1375    expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();1376    let text = '0123456789abcdefg';1377    try {1378      let ss = fileio.createStreamSync(fpath, 'r+');1379      expect(ss !== null).assertTrue();1380      expect(ss.writeSync(text) == text.length).assertTrue();1381      expect(ss.closeSync() !== null).assertTrue();1382      expect(fileio.unlinkSync(fpath) !== null).assertTrue();1383      console.log('---fileio_test_stream_write_sync_000 is passed!');1384    } 1385    catch (e) {1386      console.log('fileio_test_stream_write_sync_000 has failed for ' + e);1387      expect(null).assertFail();1388    }1389  });1390  /**1391   * @tc.number SUB_STORAGE_FileIO_stream_WriteSync_01001392   * @tc.name fileio_test_stream_write_sync_0011393   * @tc.desc Function of API, invalid encoding.1394   */1395  it('fileio_test_stream_write_sync_001', 0, async function () {1396    let fpath = await nextFileName('fileio_test_stream_write_sync_001');1397    expect(prepareFile(fpath, '')).assertTrue();1398    let ss1399    try {1400      ss = fileio.createStreamSync(fpath, 'w+');1401      expect(ss !== null).assertTrue();1402      expect(ss.writeSync(FILE_CONTENT, {1403        encoding: 'ASCII'1404      }) !== null).assertTrue();1405      expect(null).assertFail();1406    } 1407    catch (e) {1408      console.log('fileio_test_stream_write_sync_001 has failed for ' + e);1409      expect(ss.closeSync() !== null).assertTrue();1410      expect(fileio.unlinkSync(fpath) !== null).assertTrue();1411    }1412  });1413  /**1414   * @tc.number SUB_STORAGE_FileIO_stream_WriteSync_02001415   * @tc.name fileio_test_stream_write_sync_0021416   * @tc.desc Function of API, position.1417   */1418  it('fileio_test_stream_write_sync_002', 0, async function () {1419    let fpath = await nextFileName('fileio_test_stream_write_sync_002');1420    expect(prepareFile(fpath, 'a')).assertTrue();1421    expect(fileToWriteOnly(fpath)).assertTrue();1422    try {1423      let fd = fileio.openSync(fpath, 0o001);1424      expect(fd !== null).assertTrue();1425      let ss = fileio.fdopenStreamSync(fd, 'w');1426      expect(ss !== null).assertTrue();1427      expect(ss.writeSync('aaa') !== null).assertTrue();1428      expect(ss.closeSync() !== null).assertTrue();1429      expect(fileToReadOnly(fpath)).assertTrue();1430      ss = fileio.createStreamSync(fpath, 'r');1431      let rlen = ss.readSync(new ArrayBuffer(4096));1432      expect(rlen == 3).assertTrue();1433      expect(ss.closeSync() !== null).assertTrue();1434      expect(fileio.unlinkSync(fpath) !== null).assertTrue();1435    } 1436    catch (e) {1437      console.log('fileio_test_stream_write_sync_002 has failed for ' + e);1438      expect(null).assertFail();1439    }1440  });1441  /**1442   * @tc.number SUB_STORAGE_FileIO_stream_WriteSync_03001443   * @tc.name fileio_test_stream_write_sync_0031444   * @tc.desc Function of API, offset.1445   */1446  it('fileio_test_stream_write_sync_003', 0, async function () {1447    let fpath = await nextFileName('fileio_test_stream_write_sync_003');1448    expect(prepareFile(fpath, 'a')).assertTrue();1449    expect(fileToWriteOnly(fpath)).assertTrue();1450    try {1451      let fd = fileio.openSync(fpath, 0o001);1452      expect(fd !== null).assertTrue();1453      let ss = fileio.fdopenStreamSync(fd, 'w');1454      expect(ss !== null).assertTrue();1455      expect(ss.writeSync('aaa') !== null).assertTrue();1456      expect(ss.closeSync() !== null).assertTrue();1457      expect(fileToReadOnly(fpath)).assertTrue();1458      ss = fileio.createStreamSync(fpath, 'r');1459      let rlen = ss.readSync(new ArrayBuffer(4096));1460      expect(rlen == 3).assertTrue();1461      expect(ss.closeSync() !== null).assertTrue();1462      expect(fileio.unlinkSync(fpath) !== null).assertTrue();1463    } 1464    catch (e) {1465      console.log('fileio_test_stream_write_sync_003 has failed for ' + e);1466      expect(null).assertFail();1467    }1468  });1469  /**1470   * @tc.number SUB_STORAGE_FileIO_stream_WriteSync_04001471   * @tc.name fileio_test_stream_write_sync_0041472   * @tc.desc Function of API, length.1473   */1474  it('fileio_test_stream_write_sync_004', 0, async function () {1475    let fpath = await nextFileName('fileio_test_stream_write_sync_004');1476    expect(prepareFile(fpath, 'a')).assertTrue();1477    let text = '0123456789abcdefg';1478    try {1479      let ss = fileio.createStreamSync(fpath, 'r+');1480      expect(ss !== null).assertTrue();1481      let wlen = ss.writeSync(text);1482      expect(wlen == text.length).assertTrue();1483      expect(ss.closeSync() !== null).assertTrue();1484      ss = fileio.createStreamSync(fpath, 'r+');1485      let rlen = ss.readSync(new ArrayBuffer(4096));1486      expect(rlen == text.length).assertTrue();1487      expect(ss.closeSync() !== null).assertTrue();1488      expect(fileio.unlinkSync(fpath) !== null).assertTrue();1489    } 1490    catch (e) {1491      console.log('fileio_test_stream_write_sync_004 has failed for ' + e);1492      expect(null).assertFail();1493    }1494  });1495  /**1496   * @tc.number SUB_STORAGE_FileIO_stream_WriteSync_05001497   * @tc.name fileio_test_stream_write_sync_0051498   * @tc.desc Function of API, encoding.1499   */1500  it('fileio_test_stream_write_sync_005', 0, async function () {1501    let fpath = await nextFileName('fileio_test_stream_write_sync_005');1502    expect(prepareFile(fpath, '')).assertTrue();1503    let writeStrArray = new Array('aaa', '123');1504    let encodingArray = new Array('utf-8', 'utf-16');1505    try {1506      for (let i = 0; i < encodingArray.length; i++) {1507        let ss = fileio.createStreamSync(fpath, 'w+');1508        expect(ss !== null).assertTrue();1509        expect(ss.writeSync(writeStrArray[i], {1510          encoding: encodingArray[i]1511        }) !== null).assertTrue();1512        expect(ss.closeSync() !== null).assertTrue();1513        ss = fileio.createStreamSync(fpath, 'r+');1514        let rlen = ss.readSync(new ArrayBuffer(4096));1515        expect(rlen !== null).assertTrue();1516        expect(ss.closeSync() !== null).assertTrue();1517      }1518      expect(fileio.unlinkSync(fpath) !== null).assertTrue();1519    }1520    catch (e) {1521      console.log('fileio_test_stream_write_sync_005 has failed for ' + e);1522      expect(fileio.unlinkSync(fpath) !== null).assertTrue();1523      expect(null).assertFail();1524    }1525  });1526  /**1527   * @tc.number SUB_STORAGE_FileIO_stream_WriteSync_06001528   * @tc.name fileio_test_stream_write_sync_0061529   * @tc.desc Function of API, position.1530   */1531  it('fileio_test_stream_write_sync_006', 0, async function () {1532    let fpath = await nextFileName('fileio_test_stream_write_sync_006');1533    expect(prepareFile(fpath, 'a')).assertTrue();1534    expect(fileToWriteOnly(fpath)).assertTrue();1535    try {1536      let fd = fileio.openSync(fpath, 0o001);1537      expect(fd !== null).assertTrue();1538      let ss = fileio.fdopenStreamSync(fd, 'w');1539      expect(ss !== null).assertTrue();1540      expect(ss.writeSync('aaa', {1541        position: 11542      }) !== null).assertTrue();1543      expect(ss.closeSync() !== null).assertTrue();1544      expect(fileToReadOnly(fpath)).assertTrue();1545      ss = fileio.createStreamSync(fpath, 'r');1546      let rlen = ss.readSync(new ArrayBuffer(4096));1547      expect(rlen == 4).assertTrue();1548      expect(ss.closeSync() !== null).assertTrue();1549      expect(fileio.unlinkSync(fpath) !== null).assertTrue();1550    } 1551    catch (e) {1552      console.log('fileio_test_stream_write_sync_006 has failed for ' + e);1553      expect(null).assertFail();1554    }1555  });1556  /**1557   * @tc.number SUB_STORAGE_FileIO_stream_WriteSync_07001558   * @tc.name fileio_test_stream_write_sync_0071559   * @tc.desc Function of API, offset.1560   */1561  it('fileio_test_stream_write_sync_007', 0, async function () {1562    let fpath = await nextFileName('fileio_test_stream_write_sync_007');1563    expect(prepareFile(fpath, 'a')).assertTrue();1564    expect(fileToWriteOnly(fpath)).assertTrue();1565    try {1566      let fd = fileio.openSync(fpath, 0o001);1567      expect(fd !== null).assertTrue();1568      let ss = fileio.fdopenStreamSync(fd, 'w');1569      expect(ss !== null).assertTrue();1570      expect(ss.writeSync('aaa', {1571        offset: 11572      }) !== null).assertTrue();1573      expect(ss.closeSync() !== null).assertTrue();1574      expect(fileToReadOnly(fpath)).assertTrue();1575      ss = fileio.createStreamSync(fpath, 'r');1576      let rlen = ss.readSync(new ArrayBuffer(4096));1577      expect(rlen == 2).assertTrue();1578      expect(ss.closeSync() !== null).assertTrue();1579      expect(fileio.unlinkSync(fpath) !== null).assertTrue();1580    } 1581    catch (e) {1582      console.log('fileio_test_stream_write_sync_007 has failed for ' + e);1583      expect(null).assertFail();1584    }1585  });1586  /**1587   * @tc.number SUB_STORAGE_FileIO_stream_WriteSync_08001588   * @tc.name fileio_test_stream_write_sync_0081589   * @tc.desc Function of API, length.1590   */1591  it('fileio_test_stream_write_sync_008', 0, async function () {1592    let fpath = await nextFileName('fileio_test_stream_write_sync_008');1593    expect(prepareFile(fpath, '')).assertTrue();1594    let text = '0123456789abcdefg';1595    try {1596      let ss = fileio.createStreamSync(fpath, 'r+');1597      expect(ss !== null).assertTrue();1598      let wlen = ss.writeSync(text, {1599        length: text.length1600      });1601      expect(wlen == text.length).assertTrue();1602      expect(ss.closeSync() !== null).assertTrue();1603      ss = fileio.createStreamSync(fpath, 'r+');1604      let rlen = ss.readSync(new ArrayBuffer(4096));1605      expect(rlen == text.length).assertTrue();1606      expect(ss.closeSync() !== null).assertTrue();1607      expect(fileio.unlinkSync(fpath) !== null).assertTrue();1608    } 1609    catch (e) {1610      console.log('fileio_test_stream_write_sync_008 has failed for ' + e);1611      expect(null).assertFail();1612    }1613  });1614  /**1615   * @tc.number SUB_STORAGE_FileIO_stream_WriteSync_09001616   * @tc.name fileio_test_stream_write_sync_0091617   * @tc.desc Function of API, invalid fcontent.1618   */1619  it('fileio_test_stream_write_sync_009', 0, async function () {1620    let fpath = await nextFileName('fileio_test_stream_write_sync_009');1621    expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();1622    try {1623      var ss = fileio.createStreamSync(fpath, 'r+');1624      expect(ss !== null).assertTrue();1625      ss.writeSync(-1);1626      expect(null).assertFail();1627    } 1628    catch (e) {1629      expect(fileio.unlinkSync(fpath) !== null).assertTrue();1630      console.log('fileio_test_stream_write_sync_009 has failed for ' + e);1631    }1632  });1633  /**1634   * @tc.number SUB_STORAGE_FileIO_stream_WriteSync_10001635   * @tc.name fileio_test_stream_write_sync_0101636   * @tc.desc Function of API, invalid encoding.1637   */1638  it('fileio_test_stream_write_sync_010', 0, async function () {1639    let fpath = await nextFileName('fileio_test_stream_write_sync_010');1640    expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();1641    try {1642      var ss = fileio.createStreamSync(fpath, 'r+');1643      expect(ss !== null).assertTrue();1644      expect(ss.writeSync(FILE_CONTENT, {1645        encoding: ''1646      }) == null).assertTrue();1647      expect(null).assertFail();1648    } 1649    catch (e) {1650      console.log('fileio_test_stream_write_sync_010 has failed for ' + e);1651      expect(ss.closeSync() !== null).assertTrue();1652      expect(fileio.unlinkSync(fpath) !== null).assertTrue();1653    }1654  });1655  /**1656   * @tc.number SUB_STORAGE_FileIO_stream_WriteSync_11001657   * @tc.name fileio_test_stream_write_sync_0111658   * @tc.desc Function of API, invalid position.1659   */1660  it('fileio_test_stream_write_sync_011', 0, async function () {1661    let fpath = await nextFileName('fileio_test_stream_write_sync_011');1662    expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();1663    try {1664      var ss = fileio.createStreamSync(fpath, 'r+');1665      expect(ss !== null).assertTrue();1666      expect(ss.writeSync(FILE_CONTENT, {1667        position: -11668      }) == null).assertTrue();1669      expect(null).assertFail();1670    } 1671    catch (e) {1672      console.log('fileio_test_stream_write_sync_011 has failed for ' + e);1673      expect(ss.closeSync() !== null).assertTrue();1674      expect(fileio.unlinkSync(fpath) !== null).assertTrue();1675    }1676  });1677  /**1678   * @tc.number SUB_STORAGE_FileIO_stream_WriteSync_12001679   * @tc.name fileio_test_stream_write_sync_0121680   * @tc.desc Function of API, invalid offset.1681   */1682  it('fileio_test_stream_write_sync_012', 0, async function () {1683    let fpath = await nextFileName('fileio_test_stream_write_sync_012');1684    expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();1685    try {1686      var ss = fileio.createStreamSync(fpath, 'r+');1687      expect(ss !== null).assertTrue();1688      expect(ss.writeSync(FILE_CONTENT, {1689        offset: -11690      }) == null).assertTrue();1691      expect(null).assertFail();1692    } 1693    catch (e) {1694      console.log('fileio_test_stream_write_sync_012 has failed for ' + e);1695      expect(ss.closeSync() !== null).assertTrue();1696      expect(fileio.unlinkSync(fpath) !== null).assertTrue();1697    }1698  });1699  /**1700   * @tc.number SUB_STORAGE_FileIO_stream_WriteSync_13001701   * @tc.name fileio_test_stream_write_sync_0131702   * @tc.desc Function of API, Set all parameters.1703   */1704  it('fileio_test_stream_write_sync_013', 0, async function () {1705    let fpath = await nextFileName('fileio_test_stream_write_sync_013');1706    expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();1707    let text = '0123456789abcdefg';1708    try {1709      let ss = fileio.createStreamSync(fpath, 'r+');1710      expect(ss !== null).assertTrue();1711      expect(ss.writeSync(text, {1712        encoding: 'utf-8',1713        position: 0,1714        offset: 1,1715        length: 1,1716      }) == 1).assertTrue();1717      expect(ss.closeSync() !== null).assertTrue();1718      expect(fileio.unlinkSync(fpath) !== null).assertTrue();1719      console.log('---fileio_test_stream_write_sync_013 is passed!');1720    } 1721    catch (e) {1722      console.log('fileio_test_stream_write_sync_013 has failed for ' + e);1723      expect(null).assertFail();1724    }1725  });1726  /**1727   * @tc.number SUB_STORAGE_FileIO_stream_WriteSync_14001728   * @tc.name fileio_test_stream_write_sync_0141729   * @tc.desc Function of API, Set all parameters.1730   */1731  it('fileio_test_stream_write_sync_014', 0, async function () {1732    let fpath = await nextFileName('fileio_test_stream_write_sync_014');1733    expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();1734    let text = '0123456789abcdefg';1735    try {1736      let ss = fileio.createStreamSync(fpath, 'r+');1737      expect(ss !== null).assertTrue();1738      expect(ss.writeSync(text, {1739        offset: 2,1740        length: 2,1741      }) == 2).assertTrue();1742      expect(ss.closeSync() !== null).assertTrue();1743      expect(fileio.unlinkSync(fpath) !== null).assertTrue();1744      console.log('---fileio_test_stream_write_sync_014 is passed!');1745    } 1746    catch (e) {1747      console.log('fileio_test_stream_write_sync_014 has failed for ' + e);1748      expect(null).assertFail();1749    }1750  });1751  /**1752   * @tc.number SUB_STORAGE_FileIO_stream_write_read_4k_sync1753   * @tc.name fileio_test_stream_write_read_4k_sync1754   * @tc.desc Function of API, read 4k file.1755   */1756  it('fileio_test_stream_write_read_4k_sync', 0, async function () {1757    let fpath = await nextFileName('fileio_test_stream_write_read_4k_sync');1758    expect(prepareFile(fpath, 'a')).assertTrue();1759    expect(fileToWriteOnly(fpath)).assertTrue();1760    try {1761      let fd = fileio.openSync(fpath, 0o001);1762      expect(fd !== null).assertTrue();1763      let ss = fileio.fdopenStreamSync(fd, 'w');1764      expect(ss !== null).assertTrue();1765      expect(ss.writeSync(randomString(4096)) !== null).assertTrue();1766      expect(ss.closeSync() !== null).assertTrue();1767      expect(fileToReadOnly(fpath)).assertTrue();1768      ss = fileio.createStreamSync(fpath, 'r');1769      let rlen = ss.readSync(new ArrayBuffer(4096));1770      expect(ss.closeSync() !== null).assertTrue();1771      expect(fileio.unlinkSync(fpath) !== null).assertTrue();1772    } 1773    catch (e) {1774      console.log('fileio_test_stream_write_read_4k_sync has failed for ' + e);1775      expect(null).assertFail();1776    }1777  });1778  /**1779   * @tc.number SUB_STORAGE_FileIO_stream_FlushSync_00001780   * @tc.name fileio_test_stream_flush_sync_0001781   * @tc.desc Function of API, flushSync.1782   */1783  it('fileio_test_stream_flush_sync_000', 0, async function () {1784    let fpath = await nextFileName('fileio_test_stream_flush_sync_000');1785    expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();1786    let text = '0123456789abcdefg';1787    try {1788      let ss = fileio.createStreamSync(fpath, 'r+');1789      expect(ss !== null).assertTrue();1790      expect(ss.writeSync(text) == text.length).assertTrue();1791      expect(ss.flushSync() !== null).assertTrue();1792      expect(ss.closeSync() !== null).assertTrue();1793      expect(fileio.unlinkSync(fpath) !== null).assertTrue();1794    } 1795    catch (e) {1796      console.log('fileio_test_stream_flush_sync_001 has failed for ' + e);1797      expect(null).assertFail();1798    }1799  });1800  /**1801   * @tc.number SUB_STORAGE_FileIO_stream_FlushSync_01001802   * @tc.name fileio_test_stream_flush_sync_0011803   * @tc.desc Function of API, error.1804   */1805  it('fileio_test_stream_flush_sync_001', 0, async function () {1806    let fpath = await nextFileName('fileio_test_stream_flush_sync_001');1807    expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();1808    try {1809      let ss = fileio.createStreamSync(fpath, 'r+');1810      expect(ss !== null).assertTrue();1811      expect(ss.closeSync() !== null).assertTrue();1812      ss.flushSync();1813      expect(null).assertFail();1814    } 1815    catch (e) {1816      console.log('fileio_test_stream_flush_sync_001 has failed for ' + e);1817      expect(fileio.unlinkSync(fpath) !== null).assertTrue();1818    }1819  });1820  /**1821   * @tc.number SUB_STORAGE_FileIO_stream_CloseSync_00001822   * @tc.name fileio_test_stream_close_sync_0001823   * @tc.desc Function of API, closeSync.1824   */1825  it('fileio_test_stream_close_sync_000', 0, async function () {1826    let fpath = await nextFileName('fileio_test_stream_close_sync_000');1827    expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();1828    try {1829      let ss = fileio.createStreamSync(fpath, 'r+');1830      expect(ss.closeSync() !== null).assertTrue();1831      expect(fileio.unlinkSync(fpath) !== null).assertTrue();1832    } 1833    catch (e) {1834      console.log('fileio_test_stream_close_sync_000 has failed for ' + e);1835      expect(null).assertFail();1836    }1837  });1838  /**1839   * @tc.number SUB_STORAGE_FileIO_stream_CloseSync_01001840   * @tc.name fileio_test_stream_close_sync_0011841   * @tc.desc Function of API, error.1842   */1843  it('fileio_test_stream_close_sync_001', 0, async function () {1844    let fpath = await nextFileName('fileio_test_stream_close_sync_001');1845    expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();1846    let ss;1847    try {1848      ss = fileio.createStreamSync(fpath, 'r+');1849      expect(ss.closeSync() !== null).assertTrue();1850      expect(ss.closeSync() == null).assertTrue();1851      expect(null).assertFail();1852    } 1853    catch (e) {1854      expect(fileio.unlinkSync(fpath) !== null).assertTrue();1855      console.log('fileio_test_stream_close_sync_001 has failed for ' + e);1856    }1857  });...links.js
Source:links.js  
1export const links = [2  { fpath: "IMG_0626.JPEG" },3  { fpath: "IMG_0620.JPEG" },4  { fpath: "IMG_0644.JPEG" },5  { fpath: "IMG_0622.JPEG" },6  { fpath: "IMG_0598.JPEG" },7  { fpath: "IMG_0643.JPEG" },8  { fpath: "IMG_0637.JPEG" },9  { fpath: "IMG_0617.JPEG" },10  { fpath: "IMG_0645.JPEG" },11  { fpath: "IMG_0642.JPEG" },12  { fpath: "IMG_0632.JPEG" },13  { fpath: "IMG_0640.JPEG" },14  { fpath: "IMG_0631.JPEG" },15  { fpath: "IMG_0633.JPEG" },16  { fpath: "IMG_0625.JPEG" },17  { fpath: "IMG_0592.JPEG" },18  { fpath: "IMG_0584.JPEG" },19  { fpath: "IMG_0585.JPEG" },20  { fpath: "IMG_0582.JPEG" },21  { fpath: "addcfc29adc8d237b21c44926784f542.jpg" },22  { fpath: "IMG_0561.JPEG" },23  { fpath: "IMG_0328.PNG" },24  { fpath: "b0daf80b71602c00bf644c395eaee705.jpg" },25  { fpath: "IMG_0472.JPEG" },26  { fpath: "IMG_0527.JPEG" },27  { fpath: "IMG_0523.JPEG" },28  { fpath: "IMG_0514.JPEG" },29  { fpath: "IMG_0475.JPEG" },30  { fpath: "IMG_0528.JPEG" },31  { fpath: "IMG_0517.JPEG" },32  { fpath: "IMG_0518.JPEG" },33  { fpath: "IMG_0521.JPEG" },34  { fpath: "IMG_0529.JPEG" },35  { fpath: "IMG_0522.JPEG" },36  { fpath: "IMG_0476.JPEG" },37  { fpath: "IMG_0398.JPEG" },38  { fpath: "IMG_0419.JPEG" },39  { fpath: "IMG_0431.JPEG" },40  { fpath: "IMG_0373.JPEG" },41  { fpath: "IMG_0494.JPEG" },42  { fpath: "IMG_0404.JPEG" },43  { fpath: "IMG_0406.JPEG" },44  { fpath: "IMG_0427.JPEG" },45  { fpath: "IMG_0438.JPEG" },46  { fpath: "IMG_0489.JPEG" },47  { fpath: "IMG_0434.JPEG" },48  { fpath: "IMG_0418.JPEG" },49  { fpath: "IMG_0453.JPEG" },50  { fpath: "IMG_0414.JPEG" },51  { fpath: "IMG_0446.JPEG" },52  { fpath: "IMG_0461.JPEG" },53  { fpath: "IMG_0393.JPEG" },54  { fpath: "IMG_0505.JPEG" },55  { fpath: "IMG_0512.JPEG" },56  { fpath: "IMG_0500.JPEG" },57  { fpath: "IMG_0425.JPEG" },58  { fpath: "IMG_0492.JPEG" },59  { fpath: "IMG_0428.JPEG" },60  { fpath: "IMG_0371.JPEG" },61  { fpath: "IMG_0366.JPEG" },62  { fpath: "IMG_0317.JPEG" },63  { fpath: "IMG_0359.JPEG" },64  { fpath: "IMG_0336.JPEG" },65  { fpath: "IMG_0271.JPEG" },66  { fpath: "IMG_0337.JPEG" },67  { fpath: "IMG_0308.JPEG" },68  { fpath: "IMG_0318.JPEG" },69  { fpath: "IMG_0323.JPEG" },70  { fpath: "IMG_0327.JPEG" },71  { fpath: "IMG_0326.JPEG" },72  { fpath: "IMG_0305.JPEG" },73  { fpath: "IMG_0303.JPEG" },74  { fpath: "IMG_0353.JPEG" },75  { fpath: "IMG_0320.JPEG" },76  { fpath: "IMG_0325.JPEG" },77  { fpath: "IMG_0309.JPEG" },78  { fpath: "IMG_0285.JPEG" },79  { fpath: "IMG_0121.JPEG" },80  { fpath: "IMG_0102.JPEG" },81  { fpath: "IMG_0111.JPEG" },82  { fpath: "IMG_0292.JPEG" },83  { fpath: "IMG_0181.JPEG" },84  { fpath: "IMG_0197.JPEG" },85  { fpath: "IMG_0276.JPEG" },86  { fpath: "IMG_0288.JPEG" },87  { fpath: "IMG_0283.JPEG" },88  { fpath: "IMG_0183.JPEG" },89  { fpath: "IMG_0110.JPEG" },90  { fpath: "IMG_0182.JPEG" },91  { fpath: "IMG_0093.JPEG" },92  { fpath: "IMG_0175.JPG" },93  { fpath: "IMG_0209.JPEG" },94  { fpath: "IMG_0230.JPEG" },95  { fpath: "IMG_0072.JPEG" },96  { fpath: "IMG_0061.JPEG" },97  { fpath: "IMG_0053.PNG" },98  { fpath: "IMG_0179.JPEG" },99  { fpath: "IMG_0076.JPEG" },100  { fpath: "IMG_0141.JPG" },101  { fpath: "IMG_0226.JPEG" },102  { fpath: "IMG_0050.JPG" },103  { fpath: "IMG_0247.JPEG" },104  { fpath: "IMG_0099.JPEG" },105  { fpath: "IMG_0180.JPEG" },106  { fpath: "IMG_0139.JPG" },107  { fpath: "IMG_0177.JPG" },108  { fpath: "f3d44643f0249955b0684c1923f21ca7.jpg" },109  { fpath: "IMG_0143.JPG" },110  { fpath: "IMG_0120.JPEG" },111  { fpath: "IMG_0116.JPG" },112  { fpath: "IMG_0071.JPEG" },113  { fpath: "IMG_0131.JPG" },114  { fpath: "IMG_0064.JPG" },115  { fpath: "IMG_0069.JPG" },116  { fpath: "IMG_0038.JPG" },117  { fpath: "IMG_0144.JPG" },118  { fpath: "a51ea616d4256fe8757b6d46000e452b.jpg" },119  { fpath: "IMG_0138.JPG" },120  { fpath: "beauty_1624185453275.jpeg" },121  { fpath: "IMG_0133.JPG" },122  { fpath: "IMG_0630.JPEG" },123  { fpath: "IMG_0612.JPEG" },124  { fpath: "DSC_3444.jpg" },125  { fpath: "4e5d19284b5911e2484c19770cea7f7f.jpg" },126  { fpath: "IMG_0027.JPG" },127  { fpath: "IMG_0624.JPEG" },128  { fpath: "IMG_0634.JPEG" },129  { fpath: "IMG_0641.JPEG" },130  { fpath: "IMG_0635.JPEG" },131  { fpath: "IMG_0602.JPEG" },132  { fpath: "IMG_0597.JPEG" },133  { fpath: "IMG_0603.PNG" },134  { fpath: "IMG_0577.JPEG" },135  { fpath: "IMG_0594.JPG" },136  { fpath: "IMG_0575.JPEG" },137  { fpath: "IMG_0580.JPEG" },138  { fpath: "IMG_0593.JPEG" },139  { fpath: "IMG_0588.JPEG" },140  { fpath: "IMG_0578.JPEG" },141  { fpath: "IMG_0576.JPEG" },142  { fpath: "1849a007ee77eff86bbeba8b19b78b7b.jpg" },143  { fpath: "IMG_0515.JPEG" },144  { fpath: "IMG_0473.JPEG" },145  { fpath: "IMG_0483.JPEG" },146  { fpath: "IMG_0520.JPEG" },147  { fpath: "IMG_0479.JPEG" },148  { fpath: "a61bcd03bdcec01dd966e67572773d07.jpg" },149  { fpath: "d78e232cd4a3cfba0e4530772ef35075.jpg" },150  { fpath: "IMG_0562.JPEG" },151  { fpath: "IMG_0480.JPEG" },152  { fpath: "IMG_0508.JPEG" },153  { fpath: "IMG_0486.JPEG" },154  { fpath: "IMG_0511.JPEG" },155  { fpath: "IMG_0478.JPEG" },156  { fpath: "IMG_0564.JPEG" },157  { fpath: "IMG_0526.JPEG" },158  { fpath: "IMG_0459.JPEG" },159  { fpath: "IMG_0502.JPEG" },160  { fpath: "IMG_0464.JPEG" },161  { fpath: "IMG_0454.JPEG" },162  { fpath: "IMG_0440.JPEG" },163  { fpath: "IMG_0449.JPEG" },164  { fpath: "IMG_0456.JPEG" },165  { fpath: "IMG_0451.JPEG" },166  { fpath: "IMG_0462.JPEG" },167  { fpath: "IMG_0491.JPEG" },168  { fpath: "IMG_0455.JPEG" },169  { fpath: "IMG_0493.JPEG" },170  { fpath: "IMG_0457.JPEG" },171  { fpath: "IMG_0506.JPEG" },172  { fpath: "IMG_0497.JPEG" },173  { fpath: "IMG_0369.JPEG" },174  { fpath: "IMG_0442.PNG" },175  { fpath: "IMG_0410.JPEG" },176  { fpath: "IMG_0391.JPEG" },177  { fpath: "IMG_0413.JPEG" },178  { fpath: "IMG_0415.JPEG" },179  { fpath: "IMG_0412.JPEG" },180  { fpath: "IMG_0389.JPEG" },181  { fpath: "IMG_0417.JPEG" },182  { fpath: "IMG_0416.JPEG" },183  { fpath: "IMG_0386.JPEG" },184  { fpath: "IMG_0430.JPEG" },185  { fpath: "IMG_0422.JPEG" },186  { fpath: "IMG_0433.JPEG" },187  { fpath: "IMG_0426.JPEG" },188  { fpath: "IMG_0409.JPEG" },189  { fpath: "IMG_0390.JPEG" },190  { fpath: "IMG_0378.JPEG" },191  { fpath: "IMG_0381.JPEG" },192  { fpath: "IMG_0385.JPEG" },193  { fpath: "IMG_0365.JPEG" },194  { fpath: "IMG_0379.JPEG" },195  { fpath: "IMG_0367.JPEG" },196  { fpath: "IMG_0380.JPEG" },197  { fpath: "IMG_0319.JPEG" },198  { fpath: "IMG_0360.JPEG" },199  { fpath: "IMG_0252.JPEG" },200  { fpath: "IMG_0294.JPEG" },201  { fpath: "IMG_0314.JPEG" },202  { fpath: "beauty_1627971157311.jpeg" },203  { fpath: "f7bbb5240bcf552c547c818bb323a719.jpg" },204  { fpath: "IMG_0338.JPEG" },205  { fpath: "beauty_1627971161260.jpeg" },206  { fpath: "IMG_0307.JPEG" },207  { fpath: "IMG_0312.JPEG" },208  { fpath: "beauty_1627971159610.jpeg" },209  { fpath: "IMG_0355.JPEG" },210  { fpath: "IMG_0311.JPEG" },211  { fpath: "IMG_0324.JPEG" },212  { fpath: "IMG_0313.JPEG" },213  { fpath: "IMG_0322.JPEG" },214  { fpath: "IMG_0351.JPEG" },215  { fpath: "IMG_0354.JPEG" },216  { fpath: "IMG_0310.JPEG" },217  { fpath: "IMG_0290.JPEG" },218  { fpath: "IMG_0284.JPEG" },219  { fpath: "IMG_0267.JPEG" },220  { fpath: "beauty_1627971166190.jpeg" },221  { fpath: "IMG_0304.JPEG" },222  { fpath: "IMG_0289.JPEG" },223  { fpath: "IMG_0266.JPEG" },224  { fpath: "IMG_0232.JPEG" },225  { fpath: "IMG_0112.JPEG" },226  { fpath: "IMG_0253.JPEG" },227  { fpath: "IMG_0126.JPEG" },228  { fpath: "IMG_0089.JPEG" },229  { fpath: "IMG_0100.JPEG" },230  { fpath: "IMG_0113.JPEG" },231  { fpath: "IMG_0094.JPEG" },232  { fpath: "IMG_0200.JPEG" },233  { fpath: "IMG_0142.JPG" },234  { fpath: "IMG_0107.JPEG" },235  { fpath: "IMG_0185.JPEG" },236  { fpath: "IMG_0178.JPG" },237  { fpath: "IMG_0097.JPEG" },238  { fpath: "IMG_0228.JPEG" },239  { fpath: "IMG_0234.JPEG" },240  { fpath: "IMG_0205.JPEG" },241  { fpath: "IMG_0248.JPEG" },242  { fpath: "IMG_0054.PNG" },243  { fpath: "IMG_0124.JPEG" },244  { fpath: "IMG_0125.JPEG" },245  { fpath: "IMG_0134.JPG" },246  { fpath: "a52adcc1f56a4487ee7814776462c344.JPG" },247  { fpath: "IMG_0086.JPEG" },248  { fpath: "IMG_0219.JPG" },249  { fpath: "IMG_0160.JPEG" },250  { fpath: "IMG_0212.JPEG" },251  { fpath: "IMG_0132.JPG" },252  { fpath: "IMG_0174.JPEG" },253  { fpath: "IMG_0208.JPEG" },254  { fpath: "beauty_1624185458333.jpeg" },255  { fpath: "IMG_0135.JPG" },256  { fpath: "IMG_0130.JPG" },257  { fpath: "IMG_0128.JPG" },258  { fpath: "IMG_0140.JPG" },259  { fpath: "IMG_0206.JPEG" },260  { fpath: "IMG_0189.JPEG" },261  { fpath: "IMG_0129.JPG" },262  { fpath: "IMG_0162.JPG" },263  { fpath: "IMG_0118.JPEG" },264  { fpath: "IMG_0213.JPEG" },265  { fpath: "IMG_0137.JPG" },266  { fpath: "dfb82681a471a1b226d4606d383a7d18.jpg" },267  { fpath: "IMG_0077.JPEG" },268  { fpath: "IMG_0105.JPEG" },269  { fpath: "ea729d1d96096e65616087850b6bdd91.jpg" },270  { fpath: "IMG_0087.JPEG" },271  { fpath: "IMG_0070.JPG" },272  { fpath: "IMG_0090.JPEG" },273  { fpath: "IMG_0063.JPEG" },274  { fpath: "IMG_0062.JPG" },275  { fpath: "IMG_0114.JPEG" },276  { fpath: "IMG_0092.JPEG" },277  { fpath: "257ee3d62b525131818a957cf73264cc.jpg" },278  { fpath: "c0db48338c4c36324e4595c322289e35.jpg" },279  { fpath: "af9e26f4bac45521aa4bf2863599f014.jpg" },280  { fpath: "08422bf0cd0229f49df89a1b9f8e5a13.jpg" },281  { fpath: "681e5fd6b74897a580dbab06603203a9.jpg" },282  { fpath: "DSC_3434.jpg" },283  { fpath: "13d481ea89d825308594147d2054da03.jpg" },284  { fpath: "IMG_0044.JPEG" },285  { fpath: "IMG_0052.JPG" },286  { fpath: "IMG_0036.JPEG" },287  { fpath: "IMG_0647.JPEG" },288  { fpath: "IMG_0610.JPEG" },289  { fpath: "IMG_0627.JPEG" },290  { fpath: "IMG_0613.JPEG" },291  { fpath: "IMG_0611.JPEG" },292  { fpath: "IMG_0636.JPEG" },293  { fpath: "IMG_0629.JPEG" },294  { fpath: "IMG_0628.JPEG" },295  { fpath: "IMG_0618.JPEG" },296  { fpath: "IMG_0621.JPEG" },297  { fpath: "IMG_0623.JPEG" },298  { fpath: "IMG_0616.JPEG" },299  { fpath: "IMG_0619.JPEG" },300  { fpath: "IMG_0639.JPEG" },301  { fpath: "IMG_0601.JPEG" },302  { fpath: "IMG_0599.JPEG" },303  { fpath: "IMG_0604.JPEG" },304  { fpath: "IMG_0600.JPEG" },305  { fpath: "IMG_0579.JPEG" },306  { fpath: "IMG_0581.JPEG" },307  { fpath: "IMG_0589.JPEG" },308  { fpath: "IMG_0590.JPEG" },309  { fpath: "IMG_0583.JPEG" },310  { fpath: "IMG_0586.JPEG" },311  { fpath: "IMG_0591.JPEG" },312  { fpath: "95507b52977b2cad38a3918922338dbf.jpg" },313  { fpath: "IMG_0563.JPEG" },314  { fpath: "9cd3e91ebb21d9b12293d653798884d9.jpg" },315  { fpath: "IMG_0329.PNG" },316  { fpath: "IMG_0560.JPEG" },317  { fpath: "IMG_0330.PNG" },318  { fpath: "IMG_0545.JPEG" },319  { fpath: "IMG_0484.JPEG" },320  { fpath: "IMG_0488.JPEG" },321  { fpath: "IMG_0485.JPEG" },322  { fpath: "IMG_0495.JPEG" },323  { fpath: "IMG_0482.JPEG" },324  { fpath: "IMG_0550.JPEG" },325  { fpath: "IMG_0510.JPEG" },326  { fpath: "IMG_0477.JPEG" },327  { fpath: "IMG_0525.JPEG" },328  { fpath: "IMG_0503.JPEG" },329  { fpath: "IMG_0499.JPEG" },330  { fpath: "IMG_0509.JPEG" },331  { fpath: "IMG_0519.JPEG" },332  { fpath: "IMG_0504.JPEG" },333  { fpath: "IMG_0481.JPEG" },334  { fpath: "IMG_0516.JPEG" },335  { fpath: "IMG_0474.JPEG" },336  { fpath: "IMG_0429.JPEG" },337  { fpath: "IMG_0432.JPEG" },338  { fpath: "IMG_0463.JPEG" },339  { fpath: "IMG_0423.JPEG" },340  { fpath: "IMG_0448.JPEG" },341  { fpath: "IMG_0458.JPEG" },342  { fpath: "IMG_0460.JPEG" },343  { fpath: "IMG_0490.JPEG" },344  { fpath: "IMG_0441.JPEG" },345  { fpath: "IMG_0452.JPEG" },346  { fpath: "IMG_0424.JPEG" },347  { fpath: "IMG_0437.JPEG" },348  { fpath: "IMG_0439.JPEG" },349  { fpath: "IMG_0445.JPEG" },350  { fpath: "IMG_0450.JPEG" },351  { fpath: "IMG_0447.JPEG" },352  { fpath: "IMG_0377.JPEG" },353  { fpath: "IMG_0411.JPEG" },354  { fpath: "IMG_0420.JPEG" },355  { fpath: "IMG_0407.JPEG" },356  { fpath: "IMG_0399.JPEG" },357  { fpath: "IMG_0408.JPEG" },358  { fpath: "IMG_0388.JPEG" },359  { fpath: "IMG_0387.JPEG" },360  { fpath: "IMG_0392.JPEG" },361  { fpath: "IMG_0383.JPEG" },362  { fpath: "IMG_0375.JPEG" },363  { fpath: "IMG_0405.JPEG" },364  { fpath: "IMG_0374.JPEG" },365  { fpath: "IMG_0370.JPEG" },366  { fpath: "IMG_0382.JPEG" },367  { fpath: "IMG_0368.JPEG" },368  { fpath: "IMG_0372.JPEG" },369  { fpath: "IMG_0384.JPEG" },370  { fpath: "6b5b5c5272581e663ef9a96f8a5b6702.JPG" },371  { fpath: "IMG_0098.JPEG" },372  { fpath: "IMG_0347.JPEG" },373  { fpath: "IMG_0246.JPEG" },374  { fpath: "IMG_0346.JPEG" },375  { fpath: "IMG_0302.JPEG" },376  { fpath: "beauty_1627971154053.jpeg" },377  { fpath: "IMG_0352.JPEG" },378  { fpath: "IMG_0190.JPEG" },379  { fpath: "IMG_0321.JPEG" },380  { fpath: "IMG_0315.JPEG" },381  { fpath: "IMG_0306.JPEG" },382  { fpath: "IMG_0334.JPEG" },383  { fpath: "IMG_0293.JPEG" },384  { fpath: "IMG_0269.JPEG" },385  { fpath: "IMG_0282.JPEG" },386  { fpath: "IMG_0273.JPEG" },387  { fpath: "IMG_0280.JPEG" },388  { fpath: "IMG_0268.JPEG" },389  { fpath: "IMG_0291.JPEG" },390  { fpath: "IMG_0272.JPEG" },391  { fpath: "IMG_0286.JPEG" },392  { fpath: "IMG_0270.JPEG" },393  { fpath: "IMG_0287.PNG" },394  { fpath: "IMG_0277.JPEG" },395  { fpath: "IMG_0275.JPEG" },396  { fpath: "IMG_0274.JPEG" },397  { fpath: "IMG_0207.JPEG" },398  { fpath: "IMG_0198.JPEG" },399  { fpath: "IMG_0236.JPEG" },400  { fpath: "IMG_0122.JPEG" },401  { fpath: "IMG_0088.JPEG" },402  { fpath: "IMG_0199.JPEG" },403  { fpath: "IMG_0235.JPEG" },404  { fpath: "IMG_0184.JPEG" },405  { fpath: "IMG_0237.JPEG" },406  { fpath: "20200125_094133.jpg" },407  { fpath: "IMG_0231.JPEG" },408  { fpath: "IMG_0229.JPEG" },409  { fpath: "IMG_0165.JPEG" },410  { fpath: "IMG_0227.JPEG" },411  { fpath: "IMG_0233.JPEG" },412  { fpath: "IMG_0225.JPEG" },413  { fpath: "DSC_3491.jpg" },414  { fpath: "IMG_0220.JPG" },415  { fpath: "IMG_0222.JPEG" },416  { fpath: "IMG_0058.PNG" },417  { fpath: "IMG_0117.JPEG" },418  { fpath: "IMG_0217.JPG" },419  { fpath: "IMG_0079.JPEG" },420  { fpath: "IMG_0242.JPG" },421  { fpath: "IMG_0218.JPG" },422  { fpath: "b600090c830739539df37f818aaa9f3d.JPG" },423  { fpath: "IMG_0188.JPEG" },424  { fpath: "beauty_1624185444812.jpeg" },425  { fpath: "IMG_0204.JPEG" },426  { fpath: "IMG_0163.JPG" },427  { fpath: "IMG_0171.JPEG" },428  { fpath: "IMG_0210.JPEG" },429  { fpath: "IMG_0176.JPG" },430  { fpath: "IMG_0214.JPEG" },431  { fpath: "IMG_0119.JPEG" },432  { fpath: "6de0d078b6c1095808afff8199845c9a.jpg" },433  { fpath: "IMG_0146.JPG" },434  { fpath: "IMG_0051.JPG" },435  { fpath: "IMG_0091.JPEG" },436  { fpath: "IMG_0042.JPEG" },437  { fpath: "IMG_0145.JPG" },438  { fpath: "IMG_0147.JPG" },439  { fpath: "bcc80ed8bbbd661af650e0f3b4fd4d5b.jpg" },440  { fpath: "IMG_0048.JPEG" },441  { fpath: "IMG_0028.JPG" },442  { fpath: "IMG_0136.JPG" },443  { fpath: "IMG_0068.JPG" },444  { fpath: "IMG_0082.JPG" },445  { fpath: "IMG_0161.PNG" },446  { fpath: "IMG_0108.JPEG" },447  { fpath: "IMG_0078.JPEG" },448  { fpath: "IMG_0095.JPEG" },449  { fpath: "IMG_0104.JPEG" },450  { fpath: "IMG_0010.JPG" },451  { fpath: "DSC_3468.jpg" },452  { fpath: "d00eaa19ac416652348e2cbcd0f08d1d.jpg" },453  { fpath: "IMG_0035.JPEG" },...Using AI Code Generation
1var fpath = require('apimocker').fpath;2var path = require('path');3var fs = require('fs');4var express = require('express');5var bodyParser = require('body-parser');6var app = express();7app.use(bodyParser.json());8app.post('/api/submit', function(req, res) {9  var data = req.body;10  var user = data.user;11  var password = data.password;12  if(user === 'admin' && password === 'admin') {13    res.send('Login successful!');14  } else {15    res.status(400).send('Login failed!');16  }17});18app.listen(3000, function() {19  console.log('Server running on port 3000');20});21{22    {23      "options": {24      }25    }26}Using AI Code Generation
1var apimocker = require('apimocker');2apimocker.setConfigFile('./apimocker.json');3apimocker.fpath(__dirname + '/mocks');4apimocker.listen(3000);5{6}7var apimocker = require('apimocker');8apimocker.setConfigFile('./apimocker.json');9var app = express();10app.use(apimocker.middleware);11{12}13var apimocker = require('apimocker');14apimocker.setConfigFile('./apimocker.json');15var app = express();16app.use('/api', apimocker.middleware);17{18}19var apimocker = require('apimocker');20apimocker.setConfigFile('./apimocker.json');21var app = express();22app.use(apimocker.middleware);23apimocker.fpath(__dirname + '/mocks');24{25}26var apimocker = require('apimocker');27apimocker.setConfigFile('./apimocker.json');28var app = express();Using AI Code Generation
1const fpath = require('apimocker/fpath');2module.exports = {3  '/api/v1/users': {4    get: {5      handler: fpath('users.json'),6    },7  },8};Using AI Code Generation
1var apimocker = require('apimocker');2var mocker = apimocker();3mocker.setFPath('./mocks');4mocker.startServer(8000);5mocker.setDefaultResponse({6  "headers": {7  },8});9mocker.setResponse('/test', {10  "headers": {11  },12});13mocker.setResponse('/test', 'POST', {14  "headers": {15  },16});17mocker.setResponse('/test', 'POST', 200, {18  "headers": {19  },20});21mocker.setResponse('/test', 'POST', 200, {22  "headers": {23  },24});25mocker.setResponse('/test', 'POST', 200, {26  "headers": {27  },28});29mocker.setResponse('/test', 'POST', 200, {30  "headers": {31  },32});33mocker.setResponse('/test', 'POST', 200, {Using AI Code Generation
1var apimocker = require('apimocker');2apimocker.setConfig({3});4apimocker.fpath('/api/v1/employee/:id');5apimocker.listen(3001);6console.log('Mock api server running on port 3001');7var apimocker = require('apimocker');8apimocker.setConfig({9});10apimocker.fpath('/api/v1/employee/:id', function(req, res, next) {11    console.log('middleware called');12    next();13});14apimocker.listen(3001);15console.log('Mock api server running on port 3001');16var apimocker = require('apimocker');17apimocker.setConfig({18});19apimocker.fpath('/api/v1/employee/:id', function(req, res, next) {20    console.log('middleware called');21    res.send('custom response');22}, function(req, res, next) {23    console.log('middleware called');24    next();25});26apimocker.listen(3001);27console.log('Mock api server running on port 3001');28var apimocker = require('apimocker');29apimocker.setConfig({30});31apimocker.fpath('/api/v1/employee/:id', function(req, res, next) {32    console.log('middleware called');33    res.send('custom response');34}, function(req, res, next) {35    console.log('middleware called');36    next();37}, function(req, res, next) {Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!
