[LTP] [PATCH 1/6] API/cgroup: Modify tst_cgroup_print_config for easier parsing and consumption
Luke Nowakowski-Krijger
luke.nowakowskikrijger@canonical.com
Wed Jan 5 11:00:02 CET 2022
Prepare tst_cgroup_print_config to be more easily parsed and consumed by
shell scripts and other programs.
Also add any detected root information as well as the relevant state
associated with the roots that would be needed by the test to properly
cleanup.
Signed-off-by: Luke Nowakowski-Krijger <luke.nowakowskikrijger@canonical.com>
---
lib/tst_cgroup.c | 38 ++++++++++++++++++++++++++++++++++----
1 file changed, 34 insertions(+), 4 deletions(-)
diff --git a/lib/tst_cgroup.c b/lib/tst_cgroup.c
index c08ff2f20..166d0f97e 100644
--- a/lib/tst_cgroup.c
+++ b/lib/tst_cgroup.c
@@ -300,12 +300,27 @@ opendir:
O_PATH | O_DIRECTORY);
}
+#define CONFIG_LTPDIR_KEY "Created_Ltp_Dir"
+#define CONFIG_MOUNTROOT_KEY "Mounted_Root"
+#define CONFIG_DRAINDIR_KEY "Created_Drain_Dir"
+#define CONFIG_TESTID_KEY "Test_Id"
+#define CONFIG_CTRL_REQUIRED "Required"
+#define CONFIG_CTRL_HEADER "Detected Controllers:"
+#define CONFIG_ROOT_HEADER "Detected Roots:"
+
+/* Prints out the minimal internal state of the test to be consumed
+ * by tst_cgroup_load_config().
+ *
+ * The config keeps track of the minimal state needed for tst_cgroup_cleanup
+ * to cleanup after a test and does not keep track of the creation of
+ * test cgroups that might be created through tst_cgroup_group_mk().
+ */
void tst_cgroup_print_config(void)
{
struct cgroup_root *root;
const struct cgroup_ctrl *ctrl;
- tst_res(TINFO, "Detected Controllers:");
+ printf("%s\n", CONFIG_CTRL_HEADER);
for_each_ctrl(ctrl) {
root = ctrl->ctrl_root;
@@ -313,11 +328,26 @@ void tst_cgroup_print_config(void)
if (!root)
continue;
- tst_res(TINFO, "\t%.10s %s @ %s:%s",
+ printf("%s %s @ %s %s\n",
ctrl->ctrl_name,
- root->no_cpuset_prefix ? "[noprefix]" : "",
root->ver == TST_CGROUP_V1 ? "V1" : "V2",
- root->mnt_path);
+ root->mnt_path,
+ ctrl->we_require_it ? CONFIG_CTRL_REQUIRED : "");
+ }
+
+ printf("%s\n", CONFIG_ROOT_HEADER);
+
+ for_each_root(root) {
+ printf("%s %s=%s %s=%s %s=%s %s=%s\n",
+ root->mnt_path,
+ CONFIG_MOUNTROOT_KEY,
+ root->we_mounted_it ? "yes" : "no",
+ CONFIG_LTPDIR_KEY,
+ root->ltp_dir.we_created_it ? "yes" : "no",
+ CONFIG_DRAINDIR_KEY,
+ root->drain_dir.we_created_it ? "yes" : "no",
+ CONFIG_TESTID_KEY,
+ root->test_dir.dir_name ? root->test_dir.dir_name : "NULL");
}
}
--
2.32.0
More information about the ltp
mailing list