2
* Copyright (C) 2010 Joel Rosdahl
4
* This program is free software; you can redistribute it and/or modify it
5
* under the terms of the GNU General Public License as published by the Free
6
* Software Foundation; either version 3 of the License, or (at your option)
9
* This program is distributed in the hope that it will be useful, but WITHOUT
10
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14
* You should have received a copy of the GNU General Public License along with
15
* this program; if not, write to the Free Software Foundation, Inc., 51
16
* Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20
* This file contains tests for the processing of compiler arguments.
24
#include "test/framework.h"
25
#include "test/util.h"
27
TEST_SUITE(argument_processing)
29
TEST(dash_E_should_be_unsupported)
31
struct args *orig = args_init_from_string("cc -c foo.c -E");
32
struct args *preprocessed, *compiler;
34
create_file("foo.c", "");
35
CHECK(!cc_process_args(orig, &preprocessed, &compiler));
36
CHECK_UNS_EQ(1, stats_get_pending(STATS_UNSUPPORTED));
41
TEST(dependency_flags_should_only_be_sent_to_the_preprocessor)
44
"cc -c -MD -MMD -MP -MF foo.d -MT mt1 -MT mt2 -MQ mq1 -MQ mq2" \
45
" -Wp,-MD,wpmd -Wp,-MMD,wpmmd"
46
struct args *orig = args_init_from_string(CMD " foo.c -o foo.o");
47
struct args *exp_cpp = args_init_from_string(CMD);
49
struct args *exp_cc = args_init_from_string("cc -c");
50
struct args *act_cpp = NULL, *act_cc = NULL;
51
create_file("foo.c", "");
53
CHECK(cc_process_args(orig, &act_cpp, &act_cc));
54
CHECK_ARGS_EQ_FREE12(exp_cpp, act_cpp);
55
CHECK_ARGS_EQ_FREE12(exp_cc, act_cc);
60
TEST(dependency_flags_that_take_an_argument_should_not_require_space_delimiter)
62
struct args *orig = args_init_from_string(
63
"cc -c -MMD -MFfoo.d -MTmt -MQmq foo.c -o foo.o");
64
struct args *exp_cpp = args_init_from_string(
65
"cc -c -MMD -MFfoo.d -MTmt -MQmq");
66
struct args *exp_cc = args_init_from_string("cc -c");
67
struct args *act_cpp = NULL, *act_cc = NULL;
68
create_file("foo.c", "");
70
CHECK(cc_process_args(orig, &act_cpp, &act_cc));
71
CHECK_ARGS_EQ_FREE12(exp_cpp, act_cpp);
72
CHECK_ARGS_EQ_FREE12(exp_cc, act_cc);