未验证 提交 79aacd42 编写于 作者: O openharmony_ci 提交者: Gitee

!7515 【XTS】【master】删除冗余代码

Merge pull request !7515 from jiaxugangzz/master
......@@ -78,7 +78,6 @@ def writemulbuildgn():
pagenametext = suitename + "-" + casenamecap
pagefilename = hapdirpath + G_PATHDIRPATH + suitename + ".ets"
attrtmp = G_TMPPATH + G_PAGEATTRTEMPPATH
#print("addattr:", subattcnt, pagename, attrtmp)
with open(attrtmp, encoding="utf-8", mode="r") as attrtmpfile:
for attrtempline in attrtmpfile:
attrtempline = attrtempline.replace(" ", "\ ")
......@@ -109,7 +108,6 @@ def writemulbuildgn():
#追加page里的attr
pagenametext = suitename + "-" + casenamecap
attrtmp = G_TMPPATH + G_PAGEATTRTEMPPATH
#print("addattr:", subattcnt, pagename, attrtmp)
with open(attrtmp, encoding="utf-8", mode="r") as attrtmpfile:
for attrtempline in attrtmpfile:
attrtempline = attrtempline.replace(" ", "\ ")
......@@ -121,7 +119,6 @@ def writemulbuildgn():
temptestfilename = G_TMPPATH + G_TESTCASETEMPPATH
testfilename = hapdirpath + G_TESTDIRPATH + suitename + ".test.ets"
#print("createpage:", subgncnt, dirpath, pagefilename, testfilename)
os.system(r"cp {} {}".format(temptestfilename, testfilename))
#替换test里的名称
os.system(r"sed -i 's/{}/{}/g' {}".format(G_ATTRNAMEPATTERN, testname, testfilename))
......@@ -136,7 +133,6 @@ def writemulbuildgn():
buildgnname = hapdirpath + G_BUILDGNPATH
os.system(r"sed -i 's/{}/{}/g' {}".format(G_SUITENAMEPATTERN, suiteitemcap, buildgnname))
# formate gn
#print("Formate: dirpath:",buildgnname)
formatcmd = "cat "+buildgnname+" | ~/workspace/oh31/prebuilts/build-tools/linux-x86/bin/gn format --stdin > FORMAT_RESULT.gn;cp -f FORMAT_RESULT.gn "+buildgnname+";rm FORMAT_RESULT.gn"
os.system(formatcmd)
#替换index.ets里的名称
......@@ -147,12 +143,9 @@ def writemulbuildgn():
testjsonname = hapdirpath + G_TESTJSONPATH
os.system(r"sed -i 's/{}/{}/g' {}".format(G_SUITENAMEPATTERN, suiteitemcap, testjsonname))
#G_IMPORTTEST = "import {} from './{}Jsunit.test';\n"
importtestheads.append(G_IMPORTTEST.format(testname, suitename))
importtests.append(G_IMPORTTESTCASE.format(testname))
subcasecnt += 1
#print("importtestheads:", importtestheads)
#print("importtests:", importtests)
#插入List.test.ets,装载多个testcase
ind = 16
for importtestsline in importtests:
......@@ -187,7 +180,6 @@ def new_report(bakdir, str):
files = os.listdir(bakdir)
lists = [] #列出目录的下所有文件和文件夹保存到lists
for f in files:
# if f.startswith(str):
if "latest" in f:
continue
lists.append(f)
......@@ -239,7 +231,6 @@ if __name__ == '__main__':
total +=1
failcnt += 1
testcaselist.append(caseline[1]+"-false")
#print("tasklogfile line:", caseline[0], caseline[1])
#将testcase信息生成文件
xmlfile = open(tmpfile, mode='w+')
xmlfile.write("<?xml version='1.0' encoding='UTF-8'?>\n")
......
......@@ -20,7 +20,6 @@
#include <string>
#include "napi/native_api.h"
//#include "napi/native_node_api.h"
#include "rawfile/raw_file_manager.h"
namespace OHOS {
......
......@@ -36,7 +36,6 @@ namespace OHOS {
{
errMsg_ = msg;
success_ = false;
// HiLog::Error(LABEL, "%{public}s", msg.c_str());
}
napi_async_execute_callback TestRawFileExecute()
......@@ -46,41 +45,30 @@ namespace OHOS {
// test OH_ResourceManager_OpenRawDir
RawDir* rawDir = OH_ResourceManager_OpenRawDir(asyncContext->ndk_, asyncContext->path_.c_str());
// HiLog::Error(LABEL, "OpenRawDir ndk_:%{public}p path_:%{public}s",asyncContext->ndk_, asyncContext->path_.c_str());
// test OH_ResourceManager_GetRawFileCount
int count = OH_ResourceManager_GetRawFileCount(rawDir);
// HiLog::Error(LABEL, "GetRawFileCount:%{public}d", count);
// test OH_ResourceManager_GetRawFileName
for (int i = 0; i< count; i++) {
std::string tempFileName = OH_ResourceManager_GetRawFileName(rawDir, i);
// HiLog::Error(LABEL, "GetRawFileName[%{public}d]:%{public}s", i, tempFileName.c_str());
}
// test OH_ResourceManager_OpenRawFile
std::string fileName = OH_ResourceManager_GetRawFileName(rawDir, 0);
asyncContext->path_ = fileName;
RawFile* rawFile = OH_ResourceManager_OpenRawFile(asyncContext->ndk_, fileName.c_str());
// HiLog::Error(LABEL, "OpenRawFile fileName:%{public}s", fileName.c_str());
// test OH_ResourceManager_GetRawFileSize
asyncContext->len_ = OH_ResourceManager_GetRawFileSize(rawFile);
// HiLog::Error(LABEL, "GetRawFileSize:%{public}ld", asyncContext->len_);
// // test OH_ResourceManager_SeekRawFile
// HiLog::Error(LABEL, "SeekRawFile SEEK_END:%{public}d", OH_ResourceManager_SeekRawFile(rawFile, 0 ,2));
// HiLog::Error(LABEL, "SeekRawFile SEEK_SET:%{public}d", OH_ResourceManager_SeekRawFile(rawFile, 0 ,0));
// HiLog::Error(LABEL, "SeekRawFile SEEK_CUR:%{public}d", OH_ResourceManager_SeekRawFile(rawFile, 0 ,1));
// // test OH_ResourceManager_GetRawFileOffset
// HiLog::Error(LABEL, "GetRawFileOffset:%{public}ld", OH_ResourceManager_GetRawFileOffset(rawFile));
// test OH_ResourceManager_GetRawFileDescriptor
RawFileDescriptor descriptor;
bool getFd = OH_ResourceManager_GetRawFileDescriptor(rawFile, descriptor);
// HiLog::Error(LABEL, "GetRawFileDescriptor getFd:%{public}d fd:%{public}d length:%{public}ld start:%{public}ld",
// getFd, descriptor.fd, descriptor.length, descriptor.start);
// test OH_ResourceManager_ReadRawFile
asyncContext->mediaData = std::make_unique<char[]>(asyncContext->len_);
......@@ -88,25 +76,20 @@ namespace OHOS {
// test OH_ResourceManager_ReleaseRawFileDescriptor
OH_ResourceManager_ReleaseRawFileDescriptor(descriptor);
// HiLog::Error(LABEL, "ReleaseRawFileDescriptor ok");
// test OH_ResourceManager_CloseRawFile
OH_ResourceManager_CloseRawFile(rawFile);
// HiLog::Error(LABEL, "CloseRawFile ok");
// test OH_ResourceManager_CloseRawDir
OH_ResourceManager_CloseRawDir(rawDir);
// HiLog::Error(LABEL, "CloseRawDir ok");
// test OH_ResourceManager_ReleaseNativeResourceManager
OH_ResourceManager_ReleaseNativeResourceManager(asyncContext->ndk_);
// HiLog::Error(LABEL, "ReleaseNativeResourceManager ok asyncContext->ndk_:%{public}p", asyncContext->ndk_);
asyncContext->createValueFunc_ = [](napi_env env, NdkAsyncContext &context) -> napi_value {
napi_value buffer;
napi_status status = napi_create_external_arraybuffer(env, context.mediaData.get(), context.len_,
[](napi_env env, void *data, void *hint) {
// HiLog::Error(LABEL, "Media buffer finalized");
delete[] static_cast<char*>(data);
}, nullptr, &buffer);
if (status != napi_ok) {
......@@ -148,29 +131,24 @@ namespace OHOS {
if (asyncContext->deferred_) {
if (asyncContext->success_) {
if (napi_resolve_deferred(env, asyncContext->deferred_, result[1]) != napi_ok) {
// HiLog::Error(LABEL, "napi_resolve_deferred failed");
}
} else {
if (napi_reject_deferred(env, asyncContext->deferred_, result[0]) != napi_ok) {
// HiLog::Error(LABEL, "napi_reject_deferred failed");
}
}
} else {
napi_value callback = nullptr;
napi_status status = napi_get_reference_value(env, asyncContext->callbackRef_, &callback);
if (status != napi_ok) {
// HiLog::Error(LABEL, "napi_get_reference_value failed status=%{public}d", status);
break;
}
napi_value userRet = nullptr;
status = napi_call_function(env, nullptr, callback, sizeof(result) / sizeof(napi_value), result, &userRet);
if (status != napi_ok) {
// HiLog::Error(LABEL, "napi_call_function failed status=%{public}d", status);
break;
}
status = napi_delete_reference(env, asyncContext->callbackRef_);
if (status != napi_ok) {
// HiLog::Error(LABEL, "napi_delete_reference failed status=%{public}d", status);
break;
}
}
......@@ -191,20 +169,17 @@ namespace OHOS {
size_t len = 0;
napi_status status = napi_get_value_string_utf8(env, argv[0], nullptr, 0, &len);
if (status != napi_ok) {
// HiLog::Error(LABEL, "Failed to get bundle name length");
return nullptr;
}
std::vector<char> buf(len + 1);
status = napi_get_value_string_utf8(env, argv[0], buf.data(), len + 1, &len);
if (status != napi_ok) {
// HiLog::Error(LABEL, "Failed to get bundle name");
return nullptr;
}
asyncContext->path_ = buf.data();
} else if (i == 1 && valueType == napi_object) {
// test OH_ResourceManager_InitNativeResourceManager
asyncContext->ndk_ = OH_ResourceManager_InitNativeResourceManager(env, argv[i]);
// HiLog::Error(LABEL, "InitNativeResourceManager asyncContext->ndk_:%{public}p", asyncContext->ndk_);
} else if (i == 2 && valueType == napi_function) {
napi_create_reference(env, argv[i], 1, &asyncContext->callbackRef_);
break;
......@@ -222,16 +197,13 @@ namespace OHOS {
napi_value resource = nullptr;
napi_create_string_utf8(env, "testRawFile", NAPI_AUTO_LENGTH, &resource);
// HiLog::Error(LABEL, "guojia testRawFile");
napi_status status = napi_create_async_work(env, nullptr, resource, TestRawFileExecute(), completeFunc,
static_cast<void*>(asyncContext.get()), &asyncContext->work_);
if (status != napi_ok) {
// HiLog::Error(LABEL, "Failed to create async work for testRawFile %{public}d",status);
return result;
}
status = napi_queue_async_work(env, asyncContext->work_);
if (status != napi_ok) {
// HiLog::Error(LABEL, "Failed to queue async work for testRawFile %{public}d",status);
return result;
}
......
......@@ -248,30 +248,3 @@ HWTEST_F(FileSystemTest, testGlob, Function | MediumTest | Level3)
}
globfree(&buf);
}
#if 0
/**
* @tc.number SUB_KERNEL_FS_OTHER_0500
* @tc.name basic function test : Use fwprintf function to write wide characters
* @tc.desc [C- SOFTWARE -0200]
*/
HWTEST_F(FileSystemTest, testFwprintf, Function | MediumTest | Level3)
{
const char filePath[] = TOP_DIR "/" DIR0 "/" DIR0_FILE0;
FILE *fp = nullptr;
wchar_t writeBuf[30] = L"this is a file";
wchar_t readBuf[30];
// write
CreateTestFolder();
fp = fopen(filePath, "w+");
EXPECT_NE(fwprintf(fp, L"%ls", writeBuf), -1);
EXPECT_NE(fclose(fp), -1) << "> fclose errno =" << errno;
// read
fp = fopen(filePath, "r");
ASSERT_NE(fp, nullptr) << "> fopen errno = " << errno;
EXPECT_NE(fgetws(readBuf, 30, fp), nullptr) << "fgetws error";
EXPECT_TRUE(wcscmp(writeBuf, readBuf) == 0) << "writeBuf != readBuf";
EXPECT_NE(fclose(fp), -1) << "> fclose errno =" << errno;
}
#endif
......@@ -50,34 +50,6 @@ HWTEST_F(FileSystemTest, testUmask, Function | MediumTest | Level2)
EXPECT_EQ(umask(maskPre), maskNew) << "> umask error";
}
#endif
#if 0
/**
* @tc.number SUB_KERNEL_FS_STAT_0200
* @tc.name basic function test : Run the stat function to obtain the file status.
* @tc.desc [C- SOFTWARE -0200]
*/
HWTEST_F(FileSystemTest, testStat, Function | MediumTest | Level3)
{
int fd = 0;
mode_t mode = 0777;
const char *filePath = TOP_DIR "/" FILE0;
struct stat buf = {0};
char writeBuf[] = "this is a file";
fd = open(FILE0, O_CREAT | O_RDWR, mode);
EXPECT_NE(fd, -1) << "> open faild errno = " << errno;
WriteCloseTest(fd);
EXPECT_NE(stat(filePath, &buf), -1) << "> fstat errno = " << errno;
LOG("> buf.st_dev = %lu", buf.st_dev); // IDs of device on which file resides
LOG("> buf.st_ino = %lu", buf.st_ino); // I-node number of file
EXPECT_EQ(buf.st_rdev, 0) << "> buf.st_rdev not expect"; // IDs for device special files
EXPECT_EQ(buf.st_size, sizeof(writeBuf)) << "> buf.st_size = " << buf.st_size;
LOG("> buf.st_atim = %lds,%ldns", buf.st_atim.tv_sec, buf.st_atim.tv_nsec); // time for last file access
LOG("> buf.st_mtim = %lds,%ldns", buf.st_mtim.tv_sec, buf.st_mtim.tv_nsec); // time for last file modification
LOG("> buf.st_ctim = %lds,%ldns", buf.st_ctim.tv_sec, buf.st_ctim.tv_nsec); // time for last file status change
}
#endif
#if defined(LITE_FS_JFFS2)
#ifndef COMMERCIAL
/**
......@@ -113,35 +85,6 @@ HWTEST_F(FileSystemTest, testStatLimt, Function | MediumTest | Level3)
}
#endif
#endif
#if 0
/**
* @tc.number SUB_KERNEL_FS_STAT_0300
* @tc.name basic function test : Run the lstat function to obtain the file status.
* @tc.desc [C- SOFTWARE -0200]
*/
HWTEST_F(FileSystemTest, testLstat, Function | MediumTest | Level3)
{
int fd = 0;
mode_t mode = 0777;
const char *filePath = TOP_DIR "/" FILE0;
struct stat buf = {0};
char writeBuf[] = "this is a file";
fd = open(filePath, O_CREAT | O_RDWR, mode);
EXPECT_NE(fd, -1) << "> open faild errno = " << errno;
WriteCloseTest(fd);
EXPECT_NE(lstat(filePath, &buf), -1) << "> fstat errno = " << errno;
LOG("> buf.st_dev = %lu", buf.st_dev); // IDs of device on which file resides
LOG("> buf.st_ino = %lu", buf.st_ino); // I-node number of file
EXPECT_EQ(buf.st_rdev, 0) << "> buf.st_rdev not expect"; // IDs for device special files
EXPECT_EQ(buf.st_size, sizeof(writeBuf)) << "> buf.st_size = " << buf.st_size;
LOG("> buf.st_atim = %lds,%ldns", buf.st_atim.tv_sec, buf.st_atim.tv_nsec); // time for last file access
LOG("> buf.st_mtim = %lds,%ldns", buf.st_mtim.tv_sec, buf.st_mtim.tv_nsec); // time for last file modification
LOG("> buf.st_ctim = %lds,%ldns", buf.st_ctim.tv_sec, buf.st_ctim.tv_nsec); // time for last file status change
}
#endif
#if defined(LITE_FS_JFFS2)
#ifndef COMMERCIAL
/**
......@@ -178,34 +121,6 @@ HWTEST_F(FileSystemTest, testLstatLimt, Function | MediumTest | Level3)
}
#endif
#endif
#if 0
/**
* @tc.number SUB_KERNEL_FS_STAT_0400
* @tc.name basic function test : Run the fstat function to obtain the file status.
* @tc.desc [C- SOFTWARE -0200]
*/
HWTEST_F(FileSystemTest, testFstat, Function | MediumTest | Level3)
{
int fd = 0;
mode_t mode = 0777;
struct stat buf = {0};
char writeBuf[] = "this is a file";
fd = open(FILE0, O_CREAT | O_RDWR, mode);
EXPECT_NE(fd, -1) << "> open faild errno = " << errno;
EXPECT_NE(write(fd, writeBuf, sizeof(writeBuf)), -1) << "> write errno = " << errno;
EXPECT_NE(fstat(fd, &buf), -1) << "> fstat errno = " << errno;
LOG("> buf.st_dev = %lu", buf.st_dev); // IDs of device on which file resides
LOG("> buf.st_ino = %lu", buf.st_ino); // I-node number of file
EXPECT_EQ(buf.st_rdev, 0) << "> buf.st_rdev not expect"; // IDs for device special files
EXPECT_EQ(buf.st_size, sizeof(writeBuf)) << "> buf.st_size = " << buf.st_size;
LOG("> buf.st_atim = %lds,%ldns", buf.st_atim.tv_sec, buf.st_atim.tv_nsec); // time for last file access
LOG("> buf.st_mtim = %lds,%ldns", buf.st_mtim.tv_sec, buf.st_mtim.tv_nsec); // time for last file modification
LOG("> buf.st_ctim = %lds,%ldns", buf.st_ctim.tv_sec, buf.st_ctim.tv_nsec); // time for last file status change
EXPECT_NE(close(fd), -1) << "> close errno = " << errno;
}
#endif
#if defined(LITE_FS_JFFS2)
#ifndef COMMERCIAL
/**
......
......@@ -33,360 +33,6 @@
#include "libfs.h"
using namespace testing::ext;
#if 0
/**
* @tc.number SUB_KERNEL_FS_STDIO_0100
* @tc.name basic function test : read and write with stream
* @tc.desc [C- SOFTWARE -0200]
*/
HWTEST_F(FileSystemTest, testFILE, Function | MediumTest | Level2)
{
FILE *fp = nullptr;
int fd = 0;
char writeBuf[] = "this is a file";
char readBuf[20] = {0};
// write
fd = creat(FILE0, 0777);
EXPECT_NE(fd, -1) << "> creat faild errno = " << errno;
EXPECT_NE(close(fd), -1) << "> close errno = " << errno;
fp = fopen(FILE0, "w+");
ASSERT_NE(fp, nullptr) << "> fopen errno = " << errno;
EXPECT_EQ(fwrite(writeBuf, sizeof(writeBuf), 1, fp), 1) << "> fwrite errno = " << errno;
EXPECT_NE(fclose(fp), -1) << "> fclose errno =" << errno;
// read
fp = fopen(FILE0, "r+");
ASSERT_NE(fp, nullptr) << "> fopen errno = " << errno;
EXPECT_NE(fread(readBuf, sizeof(writeBuf), 1, fp), 0) << "> fread errno = " << errno;
EXPECT_STREQ(writeBuf, readBuf) << "> writeBuf = " << writeBuf << "\n> readBuf = " << readBuf;
EXPECT_NE(fclose(fp), -1) << "> fclose errno =" << errno;
}
/**
* @tc.number SUB_KERNEL_FS_STDIO_0200
* @tc.name basic function test : Use the feof function to determine the end identifier of the file
* @tc.desc [C- SOFTWARE -0200]
*/
HWTEST_F(FileSystemTest, testFeof, Function | MediumTest | Level3)
{
FILE *fp = nullptr;
int fd = 0;
char writeBuf[] = "this is a file";
char readBuf[20] = {0};
// write
fd = creat(FILE0, 0777);
EXPECT_NE(fd, -1) << "> creat faild errno = " << errno;
WriteCloseTest(fd);
// read
fp = fopen(FILE0, "r+");
ASSERT_NE(fp, nullptr) << "> fopen errno = " << errno;
EXPECT_EQ(fseeko(fp, 0, SEEK_SET), 0) << "> fseeko errno = " << errno;
fgetc(fp);
EXPECT_EQ(feof(fp), 0) << "> file should not be end!"; // check end
EXPECT_EQ(fseeko(fp, 0, SEEK_SET), 0) << "> fseeko errno = " << errno;
EXPECT_NE(fread(readBuf, sizeof(writeBuf), 1, fp), 0) << "> fread errno = " << errno;
EXPECT_STREQ(writeBuf, readBuf) << "> writeBuf = " << writeBuf << "\n> readBuf = " << readBuf;
fgetc(fp);
EXPECT_NE(feof(fp), 0) << "> file should be end!"; // check end
EXPECT_NE(fclose(fp), -1) << "> fclose errno =" << errno;
}
/**
* @tc.number SUB_KERNEL_FS_STDIO_0300
* @tc.name basic function test : Use fseek to set the stream pointer position with SEEK_SET
* @tc.desc [C- SOFTWARE -0200]
*/
HWTEST_F(FileSystemTest, testFseek, Function | MediumTest | Level3)
{
FILE *fp = nullptr;
int fd = 0;
char writeBuf[] = "this is a file";
char readBuf[20] = {0};
// write
fd = creat(FILE0, 0777);
EXPECT_NE(fd, -1) << "> creat faild errno = " << errno;
WriteCloseTest(fd);
// read
fp = fopen(FILE0, "r+");
ASSERT_NE(fp, nullptr) << "> fopen errno = " << errno;
fpos_t offset;
EXPECT_EQ(fgetpos(fp, &offset), 0) << "> fgetpos errno = " << errno;
EXPECT_EQ(fseek(fp, 2, SEEK_SET), 0) << "> fseek errno = " << errno;
EXPECT_EQ(ftell(fp), 2) << " errno = " << errno;
EXPECT_EQ(fsetpos(fp, &offset), 0) << "> fsetpos errno = " << errno;
EXPECT_NE(fread(readBuf, sizeof(writeBuf), 1, fp), 0) << "> fread errno = " << errno;
EXPECT_STREQ(writeBuf, readBuf) << "> writeBuf = " << writeBuf << "\n> readBuf = " << readBuf;
EXPECT_NE(fclose(fp), -1) << "> fclose errno =" << errno;
}
/**
* @tc.number SUB_KERNEL_FS_STDIO_0310
* @tc.name basic function test : Use fseek to set the stream pointer position with SEEK_CUR
* @tc.desc [C- SOFTWARE -0200]
*/
HWTEST_F(FileSystemTest, testFseekSeekCur, Function | MediumTest | Level3)
{
FILE *fp = nullptr;
int fd = 0;
char writeBuf[] = "this is a file";
char readBuf[20] = {0};
// write
fd = creat(FILE0, 0777);
EXPECT_NE(fd, -1) << "> creat faild errno = " << errno;
WriteCloseTest(fd);
// read
fp = fopen(FILE0, "r+");
ASSERT_NE(fp, nullptr) << "> fopen errno = " << errno;
fpos_t offset;
EXPECT_EQ(fgetpos(fp, &offset), 0) << "> fgetpos errno = " << errno;
EXPECT_EQ(fseek(fp, 2, SEEK_CUR), 0) << "> fseek errno = " << errno;
EXPECT_EQ(ftell(fp), 2) << " errno = " << errno;
EXPECT_EQ(fsetpos(fp, &offset), 0) << "> fsetpos errno = " << errno;
EXPECT_NE(fread(readBuf, sizeof(writeBuf), 1, fp), 0) << "> fread errno = " << errno;
EXPECT_STREQ(writeBuf, readBuf) << "> writeBuf = " << writeBuf << "\n> readBuf = " << readBuf;
EXPECT_NE(fclose(fp), -1) << "> fclose errno =" << errno;
}
/**
* @tc.number SUB_KERNEL_FS_STDIO_0320
* @tc.name basic function test : Use fseek to set the stream pointer position with SEEK_END
* @tc.desc [C- SOFTWARE -0200]
*/
HWTEST_F(FileSystemTest, testFseekSeekEnd, Function | MediumTest | Level3)
{
FILE *fp = nullptr;
int fd = 0;
char writeBuf[] = "this is a file";
char readBuf[20] = {0};
// write
fd = creat(FILE0, 0777);
EXPECT_NE(fd, -1) << "> creat faild errno = " << errno;
WriteCloseTest(fd);
// read
fp = fopen(FILE0, "r+");
ASSERT_NE(fp, nullptr) << "> fopen errno = " << errno;
fpos_t offset;
EXPECT_EQ(fgetpos(fp, &offset), 0) << "> fgetpos errno = " << errno;
EXPECT_EQ(fseek(fp, 0, SEEK_END), 0) << "> fseek errno = " << errno;
EXPECT_EQ(ftell(fp), sizeof(writeBuf)) << " errno = " << errno;
EXPECT_EQ(fsetpos(fp, &offset), 0) << "> fsetpos errno = " << errno;
EXPECT_NE(fread(readBuf, sizeof(writeBuf), 1, fp), 0) << "> fread errno = " << errno;
EXPECT_STREQ(writeBuf, readBuf) << "> writeBuf = " << writeBuf << "\n> readBuf = " << readBuf;
EXPECT_NE(fclose(fp), -1) << "> fclose errno =" << errno;
}
/**
* @tc.number SUB_KERNEL_FS_STDIO_0400
* @tc.name basic function test : Use fseeko to set the stream pointer position with SEEK_SET
* @tc.desc [C- SOFTWARE -0200]
*/
HWTEST_F(FileSystemTest, testFseeko, Function | MediumTest | Level3)
{
FILE *fp = nullptr;
int fd = 0;
char writeBuf[] = "this is a file";
char readBuf[20] = {0};
// write
fd = creat(FILE0, 0777);
EXPECT_NE(fd, -1) << "> creat faild errno = " << errno;
WriteCloseTest(fd);
// read
fp = fopen(FILE0, "r+");
ASSERT_NE(fp, nullptr) << "> fopen errno = " << errno;
EXPECT_EQ(fseeko(fp, 2, SEEK_SET), 0) << "> fseeko errno = " << errno;
EXPECT_EQ(ftello(fp), 2) << " errno = " << errno;
EXPECT_EQ(fseeko(fp, 0, SEEK_SET), 0) << "> fseeko errno = " << errno;
EXPECT_EQ(ftello(fp), 0) << " errno = " << errno;
EXPECT_NE(fread(readBuf, sizeof(writeBuf), 1, fp), 0) << "> fread errno = " << errno;
EXPECT_STREQ(writeBuf, readBuf) << "> writeBuf = " << writeBuf << "\n> readBuf = " << readBuf;
EXPECT_NE(fclose(fp), -1) << "> fclose errno =" << errno;
}
/**
* @tc.number SUB_KERNEL_FS_STDIO_0410
* @tc.name basic function test : Use fseeko to set the stream pointer position with SEEK_CUR
* @tc.desc [C- SOFTWARE -0200]
*/
HWTEST_F(FileSystemTest, testFseekoSeekCur, Function | MediumTest | Level3)
{
FILE *fp = nullptr;
int fd = 0;
char writeBuf[] = "this is a file";
char readBuf[20] = {0};
// write
fd = creat(FILE0, 0777);
EXPECT_NE(fd, -1) << "> creat faild errno = " << errno;
WriteCloseTest(fd);
// read
fp = fopen(FILE0, "r+");
ASSERT_NE(fp, nullptr) << "> fopen errno = " << errno;
EXPECT_EQ(fseeko(fp, 2, SEEK_CUR), 0) << "> fseeko errno = " << errno;
EXPECT_EQ(ftello(fp), 2) << " errno = " << errno;
EXPECT_EQ(fseeko(fp, 0, SEEK_SET), 0) << "> fseeko errno = " << errno;
EXPECT_EQ(ftello(fp), 0) << " errno = " << errno;
EXPECT_NE(fread(readBuf, sizeof(writeBuf), 1, fp), 0) << "> fread errno = " << errno;
EXPECT_STREQ(writeBuf, readBuf) << "> writeBuf = " << writeBuf << "\n> readBuf = " << readBuf;
EXPECT_NE(fclose(fp), -1) << "> fclose errno =" << errno;
}
/**
* @tc.number SUB_KERNEL_FS_STDIO_0420
* @tc.name basic function test : Use fseeko to set the stream pointer position with SEEK_END
* @tc.desc [C- SOFTWARE -0200]
*/
HWTEST_F(FileSystemTest, testFseekoSeekEnd, Function | MediumTest | Level3)
{
FILE *fp = nullptr;
int fd = 0;
char writeBuf[] = "this is a file";
char readBuf[20] = {0};
// write
fd = creat(FILE0, 0777);
EXPECT_NE(fd, -1) << "> creat faild errno = " << errno;
WriteCloseTest(fd);
// read
fp = fopen(FILE0, "r+");
ASSERT_NE(fp, nullptr) << "> fopen errno = " << errno;
EXPECT_EQ(fseeko(fp, 0, SEEK_END), 0) << "> fseeko errno = " << errno;
EXPECT_EQ(ftello(fp), sizeof(writeBuf)) << " errno = " << errno;
EXPECT_EQ(fseeko(fp, 0, SEEK_SET), 0) << "> fseeko errno = " << errno;
EXPECT_EQ(ftello(fp), 0) << " errno = " << errno;
EXPECT_NE(fread(readBuf, sizeof(writeBuf), 1, fp), 0) << "> fread errno = " << errno;
EXPECT_STREQ(writeBuf, readBuf) << "> writeBuf = " << writeBuf << "\n> readBuf = " << readBuf;
EXPECT_NE(fclose(fp), -1) << "> fclose errno =" << errno;
}
void *ChildWrite(void *p)
{
FILE *fp = (FILE*)p;
flockfile(fp);
size_t re0 = fwrite("this is ", sizeof("this is"), 1, fp);
EXPECT_EQ(re0, 1) << "fwrite errno = " << errno;
Msleep(FOURTY_MS);
size_t re1 = fwrite("a file", sizeof("a file"), 1, fp);
EXPECT_EQ(re1, 1) << "fwrite errno = " << errno;
funlockfile(fp);
LOG("> ChildWrite over");
return nullptr;
}
/**
* @tc.number SUB_KERNEL_FS_STDIO_0500
* @tc.name basic function test : Use the funlockfile function to unlock the file
* @tc.desc [C- SOFTWARE -0200]
*/
HWTEST_F(FileSystemTest, testFunlockfile, Function | MediumTest | Level3)
{
const char filePath[] = TOP_DIR "/" DIR0 "/" DIR0_FILE0;
char readBuf[20];
char writeBuf[] = "this is a file";
CreateTestFolder();
FILE *fp = fopen(filePath, "r+");
ASSERT_NE(fp, nullptr) << "> fopen errno = " << errno;
pthread_t tid;
int reInt = pthread_create(&tid, nullptr, ChildWrite, (void*)fp);
ASSERT_EQ(reInt, 0) << "> pthread_create errno, reInt = " << reInt;
Msleep(20);
flockfile(fp);
LOG("> childRead over");
EXPECT_EQ(fseek(fp, 0, SEEK_SET), 0) << "> fseek errno = " << errno;
EXPECT_NE(fread(readBuf, sizeof(writeBuf), 1, fp), 0) << "> fread error";
EXPECT_STREQ(writeBuf, readBuf);
funlockfile(fp);
int ret = pthread_join(tid, nullptr);
EXPECT_EQ(ret, 0) << "pthread_join failed, errno=" << ret;
EXPECT_NE(fclose(fp), -1) << "> fclose errno =" << errno;
}
/**
* @tc.number SUB_KERNEL_FS_STDIO_0600
* @tc.name basic function test : Use the fileno function to return the file descriptor of the stream, test write
* @tc.desc [C- SOFTWARE -0200]
*/
HWTEST_F(FileSystemTest, testFileno, Function | MediumTest | Level2)
{
const char filePath[] = TOP_DIR "/" FILE0;
FILE *fp = nullptr;
int fd = 0;
// write
fd = creat(filePath, 0777);
ASSERT_NE(fd, -1) << "> creat errno = " << errno;
ASSERT_NE(close(fd), -1) << "> close errno = " << errno;
fp = fopen(filePath, "w+");
ASSERT_NE(fp, nullptr) << "> fopen errno = " << errno;
fd = fileno(fp);
EXPECT_NE(fd, -1) << "> fileno errno = " << errno;
WriteCloseTest(fd);
// read
fd = open(filePath, O_RDWR);
EXPECT_NE(fd, -1) << "> open errno = " << errno;
ReadCloseTest(fd);
}
/**
* @tc.number SUB_KERNEL_FS_STDIO_0610
* @tc.name basic function test : Use the fileno function to return the file descriptor of the stream, test read
* @tc.desc [C- SOFTWARE -0200]
*/
HWTEST_F(FileSystemTest, testFileno1, Function | MediumTest | Level2)
{
const char filePath[] = TOP_DIR "/" FILE0;
FILE *fp = nullptr;
int fd = 0;
// write
fd = creat(filePath, 0777);
EXPECT_NE(fd, -1) << "> creat faild errno = " << errno;
WriteCloseTest(fd);
// read
fp = fopen(filePath, "r+");
ASSERT_NE(fp, nullptr) << "> fopen errno = " << errno;
fd = fileno(fp);
EXPECT_NE(fd, -1) << "> fileno errno = " << errno;
ReadCloseTest(fd);
}
#endif
/**
* @tc.number SUB_KERNEL_FS_STDIO_0700
* @tc.name basic function test : Use the rename function to rename files.
......@@ -417,61 +63,3 @@ HWTEST_F(FileSystemTest, testRenameDir, Function | MediumTest | Level3)
EXPECT_NE(rename(DIR0, newDirName), -1) << "> rename errno = " << errno;
EXPECT_NE(rmdir(newDirName), -1) << "> rmdir errno = " << errno;
}
#if 0
/**
* @tc.number SUB_KERNEL_FS_STDIO_0800
* @tc.name basic function test : Use the fflush function to refresh stream
* @tc.desc [C- SOFTWARE -0200]
*/
HWTEST_F(FileSystemTest, testFflush, Function | MediumTest | Level3)
{
const char filePath[] = TOP_DIR "/" DIR0 "/" DIR0_FILE0;
char writeBuf[] = "0123456789ABCDE";
char readBuf[50] = {0};
CreateTestFolder();
pid_t pid = fork();
ASSERT_TRUE(pid >= 0) << "> parent: fork errno = " << errno;
if (pid == 0) {
int exitCode = 0;
FILE *fp = fopen(filePath, "a+");
if (fp == nullptr) {
LOG("fp is null");
exit(1);
}
setvbuf(fp, nullptr, _IOFBF, 1024);
int reInt = fwrite(writeBuf, sizeof(writeBuf), 1, fp);
if (reInt != 1) {
LOG("fwrite return reInt = %d, errno = %d", reInt, errno);
exitCode = 1;
}
Msleep(100);
if (fflush(fp) == -1){
LOG("fflush errno = %d", errno);
exitCode = 1;
}
Msleep(100);
if (fclose(fp) == -1){
LOG("fclose errno = %d", errno);
exitCode = 1;
}
exit(exitCode);
}
Msleep(50);
FILE *fp = fopen(filePath, "r");
ASSERT_NE(fp, nullptr);
EXPECT_EQ(fseek(fp, 0, SEEK_END), 0) << "> fseek errno = " << errno;
EXPECT_EQ(ftell(fp), 0);
EXPECT_NE(fclose(fp), -1) << "> fclose errno =" << errno;
Msleep(100);
fp = fopen(filePath, "r");
ASSERT_NE(fp, nullptr);
EXPECT_NE(fread(readBuf, sizeof(writeBuf), 1, fp), 0) << "> fread errno = " << errno;
EXPECT_STREQ(readBuf, writeBuf);
LOG("> readBuf = %s", readBuf);
EXPECT_NE(fclose(fp), -1) << "> fclose errno =" << errno;
Msleep(100);
AssertProcExitedOK(pid);
}
#endif
......@@ -33,61 +33,6 @@
#include "libfs.h"
using namespace testing::ext;
#if 0
/**
* @tc.number SUB_KERNEL_FS_STDLIB_0100
* @tc.name basic function test : mkstemp create a temporary file
* @tc.desc [C- SOFTWARE -0200]
*/
HWTEST_F(FileSystemTest, testMkstemp, Function | MediumTest | Level2)
{
int fd = 0;
char tmpFileName[]= "tmpFile_XXXXXX";
fd = mkstemp(tmpFileName);
EXPECT_NE(fd, -1) << "> mkstemp errno = " << errno;
WriteCloseTest(fd);
fd = open(tmpFileName, O_RDWR);
EXPECT_NE(fd, -1) << "> open errno = " << errno;
ReadCloseTest(fd);
EXPECT_NE(unlink(tmpFileName), -1) << "> unlink errno = " << errno;
}
/**
* @tc.number SUB_KERNEL_FS_STDLIB_0200
* @tc.name basic function test : mkstemps create a temporary file
* @tc.desc [C- SOFTWARE -0200]
*/
HWTEST_F(FileSystemTest, testMkstemps, Function | MediumTest | Level2)
{
int fd = 0;
char tmpFileName[] = "tmpFile_XXXXXX";
fd = mkstemps(tmpFileName, 0);
EXPECT_NE(fd, -1) << "> mkstemp errno = " << errno;
WriteCloseTest(fd);
fd = open(tmpFileName, O_RDWR);
EXPECT_NE(fd, -1) << "> open errno = " << errno;
ReadCloseTest(fd);
EXPECT_NE(unlink(tmpFileName), -1) << "> unlink errno = " << errno;
}
/**
* @tc.number SUB_KERNEL_FS_STDLIB_0300
* @tc.name basic function test : mkostemp create a temporary file with read and write
* @tc.desc [C- SOFTWARE -0200]
*/
HWTEST_F(FileSystemTest, testMkostemp, Function | MediumTest | Level2)
{
int fd = 0;
char tmpFileName[] = "tmpFile_XXXXXX";
fd = mkostemp(tmpFileName, O_RDWR);
EXPECT_NE(fd, -1) << "> mkstemp errno = " << errno;
WriteCloseTest(fd);
fd = open(tmpFileName, O_RDWR);
EXPECT_NE(fd, -1) << "> open errno = " << errno;
ReadCloseTest(fd);
EXPECT_NE(unlink(tmpFileName), -1) << "> unlink errno = " << errno;
}
#endif
/**
* @tc.number SUB_KERNEL_FS_STDLIB_0400
* @tc.name basic function test : mktemp create a temporary file name, mkdtemp create a directory
......
......@@ -174,56 +174,6 @@ HWTEST_F(FileSystemTest, testChdirEnotdir, Function | MediumTest | Level3)
EXPECT_EQ(errno, ENOTDIR);
EXPECT_NE(chdir(TOP_DIR), -1) << "> chdir errno = " << errno;
}
#if 0
#if defined(LITE_FS_NFS) || defined(LITE_FS_VFAT)
/**
* @tc.number SUB_KERNEL_FS_UNISTD_0300
* @tc.name basic function test : dup copy file description, then write and read
* @tc.desc [C- SOFTWARE -0200]
*/
HWTEST_F(FileSystemTest, testDup, Function | MediumTest | Level3)
{
int fd = 0;
int fdNew = 0;
fd = open(FILE0, O_CREAT | O_RDWR, 0777);
EXPECT_NE(fd, -1) << "> open faild errno = " << errno;
WriteCloseTest(fd);
fd = open(FILE0, O_RDONLY, 0777);
EXPECT_NE(fd, -1) << "> open faild errno = " << errno;
fdNew = dup(fd);
#if defined(LITE_FS_NFS)
EXPECT_NE(fdNew, -1) << "> dup errno = " << errno;
#endif
// vfat not suuport, after support change to NE
#if defined(LITE_FS_VFAT)
EXPECT_EQ(fdNew, -1) << "> dup errno = " << errno;
#endif
if (fdNew != -1) {
ReadCloseTest(fdNew);
}
EXPECT_NE(close(fd), -1) << "> close errno = " << errno;
}
#endif
/**
* @tc.number SUB_KERNEL_FS_UNISTD_0400
* @tc.name basic function test : dup2 copy file description, then write and read
* @tc.desc [C- SOFTWARE -0200]
*/
HWTEST_F(FileSystemTest, testDup2, Function | MediumTest | Level3)
{
int fd = 0;
int fdNew = 0;
fd = open(FILE0, O_CREAT | O_RDWR, 0777);
EXPECT_NE(fd, -1) << "> open faild errno = " << errno;
WriteCloseTest(fd);
fd = open(FILE0, O_RDONLY, 0777);
EXPECT_NE(fd, -1) << "> open faild errno = " << errno;
EXPECT_NE(dup2(fd, fdNew), -1) << "> dup2 errno = " << errno;
ReadCloseTest(fdNew);
EXPECT_NE(close(fd), -1) << "> close errno = " << errno;
}
#endif
#if defined(LITE_FS_VFAT)
/**
* @tc.number SUB_KERNEL_FS_UNISTD_0500
......
......@@ -274,45 +274,6 @@ HWTEST_F(ProcessTest, testExit, Function | MediumTest | Level2)
ASSERT_EQ(exitCode, reInt[i]);
}
}
#if 0
/**
* @tc.number SUB_KERNEL_PROCESS_EXIT_0200
* @tc.name Test exit about IO flush
* @tc.desc [C- SOFTWARE -0200]
*/
HWTEST_F(ProcessTest, testExitFlush, Function | MediumTest | Level3)
{
const char* testFile = "TEST_FILE.txt";
char writeBuf[] = "this is a file";
char readBuf[20] = {0};
pid_t pid;
pid = fork();
ASSERT_TRUE(pid >= 0) << "> parent: fork errno = " << errno;
if (pid == 0) {
// write
FILE *fp = fopen(testFile, "w+");
if (fp == nullptr) {
LOG("> child fopen errno = %d", errno);
exit(1);
}
fwrite(writeBuf, sizeof(writeBuf), 1, fp);
exit(0);
}
WaitProcExitedOK(pid);
// read
FILE *fp = fopen(testFile, "r+");
ASSERT_NE(fp, nullptr) << "> fopen errno = " << errno;
EXPECT_NE(fread(readBuf, sizeof(writeBuf), 1, fp), 0);
EXPECT_STREQ(writeBuf, readBuf) << "> writeBuf = " << writeBuf\
<< "\n> readBuf = " << readBuf;
EXPECT_NE(fclose(fp), -1) << "> fclose errno =" <<errno;
remove(testFile);
}
#endif
/**
* @tc.number SUB_KERNEL_PROCESS_ASSERT_0100
* @tc.name Basic test about assert true
......
......@@ -390,8 +390,6 @@ HWTEST_F(ActsUtilCheckApiTest, testIsascii2200, Function | MediumTest | Level1)
// int returnVal;
// paraVal = 128;
// returnVal = isastream(paraVal);
// LOGD(" isastream returnVal:='%d'\n", returnVal);
// ASSERT_TRUE(-1 == returnVal) << "ErrInfo: isastream returnVal:='" << returnVal << "'";
// }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册