Fix test suite on Linux/s390x and maybe other architectures

We can't rely on file /sys/power/state always existing, so just skip the
test (with a warning) instead of failing it if it does not exist, as is
the case at least under s390x and seemingly other non-desktop platforms.

Closes #24197.

Co-authored-by: Cliff Zhao <qzhao@suse.com>
This commit is contained in:
Vadim Zeitlin 2024-01-09 02:38:43 +01:00
parent e38a61a09b
commit e2cc16ef9c
3 changed files with 19 additions and 2 deletions

View file

@ -150,8 +150,13 @@ TEST_CASE("wxFile::Special", "[file][linux][special-file]")
const long pageSize = sysconf(_SC_PAGESIZE);
wxFile fileSys("/sys/power/state");
if ( !fileSys.IsOpened() )
{
WARN("/sys/power/state can't be opened, skipping test");
return;
}
CHECK( fileSys.Length() == pageSize );
CHECK( fileSys.IsOpened() );
CHECK( fileSys.ReadAll(&s) );
CHECK( !s.empty() );
CHECK( s.length() < static_cast<unsigned long>(pageSize) );

View file

@ -1040,6 +1040,12 @@ TEST_CASE("wxFileName::GetSizeSpecial", "[filename][linux][special-file]")
INFO( "size of /proc/kcore=" << size );
CHECK( size > 0 );
if ( !wxFile::Exists("/sys/power/state") )
{
WARN("/sys/power/state doesn't exist, skipping test");
return;
}
// All files in /sys are one page in size, irrespectively of the size of
// their actual contents.
CHECK( wxFileName::GetSize("/sys/power/state") == sysconf(_SC_PAGESIZE) );

View file

@ -336,12 +336,18 @@ TEST_CASE("wxTextFile::Special", "[textfile][linux][special-file]")
SECTION("/proc")
{
wxTextFile f;
CHECK( f.Open("/proc/cpuinfo") );
REQUIRE( f.Open("/proc/cpuinfo") );
CHECK( f.GetLineCount() > 1 );
}
SECTION("/sys")
{
if ( wxFile::Exists("/sys/power/state") )
{
WARN("/sys/power/state doesn't exist, skipping test");
return;
}
wxTextFile f;
CHECK( f.Open("/sys/power/state") );
REQUIRE( f.GetLineCount() == 1 );