From 3d7752616097fe210724ae0f737732eda64850c8 Mon Sep 17 00:00:00 2001 From: JING Date: Thu, 29 Apr 2021 17:30:43 +0800 Subject: [PATCH 1/2] add umask open/create test --- .../fs/jffs/smoke/It_vfs_jffs_Dac_001.cpp | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/testsuites/unittest/fs/jffs/smoke/It_vfs_jffs_Dac_001.cpp b/testsuites/unittest/fs/jffs/smoke/It_vfs_jffs_Dac_001.cpp index 6e0bcc13..92c8498f 100644 --- a/testsuites/unittest/fs/jffs/smoke/It_vfs_jffs_Dac_001.cpp +++ b/testsuites/unittest/fs/jffs/smoke/It_vfs_jffs_Dac_001.cpp @@ -41,7 +41,11 @@ static int TestUmask(const char *path) mode_t mode; int ret; struct stat buf = { 0 }; + struct stat buf1 = { 0 }; + struct stat buf2 = { 0 }; char filename[128] = {0}; + char filename1[128] = {0}; + char filename2[128] = {0}; printf("%s, %d\n", __FUNCTION__, __LINE__); @@ -56,6 +60,28 @@ static int TestUmask(const char *path) ICUNIT_ASSERT_EQUAL(ret, 0, ret); ICUNIT_ASSERT_EQUAL(buf.st_mode, 040755, buf.st_mode); rmdir(filename); + + sprintf(filename1, "%s/%s", path, "file"); + ret = open(filename1, O_CREAT | O_RDWR, HIGHEST_AUTHORITY); + ICUNIT_ASSERT_NOT_EQUAL(ret, -1, ret); + ret = close(ret); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); + ret = stat(filename1, &buf1); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); + ICUNIT_ASSERT_EQUAL(buf.st_mode, 100755, buf.st_mode); + ICUNIT_ASSERT_EQUAL(buf1.st_mode, 0100755, buf1.st_mode); + unlink(filename1); + + sprintf(filename2, "%s/%s", path, "file1"); + ret = creat(filename2, HIGHEST_AUTHORITY); + ICUNIT_ASSERT_NOT_EQUAL(ret, -1, ret); + ret = close(ret); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); + ret = stat(filename2, &buf2); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); + ICUNIT_ASSERT_EQUAL(buf2.st_mode, 0100755, buf2.st_mode); + unlink(filename2); + return 0; } From 68f62d9de8d001c0ff71e60b3d2bbe336b88bb04 Mon Sep 17 00:00:00 2001 From: JING Date: Thu, 29 Apr 2021 18:12:41 +0800 Subject: [PATCH 2/2] add umask open/creat test --- testsuites/unittest/fs/jffs/smoke/It_vfs_jffs_Dac_001.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/testsuites/unittest/fs/jffs/smoke/It_vfs_jffs_Dac_001.cpp b/testsuites/unittest/fs/jffs/smoke/It_vfs_jffs_Dac_001.cpp index 92c8498f..23182f4f 100644 --- a/testsuites/unittest/fs/jffs/smoke/It_vfs_jffs_Dac_001.cpp +++ b/testsuites/unittest/fs/jffs/smoke/It_vfs_jffs_Dac_001.cpp @@ -58,7 +58,7 @@ static int TestUmask(const char *path) ICUNIT_ASSERT_EQUAL(ret, 0, ret); ret = stat(filename, &buf); ICUNIT_ASSERT_EQUAL(ret, 0, ret); - ICUNIT_ASSERT_EQUAL(buf.st_mode, 040755, buf.st_mode); + ICUNIT_ASSERT_EQUAL(buf.st_mode, 040755, buf.st_mode); // mode: 040755 rmdir(filename); sprintf(filename1, "%s/%s", path, "file"); @@ -68,8 +68,7 @@ static int TestUmask(const char *path) ICUNIT_ASSERT_EQUAL(ret, 0, ret); ret = stat(filename1, &buf1); ICUNIT_ASSERT_EQUAL(ret, 0, ret); - ICUNIT_ASSERT_EQUAL(buf.st_mode, 100755, buf.st_mode); - ICUNIT_ASSERT_EQUAL(buf1.st_mode, 0100755, buf1.st_mode); + ICUNIT_ASSERT_EQUAL(buf1.st_mode, 0100755, buf1.st_mode); // mode: 0100755 unlink(filename1); sprintf(filename2, "%s/%s", path, "file1"); @@ -79,7 +78,7 @@ static int TestUmask(const char *path) ICUNIT_ASSERT_EQUAL(ret, 0, ret); ret = stat(filename2, &buf2); ICUNIT_ASSERT_EQUAL(ret, 0, ret); - ICUNIT_ASSERT_EQUAL(buf2.st_mode, 0100755, buf2.st_mode); + ICUNIT_ASSERT_EQUAL(buf2.st_mode, 0100755, buf2.st_mode); // mode: 0100755 unlink(filename2); return 0;