From: Joel Rosdahl Date: Fri, 30 Jul 2010 19:49:33 +0000 (+0200) Subject: Introduce cc_reset(), enabling the test suite to reset global state X-Git-Tag: v3.1~131 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=2538f20aabde0586b0c8b0a2be4719595e8d569d;p=thirdparty%2Fccache.git Introduce cc_reset(), enabling the test suite to reset global state --- diff --git a/ccache.c b/ccache.c index e9d291275..aac48ef68 100644 --- a/ccache.c +++ b/ccache.c @@ -1812,6 +1812,40 @@ out: return result; } +/* Reset the global state. Used by the test suite. */ +void cc_reset(void) +{ + free(current_working_dir); current_working_dir = NULL; + free(cache_dir); cache_dir = NULL; + cache_logfile = NULL; + base_dir = NULL; + args_free(orig_args); orig_args = NULL; + free(input_file); input_file = NULL; + output_obj = NULL; + free(output_dep); output_dep = NULL; + free(cached_obj_hash); cached_obj_hash = NULL; + free(cached_obj); cached_obj = NULL; + free(cached_stderr); cached_stderr = NULL; + free(cached_dep); cached_dep = NULL; + free(manifest_path); manifest_path = NULL; + time_of_compilation = 0; + sloppiness = 0; + if (included_files) { + hashtable_destroy(included_files, 1); included_files = NULL; + } + generating_dependencies = 0; + i_extension = NULL; + i_tmpfile = NULL; + direct_i_file = 0; + free(cpp_stderr); cpp_stderr = NULL; + free(stats_file); stats_file = NULL; + enable_unify = 0; + enable_direct = 1; + enable_compression = 0; + nlevels = 2; + compile_preprocessed_source_code = 0; +} + static unsigned parse_sloppiness(char *p) { unsigned result = 0; @@ -2153,7 +2187,9 @@ int ccache_main(int argc, char *argv[]) current_working_dir = get_cwd(); cache_dir = getenv("CCACHE_DIR"); - if (!cache_dir) { + if (cache_dir) { + cache_dir = x_strdup(cache_dir); + } else { const char *home_directory = get_home_directory(); if (home_directory) { cache_dir = format("%s/.ccache", home_directory); diff --git a/ccache.h b/ccache.h index 5b8d287d9..bbde9070d 100644 --- a/ccache.h +++ b/ccache.h @@ -206,6 +206,7 @@ int args_equal(struct args *args1, struct args *args2); int cc_process_args(struct args *orig_args, struct args **preprocessor_args, struct args **compiler_args); +void cc_reset(void); /* ------------------------------------------------------------------------- */ diff --git a/test/framework.c b/test/framework.c index a5328afb2..fbde7dac7 100644 --- a/test/framework.c +++ b/test/framework.c @@ -151,6 +151,7 @@ void cct_test_begin(const char *name) cct_chdir(name); current_test = name; failed_asserts_before_test = failed_asserts; + cc_reset(); } void cct_test_end()