MCPcopy Create free account
hub / github.com/alibaba/MNN / run

Method run

test/core/FileUtilsTest.cpp:25–318  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

23public:
24 virtual ~FileUtilsTest() = default;
25 virtual bool run(int precision) {
26 /*======== Create and Remove ========*/
27 do {
28 // create a new file
29 file_t file = MNNCreateFile(file_path);
30 if (file == INVALID_FILE) {
31 return false;
32 } else {
33 MNNCloseFile(file);
34 }
35 bool exist = MNNFileExist(file_path);
36 if (!exist) {
37 return false;
38 }
39 // create a new file to cover an existing file
40 file = MNNCreateFile(file_path);
41 if (file == INVALID_FILE) {
42 return false;
43 } else {
44 MNNCloseFile(file);
45 }
46 exist = MNNFileExist(file_path);
47 if (!exist) {
48 return false;
49 }
50 // remove a file
51 MNN::ErrorCode ec = MNNRemoveFile(file_path);
52 if (ec != NO_ERROR) {
53 return false;
54 }
55 exist = MNNFileExist(file_path);
56 if (exist) {
57 return false;
58 }
59 printf("File Utils Test: Create and Remove passed\n");
60 } while(false);
61
62 /*======== Open and Close ========*/
63 do {
64 // Open and close a non-existent file
65 file_t file = MNNOpenFile(file_path, MNN_FILE_READ | MNN_FILE_WRITE);
66 if (file != INVALID_FILE) {
67 return false;
68 }
69 MNN::ErrorCode ec = MNNCloseFile(file);
70 if (ec != FILE_NOT_EXIST) {
71 return false;
72 }
73 // Open and close an existent file
74 file = MNNCreateFile(file_path);
75 if (file == INVALID_FILE) {
76 return false;
77 }
78 bool exist = MNNFileExist(file_path);
79 if (!exist) {
80 return false;
81 }
82 ec = MNNCloseFile(file);

Callers

nothing calls this directly

Calls 12

MNNCreateFileFunction · 0.85
MNNCloseFileFunction · 0.85
MNNFileExistFunction · 0.85
MNNRemoveFileFunction · 0.85
MNNOpenFileFunction · 0.85
MNNGetFileSizeFunction · 0.85
MNNSetFileSizeFunction · 0.85
MNNReadFileFunction · 0.85
MNNWriteFileFunction · 0.85
MNNSetFilePointerFunction · 0.85
MNNMmapFileFunction · 0.85
MNNUnmapFileFunction · 0.85

Tested by

no test coverage detected