Add fuzzing to the cgroup_new_cgroup() API, by passing NULL as cgroup
name.
[----------] 2 tests from APIArgsTest
[ RUN ] APIArgsTest.API_cgroup_set_permissions
[ OK ] APIArgsTest.API_cgroup_set_permissions (0 ms)
[ RUN ] APIArgsTest.API_cgroup_new_cgroup
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
(cherry picked from commit
be62c2649a845726ca67faa7707fbeae7eb84c90)
std::string result = testing::internal::GetCapturedStdout();
ASSERT_EQ(result, "Error: Cgroup, operation not allowed\n");
}
+
+/**
+ * Pass NULL cgroup name for creating a cgroup
+ * @param APIArgsTest googletest test case name
+ * @param API_cgroup_new_cgroup test name
+ *
+ * This test will pass NULL cgroup name to the cgroup_new_cgroup()
+ * and check it handles it gracefully.
+ */
+TEST_F(APIArgsTest, API_cgroup_new_cgroup)
+{
+ struct cgroup *cgroup = NULL;
+ char *name = NULL;
+
+ cgroup = cgroup_new_cgroup(name);
+ ASSERT_EQ(cgroup, nullptr);
+}