[Git][ghc/ghc][wip/supersven/riscv64-ncg] 2 commits: hadrian: Pass CROSS_EMULATOR to runtests.py

Sven Tennie (@supersven) gitlab at gitlab.haskell.org
Thu May 18 11:04:31 UTC 2023



Sven Tennie pushed to branch wip/supersven/riscv64-ncg at Glasgow Haskell Compiler / GHC


Commits:
5545140f by Ben Gamari at 2023-05-18T12:56:34+02:00
hadrian: Pass CROSS_EMULATOR to runtests.py

- - - - -
ce78097c by Ben Gamari at 2023-05-18T12:56:34+02:00
testsuite/driver: Add basic support for testing cross-compilers

- - - - -


4 changed files:

- hadrian/src/Settings/Builders/RunTest.hs
- testsuite/driver/runtests.py
- testsuite/driver/testglobals.py
- testsuite/driver/testlib.py


Changes:

=====================================
hadrian/src/Settings/Builders/RunTest.hs
=====================================
@@ -211,6 +211,7 @@ runTestBuilderArgs = builder Testsuite ? do
     (testEnv, testMetricsFile) <- expr . liftIO $
         (,) <$> lookupEnv "TEST_ENV" <*> lookupEnv "METRICS_FILE"
     perfBaseline <- expr . liftIO $ lookupEnv "PERF_BASELINE_COMMIT"
+    targetWrapper <- expr . liftIO $ lookupEnv "CROSS_EMULATOR"
 
     threads     <- shakeThreads <$> expr getShakeOptions
     top         <- expr $ topDirectory
@@ -280,6 +281,7 @@ runTestBuilderArgs = builder Testsuite ? do
             , case perfBaseline of
                 Just commit | not (null commit) -> arg ("--perf-baseline=" ++ commit)
                 _ -> mempty
+            , emitWhenSet targetWrapper $ \cmd -> arg ("--target-wrapper=" ++ cmd)
             , emitWhenSet testEnv $ \env -> arg ("--test-env=" ++ env)
             , emitWhenSet testMetricsFile $ \file -> arg ("--metrics-file=" ++ file)
             , getTestArgs -- User-provided arguments from command line.


=====================================
testsuite/driver/runtests.py
=====================================
@@ -71,6 +71,7 @@ parser.add_argument("--config", action='append', help="config field")
 parser.add_argument("--rootdir", action='append', help="root of tree containing tests (default: .)")
 parser.add_argument("--metrics-file", help="file in which to save (append) the performance test metrics. If omitted, git notes will be used.")
 parser.add_argument("--summary-file", help="file in which to save the (human-readable) summary")
+parser.add_argument("--target-wrapper", help="wrapper executable to use when executing binaries compiled for the target")
 parser.add_argument("--no-print-summary", action="store_true", help="should we print the summary?")
 parser.add_argument("--only", action="append", help="just this test (can be give multiple --only= flags)")
 parser.add_argument("--way", action="append", help="just this way")
@@ -118,6 +119,7 @@ hasMetricsFile = config.metrics_file is not None
 config.summary_file = args.summary_file
 config.no_print_summary = args.no_print_summary
 config.baseline_commit = args.perf_baseline
+config.target_wrapper = args.target_wrapper
 
 if args.top:
     config.top = args.top


=====================================
testsuite/driver/testglobals.py
=====================================
@@ -175,6 +175,11 @@ class TestConfig:
         # threads
         self.threads = 1
 
+        # An optional executable used to wrap target code execution
+        # When set tests which aren't marked with TestConfig.cross_okay
+        # are skipped.
+        self.target_wrapper = None
+
         # tests which should be considered to be broken during this testsuite
         # run.
         self.broken_tests = set() # type: Set[TestName]
@@ -445,6 +450,12 @@ class TestOptions:
        # Should we copy the files of symlink the files for the test?
        self.copy_files = False
 
+       # Should the test be run in a cross-compiled tree?
+       #   None:  infer from test function
+       #   True:  run when --target-wrapper is set
+       #   False: do not run in cross-compiled trees
+       self.cross_okay = None # type: Optional[bool]
+
        # The extra hadrian dependencies we need for this particular test
        self.hadrian_deps = set(["test:ghc"]) # type: Set[str]
 


=====================================
testsuite/driver/testlib.py
=====================================
@@ -90,6 +90,10 @@ def setLocalTestOpts(opts: TestOptions) -> None:
     global testopts_local
     testopts_local.x = opts
 
+def isCross() -> bool:
+    """ Are we testing a cross-compiler? """
+    return config.target_wrapper is not None
+
 def isCompilerStatsTest() -> bool:
     opts = getTestOpts()
     return bool(opts.is_compiler_stats_test)
@@ -255,7 +259,7 @@ def req_dynamic_hs( name, opts ):
         opts.expect = 'fail'
 
 def req_interp( name, opts ):
-    if not config.have_interp:
+    if not config.have_interp or isCross():
         opts.expect = 'fail'
     # JS backend doesn't provide an interpreter yet
     js_skip(name, opts)
@@ -1080,14 +1084,21 @@ def test_common_work(name: TestName, opts,
                 all_ways = [WayName('ghci')]
             else:
                 all_ways = []
+            if isCross():
+                opts.cross_okay = False
         elif func in [makefile_test, run_command]:
             # makefile tests aren't necessarily runtime or compile-time
             # specific. Assume we can run them in all ways. See #16042 for what
             # happened previously.
             all_ways = config.compile_ways + config.run_ways
+            if isCross():
+                opts.cross_okay = False
         else:
             all_ways = [WayName('normal')]
 
+        if isCross() and opts.cross_okay is False:
+            opts.skip = True
+
         # A test itself can request extra ways by setting opts.extra_ways
         all_ways = list(OrderedDict.fromkeys(all_ways + [way for way in opts.extra_ways if way not in all_ways]))
 
@@ -1813,7 +1824,10 @@ def simple_run(name: TestName, way: WayName, prog: str, extra_run_opts: str) ->
         stats_args = ''
 
     # Put extra_run_opts last: extra_run_opts('+RTS foo') should work.
-    cmd = ' '.join([prog, stats_args, my_rts_flags, extra_run_opts])
+    args = [prog, stats_args, my_rts_flags, extra_run_opts]
+    if config.target_wrapper is not None:
+        args = [config.target_wrapper] + args
+    cmd = ' '.join(args)
 
     if opts.cmd_wrapper is not None:
         cmd = opts.cmd_wrapper(cmd)



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/0484fa822a5bf4ea53ec2bd0f0fa9704c8ab093f...ce78097cd4100df76443b8a68ed192f987aa44fe

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/0484fa822a5bf4ea53ec2bd0f0fa9704c8ab093f...ce78097cd4100df76443b8a68ed192f987aa44fe
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20230518/3cd75ec7/attachment-0001.html>


More information about the ghc-commits mailing list