@@ -191,5 +191,13 @@ void safe_cgroup_scanf(const char *file, const int lineno,
const char *fmt, ...)
__attribute__ ((format (scanf, 5, 6), nonnull));
+#define SAFE_CGROUP_OCCURSIN(cg, file_name, needle) \
+ safe_cgroup_occursin(__FILE__, __LINE__, \
+ (cg), (file_name), (needle))
+
+int safe_cgroup_occursin(const char *file, const int lineno,
+ const struct tst_cgroup_group *const cg,
+ const char *const file_name,
+ const char *const needle);
#endif /* TST_CGROUP_H */
@@ -1153,3 +1153,15 @@ void safe_cgroup_scanf(const char *const file, const int lineno,
"'%s': vsscanf('%s', '%s', ..): Less conversions than expected: %d != %d",
file_name, buf, fmt, ret, conv_cnt);
}
+
+int safe_cgroup_occursin(const char *const file, const int lineno,
+ const struct tst_cgroup_group *const cg,
+ const char *const file_name,
+ const char *const needle)
+{
+ char buf[BUFSIZ];
+
+ safe_cgroup_read(file, lineno, cg, file_name, buf, sizeof(buf));
+
+ return !!strstr(buf, needle);
+}
Similar to cg_read_strstr from kselftests. The name was changed because strstr from string.h returns a ptr and this does not. Signed-off-by: Richard Palethorpe <rpalethorpe@suse.com> --- include/tst_cgroup.h | 8 ++++++++ lib/tst_cgroup.c | 12 ++++++++++++ 2 files changed, 20 insertions(+)