From 8932fd27260b5cff766c0f36aeb85eb7a99a296a Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Tue, 7 Apr 2020 02:31:26 +0200 Subject: [PATCH 1/8] Test more architectures and iOS port on Travis [skip appveyor] --- .travis.yml | 80 ++++++++++++++++++++++++++++++----------------------- 1 file changed, 45 insertions(+), 35 deletions(-) diff --git a/.travis.yml b/.travis.yml index 62907a985a..e4d8121aa2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,42 +7,52 @@ sudo: required matrix: include: - - dist: precise - compiler: gcc - env: wxUSE_XVFB=1 - - dist: trusty - compiler: gcc - - dist: trusty - compiler: gcc - env: wxCONFIGURE_FLAGS="--enable-utf8 --enable-utf8only --enable-monolithic" wxUSE_XVFB=1 - - dist: trusty - compiler: gcc - env: wxGTK_VERSION=3 wxCONFIGURE_FLAGS="--enable-cxx11 --enable-stl --disable-webview" wxMAKEFILE_FLAGS="CXXFLAGS=-std=c++11" wxUSE_XVFB=1 - - dist: trusty - compiler: clang - env: wxCONFIGURE_FLAGS="--disable-shared --disable-sys-libs --disable-webview" wxUSE_XVFB=1 - - dist: trusty - compiler: gcc - env: wxTOOLSET=cmake wxCMAKE_GENERATOR="Unix Makefiles" + - os: linux + arch: arm64 + - os: linux + arch: ppc64le + - os: linux + arch: s390x - os: osx - osx_image: xcode6.4 - compiler: clang - env: wxCONFIGURE_FLAGS="--enable-cxx11" wxMAKEFILE_FLAGS="CXXFLAGS=-std=c++11" wxSKIP_SAMPLES=1 - - os: osx - compiler: clang - env: wxTOOLSET=cmake wxCMAKE_GENERATOR=Xcode wxCMAKE_DEFINES="-DCMAKE_CXX_STANDARD=11" - - dist: trusty - compiler: gcc - env: wxCONFIGURE_FLAGS="--with-x11 --enable-pch --disable-stc" wxSKIP_SAMPLES=1 - - dist: trusty - compiler: gcc - env: wxCONFIGURE_FLAGS="--with-directfb --enable-pch --disable-stc" wxSKIP_SAMPLES=1 - - dist: trusty - compiler: gcc - env: wxCONFIGURE_FLAGS="--with-motif --enable-pch --disable-stc" wxSKIP_SAMPLES=1 - - dist: trusty - compiler: gcc - env: wxCONFIGURE_FLAGS="--with-qt --enable-pch" wxSKIP_SAMPLES=1 + osx_image: xcode10 + env: wxCONFIGURE_FLAGS="--with-osx_iphone --enable-monolithic --disable-shared" wxSKIP_SAMPLES=1 + +# - dist: precise +# compiler: gcc +# env: wxUSE_XVFB=1 +# - dist: trusty +# compiler: gcc +# - dist: trusty +# compiler: gcc +# env: wxCONFIGURE_FLAGS="--enable-utf8 --enable-utf8only --enable-monolithic" wxUSE_XVFB=1 +# - dist: trusty +# compiler: gcc +# env: wxGTK_VERSION=3 wxCONFIGURE_FLAGS="--enable-cxx11 --enable-stl --disable-webview" wxMAKEFILE_FLAGS="CXXFLAGS=-std=c++11" wxUSE_XVFB=1 +# - dist: trusty +# compiler: clang +# env: wxCONFIGURE_FLAGS="--disable-shared --disable-sys-libs --disable-webview" wxUSE_XVFB=1 +# - dist: trusty +# compiler: gcc +# env: wxTOOLSET=cmake wxCMAKE_GENERATOR="Unix Makefiles" +# - os: osx +# osx_image: xcode6.4 +# compiler: clang +# env: wxCONFIGURE_FLAGS="--enable-cxx11" wxMAKEFILE_FLAGS="CXXFLAGS=-std=c++11" wxSKIP_SAMPLES=1 +# - os: osx +# compiler: clang +# env: wxTOOLSET=cmake wxCMAKE_GENERATOR=Xcode wxCMAKE_DEFINES="-DCMAKE_CXX_STANDARD=11" +# - dist: trusty +# compiler: gcc +# env: wxCONFIGURE_FLAGS="--with-x11 --enable-pch --disable-stc" wxSKIP_SAMPLES=1 +# - dist: trusty +# compiler: gcc +# env: wxCONFIGURE_FLAGS="--with-directfb --enable-pch --disable-stc" wxSKIP_SAMPLES=1 +# - dist: trusty +# compiler: gcc +# env: wxCONFIGURE_FLAGS="--with-motif --enable-pch --disable-stc" wxSKIP_SAMPLES=1 +# - dist: trusty +# compiler: gcc +# env: wxCONFIGURE_FLAGS="--with-qt --enable-pch" wxSKIP_SAMPLES=1 branches: only: From 3afc68bb63396ee07c1a6c286d267301c0800048 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Tue, 7 Apr 2020 02:31:26 +0200 Subject: [PATCH 2/8] Remove iOS port build from Travis, will do separately later [skip appveyor] --- .travis.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index e4d8121aa2..8cd82972f2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,10 +13,6 @@ matrix: arch: ppc64le - os: linux arch: s390x - - os: osx - osx_image: xcode10 - env: wxCONFIGURE_FLAGS="--with-osx_iphone --enable-monolithic --disable-shared" wxSKIP_SAMPLES=1 - # - dist: precise # compiler: gcc # env: wxUSE_XVFB=1 From b2b1b21bf2f177de04d5eefb0d1f111e1eaa259e Mon Sep 17 00:00:00 2001 From: Scott Talbert Date: Tue, 7 Apr 2020 01:48:38 +0200 Subject: [PATCH 3/8] Fix tests when run on ppc64le arch Don't assume that files in /sys are 4KiB in size, their actual size is equal to the kernel page size which varies depending on the architecture and kernel build options. --- tests/file/filetest.cpp | 2 +- tests/filename/filenametest.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/file/filetest.cpp b/tests/file/filetest.cpp index f1876daf94..9692bd3c60 100644 --- a/tests/file/filetest.cpp +++ b/tests/file/filetest.cpp @@ -159,7 +159,7 @@ TEST_CASE("wxFile::Special", "[file][linux][special-file]") // All files in /sys seem to have size of 4KiB currently, even if they // don't have that much data in them. wxFile fileSys("/sys/power/state"); - CHECK( fileSys.Length() == 4096 ); + CHECK( fileSys.Length() == sysconf(_SC_PAGESIZE) ); CHECK( fileSys.IsOpened() ); CHECK( fileSys.ReadAll(&s) ); CHECK( !s.empty() ); diff --git a/tests/filename/filenametest.cpp b/tests/filename/filenametest.cpp index 240e95205c..2928b8d4cb 100644 --- a/tests/filename/filenametest.cpp +++ b/tests/filename/filenametest.cpp @@ -1060,7 +1060,7 @@ TEST_CASE("wxFileName::GetSizeSpecial", "[filename][linux][special-file]") CHECK( size > 0 ); // All files in /sys seem to have size of 4KiB currently. - CHECK( wxFileName::GetSize("/sys/power/state") == 4096 ); + CHECK( wxFileName::GetSize("/sys/power/state") == sysconf(_SC_PAGESIZE) ); } #endif // __LINUX__ From b714a3614b547d04161fe46118cb55c79ede4c5d Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Tue, 7 Apr 2020 13:38:34 +0200 Subject: [PATCH 4/8] Update comments to remove mentions of 4KiB for /sys files The actual size is the page size, so update the comments to match the changes to the code in the previous commit. --- tests/file/filetest.cpp | 10 ++++++---- tests/filename/filenametest.cpp | 3 ++- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/tests/file/filetest.cpp b/tests/file/filetest.cpp index 9692bd3c60..d418362875 100644 --- a/tests/file/filetest.cpp +++ b/tests/file/filetest.cpp @@ -156,14 +156,16 @@ TEST_CASE("wxFile::Special", "[file][linux][special-file]") CHECK( fileProc.ReadAll(&s) ); CHECK( !s.empty() ); - // All files in /sys seem to have size of 4KiB currently, even if they - // don't have that much data in them. + // All files in /sys have the size of one kernel page, even if they don't + // have that much data in them. + const long pageSize = sysconf(_SC_PAGESIZE); + wxFile fileSys("/sys/power/state"); - CHECK( fileSys.Length() == sysconf(_SC_PAGESIZE) ); + CHECK( fileSys.Length() == pageSize ); CHECK( fileSys.IsOpened() ); CHECK( fileSys.ReadAll(&s) ); CHECK( !s.empty() ); - CHECK( s.length() < 4096 ); + CHECK( s.length() < pageSize ); } #endif // __LINUX__ diff --git a/tests/filename/filenametest.cpp b/tests/filename/filenametest.cpp index 2928b8d4cb..1db0edc52d 100644 --- a/tests/filename/filenametest.cpp +++ b/tests/filename/filenametest.cpp @@ -1059,7 +1059,8 @@ TEST_CASE("wxFileName::GetSizeSpecial", "[filename][linux][special-file]") INFO( "size of /proc/kcore=" << size ); CHECK( size > 0 ); - // All files in /sys seem to have size of 4KiB currently. + // 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) ); } From 2005e50b27128dccc067d7aa7755553e5ea4eaa7 Mon Sep 17 00:00:00 2001 From: Scott Talbert Date: Tue, 7 Apr 2020 03:30:44 +0200 Subject: [PATCH 5/8] Fix tests when run on s390x arch Don't assume "mem" is always present in /sys/power/state, but hopefully one of "mem" and "disk" is. --- tests/textfile/textfiletest.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/textfile/textfiletest.cpp b/tests/textfile/textfiletest.cpp index eda450d1f3..d76cb1b244 100644 --- a/tests/textfile/textfiletest.cpp +++ b/tests/textfile/textfiletest.cpp @@ -357,7 +357,7 @@ TEST_CASE("wxTextFile::Special", "[textfile][linux][special-file]") CHECK( f.Open("/sys/power/state") ); REQUIRE( f.GetLineCount() == 1 ); INFO( "/sys/power/state contains \"" << f[0] << "\"" ); - CHECK( f[0].find("mem") != wxString::npos ); + CHECK( (f[0].find("mem") != wxString::npos || f[0].find("disk") != wxString::npos) ); } } From a776a9112e4829a997cc29e7fcb8db03e542ba25 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Tue, 7 Apr 2020 13:41:21 +0200 Subject: [PATCH 6/8] Use /proc/cpuinfo instead of /proc/diskstats in Linux file tests The file /proc/diskstats doesn't seem to contain anything on some Travis builds, so try using /proc/cpuinfo instead. --- tests/file/filetest.cpp | 2 +- tests/textfile/textfiletest.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/file/filetest.cpp b/tests/file/filetest.cpp index d418362875..4df22d037a 100644 --- a/tests/file/filetest.cpp +++ b/tests/file/filetest.cpp @@ -149,7 +149,7 @@ TEST_CASE("wxFile::Special", "[file][linux][special-file]") // for reading) and usually we don't have the permissions to do it. // This file is not seekable and has 0 size, but can still be read. - wxFile fileProc("/proc/diskstats"); + wxFile fileProc("/proc/cpuinfo"); CHECK( fileProc.IsOpened() ); wxString s; diff --git a/tests/textfile/textfiletest.cpp b/tests/textfile/textfiletest.cpp index d76cb1b244..57b3b5dc2a 100644 --- a/tests/textfile/textfiletest.cpp +++ b/tests/textfile/textfiletest.cpp @@ -347,7 +347,7 @@ TEST_CASE("wxTextFile::Special", "[textfile][linux][special-file]") SECTION("/proc") { wxTextFile f; - CHECK( f.Open("/proc/diskstats") ); + CHECK( f.Open("/proc/cpuinfo") ); CHECK( f.GetLineCount() > 1 ); } From 82cfdd07c2f0f85b34c85ce189bae065e43f94aa Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Tue, 7 Apr 2020 14:30:01 +0200 Subject: [PATCH 7/8] Disable tests of /proc/cpuinfo in LXC containers It seems that we can't access /proc files when running inside such containers, so don't try to do it. --- tests/file/filetest.cpp | 5 ++++- tests/test.cpp | 15 +++++++++++++++ tests/testprec.h | 4 ++++ tests/textfile/textfiletest.cpp | 6 +++++- 4 files changed, 28 insertions(+), 2 deletions(-) diff --git a/tests/file/filetest.cpp b/tests/file/filetest.cpp index 4df22d037a..0f31b12db3 100644 --- a/tests/file/filetest.cpp +++ b/tests/file/filetest.cpp @@ -154,7 +154,10 @@ TEST_CASE("wxFile::Special", "[file][linux][special-file]") wxString s; CHECK( fileProc.ReadAll(&s) ); - CHECK( !s.empty() ); + + // /proc files seem to be always empty in LXC containers. + if ( !IsRunningInLXC() ) + CHECK( !s.empty() ); // All files in /sys have the size of one kernel page, even if they don't // have that much data in them. diff --git a/tests/test.cpp b/tests/test.cpp index bb4b04564f..6dce6f2249 100644 --- a/tests/test.cpp +++ b/tests/test.cpp @@ -69,6 +69,10 @@ std::string wxTheCurrentTestClass, wxTheCurrentTestMethod; #endif // __WXGTK__ #endif // wxUSE_GUI +#ifdef __LINUX__ + #include "wx/filename.h" +#endif + #include "wx/socket.h" #include "wx/evtloop.h" @@ -418,6 +422,17 @@ extern bool IsRunningUnderXVFB() return s_isRunningUnderXVFB == 1; } +#ifdef __LINUX__ + +extern bool IsRunningInLXC() +{ + // This is simplistic but should work in the normal cases and can always be + // made more precise later if necessary. + return wxFileName::DirExists("/dev/lxd"); +} + +#endif // __LINUX__ + #if wxUSE_GUI bool EnableUITests() diff --git a/tests/testprec.h b/tests/testprec.h index 7ae35168cc..38e2ce14e0 100644 --- a/tests/testprec.h +++ b/tests/testprec.h @@ -123,6 +123,10 @@ extern bool IsAutomaticTest(); extern bool IsRunningUnderXVFB(); +#ifdef __LINUX__ +extern bool IsRunningInLXC(); +#endif // __LINUX__ + // Helper class setting the locale to the given one for its lifetime. class LocaleSetter { diff --git a/tests/textfile/textfiletest.cpp b/tests/textfile/textfiletest.cpp index 57b3b5dc2a..dc7d22423d 100644 --- a/tests/textfile/textfiletest.cpp +++ b/tests/textfile/textfiletest.cpp @@ -348,7 +348,11 @@ TEST_CASE("wxTextFile::Special", "[textfile][linux][special-file]") { wxTextFile f; CHECK( f.Open("/proc/cpuinfo") ); - CHECK( f.GetLineCount() > 1 ); + + // /proc files seem to be always empty in LXC containers, so skip this + // check there. + if ( !IsRunningInLXC() ) + CHECK( f.GetLineCount() > 1 ); } SECTION("/sys") From 17c7469af348746cb79d4f4f927389c86589f9d2 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Tue, 7 Apr 2020 17:15:04 +0200 Subject: [PATCH 8/8] Switch to manual method of LXC "detection" Just define wxLXC environment variable for the builds using LXC on Travis. --- .travis.yml | 3 +++ tests/test.cpp | 13 ++++++------- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index 8cd82972f2..67c5f41e6f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,10 +9,13 @@ matrix: include: - os: linux arch: arm64 + env: wxCONFIGURE_FLAGS="--disable-sys-libs" wxLXC=1 - os: linux arch: ppc64le + env: wxCONFIGURE_FLAGS="--disable-sys-libs" wxLXC=1 - os: linux arch: s390x + env: wxCONFIGURE_FLAGS="--disable-sys-libs" wxLXC=1 # - dist: precise # compiler: gcc # env: wxUSE_XVFB=1 diff --git a/tests/test.cpp b/tests/test.cpp index 6dce6f2249..22350ff04f 100644 --- a/tests/test.cpp +++ b/tests/test.cpp @@ -69,10 +69,6 @@ std::string wxTheCurrentTestClass, wxTheCurrentTestMethod; #endif // __WXGTK__ #endif // wxUSE_GUI -#ifdef __LINUX__ - #include "wx/filename.h" -#endif - #include "wx/socket.h" #include "wx/evtloop.h" @@ -426,9 +422,12 @@ extern bool IsRunningUnderXVFB() extern bool IsRunningInLXC() { - // This is simplistic but should work in the normal cases and can always be - // made more precise later if necessary. - return wxFileName::DirExists("/dev/lxd"); + // We're supposed to be able to detect running in LXC by checking for + // /dev/lxd existency, but this doesn't work under Travis for some reason, + // so just rely on having the environment variable defined for the + // corresponding builds in our .travis.yml. + wxString value; + return wxGetEnv("wxLXC", &value) && value == "1"; } #endif // __LINUX__