8327071: [Testbug] g-tests for cgroup leave files in /tmp on linux

Reviewed-by: mbaesken, gli, stuefe
This commit is contained in:
Arno Zeller 2024-03-04 08:40:50 +00:00 committed by Matthias Baesken
parent 7c71f188a3
commit e889b460c0

View File

@ -61,7 +61,7 @@ static void delete_file(const char* filename) {
class TestController : public CgroupController {
public:
char* subsystem_path() override {
// The real subsystem is in /tmp/, generaed by temp_file()
// The real subsystem is in /tmp/, generated by temp_file()
return (char*)"/";
};
};
@ -99,6 +99,9 @@ TEST(cgroupTest, SubSystemFileLineContentsMultipleLinesErrorCases) {
fill_file(test_file, "foof bar");
err = subsystem_file_line_contents(&my_controller, test_file, "foo", "%s", &s);
EXPECT_NE(err, 0) << "Key must be exact match";
// Cleanup
delete_file(test_file);
}
TEST(cgroupTest, SubSystemFileLineContentsMultipleLinesSuccessCases) {
@ -149,6 +152,9 @@ TEST(cgroupTest, SubSystemFileLineContentsMultipleLinesSuccessCases) {
err = subsystem_file_line_contents(&my_controller, test_file, nullptr, "%*s %d", &x);
EXPECT_EQ(err, 0);
EXPECT_EQ(x, 10001);
// Cleanup
delete_file(test_file);
}
TEST(cgroupTest, SubSystemFileLineContentsSingleLine) {
@ -190,6 +196,9 @@ TEST(cgroupTest, SubSystemFileLineContentsSingleLine) {
err = subsystem_file_line_contents(&my_controller, test_file, nullptr, JULONG_FORMAT, &z);
EXPECT_EQ(err, 0);
EXPECT_EQ(z, (julong)1337) << "Wrong value for z";
// Cleanup
delete_file(test_file);
}
#endif // LINUX