6 #include <gtest/gtest.h>
15 std::vector<const char *> cStrings;
16 for (
const auto & commandLineArgument : commandLineArguments)
18 cStrings.push_back(commandLineArgument.c_str());
23 static_cast<int>(cStrings.size()),
27 TEST(JlcCommandLineParserTests, Test1)
30 std::vector<std::string> commandLineArguments({
"jlc",
"-c",
"-o",
"foo.o",
"foo.c" });
36 EXPECT_EQ(commandLineOptions.Compilations_.size(), 1u);
37 auto & compilation = commandLineOptions.Compilations_[0];
39 EXPECT_EQ(compilation.RequiresLinking(),
false);
40 EXPECT_EQ(compilation.OutputFile(),
"foo.o");
43 TEST(JlcCommandLineParserTests, Test2)
46 std::vector<std::string> commandLineArguments({
"jlc",
"-o",
"foobar",
"/tmp/f1.o" });
52 EXPECT_EQ(commandLineOptions.Compilations_.size(), 1u);
53 EXPECT_EQ(commandLineOptions.OutputFile_,
"foobar");
55 auto & compilation = commandLineOptions.Compilations_[0];
56 EXPECT_FALSE(compilation.RequiresParsing());
57 EXPECT_FALSE(compilation.RequiresOptimization());
58 EXPECT_FALSE(compilation.RequiresAssembly());
59 EXPECT_TRUE(compilation.RequiresLinking());
62 TEST(JlcCommandLineParserTests, Test3)
67 std::vector<std::string> commandLineArguments({
"jlc",
"-O",
"foobar.c" });
76 TEST(JlcCommandLineParserTests, Test4)
79 std::vector<std::string> commandLineArguments({
"jlc",
"foobar.c",
"-c" });
85 EXPECT_EQ(commandLineOptions.Compilations_.size(), 1u);
87 auto & compilation = commandLineOptions.Compilations_[0];
88 EXPECT_FALSE(compilation.RequiresLinking());
89 EXPECT_EQ(compilation.OutputFile(),
"foobar.o");
92 TEST(JlcCommandLineParserTests, TestJlmOptOptimizations)
97 std::vector<std::string> commandLineArguments(
98 {
"jlc",
"foobar.c",
"-JCommonNodeElimination",
"-JDeadNodeElimination" });
104 EXPECT_EQ(commandLineOptions.JlmOptOptimizations_.size(), 2u);
106 commandLineOptions.JlmOptOptimizations_[0],
109 commandLineOptions.JlmOptOptimizations_[1],
113 TEST(JlcCommandLineParserTests, TestFalseJlmOptOptimization)
118 std::vector<std::string> commandLineArguments({
"jlc",
"-JFoobar",
"foobar.c" });
124 TEST(JlcCommandLineParserTests, TestJlmOptPassStatistics)
129 std::vector<std::string> commandLineArguments({
"jlc",
130 "--JlmOptPassStatistics=print-aggregation-time",
131 "--JlmOptPassStatistics=print-andersen-analysis",
141 EXPECT_EQ(commandLineOptions.JlmOptPassStatistics_, expectedStatistics);
TEST(JlcCommandLineParserTests, Test1)
static const jlm::tooling::JlcCommandLineOptions & ParseCommandLineArguments(const std::vector< std::string > &commandLineArguments)