Remove temporary files created by unit test on end
All checks were successful
Run Unit Tests / build-and-run-unit-tests (push) Successful in 33s
All checks were successful
Run Unit Tests / build-and-run-unit-tests (push) Successful in 33s
This commit is contained in:
parent
229e3a330f
commit
676b98751d
1 changed files with 16 additions and 0 deletions
16
src/test.c
16
src/test.c
|
@ -79,9 +79,18 @@ static int checks_passed = 0;
|
||||||
} \
|
} \
|
||||||
} while (0);
|
} while (0);
|
||||||
|
|
||||||
|
void test_internal_cleanup_delete_temporary_file(const char **filename) {
|
||||||
|
if (filename && *filename) {
|
||||||
|
if (remove(*filename) != 0) {
|
||||||
|
fprintf(stderr, "ERROR Failed to remove file \"%s\"!\n", *filename);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int main(void) {
|
int main(void) {
|
||||||
// Test config.
|
// Test config.
|
||||||
{
|
{
|
||||||
|
__attribute__((cleanup(test_internal_cleanup_delete_temporary_file)))
|
||||||
const char *test_config_filename = "/tmp/c_simple_http_test.config";
|
const char *test_config_filename = "/tmp/c_simple_http_test.config";
|
||||||
__attribute__((cleanup(simple_archiver_helper_cleanup_FILE)))
|
__attribute__((cleanup(simple_archiver_helper_cleanup_FILE)))
|
||||||
FILE *test_file = fopen(test_config_filename, "w");
|
FILE *test_file = fopen(test_config_filename, "w");
|
||||||
|
@ -211,6 +220,7 @@ int main(void) {
|
||||||
|
|
||||||
// Test http_template.
|
// Test http_template.
|
||||||
{
|
{
|
||||||
|
__attribute__((cleanup(test_internal_cleanup_delete_temporary_file)))
|
||||||
const char *test_http_template_filename =
|
const char *test_http_template_filename =
|
||||||
"/tmp/c_simple_http_template_test.config";
|
"/tmp/c_simple_http_template_test.config";
|
||||||
__attribute__((cleanup(simple_archiver_helper_cleanup_FILE)))
|
__attribute__((cleanup(simple_archiver_helper_cleanup_FILE)))
|
||||||
|
@ -244,6 +254,7 @@ int main(void) {
|
||||||
ASSERT_TRUE(strcmp(buf, "<h1>Test</h1>") == 0);
|
ASSERT_TRUE(strcmp(buf, "<h1>Test</h1>") == 0);
|
||||||
simple_archiver_helper_cleanup_c_string(&buf);
|
simple_archiver_helper_cleanup_c_string(&buf);
|
||||||
|
|
||||||
|
__attribute__((cleanup(test_internal_cleanup_delete_temporary_file)))
|
||||||
const char *test_http_template_filename2 =
|
const char *test_http_template_filename2 =
|
||||||
"/tmp/c_simple_http_template_test2.config";
|
"/tmp/c_simple_http_template_test2.config";
|
||||||
test_file = fopen(test_http_template_filename2, "w");
|
test_file = fopen(test_http_template_filename2, "w");
|
||||||
|
@ -282,8 +293,10 @@ int main(void) {
|
||||||
== 0);
|
== 0);
|
||||||
simple_archiver_helper_cleanup_c_string(&buf);
|
simple_archiver_helper_cleanup_c_string(&buf);
|
||||||
|
|
||||||
|
__attribute__((cleanup(test_internal_cleanup_delete_temporary_file)))
|
||||||
const char *test_http_template_filename3 =
|
const char *test_http_template_filename3 =
|
||||||
"/tmp/c_simple_http_template_test3.config";
|
"/tmp/c_simple_http_template_test3.config";
|
||||||
|
__attribute__((cleanup(test_internal_cleanup_delete_temporary_file)))
|
||||||
const char *test_http_template_html_filename =
|
const char *test_http_template_html_filename =
|
||||||
"/tmp/c_simple_http_template_test.html";
|
"/tmp/c_simple_http_template_test.html";
|
||||||
test_file = fopen(test_http_template_filename3, "w");
|
test_file = fopen(test_http_template_filename3, "w");
|
||||||
|
@ -342,10 +355,13 @@ int main(void) {
|
||||||
== 0);
|
== 0);
|
||||||
simple_archiver_helper_cleanup_c_string(&buf);
|
simple_archiver_helper_cleanup_c_string(&buf);
|
||||||
|
|
||||||
|
__attribute__((cleanup(test_internal_cleanup_delete_temporary_file)))
|
||||||
const char *test_http_template_filename4 =
|
const char *test_http_template_filename4 =
|
||||||
"/tmp/c_simple_http_template_test4.config";
|
"/tmp/c_simple_http_template_test4.config";
|
||||||
|
__attribute__((cleanup(test_internal_cleanup_delete_temporary_file)))
|
||||||
const char *test_http_template_html_filename2 =
|
const char *test_http_template_html_filename2 =
|
||||||
"/tmp/c_simple_http_template_test2.html";
|
"/tmp/c_simple_http_template_test2.html";
|
||||||
|
__attribute__((cleanup(test_internal_cleanup_delete_temporary_file)))
|
||||||
const char *test_http_template_html_var_filename =
|
const char *test_http_template_html_var_filename =
|
||||||
"/tmp/c_simple_http_template_test_var.html";
|
"/tmp/c_simple_http_template_test_var.html";
|
||||||
test_file = fopen(test_http_template_filename4, "w");
|
test_file = fopen(test_http_template_filename4, "w");
|
||||||
|
|
Loading…
Reference in a new issue