Commit bd71f2fd authored by Matheus Marchini's avatar Matheus Marchini

fixup! attach to multiple identical probes

parent 3a184594
...@@ -13,6 +13,11 @@ namespace test { ...@@ -13,6 +13,11 @@ namespace test {
namespace codegen { namespace codegen {
using ::testing::_; using ::testing::_;
class MockBPFtrace : public BPFtrace {
public:
MOCK_METHOD1(add_probe, int(ast::Probe &p));
};
TEST(codegen, populate_sections) TEST(codegen, populate_sections)
{ {
...@@ -94,6 +99,21 @@ void test(const std::string &input, const std::string expected_output) ...@@ -94,6 +99,21 @@ void test(const std::string &input, const std::string expected_output)
EXPECT_EQ(full_expected_output, out.str()); EXPECT_EQ(full_expected_output, out.str());
} }
TEST(codegen, probe_count)
{
MockBPFtrace bpftrace;
EXPECT_CALL(bpftrace, add_probe(_)).Times(2);
Driver driver;
ASSERT_EQ(driver.parse_str("kprobe:f { 1; } kprobe:d { 1; }"), 0);
ast::SemanticAnalyser semantics(driver.root_, bpftrace);
ASSERT_EQ(semantics.analyse(), 0);
ast::CodegenLLVM codegen(driver.root_, bpftrace);
codegen.compile();
}
TEST(codegen, empty_function) TEST(codegen, empty_function)
{ {
test("kprobe:f { 1; }", test("kprobe:f { 1; }",
......
...@@ -9,11 +9,6 @@ namespace bpftrace { ...@@ -9,11 +9,6 @@ namespace bpftrace {
namespace test { namespace test {
namespace semantic_analyser { namespace semantic_analyser {
class MockBPFtrace : public BPFtrace {
public:
MOCK_METHOD1(add_probe, int(ast::Probe &p));
};
using ::testing::_; using ::testing::_;
void test(BPFtrace &bpftrace, Driver &driver, const std::string &input, int expected_result=0) void test(BPFtrace &bpftrace, Driver &driver, const std::string &input, int expected_result=0)
...@@ -97,14 +92,6 @@ TEST(semantic_analyser, builtin_functions) ...@@ -97,14 +92,6 @@ TEST(semantic_analyser, builtin_functions)
test("kprobe:f { fake() }", 1); test("kprobe:f { fake() }", 1);
} }
TEST(semantic_analyser, probe_count)
{
MockBPFtrace bpftrace;
EXPECT_CALL(bpftrace, add_probe(_)).Times(2);
test(bpftrace, "kprobe:f { 1; } kprobe:d { 1; }");
}
TEST(semantic_analyser, undefined_map) TEST(semantic_analyser, undefined_map)
{ {
test("kprobe:f / @mymap == 123 / { @mymap = 0 }", 0); test("kprobe:f / @mymap == 123 / { @mymap = 0 }", 0);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment