diff options
author | Ben Gamari <ben@smart-cactus.org> | 2021-09-10 11:47:09 -0400 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2021-10-12 19:16:40 -0400 |
commit | 05303f686fae8f1050c1cfb08225e39a5f13a7a1 (patch) | |
tree | 95fd87b1daa54462c29e9f1c64c2dbbc87d33262 /testsuite/driver | |
parent | 3b1c12d353eef24b29601798874eb875978452cd (diff) | |
download | haskell-05303f686fae8f1050c1cfb08225e39a5f13a7a1.tar.gz |
testsuite: Clean up dynlib support predicates
Previously it was unclear whether req_shared_libs should require:
* that the platform supports dynamic library loading,
* that GHC supports dynamic linking of Haskell code, or
* that the dyn way libraries were built
Clarify by splitting the predicate into two:
* `req_dynamic_lib_support` demands that the platform support dynamic
linking
* `req_dynamic_hs` demands that the GHC support dynamic linking of
Haskell code on the target platform
Naturally `req_dynamic_hs` cannot be true unless
`req_dynamic_lib_support` is also true.
Diffstat (limited to 'testsuite/driver')
-rw-r--r-- | testsuite/driver/runtests.py | 1 | ||||
-rw-r--r-- | testsuite/driver/testglobals.py | 24 | ||||
-rw-r--r-- | testsuite/driver/testlib.py | 17 |
3 files changed, 35 insertions, 7 deletions
diff --git a/testsuite/driver/runtests.py b/testsuite/driver/runtests.py index 98d6c134b9..2c76661184 100644 --- a/testsuite/driver/runtests.py +++ b/testsuite/driver/runtests.py @@ -42,6 +42,7 @@ ghc_env['TERM'] = 'vt100' global config config = getConfig() # get it from testglobals +config.validate() def signal_handler(signal, frame): stopNow() diff --git a/testsuite/driver/testglobals.py b/testsuite/driver/testglobals.py index f52aec281c..adb2109923 100644 --- a/testsuite/driver/testglobals.py +++ b/testsuite/driver/testglobals.py @@ -134,8 +134,16 @@ class TestConfig: # Do we have interpreter support? self.have_interp = False - # Do we have shared libraries? - self.have_shared_libs = False + # Does the platform support loading of dynamic shared libraries? e.g. + # some musl-based environments do not. + self.supports_dynamic_libs = True + + # Does GHC support dynamic linking of Haskell objects (i.e. the dynamic + # way)? + self.supports_dynamic_hs = True + + # Is the compiler dynamically linked? + self.ghc_dynamic = False # Do we have SMP support? self.have_smp = False @@ -152,9 +160,6 @@ class TestConfig: # Are we testing an in-tree compiler? self.in_tree_compiler = True - # Is the compiler dynamically linked? - self.ghc_dynamic = False - # Are we running in a ThreadSanitizer-instrumented build? self.have_thread_sanitizer = False @@ -205,6 +210,15 @@ class TestConfig: # I have no idea what this does self.package_conf_cache_file = None # type: Optional[Path] + def validate(self) -> None: + """ Check the TestConfig for self-consistency """ + def assert_implies(a: bool, b: bool): + if a: + assert(b) + + assert_implies(self.supports_dynamic_hs, self.supports_dynamic_libs) + assert_implies(self.have_dynamic, self.supports_dynamic_hs) + assert_implies(self.ghc_dynamic, self.have_dynamic) global config config = TestConfig() diff --git a/testsuite/driver/testlib.py b/testsuite/driver/testlib.py index 1a12f5c086..3202bab65c 100644 --- a/testsuite/driver/testlib.py +++ b/testsuite/driver/testlib.py @@ -206,8 +206,20 @@ def req_profiling( name, opts ): if not config.have_profiling: opts.expect = 'fail' -def req_shared_libs( name, opts ): - if not config.have_shared_libs: +def req_dynamic_lib_support( name, opts ): + ''' + Require that the platform have shared object support (N.B. this doesn't + necessary imply that GHC supports the dynamic way). + ''' + if not config.supports_dynamic_libs: + opts.expect = 'fail' + +def req_dynamic_hs( name, opts ): + ''' + Require that the GHC supports dynamic linking of Haskell objects on the + platform + ''' + if not config.supports_dynamic_hs: opts.expect = 'fail' def req_interp( name, opts ): @@ -571,6 +583,7 @@ def have_ncg( ) -> bool: return config.have_ncg def have_dynamic( ) -> bool: + ''' Were libraries built in the dynamic way? ''' return config.have_dynamic def have_profiling( ) -> bool: |