summaryrefslogtreecommitdiff
path: root/sal
diff options
context:
space:
mode:
authorMichael Stahl <michael.stahl@allotropia.de>2022-04-26 16:57:42 +0200
committerMichael Stahl <michael.stahl@allotropia.de>2022-04-29 13:05:27 +0200
commit38258c7e1d55f23b8a73e5f1ba53d9f9fce34832 (patch)
treef5c4ff1fdbbc403b122f1fa344b85ee0ebe86215 /sal
parentc0b638bad9f60289d44101fce89c252a26260b69 (diff)
sal: tweak CppunitTest_sal_osl to run as uid 0
Change-Id: I280bcc522f3cd375b5f94e644b76bc5f95899324 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133574 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
Diffstat (limited to 'sal')
-rw-r--r--sal/qa/osl/file/osl_File.cxx33
1 files changed, 30 insertions, 3 deletions
diff --git a/sal/qa/osl/file/osl_File.cxx b/sal/qa/osl/file/osl_File.cxx
index 2eac7d1688af..718fb65423d1 100644
--- a/sal/qa/osl/file/osl_File.cxx
+++ b/sal/qa/osl/file/osl_File.cxx
@@ -1716,9 +1716,18 @@ namespace osl_FileStatus
osl::FileBase::RC nError = rItem.getFileStatus(rFileStatus);
CPPUNIT_ASSERT_EQUAL(osl::FileBase::E_None, nError);
- CPPUNIT_ASSERT_EQUAL_MESSAGE("test for getAttributes function: ReadOnly, GrpRead, OwnRead, OthRead(UNX version) ",
+ if (geteuid() == 0) // as root, access(W_OK) may be true despite mode
+ {
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("test for getAttributes function: (not ReadOnly,) GrpRead, OwnRead, OthRead(UNX version) ",
+ static_cast<sal_uInt64>(osl_File_Attribute_GrpRead | osl_File_Attribute_OwnRead | osl_File_Attribute_OthRead),
+ rFileStatus.getAttributes());
+ }
+ else
+ {
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("test for getAttributes function: ReadOnly, GrpRead, OwnRead, OthRead(UNX version) ",
static_cast<sal_uInt64>(osl_File_Attribute_ReadOnly | osl_File_Attribute_GrpRead | osl_File_Attribute_OwnRead | osl_File_Attribute_OthRead),
rFileStatus.getAttributes());
+ }
}
#else // Windows version
void getAttributes_001()
@@ -1737,9 +1746,18 @@ namespace osl_FileStatus
osl::FileBase::RC nError = rItem.getFileStatus(rFileStatus);
CPPUNIT_ASSERT_EQUAL(osl::FileBase::E_None, nError);
- CPPUNIT_ASSERT_EQUAL_MESSAGE("test for getAttributes function: Executable, GrpExe, OwnExe, OthExe, the result is Readonly, Executable, GrpExe, OwnExe, OthExe, it partly not pass(Solaris version)",
+ if (geteuid() == 0) // as root, access(W_OK) may be true despite mode
+ {
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("test for getAttributes function: Executable, GrpExe, OwnExe, OthExe, the result is (not Readonly,) Executable, GrpExe, OwnExe, OthExe, it partly not pass(Solaris version)",
+ static_cast<sal_uInt64>(osl_File_Attribute_Executable | osl_File_Attribute_GrpExe | osl_File_Attribute_OwnExe | osl_File_Attribute_OthExe),
+ rFileStatus.getAttributes());
+ }
+ else
+ {
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("test for getAttributes function: Executable, GrpExe, OwnExe, OthExe, the result is Readonly, Executable, GrpExe, OwnExe, OthExe, it partly not pass(Solaris version)",
static_cast<sal_uInt64>(osl_File_Attribute_ReadOnly | osl_File_Attribute_Executable | osl_File_Attribute_GrpExe | osl_File_Attribute_OwnExe | osl_File_Attribute_OthExe),
rFileStatus.getAttributes());
+ }
#endif
}
@@ -3259,9 +3277,18 @@ namespace osl_File
nError1 = rItem.getFileStatus(rFileStatus);
CPPUNIT_ASSERT_EQUAL(osl::FileBase::E_None, nError1);
- CPPUNIT_ASSERT_EQUAL_MESSAGE("test for setAttributes function: set file attributes and get it to verify.",
+ if (geteuid() == 0) // as root, access(W_OK) may be true despite mode
+ {
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("test for setAttributes function: set file attributes and get it to verify.",
+ static_cast<sal_uInt64>(osl_File_Attribute_GrpRead | osl_File_Attribute_OwnRead | osl_File_Attribute_OthRead),
+ rFileStatus.getAttributes());
+ }
+ else
+ {
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("test for setAttributes function: set file attributes and get it to verify.",
static_cast<sal_uInt64>(osl_File_Attribute_ReadOnly | osl_File_Attribute_GrpRead | osl_File_Attribute_OwnRead | osl_File_Attribute_OthRead),
rFileStatus.getAttributes());
+ }
#else
// please see GetFileAttributes
auto nError2 = File::setAttributes(aTmpName6, osl_File_Attribute_ReadOnly);