patman: Move capture_sys_output() into terminal and rename

This function is sometimes useful outside tests. Also it can affect how
terminal output is done, e.g. whether ANSI characters should be emitted
or not.

Move it out of the test_util package and into terminal.

Signed-off-by: Simon Glass <sjg@chromium.org>
diff --git a/tools/binman/fip_util_test.py b/tools/binman/fip_util_test.py
index 56aa56f..cb4001b 100755
--- a/tools/binman/fip_util_test.py
+++ b/tools/binman/fip_util_test.py
@@ -22,6 +22,7 @@
 # pylint: disable=C0413
 from binman import bintool
 from binman import fip_util
+from u_boot_pylib import terminal
 from u_boot_pylib import test_util
 from u_boot_pylib import tools
 
@@ -215,7 +216,7 @@
 
         macros = fip_util.parse_macros(self._indir)
         names = fip_util.parse_names(self._indir)
-        with test_util.capture_sys_output() as (stdout, _):
+        with terminal.capture() as (stdout, _):
             fip_util.create_code_output(macros, names)
         self.assertIn(
             "UUID 'UUID_TRUSTED_OS_FW_KEY_CERT' is not mentioned in tbbr_config.c file",
@@ -239,7 +240,7 @@
     ] # end
 blah de blah
                         ''', binary=False)
-        with test_util.capture_sys_output() as (stdout, _):
+        with terminal.capture() as (stdout, _):
             fip_util.main(self.args, self.src_file)
         self.assertIn('Needs update', stdout.getvalue())
 
@@ -256,7 +257,7 @@
              0x9d, 0xf3, 0x19, 0xed, 0xa1, 0x1f, 0x68, 0x01]),
     ] # end
 blah blah''', binary=False)
-        with test_util.capture_sys_output() as (stdout, _):
+        with terminal.capture() as (stdout, _):
             fip_util.main(self.args, self.src_file)
         self.assertIn('is up-to-date', stdout.getvalue())
 
@@ -269,7 +270,7 @@
         args = self.args.copy()
         args.remove('-D')
         tools.write_file(self.src_file, '', binary=False)
-        with test_util.capture_sys_output():
+        with terminal.capture():
             fip_util.main(args, self.src_file)
 
     @unittest.skipIf(not HAVE_FIPTOOL, 'No fiptool available')
@@ -389,7 +390,7 @@
     def test_fiptool_errors(self):
         """Check some error reporting from fiptool"""
         with self.assertRaises(Exception) as err:
-            with test_util.capture_sys_output():
+            with terminal.capture():
                 FIPTOOL.create_bad()
         self.assertIn("unrecognized option '--fred'", str(err.exception))