From f7b1091a7cb9fdcfb038b56fd75c3dfd55d38204 Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Wed, 4 Dec 2024 16:20:49 -0800 Subject: [PATCH] Cleanup test_remove. NFC - Convert to C. - Move to `test/stdio` This test was originally added in c008b1129 and is not specific to C++ cstdio and was the only file in this directory. Also remove the cleanup code. See #23003. --- .../test_remove.cpp => stdio/test_remove.c} | 26 ++++++------------- test/{cstdio => stdio}/test_remove.out | 0 test/test_core.py | 2 +- 3 files changed, 9 insertions(+), 19 deletions(-) rename test/{cstdio/test_remove.cpp => stdio/test_remove.c} (71%) rename test/{cstdio => stdio}/test_remove.out (100%) diff --git a/test/cstdio/test_remove.cpp b/test/stdio/test_remove.c similarity index 71% rename from test/cstdio/test_remove.cpp rename to test/stdio/test_remove.c index 6ed3e3be86c27..8fecf120f4d0b 100644 --- a/test/cstdio/test_remove.cpp +++ b/test/stdio/test_remove.c @@ -5,8 +5,7 @@ #include #include -#include -#include +#include #include #include #include @@ -30,38 +29,29 @@ void setup() { mkdir("dir/subdir", 0777); } -void cleanup() { - // make sure we get it all regardless of anything failing - unlink("file"); - unlink("dir/file"); - rmdir("dir/subdir"); - rmdir("dir"); -} - void test() { int err; - - err = std::remove("dir/file"); + + err = remove("dir/file"); assert(!err); - err = std::remove("file"); + err = remove("file"); assert(!err); // should fail, folder is not empty - err = std::remove("dir"); + err = remove("dir"); assert(err); - err = std::remove("dir/subdir"); + err = remove("dir/subdir"); assert(!err); - err = std::remove("dir"); + err = remove("dir"); assert(!err); - std::cout << "success\n"; + printf("success\n"); } int main() { - atexit(cleanup); setup(); test(); return 0; diff --git a/test/cstdio/test_remove.out b/test/stdio/test_remove.out similarity index 100% rename from test/cstdio/test_remove.out rename to test/stdio/test_remove.out diff --git a/test/test_core.py b/test/test_core.py index 7511815c00a8e..76fe5992ee3dc 100644 --- a/test/test_core.py +++ b/test/test_core.py @@ -1697,7 +1697,7 @@ def test_rename(self): self.do_run_in_out_file_test('stdio/test_rename.c') def test_remove(self): - self.do_run_in_out_file_test('cstdio/test_remove.cpp') + self.do_run_in_out_file_test('stdio/test_remove.c') def test_alloca_stack(self): self.do_core_test('test_alloca_stack.c')