Skip to content

Commit

Permalink
Cleanup test_remove. NFC (emscripten-core#23081)
Browse files Browse the repository at this point in the history
- Convert to C.
- Move to `test/stdio`

This test was originally added in c008b11 and is not specific to C++
cstdio and was the only file in this directory.

Also remove the cleanup code.  See emscripten-core#23003.
  • Loading branch information
sbc100 authored Dec 5, 2024
1 parent 78c968b commit a6ecc86
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 19 deletions.
26 changes: 8 additions & 18 deletions test/cstdio/test_remove.cpp → test/stdio/test_remove.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@

#include <assert.h>
#include <errno.h>
#include <cstdio>
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <stdlib.h>
Expand All @@ -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;
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion test/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down

0 comments on commit a6ecc86

Please sign in to comment.