summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJoel Rosdahl <joel@rosdahl.net>2011-08-15 22:38:26 +0200
committerJoel Rosdahl <joel@rosdahl.net>2011-08-15 22:38:26 +0200
commit806b511643ec830f50d6d6975b2ecfd1876a6f17 (patch)
tree620be70e9e37f24aaf2bde5588e24ba8f25f6fc9 /test
parent25ae81432e30e205d123e443dd92e1206b89850c (diff)
downloadccache-806b511643ec830f50d6d6975b2ecfd1876a6f17.tar.gz
Fix -fprofile-*=dir handling when dir doesn't exist
Diffstat (limited to 'test')
-rw-r--r--test/test_argument_processing.c44
1 files changed, 44 insertions, 0 deletions
diff --git a/test/test_argument_processing.c b/test/test_argument_processing.c
index a1fdb816..18dcaea4 100644
--- a/test/test_argument_processing.c
+++ b/test/test_argument_processing.c
@@ -230,4 +230,48 @@ TEST(MT_flag_with_immediate_argument_should_add_MQobj)
args_free(orig);
}
+TEST(fprofile_flag_with_existing_dir_should_be_rewritten_to_real_path)
+{
+ struct args *orig = args_init_from_string(
+ "gcc -c -fprofile-generate=some/dir foo.c");
+ struct args *exp_cpp = args_init_from_string("gcc");
+ struct args *exp_cc = args_init_from_string("gcc");
+ struct args *act_cpp = NULL, *act_cc = NULL;
+ char *s;
+
+ create_file("foo.c", "");
+ mkdir("some", 0777);
+ mkdir("some/dir", 0777);
+ s = format("-fprofile-generate=%s", x_realpath("some/dir"));
+ args_add(exp_cpp, s);
+ args_add(exp_cc, s);
+ args_add(exp_cc, "-c");
+ free(s);
+
+ CHECK(cc_process_args(orig, &act_cpp, &act_cc));
+ CHECK_ARGS_EQ_FREE12(exp_cpp, act_cpp);
+ CHECK_ARGS_EQ_FREE12(exp_cc, act_cc);
+
+ args_free(orig);
+}
+
+TEST(fprofile_flag_with_nonexisting_dir_not_be_rewritten)
+{
+ struct args *orig = args_init_from_string(
+ "gcc -c -fprofile-generate=some/dir foo.c");
+ struct args *exp_cpp = args_init_from_string(
+ "gcc -fprofile-generate=some/dir");
+ struct args *exp_cc = args_init_from_string(
+ "gcc -fprofile-generate=some/dir -c");
+ struct args *act_cpp = NULL, *act_cc = NULL;
+
+ create_file("foo.c", "");
+
+ CHECK(cc_process_args(orig, &act_cpp, &act_cc));
+ CHECK_ARGS_EQ_FREE12(exp_cpp, act_cpp);
+ CHECK_ARGS_EQ_FREE12(exp_cc, act_cc);
+
+ args_free(orig);
+}
+
TEST_SUITE_END