未验证 提交 1c18d227 编写于 作者: O openharmony_ci 提交者: Gitee

!850 fix: 删除无效用例

Merge pull request !850 from zhushengle/cherry-pick-1647945401
......@@ -41,32 +41,3 @@ sources_smoke = []
sources_pressure = []
sources_full = []
# jffs module
if (LOSCFG_USER_TEST_FS_JFFS == true) {
import("./jffs/config.gni")
common_include_dirs += jffs_include_dirs
sources_entry += jffs_sources_entry
sources_smoke += jffs_sources_smoke
sources_pressure += jffs_sources_pressure
sources_full += jffs_sources_full
}
# proc module
if (LOSCFG_USER_TEST_FS_PROC == true) {
import("./proc/config.gni")
common_include_dirs += proc_include_dirs
sources_entry += proc_sources_entry
sources_smoke += proc_sources_smoke
sources_full += proc_sources_full
}
# vfat module
if (LOSCFG_USER_TEST_FS_VFAT == true) {
import("./vfat/config.gni")
common_include_dirs += vfat_include_dirs
sources_entry += vfat_sources_entry
sources_smoke += vfat_sources_smoke
sources_pressure += vfat_sources_pressure
sources_full += vfat_sources_full
}
此差异已折叠。
此差异已折叠。
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "It_vfs_jffs.h"
static UINT32 Testcase(VOID)
{
INT32 ret, dirFd, len;
INT32 fd = -1;
CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME01 };
CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME01 };
DIR *dir = NULL;
struct dirent *ptr = NULL;
ret = mkdir(pathname1, HIGHEST_AUTHORITY);
ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
dir = opendir(pathname1);
ICUNIT_GOTO_NOT_EQUAL(dir, NULL, dir, EXIT1);
dirFd = dirfd(dir);
ICUNIT_GOTO_NOT_EQUAL(dirFd, JFFS_IS_ERROR, dirFd, EXIT1);
fd = openat(dirFd, "test.txt", O_CREAT | O_RDWR | O_TRUNC);
ICUNIT_GOTO_NOT_EQUAL(fd, JFFS_IS_ERROR, fd, EXIT1);
len = write(fd, "01234567890123456789012345", 16); // 16 means length which will be writed
ret = close(fd);
ICUNIT_GOTO_NOT_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT1);
ret = unlinkat(dirFd, "test.txt", 0);
ICUNIT_GOTO_NOT_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT1);
ret = closedir(dir);
ICUNIT_GOTO_NOT_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT);
ret = rmdir(JFFS_PATH_NAME01);
ICUNIT_GOTO_NOT_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT);
return JFFS_NO_ERROR;
EXIT1:
close(fd);
unlink(pathname1);
closedir(dir);
EXIT:
rmdir(JFFS_PATH_NAME01);
return JFFS_NO_ERROR;
}
VOID ItJffs001(VOID)
{
TEST_ADD_CASE(__FUNCTION__, Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
}
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "It_vfs_jffs.h"
static UINT32 Testcase(VOID)
{
CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = "/test1/test2/test3";
CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = "/test1/test2";
CHAR *dname = NULL;
INT32 ret;
dname = dirname(pathname1);
ret = strcmp(pathname2, dname);
ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
return JFFS_NO_ERROR;
EXIT:
return JFFS_NO_ERROR;
}
VOID ItJffs002(VOID)
{
TEST_ADD_CASE(__FUNCTION__, Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
}
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "It_vfs_jffs.h"
static UINT32 Testcase(VOID)
{
CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_MAIN_DIR0 };
CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_MAIN_DIR0 };
CHAR *dname = NULL;
INT32 ret;
INT32 fd = -1;
DIR *dir1 = NULL;
DIR *dir2 = NULL;
dir1 = opendir(pathname1);
ICUNIT_GOTO_NOT_EQUAL(dir1, NULL, dir1, EXIT);
ret = closedir(dir1);
ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
(void)strcat_s(pathname2, JFFS_STANDARD_NAME_LENGTH, "/test123");
fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
ICUNIT_GOTO_NOT_EQUAL(fd, JFFS_IS_ERROR, fd, EXIT1);
dir2 = fdopendir(fd);
ICUNIT_GOTO_NOT_EQUAL(dir2, NULL, dir2, EXIT2);
ret = unlink(pathname2);
ICUNIT_GOTO_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT2);
ret = closedir(dir2);
ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
return JFFS_NO_ERROR;
EXIT2:
closedir(dir2);
EXIT1:
unlink(pathname2);
return JFFS_NO_ERROR;
EXIT:
closedir(dir1);
return JFFS_NO_ERROR;
}
VOID ItJffs003(VOID)
{
TEST_ADD_CASE(__FUNCTION__, Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
}
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "It_vfs_jffs.h"
static UINT32 Testcase(VOID)
{
CHAR dname1[JFFS_STANDARD_NAME_LENGTH] = "";
CHAR *dname2 = NULL;
CHAR *pret = NULL;
INT32 ret;
pret = getcwd(dname1, JFFS_STANDARD_NAME_LENGTH);
ICUNIT_GOTO_NOT_EQUAL(pret, NULL, pret, EXIT);
dname2 = get_current_dir_name();
ICUNIT_GOTO_NOT_EQUAL(dname2, NULL, dname2, EXIT);
ret = strcmp(dname1, dname2);
ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
return JFFS_NO_ERROR;
EXIT:
return JFFS_NO_ERROR;
}
VOID ItJffs004(VOID)
{
TEST_ADD_CASE(__FUNCTION__, Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
}
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "It_vfs_jffs.h"
static UINT32 Testcase(VOID)
{
INT32 ret1, ret2;
INT32 fd = -1;
CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME01 };
ret1 = getdtablesize();
fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
ICUNIT_GOTO_NOT_EQUAL(fd, JFFS_IS_ERROR, fd, EXIT2);
ret2 = getdtablesize();
ICUNIT_GOTO_EQUAL(ret2, (ret1 + 1), ret2, EXIT2);
ret1 = close(fd);
ICUNIT_GOTO_EQUAL(ret1, JFFS_NO_ERROR, ret1, EXIT2);
ret1 = unlink(pathname1);
ICUNIT_GOTO_EQUAL(ret1, JFFS_NO_ERROR, ret1, EXIT1);
return JFFS_NO_ERROR;
EXIT2:
close(fd);
EXIT1:
unlink(pathname1);
EXIT:
return JFFS_NO_ERROR;
}
VOID ItJffs005(VOID)
{
TEST_ADD_CASE(__FUNCTION__, Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
}
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "It_vfs_jffs.h"
static UINT32 Testcase(VOID)
{
INT32 ret1, ret2;
INT32 fd = -1;
CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME01 };
struct mntent *mnt = NULL;
FILE *fp = NULL;
ret1 = strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "test12");
ICUNIT_ASSERT_EQUAL(ret1, EOK, ret1);
fp = setmntent(pathname1, "w+b");
ICUNIT_GOTO_NOT_EQUAL(fp, NULL, fp, EXIT);
mnt = getmntent(fp);
ICUNIT_GOTO_NOT_EQUAL(mnt, NULL, mnt, EXIT);
printf("[%s:%d] mnt->mnt_fsname=%s\n", __FUNCTION__, __LINE__, mnt->mnt_fsname);
printf("[%s:%d] mnt->mnt_dir=%s\n", __FUNCTION__, __LINE__, mnt->mnt_dir);
printf("[%s:%d] mnt->mnt_type=%s\n", __FUNCTION__, __LINE__, mnt->mnt_type);
printf("[%s:%d] mnt->mnt_opts=%s\n", __FUNCTION__, __LINE__, mnt->mnt_opts);
printf("[%s:%d] mnt->mnt_freq=%d\n", __FUNCTION__, __LINE__, mnt->mnt_freq);
printf("[%s:%d] mnt->mnt_passno=%d\n", __FUNCTION__, __LINE__, mnt->mnt_passno);
endmntent(fp);
unlink(pathname1);
return JFFS_NO_ERROR;
EXIT:
endmntent(fp);
unlink(pathname1);
return JFFS_NO_ERROR;
}
VOID ItJffs006(VOID)
{
TEST_ADD_CASE(__FUNCTION__, Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
}
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "It_vfs_jffs.h"
static UINT32 Testcase(VOID)
{
CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_MOUNT_DIR0 };
CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_MOUNT_DIR0 };
CHAR pathname3[JFFS_STANDARD_NAME_LENGTH] = { JFFS_MOUNT_DIR0 };
glob_t buf;
int i, ret;
int fd1 = -1;
int fd2 = -2;
(void)strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/test1");
fd1 = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
ICUNIT_GOTO_NOT_EQUAL(fd1, JFFS_IS_ERROR, fd1, EXIT1);
ret = close(fd1);
ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
(void)strcat_s(pathname2, JFFS_STANDARD_NAME_LENGTH, "/test2");
fd2 = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
ICUNIT_GOTO_NOT_EQUAL(fd2, JFFS_IS_ERROR, fd2, EXIT2);
ret = close(fd2);
ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
glob("/storage/*", GLOB_NOSORT, NULL, &buf);
ICUNIT_GOTO_EQUAL(buf.gl_pathc, 2, buf.gl_pathc, EXIT1); // 2 means size of path
ret = strcmp(pathname1, buf.gl_pathv[0]);
ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
ret = strcmp(pathname2, buf.gl_pathv[1]);
ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
globfree(&buf);
ret = unlink(pathname2);
ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
ret = unlink(pathname1);
ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
return JFFS_NO_ERROR;
EXIT2:
close(fd2);
unlink(pathname2);
EXIT1:
close(fd1);
unlink(pathname1);
EXIT:
globfree(&buf);
return JFFS_NO_ERROR;
}
VOID ItJffs007(VOID)
{
TEST_ADD_CASE(__FUNCTION__, Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
}
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "It_vfs_jffs.h"
static UINT32 Testcase(VOID)
{
INT32 ret;
INT32 fd = -1;
CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_MAIN_DIR0 };
DIR *dir = NULL;
dir = opendir(pathname1);
ICUNIT_GOTO_NOT_EQUAL(dir, NULL, dir, EXIT1);
fd = dirfd(dir);
ICUNIT_GOTO_NOT_EQUAL(fd, JFFS_IS_ERROR, fd, EXIT1);
ret = mkdirat(fd, "TEST", HIGHEST_AUTHORITY);
ICUNIT_GOTO_NOT_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT2);
ret = rmdir("/storage/TEST");
ICUNIT_GOTO_NOT_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT2);
ret = closedir(dir);
ICUNIT_GOTO_NOT_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT1);
return JFFS_NO_ERROR;
EXIT2:
rmdir("/storage/TEST");
EXIT1:
closedir(dir);
return JFFS_NO_ERROR;
}
VOID ItJffs008(VOID)
{
TEST_ADD_CASE(__FUNCTION__, Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
}
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "It_vfs_jffs.h"
static UINT32 Testcase(VOID)
{
INT32 ret;
INT32 fd = -1;
CHAR tempFile[] = "tmp_XXXXXX";
CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_MAIN_DIR0 };
ret = chdir(pathname1);
ICUNIT_GOTO_NOT_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT);
fd = mkstemp(tempFile);
ICUNIT_GOTO_NOT_EQUAL(fd, JFFS_IS_ERROR, fd, EXIT1);
ret = close(fd);
ICUNIT_GOTO_NOT_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT1);
ret = unlink(tempFile);
ICUNIT_GOTO_NOT_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT1);
return JFFS_NO_ERROR;
EXIT1:
close(fd);
unlink(tempFile);
EXIT:
return JFFS_NO_ERROR;
}
VOID ItJffs009(VOID)
{
TEST_ADD_CASE(__FUNCTION__, Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
}
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "It_vfs_jffs.h"
static UINT32 Testcase(VOID)
{
INT32 ret;
INT32 fd = -1;
CHAR tempFile[] = "tmp_XXXXXX_hello";
CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_MAIN_DIR0 };
ret = chdir(pathname1);
ICUNIT_GOTO_NOT_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT);
fd = mkstemps(tempFile, 6); // 6 means size of file
ICUNIT_GOTO_NOT_EQUAL(fd, JFFS_IS_ERROR, fd, EXIT1);
ret = close(fd);
ICUNIT_GOTO_NOT_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT1);
ret = unlink(tempFile);
ICUNIT_GOTO_NOT_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT1);
return JFFS_NO_ERROR;
EXIT1:
close(fd);
unlink(tempFile);
EXIT:
return JFFS_NO_ERROR;
}
VOID ItJffs010(VOID)
{
TEST_ADD_CASE(__FUNCTION__, Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
}
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "It_vfs_jffs.h"
static UINT32 Testcase(VOID)
{
INT32 ret;
INT32 fd = -1;
CHAR tempFile[] = "test.XXXXXX";
CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_MAIN_DIR0 };
CHAR *pfd = NULL;
ret = chdir(pathname1);
ICUNIT_GOTO_NOT_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT);
pfd = mktemp(tempFile);
ICUNIT_GOTO_NOT_EQUAL(pfd, NULL, pfd, EXIT1);
printf("temp_file = %s\n", tempFile);
fd = open(pfd, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
ICUNIT_GOTO_NOT_EQUAL(fd, JFFS_IS_ERROR, fd, EXIT1);
ret = close(fd);
ICUNIT_GOTO_NOT_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT1);
ret = unlink(pfd);
ICUNIT_GOTO_NOT_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT1);
return JFFS_NO_ERROR;
EXIT1:
close(fd);
unlink(pfd);
EXIT:
return JFFS_NO_ERROR;
}
VOID ItJffs011(VOID)
{
TEST_ADD_CASE(__FUNCTION__, Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
}
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "It_vfs_jffs.h"
static UINT32 Testcase(VOID)
{
INT32 ret;
INT32 fd = -1;
CHAR tempFile[] = "test_XXXXXX";
CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_MAIN_DIR0 };
CHAR *pfd = NULL;
ret = chdir(pathname1);
ICUNIT_GOTO_NOT_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT);
pfd = mkdtemp(tempFile);
ICUNIT_GOTO_NOT_EQUAL(pfd, NULL, pfd, EXIT1);
printf("temp_file = %s, pfd=%s\n", tempFile, pfd);
ret = rmdir(tempFile);
printf("%s-%d temp=%s ret=%d\n", __FUNCTION__, __LINE__, tempFile, ret);
ICUNIT_GOTO_NOT_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT1);
return JFFS_NO_ERROR;
EXIT1:
rmdir(pfd);
EXIT:
return JFFS_NO_ERROR;
}
VOID ItJffs012(VOID)
{
TEST_ADD_CASE(__FUNCTION__, Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
}
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "It_vfs_jffs.h"
static UINT32 Testcase(VOID)
{
INT32 ret;
INT32 fd = -1;
CHAR tempFile[] = "test_XXXXXX";
CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_MAIN_DIR0 };
ret = chdir(pathname1);
ICUNIT_GOTO_NOT_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT);
fd = mkostemp(tempFile, O_APPEND);
ICUNIT_GOTO_NOT_EQUAL(fd, JFFS_IS_ERROR, fd, EXIT1);
ret = close(fd);
ICUNIT_GOTO_NOT_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT1);
ret = unlink(tempFile);
ICUNIT_GOTO_NOT_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT1);
return JFFS_NO_ERROR;
EXIT1:
close(fd);
unlink(tempFile);
EXIT:
return JFFS_NO_ERROR;
}
VOID ItJffs013(VOID)
{
TEST_ADD_CASE(__FUNCTION__, Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
}
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "It_vfs_jffs.h"
static UINT32 Testcase(VOID)
{
INT32 ret;
INT32 fd = -1;
openlog("Test", LOG_CONS | LOG_PID, LOG_USER);
syslog(LOG_INFO, "This is a massage just for test");
closelog();
return JFFS_NO_ERROR;
EXIT:
close(fd);
unlink("Test");
return JFFS_NO_ERROR;
}
VOID ItJffs014(VOID)
{
TEST_ADD_CASE(__FUNCTION__, Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
}
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "It_vfs_jffs.h"
static UINT32 Testcase(VOID)
{
CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_MAIN_DIR0 };
long ret;
ret = pathconf(pathname1, _PC_LINK_MAX);
ICUNIT_GOTO_EQUAL(ret, _POSIX_LINK_MAX, ret, EXIT);
ret = pathconf(pathname1, _PC_NAME_MAX);
ICUNIT_GOTO_EQUAL(ret, NAME_MAX, ret, EXIT);
return JFFS_NO_ERROR;
EXIT:
return JFFS_NO_ERROR;
}
VOID ItJffs015(VOID)
{
TEST_ADD_CASE(__FUNCTION__, Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
}
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "It_vfs_jffs.h"
static UINT32 Testcase(VOID)
{
INT32 ret1, ret2;
INT32 fd = -1;
CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME01 };
struct mntent *mnt = NULL;
char *buf = NULL;
static struct mntent mnt1;
FILE *fp = NULL;
(void)strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "test12");
fp = setmntent(pathname1, "w+b");
ICUNIT_GOTO_NOT_EQUAL(fp, NULL, fp, EXIT);
mnt = getmntent_r(fp, &mnt1, buf, 1);
ICUNIT_GOTO_NOT_EQUAL(mnt, NULL, mnt, EXIT);
printf("[%s:%d] mnt->mnt_fsname=%s\n", __FUNCTION__, __LINE__, mnt->mnt_fsname);
printf("[%s:%d] mnt->mnt_dir=%s\n", __FUNCTION__, __LINE__, mnt->mnt_dir);
printf("[%s:%d] mnt->mnt_type=%s\n", __FUNCTION__, __LINE__, mnt->mnt_type);
printf("[%s:%d] mnt->mnt_opts=%s\n", __FUNCTION__, __LINE__, mnt->mnt_opts);
printf("[%s:%d] mnt->mnt_freq=%d\n", __FUNCTION__, __LINE__, mnt->mnt_freq);
printf("[%s:%d] mnt->mnt_passno=%d\n", __FUNCTION__, __LINE__, mnt->mnt_passno);
endmntent(fp);
unlink(pathname1);
return JFFS_NO_ERROR;
EXIT:
endmntent(fp);
unlink(pathname1);
return JFFS_NO_ERROR;
}
VOID ItJffs016(VOID)
{
TEST_ADD_CASE(__FUNCTION__, Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
}
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "It_vfs_jffs.h"
static INT32 DisplayInfo(const char *fpath, const struct stat *sb, int tflag, struct FTW *ftwbuf)
{
printf("%-3s %2d ",
(tflag == FTW_D) ? "d" : (tflag == FTW_DNR) ? "dnr" :
(tflag == FTW_DP) ? "dp" : (tflag == FTW_F) ? "f" :
(tflag == FTW_NS) ? "ns" : (tflag == FTW_SL) ? "sl" :
(tflag == FTW_SLN) ? "sln" : "???",
ftwbuf->level);
if (tflag == FTW_NS) {
printf("-------");
} else {
printf("%7d", (intmax_t)sb->st_size);
}
printf(" %-40s %d %s\n", fpath, ftwbuf->base, fpath + ftwbuf->base);
return 0;
}
static UINT32 Testcase(VOID)
{
INT32 ret;
INT32 flags = 0;
CHAR *pathnamedir = { JFFS_MAIN_DIR0 };
CHAR pathname01[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME01 };
CHAR pathname11[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME11 };
CHAR pathname02[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME02 };
ret = mkdir(pathname01, HIGHEST_AUTHORITY);
ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
ret = mkdir(pathname11, HIGHEST_AUTHORITY);
ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
ret = mkdir(pathname02, HIGHEST_AUTHORITY);
ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT3);
ret = nftw(pathnamedir, DisplayInfo, 20, flags); // 20 means max fd
ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT3);
ret = rmdir(pathname02);
ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT3);
ret = rmdir(pathname11);
ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
ret = rmdir(pathname01);
ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
return JFFS_NO_ERROR;
EXIT3:
rmdir(pathname02);
EXIT2:
rmdir(pathname11);
EXIT1:
rmdir(pathname01);
return JFFS_IS_ERROR;
}
VOID ItJffs017(VOID)
{
TEST_ADD_CASE(__FUNCTION__, Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
}
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "It_vfs_jffs.h"
#define TEST_STR "hello world"
static UINT32 Testcase(VOID)
{
FILE *fd = NULL;
INT32 ret;
size_t size;
char *ptr = NULL;
char *ptr1 = TEST_STR;
fd = open_memstream(&ptr, &size);
ICUNIT_GOTO_NOT_EQUAL(fd, NULL, fd, EXIT1);
fprintf(fd, TEST_STR);
ret = fclose(fd);
ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
ret = strcmp(ptr, ptr1);
ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
ret = strlen(ptr);
ICUNIT_GOTO_EQUAL(size, ret, size, EXIT);
free(ptr);
return JFFS_NO_ERROR;
EXIT1:
fclose(fd);
EXIT:
free(ptr);
return JFFS_IS_ERROR;
}
VOID ItJffs018(VOID)
{
TEST_ADD_CASE(__FUNCTION__, Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
}
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "It_vfs_jffs.h"
static constexpr wchar_t* TEST_STR = L"hello world";
static UINT32 Testcase(VOID)
{
FILE *fd = NULL;
INT32 ret;
size_t size;
wchar_t *ptr = NULL;
wchar_t *ptr1 = { TEST_STR };
fd = open_wmemstream(&ptr, &size);
ICUNIT_GOTO_NOT_EQUAL(fd, NULL, fd, EXIT1);
fwprintf(fd, ptr1);
ret = fclose(fd);
ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
ret = wcscmp(ptr, ptr1);
ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
ret = wcslen(ptr);
ICUNIT_GOTO_EQUAL(size, ret, size, EXIT);
free(ptr);
return JFFS_NO_ERROR;
EXIT1:
fclose(fd);
EXIT:
free(ptr);
return JFFS_IS_ERROR;
}
VOID ItJffs019(VOID)
{
TEST_ADD_CASE(__FUNCTION__, Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
}
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "It_vfs_jffs.h"
static constexpr int LINE_LENGTH = 50;
static UINT32 Testcase(VOID)
{
INT32 ret;
CHAR pathnamedir[LINE_LENGTH] = { JFFS_MAIN_DIR0 };
FILE *file = nullptr;
CHAR line[LINE_LENGTH];
CHAR *ptr = NULL;
ret = chdir(pathnamedir);
ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
file = popen("pwd", "r");
ICUNIT_GOTO_NOT_EQUAL(file, NULL, file, EXIT);
ptr = fgets(line, LINE_LENGTH, file);
ICUNIT_GOTO_NOT_EQUAL(ptr, NULL, ptr, EXIT1);
(void)strcat_s(pathnamedir, LINE_LENGTH, "\n");
ret = strcmp(line, pathnamedir);
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
ret = pclose(file);
ICUNIT_GOTO_NOT_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT);
return JFFS_NO_ERROR;
EXIT1:
pclose(file);
EXIT:
return JFFS_IS_ERROR;
}
VOID ItJffs020(VOID)
{
TEST_ADD_CASE(__FUNCTION__, Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
}
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "It_vfs_jffs.h"
static UINT32 Testcase(VOID)
{
DIR *dirp = NULL;
INT32 ret;
CHAR *pathnamedir = { JFFS_MAIN_DIR0 };
CHAR pathname01[JFFS_STANDARD_NAME_LENGTH] = { JFFS_MAIN_DIR0 };
struct dirent *dp1 = (struct dirent *)malloc(sizeof(struct dirent));
struct dirent *dp2 = (struct dirent *)malloc(sizeof(struct dirent));
struct dirent *dp2Bak = dp2;
(void)strcat_s(pathname01, JFFS_STANDARD_NAME_LENGTH, "/test1");
ret = mkdir(pathname01, HIGHEST_AUTHORITY);
ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
dirp = opendir(pathnamedir);
ICUNIT_GOTO_NOT_EQUAL(dirp, NULL, dirp, EXIT2);
while (1) {
readdir_r(dirp, dp1, &dp2);
if (dp2 == NULL) {
break;
}
ret = strcmp(dp2->d_name, "test1");
ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
}
ret = rmdir(pathname01);
ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
closedir(dirp);
free(dp1);
free(dp2Bak);
return JFFS_NO_ERROR;
EXIT2:
rmdir(pathname01);
closedir(dirp);
free(dp1);
free(dp2Bak);
return JFFS_IS_ERROR;
EXIT1:
rmdir(pathname01);
return JFFS_IS_ERROR;
}
VOID ItJffs021(VOID)
{
TEST_ADD_CASE(__FUNCTION__, Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
}
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "It_vfs_jffs.h"
static constexpr int MB = 1024 * 1024;
static UINT32 Testcase(VOID)
{
INT32 ret;
CHAR *pathname = { JFFS_MAIN_DIR0 };
struct statvfs vfs;
fsblkcnt_t blockSize;
fsblkcnt_t blockCount;
fsblkcnt_t totalSize;
fsblkcnt_t freeSize;
fsblkcnt_t usedSize;
fsblkcnt_t availSize;
ret = statvfs(pathname, &vfs);
ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
blockSize = vfs.f_bsize;
totalSize = vfs.f_blocks * blockSize;
freeSize = vfs.f_bfree * blockSize;
usedSize = (vfs.f_blocks - vfs.f_bavail) * blockSize;
availSize = vfs.f_bavail * blockSize;
printf("total_size = %0.2lf MB\n", (double)totalSize / (MB));
printf("free_size = %0.2lf MB\n", (double)freeSize / (MB));
printf("used_size = %0.2lf MB\n", (double)usedSize / (MB));
printf("avail_size = %0.2lf MB\n", (double)availSize / (MB));
return JFFS_NO_ERROR;
EXIT:
return JFFS_IS_ERROR;
}
VOID ItJffs022(VOID)
{
TEST_ADD_CASE(__FUNCTION__, Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
}
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "It_vfs_jffs.h"
static UINT32 Testcase(VOID)
{
INT32 ret, dirFd, len;
INT32 fd = -1;
CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME01 };
CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME01 };
DIR *dir = NULL;
struct dirent *ptr = NULL;
ret = mkdir(pathname1, HIGHEST_AUTHORITY);
ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
dir = opendir(pathname1);
ICUNIT_GOTO_NOT_EQUAL(dir, NULL, dir, EXIT1);
dirFd = dirfd(dir);
ICUNIT_GOTO_NOT_EQUAL(dirFd, JFFS_IS_ERROR, dirFd, EXIT1);
printf("dirFd = %d\n", dirFd);
(void)strcat_s(pathname2, JFFS_STANDARD_NAME_LENGTH, "/test.txt");
fd = open(pathname2, O_CREAT | O_RDWR | O_TRUNC);
ICUNIT_GOTO_NOT_EQUAL(fd, JFFS_IS_ERROR, fd, EXIT1);
len = write(fd, "01234567890123456789012345", 16); // 16 means write len
ret = close(fd);
ICUNIT_GOTO_NOT_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT1);
ret = unlinkat(dirFd, "test.txt", 0);
ICUNIT_GOTO_NOT_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT1);
ret = closedir(dir);
ICUNIT_GOTO_NOT_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT);
ret = rmdir(JFFS_PATH_NAME01);
ICUNIT_GOTO_NOT_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT);
return JFFS_NO_ERROR;
EXIT1:
close(fd);
unlink(pathname1);
closedir(dir);
EXIT:
rmdir(JFFS_PATH_NAME01);
return JFFS_NO_ERROR;
}
VOID ItJffs023(VOID)
{
TEST_ADD_CASE(__FUNCTION__, Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
}
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "It_vfs_jffs.h"
static UINT32 Testcase(VOID)
{
INT32 ret, dirFd, len;
INT32 fd = -1;
CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME01 };
CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME01 };
DIR *dir = NULL;
struct dirent *ptr = NULL;
ret = mkdir(pathname1, HIGHEST_AUTHORITY);
ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
dir = opendir(pathname1);
ICUNIT_GOTO_NOT_EQUAL(dir, NULL, dir, EXIT1);
dirFd = dirfd(dir);
ICUNIT_GOTO_NOT_EQUAL(dirFd, JFFS_IS_ERROR, dirFd, EXIT1);
printf("dirFd = %d\n", dirFd);
(void)strcat_s(pathname2, JFFS_STANDARD_NAME_LENGTH, "/test.txt");
fd = open(pathname2, O_CREAT | O_RDWR | O_TRUNC);
ICUNIT_GOTO_NOT_EQUAL(fd, JFFS_IS_ERROR, fd, EXIT1);
len = write(fd, "01234567890123456789012345", 16); // 16 means write len
ret = close(fd);
ICUNIT_GOTO_NOT_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT1);
ret = renameat(dirFd, "test.txt", dirFd, "TEST.txt");
ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
(void)strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/TEST.txt");
ret = unlink(pathname1);
ICUNIT_GOTO_NOT_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT2);
ret = closedir(dir);
ICUNIT_GOTO_NOT_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT);
ret = chdir(JFFS_MAIN_DIR0);
ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
ret = rmdir(JFFS_PATH_NAME01);
ICUNIT_GOTO_NOT_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT);
return JFFS_NO_ERROR;
EXIT1:
close(fd);
EXIT2:
unlink(pathname1);
closedir(dir);
EXIT:
rmdir(JFFS_PATH_NAME01);
return JFFS_NO_ERROR;
}
VOID ItJffs024(VOID)
{
TEST_ADD_CASE(__FUNCTION__, Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
}
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "It_vfs_jffs.h"
static UINT32 Testcase(VOID)
{
FILE *fp = NULL;
INT32 ret;
CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME01 };
CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME01 };
fp = fopen(pathname1, "w+");
ICUNIT_GOTO_NOT_EQUAL(fp, NULL, fp, EXIT);
ret = fclose(fp);
ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
ret = unlink(pathname1);
ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
return JFFS_NO_ERROR;
EXIT1:
fclose(fp);
EXIT:
unlink(pathname1);
return JFFS_IS_ERROR;
}
VOID ItJffs025(VOID)
{
TEST_ADD_CASE(__FUNCTION__, Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
}
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "It_vfs_jffs.h"
static UINT32 Testcase(VOID)
{
INT32 ret;
CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
ret = mkdir(pathname1, HIGHEST_AUTHORITY);
ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
ret = mkdir(pathname1, HIGHEST_AUTHORITY);
ICUNIT_GOTO_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT);
ICUNIT_GOTO_EQUAL(errno, EEXIST, errno, EXIT);
ret = rmdir(pathname1);
ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
return JFFS_NO_ERROR;
EXIT:
rmdir(pathname1);
return JFFS_NO_ERROR;
}
VOID ItJffs026(VOID)
{
TEST_ADD_CASE(__FUNCTION__, Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
}
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "It_vfs_jffs.h"
static UINT32 Testcase(VOID)
{
INT32 ret;
CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME00 };
ret = mkdir(pathname1, HIGHEST_AUTHORITY);
ICUNIT_GOTO_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT);
ICUNIT_GOTO_EQUAL(errno, ENOENT, errno, EXIT);
return JFFS_NO_ERROR;
EXIT:
rmdir(pathname1);
return JFFS_NO_ERROR;
}
VOID ItJffs027(VOID)
{
TEST_ADD_CASE(__FUNCTION__, Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
}
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "It_vfs_jffs.h"
static constexpr int TEST_STRLEN = 30;
static UINT32 Testcase(VOID)
{
INT32 ret;
INT32 fd = -1;
CHAR pathname[TEST_STRLEN] = { JFFS_BASE_DIR };
CHAR pathname1[TEST_STRLEN] = { JFFS_PATH_NAME0 };
CHAR pathname2[TEST_STRLEN] = { JFFS_PATH_NAME0 };
CHAR *pathname3 = NULL;
CHAR buf1[TEST_STRLEN] = "";
CHAR buf2[TEST_STRLEN] = "";
CHAR *pret = NULL;
DIR *dir = NULL;
ret = mkdir(pathname1, HIGHEST_AUTHORITY);
ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
pathname3 = pathname2;
(void)strcat_s(pathname2, TEST_STRLEN, "/test1");
fd = open(pathname2, O_NONBLOCK | O_CREAT | O_EXCL, HIGHEST_AUTHORITY);
ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT1);
pret = getcwd(buf1, TEST_STRLEN);
ICUNIT_GOTO_NOT_EQUAL(pret, NULL, pret, EXIT1);
ICUNIT_GOTO_STRING_EQUAL(buf1, pathname, buf1, EXIT1);
ret = fchdir(fd);
ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
pret = getcwd(buf2, TEST_STRLEN);
ICUNIT_GOTO_NOT_EQUAL(pret, NULL, pret, EXIT1);
ICUNIT_GOTO_STRING_EQUAL(buf2, pathname3, buf2, EXIT1);
ret = chdir(pathname);
ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
ret = close(fd);
ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
ret = unlink(pathname2);
ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
ret = rmdir(pathname1);
ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
return JFFS_NO_ERROR;
EXIT1:
close(fd);
unlink(pathname2);
EXIT:
rmdir(pathname1);
return JFFS_IS_ERROR;
}
VOID ItJffs028(VOID)
{
TEST_ADD_CASE(__FUNCTION__, Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
}
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "It_vfs_jffs.h"
static constexpr int TEST_STRLEN = 30;
static UINT32 Testcase(VOID)
{
INT32 ret;
INT32 fd = -1;
CHAR pathname1[TEST_STRLEN] = { JFFS_PATH_NAME0 };
fd = open(pathname1, O_NONBLOCK | O_CREAT | O_EXCL, HIGHEST_AUTHORITY);
ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT1);
ret = fchmod(fd, S_IREAD);
ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
ret = close(fd);
ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
ret = unlink(pathname1);
ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
return JFFS_NO_ERROR;
EXIT1:
close(fd);
unlink(pathname1);
EXIT:
rmdir(pathname1);
return JFFS_IS_ERROR;
}
VOID ItJffs029(VOID)
{
TEST_ADD_CASE(__FUNCTION__, Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
}
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "It_vfs_jffs.h"
static UINT32 Testcase(VOID)
{
INT32 ret;
INT32 fd = -1;
CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_MAIN_DIR0 };
CHAR bufname[PATH_MAX] = "";
CHAR *realName = NULL;
ret = mkdir(pathname1, HIGHEST_AUTHORITY);
ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
realName = realpath(pathname1, bufname);
ICUNIT_GOTO_NOT_EQUAL(realName, NULL, realName, EXIT);
ICUNIT_GOTO_STRING_EQUAL(realName, pathname1, realName, EXIT);
(void)strcat_s(pathname2, JFFS_STANDARD_NAME_LENGTH, "/////");
(void)strcat_s(pathname2, JFFS_STANDARD_NAME_LENGTH, "test");
realName = realpath(pathname2, bufname);
ICUNIT_GOTO_NOT_EQUAL(realName, NULL, realName, EXIT);
ICUNIT_GOTO_STRING_EQUAL(realName, pathname1, realName, EXIT);
ret = rmdir(pathname2);
ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
return JFFS_NO_ERROR;
EXIT:
remove(pathname1);
return JFFS_NO_ERROR;
}
VOID ItJffs030(VOID)
{
TEST_ADD_CASE(__FUNCTION__, Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
}
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "It_vfs_jffs.h"
#define TEST_STR "abcdefghijk"
static UINT32 Testcase(VOID)
{
INT32 ret, len;
INT32 fd = -1;
CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
CHAR buf[JFFS_STANDARD_NAME_LENGTH] = { TEST_STR };
CHAR str[JFFS_STANDARD_NAME_LENGTH];
FILE *ptr = NULL;
fd = open(pathname1, O_CREAT | O_RDWR, HIGHEST_AUTHORITY);
ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT);
len = write(fd, buf, JFFS_STANDARD_NAME_LENGTH);
ICUNIT_GOTO_NOT_EQUAL(len, -1, len, EXIT);
ret = close(fd);
ICUNIT_GOTO_NOT_EQUAL(ret, -1, ret, EXIT1);
ptr = freopen(pathname1, "r", stdin);
ICUNIT_GOTO_NOT_EQUAL(ptr, NULL, ptr, EXIT1);
scanf_s("%s", str, sizeof(str));
ret = strcmp(buf, str);
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
fclose(ptr);
ret = unlink(pathname1);
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
return JFFS_NO_ERROR;
EXIT1:
close(fd);
EXIT:
unlink(pathname1);
return JFFS_NO_ERROR;
}
VOID ItJffs031(VOID)
{
TEST_ADD_CASE(__FUNCTION__, Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
}
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "It_vfs_jffs.h"
static UINT32 Testcase(VOID)
{
INT32 ret;
CHAR pathname1[50] = { JFFS_PATH_NAME0 };
struct stat buf1 = { 0 };
ret = lstat64(pathname1, &buf1);
ICUNIT_GOTO_NOT_EQUAL(ret, 0, ret, EXIT);
ICUNIT_GOTO_EQUAL(errno, ENOENT, errno, EXIT);
ret = mkdir(pathname1, HIGHEST_AUTHORITY);
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
ret = lstat64(pathname1, &buf1);
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
(void)strcat_s(pathname1, sizeof(pathname1), "/dir");
ret = lstat64(pathname1, &buf1);
ICUNIT_GOTO_NOT_EQUAL(ret, 0, ret, EXIT1);
ICUNIT_GOTO_EQUAL(errno, ENOENT, errno, EXIT1);
ret = rmdir(JFFS_PATH_NAME0);
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
return JFFS_NO_ERROR;
EXIT1:
remove(pathname1);
EXIT:
remove(JFFS_PATH_NAME0);
return JFFS_NO_ERROR;
}
VOID ItJffs032(VOID)
{
TEST_ADD_CASE(__FUNCTION__, Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
}
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "It_vfs_jffs.h"
static UINT32 Testcase(VOID)
{
INT32 ret;
CHAR pathname1[50] = { JFFS_PATH_NAME0 };
struct stat buf1 = { 0 };
ret = lstat(pathname1, &buf1);
ICUNIT_GOTO_NOT_EQUAL(ret, 0, ret, EXIT);
ICUNIT_GOTO_EQUAL(errno, ENOENT, errno, EXIT);
ret = mkdir(pathname1, HIGHEST_AUTHORITY);
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
ret = lstat(pathname1, &buf1);
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
(void)strcat_s(pathname1, sizeof(pathname1), "/dir");
ret = lstat(pathname1, &buf1);
ICUNIT_GOTO_NOT_EQUAL(ret, 0, ret, EXIT1);
ICUNIT_GOTO_EQUAL(errno, ENOENT, errno, EXIT1);
ret = rmdir(JFFS_PATH_NAME0);
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
return JFFS_NO_ERROR;
EXIT1:
remove(pathname1);
EXIT:
remove(JFFS_PATH_NAME0);
return JFFS_NO_ERROR;
}
VOID ItJffs033(VOID)
{
TEST_ADD_CASE(__FUNCTION__, Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
}
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "It_vfs_jffs.h"
#define TEST_STR "abcdefghijk"
#define EXPECT_TEST_STR "ghijk"
static constexpr int OFFSET_NUM = 6;
static UINT32 Testcase(VOID)
{
INT32 ret, len;
INT32 fd = -1;
CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
CHAR buf[JFFS_STANDARD_NAME_LENGTH] = { TEST_STR };
CHAR str[JFFS_STANDARD_NAME_LENGTH];
FILE *ptr = NULL;
off_t offset = OFFSET_NUM;
size_t fret;
fd = open(pathname1, O_CREAT | O_RDWR, HIGHEST_AUTHORITY);
ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT);
len = write(fd, buf, JFFS_STANDARD_NAME_LENGTH);
ICUNIT_GOTO_NOT_EQUAL(len, -1, len, EXIT);
ret = close(fd);
ICUNIT_GOTO_NOT_EQUAL(ret, -1, ret, EXIT1);
ptr = fopen(pathname1, "r+");
ICUNIT_GOTO_NOT_EQUAL(ptr, NULL, ptr, EXIT2);
ret = fseeko(ptr, offset, SEEK_SET);
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
fret = fread(str, 1, JFFS_STANDARD_NAME_LENGTH, ptr);
ICUNIT_GOTO_EQUAL(fret, (JFFS_STANDARD_NAME_LENGTH - OFFSET_NUM), fret, EXIT2);
ret = strcmp(EXPECT_TEST_STR, str);
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
ret = fclose(ptr);
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
ret = unlink(pathname1);
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
return JFFS_NO_ERROR;
EXIT2:
fclose(ptr);
unlink(pathname1);
return JFFS_NO_ERROR;
EXIT1:
close(fd);
EXIT:
unlink(pathname1);
return JFFS_NO_ERROR;
}
VOID ItJffs034(VOID)
{
TEST_ADD_CASE(__FUNCTION__, Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
}
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "It_vfs_jffs.h"
#define TEST_STR "abcdefghijk"
#define EXPECT_TEST_STR "ghijk"
static constexpr int OFFSET_NUM = 6;
static UINT32 Testcase(VOID)
{
INT32 ret, len;
INT32 fd = -1;
CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
CHAR buf[JFFS_STANDARD_NAME_LENGTH] = { TEST_STR };
CHAR str[JFFS_STANDARD_NAME_LENGTH];
FILE *ptr = NULL;
off_t offset1 = OFFSET_NUM;
off_t offset2;
size_t fret;
fd = open(pathname1, O_CREAT | O_RDWR, HIGHEST_AUTHORITY);
ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT);
len = write(fd, buf, JFFS_STANDARD_NAME_LENGTH);
ICUNIT_GOTO_NOT_EQUAL(len, -1, len, EXIT);
ret = close(fd);
ICUNIT_GOTO_NOT_EQUAL(ret, -1, ret, EXIT1);
ptr = fopen(pathname1, "r+");
ICUNIT_GOTO_NOT_EQUAL(ptr, NULL, ptr, EXIT2);
ret = fseeko(ptr, offset1, SEEK_SET);
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
offset2 = ftello(ptr);
ICUNIT_GOTO_EQUAL(offset2, offset1, offset2, EXIT2);
ret = fclose(ptr);
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
ret = unlink(pathname1);
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
return JFFS_NO_ERROR;
EXIT2:
fclose(ptr);
unlink(pathname1);
return JFFS_NO_ERROR;
EXIT1:
close(fd);
EXIT:
unlink(pathname1);
return JFFS_NO_ERROR;
}
VOID ItJffs035(VOID)
{
TEST_ADD_CASE(__FUNCTION__, Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
}
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "It_vfs_jffs.h"
static UINT32 Testcase(VOID)
{
INT32 ret;
INT32 fd = -1;
CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_MAIN_DIR0 };
CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
DIR *dir = NULL;
dir = opendir(pathname1);
ICUNIT_GOTO_NOT_EQUAL(dir, NULL, dir, EXIT1);
ret = closedir(dir);
ICUNIT_GOTO_NOT_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT1);
dir = opendir(pathname2);
ICUNIT_GOTO_EQUAL(dir, NULL, dir, EXIT2);
ICUNIT_GOTO_EQUAL(errno, ENOENT, errno, EXIT);
return JFFS_NO_ERROR;
EXIT2:
closedir(dir);
rmdir(pathname2);
return JFFS_IS_ERROR;
EXIT1:
closedir(dir);
EXIT:
return JFFS_IS_ERROR;
}
VOID ItJffs036(VOID)
{
TEST_ADD_CASE(__FUNCTION__, Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
}
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "It_vfs_jffs.h"
static UINT32 Testcase(VOID)
{
INT32 ret;
INT32 fd = -1;
CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_MAIN_DIR0 };
CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
DIR *dir = NULL;
dir = opendir(pathname1);
ICUNIT_GOTO_NOT_EQUAL(dir, NULL, dir, EXIT1);
ret = closedir(dir);
ICUNIT_GOTO_NOT_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT1);
fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
ICUNIT_GOTO_NOT_EQUAL(fd, JFFS_IS_ERROR, fd, EXIT3);
ret = close(fd);
ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT3);
dir = opendir(pathname2);
ICUNIT_GOTO_EQUAL(dir, NULL, dir, EXIT2);
ICUNIT_GOTO_EQUAL(errno, ENOTDIR, errno, EXIT2);
ret = unlink(pathname2);
ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
return JFFS_NO_ERROR;
EXIT3:
close(fd);
EXIT2:
unlink(pathname2);
return JFFS_IS_ERROR;
EXIT1:
closedir(dir);
return JFFS_IS_ERROR;
}
VOID ItJffs037(VOID)
{
TEST_ADD_CASE(__FUNCTION__, Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
}
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "It_vfs_jffs.h"
static UINT32 Testcase(VOID)
{
INT32 ret;
CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_MAIN_DIR0 };
CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
DIR *dir = NULL;
struct dirent *ptr = NULL;
long offset;
dir = opendir(pathname1);
ICUNIT_GOTO_NOT_EQUAL(dir, NULL, dir, EXIT1);
ret = closedir(dir);
ICUNIT_GOTO_NOT_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT1);
return JFFS_NO_ERROR;
EXIT2:
closedir(dir);
rmdir(pathname2);
return JFFS_IS_ERROR;
EXIT1:
closedir(dir);
EXIT:
return JFFS_IS_ERROR;
}
VOID ItJffs038(VOID)
{
TEST_ADD_CASE(__FUNCTION__, Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
}
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "It_vfs_jffs.h"
static UINT32 Testcase(VOID)
{
INT32 ret;
INT32 fd = -1;
CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_MAIN_DIR0 };
CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
DIR *dir = NULL;
dir = opendir(pathname1);
ICUNIT_GOTO_NOT_EQUAL(dir, NULL, dir, EXIT1);
ret = closedir(dir);
ICUNIT_GOTO_NOT_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT1);
return JFFS_NO_ERROR;
EXIT2:
closedir(dir);
rmdir(pathname2);
return JFFS_IS_ERROR;
EXIT1:
closedir(dir);
EXIT:
return JFFS_IS_ERROR;
}
VOID ItJffs039(VOID)
{
TEST_ADD_CASE(__FUNCTION__, Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
}
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "It_vfs_jffs.h"
static UINT32 Testcase(VOID)
{
INT32 ret, scandirCount;
INT32 fd = -1;
CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_MAIN_DIR0 };
CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
DIR *dir = NULL;
struct dirent **namelist = NULL;
dir = opendir(pathname1);
ICUNIT_GOTO_NOT_EQUAL(dir, NULL, dir, EXIT1);
ret = closedir(dir);
ICUNIT_GOTO_NOT_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT1);
fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
ICUNIT_GOTO_NOT_EQUAL(fd, JFFS_IS_ERROR, fd, EXIT3);
ret = close(fd);
ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT3);
scandirCount = scandir(pathname2, &namelist, 0, NULL);
ICUNIT_GOTO_EQUAL(scandirCount, -1, scandirCount, EXIT2);
ICUNIT_GOTO_EQUAL(errno, ENOTDIR, errno, EXIT2);
ret = unlink(pathname2);
ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
return JFFS_NO_ERROR;
EXIT3:
close(fd);
EXIT2:
unlink(pathname2);
return JFFS_IS_ERROR;
EXIT1:
closedir(dir);
return JFFS_IS_ERROR;
}
VOID ItJffs042(VOID)
{
TEST_ADD_CASE(__FUNCTION__, Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
}
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "It_vfs_jffs.h"
typedef struct __dirstream {
off_t tell;
int fd;
int bufPos;
int bufEnd;
volatile int lock[1];
void *dirk;
void *resv;
/* Any changes to this struct must preserve the property:
* offsetof(struct __dirent, buf) % sizeof(off_t) == 0 */
char buf[2048];
} DIR;
static UINT32 Testcase(VOID)
{
DIR *dirp = NULL;
INT32 ret;
CHAR *pathnamedir = (CHAR *)JFFS_MAIN_DIR0;
CHAR pathname01[JFFS_STANDARD_NAME_LENGTH] = { JFFS_MAIN_DIR0 };
struct dirent *dp1 = (struct dirent *)malloc(sizeof(struct dirent));
struct dirent *dp2 = (struct dirent *)malloc(sizeof(struct dirent));
struct dirent *dp2Bak = dp2;
DIR adir = { 0 };
DIR *dir1 = &adir;
(void)strcat_s(pathname01, JFFS_STANDARD_NAME_LENGTH, "/test1");
ret = mkdir(pathname01, HIGHEST_AUTHORITY);
if (ret != 0) {
if (errno != EEXIST) {
ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
}
}
dirp = opendir(pathnamedir);
ICUNIT_GOTO_NOT_EQUAL(dirp, NULL, dirp, EXIT2);
while (1) {
ret = readdir_r(dir1, dp1, &dp2);
printf("ret=%d\n", ret);
ICUNIT_GOTO_EQUAL(errno, EBADF, errno, EXIT2);
break;
}
ret = rmdir(pathname01);
ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
closedir(dirp);
free(dp1);
free(dp2Bak);
return JFFS_NO_ERROR;
EXIT2:
rmdir(pathname01);
if (dirp) closedir(dirp);
free(dp1);
free(dp2Bak);
return JFFS_IS_ERROR;
EXIT1:
rmdir(pathname01);
return JFFS_IS_ERROR;
}
VOID ItJffs043(VOID)
{
TEST_ADD_CASE(__FUNCTION__, Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
}
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册