~ubuntu-branches/debian/stretch/ccache/stretch

« back to all changes in this revision

Viewing changes to test/test_argument_processing.c

  • Committer: Bazaar Package Importer
  • Author(s): Joel Rosdahl
  • Date: 2010-12-02 21:05:17 UTC
  • mfrom: (5.1.4 sid)
  • Revision ID: james.westby@ubuntu.com-20101202210517-ji5owl2qa3s5c1rg
New upstream version.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2010 Joel Rosdahl
 
3
 *
 
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)
 
7
 * any later version.
 
8
 *
 
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
 
12
 * more details.
 
13
 *
 
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
 
17
 */
 
18
 
 
19
/*
 
20
 * This file contains tests for the processing of compiler arguments.
 
21
 */
 
22
 
 
23
#include "ccache.h"
 
24
#include "test/framework.h"
 
25
#include "test/util.h"
 
26
 
 
27
TEST_SUITE(argument_processing)
 
28
 
 
29
TEST(dash_E_should_be_unsupported)
 
30
{
 
31
        struct args *orig = args_init_from_string("cc -c foo.c -E");
 
32
        struct args *preprocessed, *compiler;
 
33
 
 
34
        create_file("foo.c", "");
 
35
        CHECK(!cc_process_args(orig, &preprocessed, &compiler));
 
36
        CHECK_UNS_EQ(1, stats_get_pending(STATS_UNSUPPORTED));
 
37
 
 
38
        args_free(orig);
 
39
}
 
40
 
 
41
TEST(dependency_flags_should_only_be_sent_to_the_preprocessor)
 
42
{
 
43
#define CMD \
 
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);
 
48
#undef 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", "");
 
52
 
 
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);
 
56
 
 
57
        args_free(orig);
 
58
}
 
59
 
 
60
TEST(dependency_flags_that_take_an_argument_should_not_require_space_delimiter)
 
61
{
 
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", "");
 
69
 
 
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);
 
73
 
 
74
        args_free(orig);
 
75
}
 
76
 
 
77
TEST_SUITE_END