} \
} 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) {
// Test config.
{
+ __attribute__((cleanup(test_internal_cleanup_delete_temporary_file)))
const char *test_config_filename = "/tmp/c_simple_http_test.config";
__attribute__((cleanup(simple_archiver_helper_cleanup_FILE)))
FILE *test_file = fopen(test_config_filename, "w");
// Test http_template.
{
+ __attribute__((cleanup(test_internal_cleanup_delete_temporary_file)))
const char *test_http_template_filename =
"/tmp/c_simple_http_template_test.config";
__attribute__((cleanup(simple_archiver_helper_cleanup_FILE)))
ASSERT_TRUE(strcmp(buf, "<h1>Test</h1>") == 0);
simple_archiver_helper_cleanup_c_string(&buf);
+ __attribute__((cleanup(test_internal_cleanup_delete_temporary_file)))
const char *test_http_template_filename2 =
"/tmp/c_simple_http_template_test2.config";
test_file = fopen(test_http_template_filename2, "w");
== 0);
simple_archiver_helper_cleanup_c_string(&buf);
+ __attribute__((cleanup(test_internal_cleanup_delete_temporary_file)))
const char *test_http_template_filename3 =
"/tmp/c_simple_http_template_test3.config";
+ __attribute__((cleanup(test_internal_cleanup_delete_temporary_file)))
const char *test_http_template_html_filename =
"/tmp/c_simple_http_template_test.html";
test_file = fopen(test_http_template_filename3, "w");
== 0);
simple_archiver_helper_cleanup_c_string(&buf);
+ __attribute__((cleanup(test_internal_cleanup_delete_temporary_file)))
const char *test_http_template_filename4 =
"/tmp/c_simple_http_template_test4.config";
+ __attribute__((cleanup(test_internal_cleanup_delete_temporary_file)))
const char *test_http_template_html_filename2 =
"/tmp/c_simple_http_template_test2.html";
+ __attribute__((cleanup(test_internal_cleanup_delete_temporary_file)))
const char *test_http_template_html_var_filename =
"/tmp/c_simple_http_template_test_var.html";
test_file = fopen(test_http_template_filename4, "w");