]> git.ipfire.org Git - thirdparty/libcgroup.git/commitdiff
ftests: Add a utilities file and an indent() function
authorTom Hromatka <tom.hromatka@oracle.com>
Thu, 17 Dec 2020 19:43:26 +0000 (12:43 -0700)
committerTom Hromatka <tom.hromatka@oracle.com>
Thu, 17 Dec 2020 21:53:31 +0000 (14:53 -0700)
Add a new file to hold generic utilities for the
functional tests.  As part of this change, a function
that can indent a block of text has been added.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
ftests/utils.py [new file with mode: 0644]

diff --git a/ftests/utils.py b/ftests/utils.py
new file mode 100644 (file)
index 0000000..47a63e5
--- /dev/null
@@ -0,0 +1,25 @@
+#
+# Utility functions for the libcgroup functional tests
+#
+# Copyright (c) 2020 Oracle and/or its affiliates.
+# Author: Tom Hromatka <tom.hromatka@oracle.com>
+#
+
+#
+# This library is free software; you can redistribute it and/or modify it
+# under the terms of version 2.1 of the GNU Lesser General Public License as
+# published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License
+# for more details.
+#
+# You should have received a copy of the GNU Lesser General Public License
+# along with this library; if not, see <http://www.gnu.org/licenses>.
+#
+
+# function to indent a block of text by cnt number of spaces
+def indent(in_str, cnt):
+    leading_indent = cnt * ' '
+    return ''.join(leading_indent + line for line in in_str.splitlines(True))