Commit 90e5443a authored by Brendan Gregg's avatar Brendan Gregg Committed by GitHub

Merge pull request #396 from caringi/fix_warnings_1

Re-enable subset of build warnings and fix some related warnings #316
parents 3a9c9d0f f0f56b02
...@@ -7,19 +7,19 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake) ...@@ -7,19 +7,19 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
add_compile_options("-std=c++14") add_compile_options("-std=c++14")
add_compile_options("-Wno-format-security") add_compile_options("-Wno-format-security")
#add_compile_options("-Wall") #add_compile_options("-Wall")
#add_compile_options("-Wextra") add_compile_options("-Wextra")
#add_compile_options("-Wundef") add_compile_options("-Wundef")
#add_compile_options("-Wpointer-arith") add_compile_options("-Wpointer-arith")
#add_compile_options("-Wcast-align") add_compile_options("-Wcast-align")
#add_compile_options("-Wwrite-strings") add_compile_options("-Wwrite-strings")
#add_compile_options("-Wcast-qual") #add_compile_options("-Wcast-qual")
#add_compile_options("-Wswitch-default") #add_compile_options("-Wswitch-default")
#add_compile_options("-Wswitch-enum") #add_compile_options("-Wswitch-enum")
#add_compile_options("-Wconversion") #add_compile_options("-Wconversion")
#add_compile_options("-Wunreachable-code") add_compile_options("-Wunreachable-code")
#add_compile_options("-Wformat=2") #add_compile_options("-Wformat=2")
#add_compile_options("-Wstrict-overflow=5") add_compile_options("-Wstrict-overflow=5")
#add_compile_options("-Wdisabled-optimization") add_compile_options("-Wdisabled-optimization")
include(CTest) include(CTest)
......
...@@ -496,7 +496,7 @@ void CodegenLLVM::visit(Call &call) ...@@ -496,7 +496,7 @@ void CodegenLLVM::visit(Call &call)
int struct_size = layout_.getTypeAllocSize(printf_struct); int struct_size = layout_.getTypeAllocSize(printf_struct);
auto *struct_layout = layout_.getStructLayout(printf_struct); auto *struct_layout = layout_.getStructLayout(printf_struct);
for (int i=0; i<args.size(); i++) for (size_t i=0; i<args.size(); i++)
{ {
Field &arg = args[i]; Field &arg = args[i];
arg.offset = struct_layout->getElementOffset(i+1); // +1 for the printf_id field arg.offset = struct_layout->getElementOffset(i+1); // +1 for the printf_id field
...@@ -506,7 +506,7 @@ void CodegenLLVM::visit(Call &call) ...@@ -506,7 +506,7 @@ void CodegenLLVM::visit(Call &call)
b_.CreateMemSet(printf_args, b_.getInt8(0), struct_size, 1); b_.CreateMemSet(printf_args, b_.getInt8(0), struct_size, 1);
b_.CreateStore(b_.getInt64(printf_id_), printf_args); b_.CreateStore(b_.getInt64(printf_id_), printf_args);
for (int i=1; i<call.vargs->size(); i++) for (size_t i=1; i<call.vargs->size(); i++)
{ {
Expression &arg = *call.vargs->at(i); Expression &arg = *call.vargs->at(i);
expr_deleter_ = nullptr; expr_deleter_ = nullptr;
...@@ -548,7 +548,7 @@ void CodegenLLVM::visit(Call &call) ...@@ -548,7 +548,7 @@ void CodegenLLVM::visit(Call &call)
int struct_size = layout_.getTypeAllocSize(printf_struct); int struct_size = layout_.getTypeAllocSize(printf_struct);
auto *struct_layout = layout_.getStructLayout(printf_struct); auto *struct_layout = layout_.getStructLayout(printf_struct);
for (int i=0; i<args.size(); i++) for (size_t i=0; i<args.size(); i++)
{ {
Field &arg = args[i]; Field &arg = args[i];
arg.offset = struct_layout->getElementOffset(i+1); // +1 for the system_id field arg.offset = struct_layout->getElementOffset(i+1); // +1 for the system_id field
...@@ -559,7 +559,7 @@ void CodegenLLVM::visit(Call &call) ...@@ -559,7 +559,7 @@ void CodegenLLVM::visit(Call &call)
// system_id_ has an offset to avoid be confused with printf // system_id_ has an offset to avoid be confused with printf
b_.CreateStore(b_.getInt64(system_id_ + asyncactionint(AsyncAction::syscall)), system_args); b_.CreateStore(b_.getInt64(system_id_ + asyncactionint(AsyncAction::syscall)), system_args);
for (int i=1; i<call.vargs->size(); i++) for (size_t i=1; i<call.vargs->size(); i++)
{ {
Expression &arg = *call.vargs->at(i); Expression &arg = *call.vargs->at(i);
expr_deleter_ = nullptr; expr_deleter_ = nullptr;
......
...@@ -366,7 +366,7 @@ Value *IRBuilderBPF::CreateStrcmp(Value* val, std::string str, bool inverse) { ...@@ -366,7 +366,7 @@ Value *IRBuilderBPF::CreateStrcmp(Value* val, std::string str, bool inverse) {
CreateStore(getInt1(inverse), store); CreateStore(getInt1(inverse), store);
const char *c_str = str.c_str(); const char *c_str = str.c_str();
for (int i = 0; i < strlen(c_str) + 1; i++) for (size_t i = 0; i < strlen(c_str) + 1; i++)
{ {
BasicBlock *char_eq = BasicBlock::Create(module_.getContext(), "strcmp.loop", parent); BasicBlock *char_eq = BasicBlock::Create(module_.getContext(), "strcmp.loop", parent);
AllocaInst *val_char = CreateAllocaBPF(getInt8Ty(), "strcmp.char"); AllocaInst *val_char = CreateAllocaBPF(getInt8Ty(), "strcmp.char");
......
...@@ -314,7 +314,7 @@ void SemanticAnalyser::visit(Call &call) ...@@ -314,7 +314,7 @@ void SemanticAnalyser::visit(Call &call)
// Promote to 64-bit if it's not an array type // Promote to 64-bit if it's not an array type
if (!ty.IsArray()) if (!ty.IsArray())
ty.size = 8; ty.size = 8;
args.push_back({ .type = ty }); args.push_back({ .type = ty, .offset = 0 });
} }
err_ << verify_format_string(fmt.str, args); err_ << verify_format_string(fmt.str, args);
...@@ -988,7 +988,7 @@ bool SemanticAnalyser::check_assignment(const Call &call, bool want_map, bool wa ...@@ -988,7 +988,7 @@ bool SemanticAnalyser::check_assignment(const Call &call, bool want_map, bool wa
return true; return true;
} }
bool SemanticAnalyser::check_nargs(const Call &call, int expected_nargs) bool SemanticAnalyser::check_nargs(const Call &call, size_t expected_nargs)
{ {
std::vector<Expression*>::size_type nargs = 0; std::vector<Expression*>::size_type nargs = 0;
if (call.vargs) if (call.vargs)
...@@ -1003,7 +1003,7 @@ bool SemanticAnalyser::check_nargs(const Call &call, int expected_nargs) ...@@ -1003,7 +1003,7 @@ bool SemanticAnalyser::check_nargs(const Call &call, int expected_nargs)
return true; return true;
} }
bool SemanticAnalyser::check_varargs(const Call &call, int min_nargs, int max_nargs) bool SemanticAnalyser::check_varargs(const Call &call, size_t min_nargs, size_t max_nargs)
{ {
std::vector<Expression*>::size_type nargs = 0; std::vector<Expression*>::size_type nargs = 0;
if (call.vargs) if (call.vargs)
......
...@@ -55,8 +55,8 @@ private: ...@@ -55,8 +55,8 @@ private:
std::string get_cast_type(Expression *expr); std::string get_cast_type(Expression *expr);
bool check_assignment(const Call &call, bool want_map, bool want_var); bool check_assignment(const Call &call, bool want_map, bool want_var);
bool check_nargs(const Call &call, int expected_nargs); bool check_nargs(const Call &call, size_t expected_nargs);
bool check_varargs(const Call &call, int min_nargs, int max_nargs); bool check_varargs(const Call &call, size_t min_nargs, size_t max_nargs);
bool check_arg(const Call &call, Type type, int arg_num, bool want_literal=false); bool check_arg(const Call &call, Type type, int arg_num, bool want_literal=false);
bool check_alpha_numeric(const Call &call, int arg_num); bool check_alpha_numeric(const Call &call, int arg_num);
......
...@@ -466,7 +466,7 @@ void BPFtrace::add_param(const std::string &param) ...@@ -466,7 +466,7 @@ void BPFtrace::add_param(const std::string &param)
params_.emplace_back(param); params_.emplace_back(param);
} }
std::string BPFtrace::get_param(int i) std::string BPFtrace::get_param(size_t i)
{ {
if (i > 0 && i < params_.size() + 1) if (i > 0 && i < params_.size() + 1)
return params_[i - 1]; return params_[i - 1];
...@@ -868,7 +868,7 @@ int BPFtrace::print_map(IMap &map, uint32_t top, uint32_t div) ...@@ -868,7 +868,7 @@ int BPFtrace::print_map(IMap &map, uint32_t top, uint32_t div)
if (div == 0) if (div == 0)
div = 1; div = 1;
uint32_t i = 0; uint32_t i = 0;
int total = values_by_key.size(); size_t total = values_by_key.size();
for (auto &pair : values_by_key) for (auto &pair : values_by_key)
{ {
auto key = pair.first; auto key = pair.first;
......
...@@ -70,7 +70,7 @@ public: ...@@ -70,7 +70,7 @@ public:
std::vector<std::unique_ptr<IPrintable>> get_arg_values(const std::vector<Field> &args, uint8_t* arg_data); std::vector<std::unique_ptr<IPrintable>> get_arg_values(const std::vector<Field> &args, uint8_t* arg_data);
void add_param(const std::string &param); void add_param(const std::string &param);
bool is_numeric(std::string str); bool is_numeric(std::string str);
std::string get_param(int index); std::string get_param(size_t index);
std::string cmd_; std::string cmd_;
int pid_{0}; int pid_{0};
......
...@@ -69,8 +69,8 @@ std::string MapKey::argument_value(BPFtrace &bpftrace, ...@@ -69,8 +69,8 @@ std::string MapKey::argument_value(BPFtrace &bpftrace,
return std::to_string(*(int32_t*)data); return std::to_string(*(int32_t*)data);
case 8: case 8:
return std::to_string(*(int64_t*)data); return std::to_string(*(int64_t*)data);
break;
} }
break;
case Type::kstack: case Type::kstack:
return bpftrace.get_stack(*(uint64_t*)data, false); return bpftrace.get_stack(*(uint64_t*)data, false);
case Type::ustack: case Type::ustack:
......
namespace bpftrace { namespace bpftrace {
inline std::string GetProviderFromPath(std::string path) { inline std::string GetProviderFromPath(std::string path) {
int i = path.rfind("/"); size_t i = path.rfind("/");
return (i != std::string::npos) ? path.substr(i + 1) : path; return (i != std::string::npos) ? path.substr(i + 1) : path;
} }
......
...@@ -107,8 +107,8 @@ TEST(bpftrace, add_begin_probe) ...@@ -107,8 +107,8 @@ TEST(bpftrace, add_begin_probe)
StrictMock<MockBPFtrace> bpftrace; StrictMock<MockBPFtrace> bpftrace;
EXPECT_EQ(0, bpftrace.add_probe(probe)); EXPECT_EQ(0, bpftrace.add_probe(probe));
EXPECT_EQ(0, bpftrace.get_probes().size()); EXPECT_EQ(0U, bpftrace.get_probes().size());
EXPECT_EQ(1, bpftrace.get_special_probes().size()); EXPECT_EQ(1U, bpftrace.get_special_probes().size());
check_special_probe(bpftrace.get_special_probes().at(0), "BEGIN_trigger", "BEGIN"); check_special_probe(bpftrace.get_special_probes().at(0), "BEGIN_trigger", "BEGIN");
} }
...@@ -121,8 +121,8 @@ TEST(bpftrace, add_end_probe) ...@@ -121,8 +121,8 @@ TEST(bpftrace, add_end_probe)
StrictMock<MockBPFtrace> bpftrace; StrictMock<MockBPFtrace> bpftrace;
EXPECT_EQ(0, bpftrace.add_probe(probe)); EXPECT_EQ(0, bpftrace.add_probe(probe));
EXPECT_EQ(0, bpftrace.get_probes().size()); EXPECT_EQ(0U, bpftrace.get_probes().size());
EXPECT_EQ(1, bpftrace.get_special_probes().size()); EXPECT_EQ(1U, bpftrace.get_special_probes().size());
check_special_probe(bpftrace.get_special_probes().at(0), "END_trigger", "END"); check_special_probe(bpftrace.get_special_probes().at(0), "END_trigger", "END");
} }
...@@ -135,8 +135,8 @@ TEST(bpftrace, add_probes_single) ...@@ -135,8 +135,8 @@ TEST(bpftrace, add_probes_single)
StrictMock<MockBPFtrace> bpftrace; StrictMock<MockBPFtrace> bpftrace;
EXPECT_EQ(0, bpftrace.add_probe(probe)); EXPECT_EQ(0, bpftrace.add_probe(probe));
EXPECT_EQ(1, bpftrace.get_probes().size()); EXPECT_EQ(1U, bpftrace.get_probes().size());
EXPECT_EQ(0, bpftrace.get_special_probes().size()); EXPECT_EQ(0U, bpftrace.get_special_probes().size());
check_kprobe(bpftrace.get_probes().at(0), "sys_read", "kprobe:sys_read"); check_kprobe(bpftrace.get_probes().at(0), "sys_read", "kprobe:sys_read");
} }
...@@ -150,8 +150,8 @@ TEST(bpftrace, add_probes_multiple) ...@@ -150,8 +150,8 @@ TEST(bpftrace, add_probes_multiple)
StrictMock<MockBPFtrace> bpftrace; StrictMock<MockBPFtrace> bpftrace;
EXPECT_EQ(0, bpftrace.add_probe(probe)); EXPECT_EQ(0, bpftrace.add_probe(probe));
EXPECT_EQ(2, bpftrace.get_probes().size()); EXPECT_EQ(2U, bpftrace.get_probes().size());
EXPECT_EQ(0, bpftrace.get_special_probes().size()); EXPECT_EQ(0U, bpftrace.get_special_probes().size());
std::string probe_orig_name = "kprobe:sys_read,kprobe:sys_write"; std::string probe_orig_name = "kprobe:sys_read,kprobe:sys_write";
check_kprobe(bpftrace.get_probes().at(0), "sys_read", probe_orig_name); check_kprobe(bpftrace.get_probes().at(0), "sys_read", probe_orig_name);
...@@ -175,8 +175,8 @@ TEST(bpftrace, add_probes_character_class) ...@@ -175,8 +175,8 @@ TEST(bpftrace, add_probes_character_class)
.Times(1); .Times(1);
EXPECT_EQ(0, bpftrace.add_probe(probe)); EXPECT_EQ(0, bpftrace.add_probe(probe));
EXPECT_EQ(3, bpftrace.get_probes().size()); EXPECT_EQ(3U, bpftrace.get_probes().size());
EXPECT_EQ(0, bpftrace.get_special_probes().size()); EXPECT_EQ(0U, bpftrace.get_special_probes().size());
std::string probe_orig_name = "kprobe:[Ss]y[Ss]_read,kprobe:sys_write"; std::string probe_orig_name = "kprobe:[Ss]y[Ss]_read,kprobe:sys_write";
check_kprobe(bpftrace.get_probes().at(0), "SyS_read", probe_orig_name); check_kprobe(bpftrace.get_probes().at(0), "SyS_read", probe_orig_name);
...@@ -202,8 +202,8 @@ TEST(bpftrace, add_probes_wildcard) ...@@ -202,8 +202,8 @@ TEST(bpftrace, add_probes_wildcard)
.Times(1); .Times(1);
EXPECT_EQ(0, bpftrace.add_probe(probe)); EXPECT_EQ(0, bpftrace.add_probe(probe));
EXPECT_EQ(4, bpftrace.get_probes().size()); EXPECT_EQ(4U, bpftrace.get_probes().size());
EXPECT_EQ(0, bpftrace.get_special_probes().size()); EXPECT_EQ(0U, bpftrace.get_special_probes().size());
std::string probe_orig_name = "kprobe:sys_read,kprobe:my_*,kprobe:sys_write"; std::string probe_orig_name = "kprobe:sys_read,kprobe:my_*,kprobe:sys_write";
check_kprobe(bpftrace.get_probes().at(0), "sys_read", probe_orig_name); check_kprobe(bpftrace.get_probes().at(0), "sys_read", probe_orig_name);
...@@ -230,8 +230,8 @@ TEST(bpftrace, add_probes_wildcard_no_matches) ...@@ -230,8 +230,8 @@ TEST(bpftrace, add_probes_wildcard_no_matches)
.Times(1); .Times(1);
EXPECT_EQ(0, bpftrace.add_probe(probe)); EXPECT_EQ(0, bpftrace.add_probe(probe));
EXPECT_EQ(2, bpftrace.get_probes().size()); EXPECT_EQ(2U, bpftrace.get_probes().size());
EXPECT_EQ(0, bpftrace.get_special_probes().size()); EXPECT_EQ(0U, bpftrace.get_special_probes().size());
std::string probe_orig_name = "kprobe:sys_read,kprobe:my_*,kprobe:sys_write"; std::string probe_orig_name = "kprobe:sys_read,kprobe:my_*,kprobe:sys_write";
check_kprobe(bpftrace.get_probes().at(0), "sys_read", probe_orig_name); check_kprobe(bpftrace.get_probes().at(0), "sys_read", probe_orig_name);
...@@ -247,8 +247,8 @@ TEST(bpftrace, add_probes_uprobe) ...@@ -247,8 +247,8 @@ TEST(bpftrace, add_probes_uprobe)
StrictMock<MockBPFtrace> bpftrace; StrictMock<MockBPFtrace> bpftrace;
EXPECT_EQ(0, bpftrace.add_probe(probe)); EXPECT_EQ(0, bpftrace.add_probe(probe));
EXPECT_EQ(1, bpftrace.get_probes().size()); EXPECT_EQ(1U, bpftrace.get_probes().size());
EXPECT_EQ(0, bpftrace.get_special_probes().size()); EXPECT_EQ(0U, bpftrace.get_special_probes().size());
check_uprobe(bpftrace.get_probes().at(0), "/bin/sh", "foo", "uprobe:/bin/sh:foo"); check_uprobe(bpftrace.get_probes().at(0), "/bin/sh", "foo", "uprobe:/bin/sh:foo");
} }
...@@ -261,8 +261,8 @@ TEST(bpftrace, add_probes_usdt) ...@@ -261,8 +261,8 @@ TEST(bpftrace, add_probes_usdt)
StrictMock<MockBPFtrace> bpftrace; StrictMock<MockBPFtrace> bpftrace;
EXPECT_EQ(0, bpftrace.add_probe(probe)); EXPECT_EQ(0, bpftrace.add_probe(probe));
EXPECT_EQ(1, bpftrace.get_probes().size()); EXPECT_EQ(1U, bpftrace.get_probes().size());
EXPECT_EQ(0, bpftrace.get_special_probes().size()); EXPECT_EQ(0U, bpftrace.get_special_probes().size());
check_usdt(bpftrace.get_probes().at(0), "/bin/sh", "foo", "usdt:/bin/sh:foo"); check_usdt(bpftrace.get_probes().at(0), "/bin/sh", "foo", "usdt:/bin/sh:foo");
} }
...@@ -275,8 +275,8 @@ TEST(bpftrace, add_probes_uprobe_wildcard) ...@@ -275,8 +275,8 @@ TEST(bpftrace, add_probes_uprobe_wildcard)
StrictMock<MockBPFtrace> bpftrace; StrictMock<MockBPFtrace> bpftrace;
EXPECT_EQ(bpftrace.add_probe(probe), 0); EXPECT_EQ(bpftrace.add_probe(probe), 0);
EXPECT_EQ(1, bpftrace.get_probes().size()); EXPECT_EQ(1U, bpftrace.get_probes().size());
EXPECT_EQ(0, bpftrace.get_special_probes().size()); EXPECT_EQ(0U, bpftrace.get_special_probes().size());
} }
TEST(bpftrace, add_probes_uprobe_wildcard_no_matches) TEST(bpftrace, add_probes_uprobe_wildcard_no_matches)
...@@ -288,8 +288,8 @@ TEST(bpftrace, add_probes_uprobe_wildcard_no_matches) ...@@ -288,8 +288,8 @@ TEST(bpftrace, add_probes_uprobe_wildcard_no_matches)
StrictMock<MockBPFtrace> bpftrace; StrictMock<MockBPFtrace> bpftrace;
EXPECT_EQ(bpftrace.add_probe(probe), 0); EXPECT_EQ(bpftrace.add_probe(probe), 0);
EXPECT_EQ(0, bpftrace.get_probes().size()); EXPECT_EQ(0U, bpftrace.get_probes().size());
EXPECT_EQ(0, bpftrace.get_special_probes().size()); EXPECT_EQ(0U, bpftrace.get_special_probes().size());
} }
TEST(bpftrace, add_probes_uprobe_string_literal) TEST(bpftrace, add_probes_uprobe_string_literal)
...@@ -301,8 +301,8 @@ TEST(bpftrace, add_probes_uprobe_string_literal) ...@@ -301,8 +301,8 @@ TEST(bpftrace, add_probes_uprobe_string_literal)
StrictMock<MockBPFtrace> bpftrace; StrictMock<MockBPFtrace> bpftrace;
EXPECT_EQ(0, bpftrace.add_probe(probe)); EXPECT_EQ(0, bpftrace.add_probe(probe));
EXPECT_EQ(1, bpftrace.get_probes().size()); EXPECT_EQ(1U, bpftrace.get_probes().size());
EXPECT_EQ(0, bpftrace.get_special_probes().size()); EXPECT_EQ(0U, bpftrace.get_special_probes().size());
check_uprobe(bpftrace.get_probes().at(0), "/bin/sh", "foo*", "uprobe:/bin/sh:foo*"); check_uprobe(bpftrace.get_probes().at(0), "/bin/sh", "foo*", "uprobe:/bin/sh:foo*");
} }
...@@ -315,8 +315,8 @@ TEST(bpftrace, add_probes_tracepoint) ...@@ -315,8 +315,8 @@ TEST(bpftrace, add_probes_tracepoint)
StrictMock<MockBPFtrace> bpftrace; StrictMock<MockBPFtrace> bpftrace;
EXPECT_EQ(0, bpftrace.add_probe(probe)); EXPECT_EQ(0, bpftrace.add_probe(probe));
EXPECT_EQ(1, bpftrace.get_probes().size()); EXPECT_EQ(1U, bpftrace.get_probes().size());
EXPECT_EQ(0, bpftrace.get_special_probes().size()); EXPECT_EQ(0U, bpftrace.get_special_probes().size());
std::string probe_orig_name = "tracepoint:sched:sched_switch"; std::string probe_orig_name = "tracepoint:sched:sched_switch";
check_tracepoint(bpftrace.get_probes().at(0), "sched", "sched_switch", probe_orig_name); check_tracepoint(bpftrace.get_probes().at(0), "sched", "sched_switch", probe_orig_name);
...@@ -338,8 +338,8 @@ TEST(bpftrace, add_probes_tracepoint_wildcard) ...@@ -338,8 +338,8 @@ TEST(bpftrace, add_probes_tracepoint_wildcard)
.Times(1); .Times(1);
EXPECT_EQ(bpftrace.add_probe(probe), 0); EXPECT_EQ(bpftrace.add_probe(probe), 0);
EXPECT_EQ(2, bpftrace.get_probes().size()); EXPECT_EQ(2U, bpftrace.get_probes().size());
EXPECT_EQ(0, bpftrace.get_special_probes().size()); EXPECT_EQ(0U, bpftrace.get_special_probes().size());
std::string probe_orig_name = "tracepoint:sched:sched_*"; std::string probe_orig_name = "tracepoint:sched:sched_*";
check_tracepoint(bpftrace.get_probes().at(0), "sched", "sched_one", probe_orig_name); check_tracepoint(bpftrace.get_probes().at(0), "sched", "sched_one", probe_orig_name);
...@@ -362,8 +362,8 @@ TEST(bpftrace, add_probes_tracepoint_wildcard_no_matches) ...@@ -362,8 +362,8 @@ TEST(bpftrace, add_probes_tracepoint_wildcard_no_matches)
.Times(1); .Times(1);
EXPECT_EQ(0, bpftrace.add_probe(probe)); EXPECT_EQ(0, bpftrace.add_probe(probe));
EXPECT_EQ(0, bpftrace.get_probes().size()); EXPECT_EQ(0U, bpftrace.get_probes().size());
EXPECT_EQ(0, bpftrace.get_special_probes().size()); EXPECT_EQ(0U, bpftrace.get_special_probes().size());
} }
TEST(bpftrace, add_probes_profile) TEST(bpftrace, add_probes_profile)
...@@ -375,8 +375,8 @@ TEST(bpftrace, add_probes_profile) ...@@ -375,8 +375,8 @@ TEST(bpftrace, add_probes_profile)
StrictMock<MockBPFtrace> bpftrace; StrictMock<MockBPFtrace> bpftrace;
EXPECT_EQ(0, bpftrace.add_probe(probe)); EXPECT_EQ(0, bpftrace.add_probe(probe));
EXPECT_EQ(1, bpftrace.get_probes().size()); EXPECT_EQ(1U, bpftrace.get_probes().size());
EXPECT_EQ(0, bpftrace.get_special_probes().size()); EXPECT_EQ(0U, bpftrace.get_special_probes().size());
std::string probe_orig_name = "profile:ms:997"; std::string probe_orig_name = "profile:ms:997";
check_profile(bpftrace.get_probes().at(0), "ms", 997, probe_orig_name); check_profile(bpftrace.get_probes().at(0), "ms", 997, probe_orig_name);
...@@ -391,8 +391,8 @@ TEST(bpftrace, add_probes_interval) ...@@ -391,8 +391,8 @@ TEST(bpftrace, add_probes_interval)
StrictMock<MockBPFtrace> bpftrace; StrictMock<MockBPFtrace> bpftrace;
EXPECT_EQ(0, bpftrace.add_probe(probe)); EXPECT_EQ(0, bpftrace.add_probe(probe));
EXPECT_EQ(1, bpftrace.get_probes().size()); EXPECT_EQ(1U, bpftrace.get_probes().size());
EXPECT_EQ(0, bpftrace.get_special_probes().size()); EXPECT_EQ(0U, bpftrace.get_special_probes().size());
std::string probe_orig_name = "interval:s:1"; std::string probe_orig_name = "interval:s:1";
check_interval(bpftrace.get_probes().at(0), "s", 1, probe_orig_name); check_interval(bpftrace.get_probes().at(0), "s", 1, probe_orig_name);
...@@ -407,8 +407,8 @@ TEST(bpftrace, add_probes_software) ...@@ -407,8 +407,8 @@ TEST(bpftrace, add_probes_software)
StrictMock<MockBPFtrace> bpftrace; StrictMock<MockBPFtrace> bpftrace;
EXPECT_EQ(0, bpftrace.add_probe(probe)); EXPECT_EQ(0, bpftrace.add_probe(probe));
EXPECT_EQ(1, bpftrace.get_probes().size()); EXPECT_EQ(1U, bpftrace.get_probes().size());
EXPECT_EQ(0, bpftrace.get_special_probes().size()); EXPECT_EQ(0U, bpftrace.get_special_probes().size());
std::string probe_orig_name = "software:faults:1000"; std::string probe_orig_name = "software:faults:1000";
check_software(bpftrace.get_probes().at(0), "faults", 1000, probe_orig_name); check_software(bpftrace.get_probes().at(0), "faults", 1000, probe_orig_name);
...@@ -423,8 +423,8 @@ TEST(bpftrace, add_probes_hardware) ...@@ -423,8 +423,8 @@ TEST(bpftrace, add_probes_hardware)
StrictMock<MockBPFtrace> bpftrace; StrictMock<MockBPFtrace> bpftrace;
EXPECT_EQ(0, bpftrace.add_probe(probe)); EXPECT_EQ(0, bpftrace.add_probe(probe));
EXPECT_EQ(1, bpftrace.get_probes().size()); EXPECT_EQ(1U, bpftrace.get_probes().size());
EXPECT_EQ(0, bpftrace.get_special_probes().size()); EXPECT_EQ(0U, bpftrace.get_special_probes().size());
std::string probe_orig_name = "hardware:cache-references:1000000"; std::string probe_orig_name = "hardware:cache-references:1000000";
check_hardware(bpftrace.get_probes().at(0), "cache-references", 1000000, probe_orig_name); check_hardware(bpftrace.get_probes().at(0), "cache-references", 1000000, probe_orig_name);
......
...@@ -21,25 +21,25 @@ TEST(clang_parser, integers) ...@@ -21,25 +21,25 @@ TEST(clang_parser, integers)
StructMap structs; StructMap structs;
parse("struct Foo { int x; int y, z; }", structs); parse("struct Foo { int x; int y, z; }", structs);
ASSERT_EQ(structs.size(), 1); ASSERT_EQ(structs.size(), 1U);
ASSERT_EQ(structs.count("Foo"), 1); ASSERT_EQ(structs.count("Foo"), 1U);
EXPECT_EQ(structs["Foo"].size, 12); EXPECT_EQ(structs["Foo"].size, 12);
ASSERT_EQ(structs["Foo"].fields.size(), 3); ASSERT_EQ(structs["Foo"].fields.size(), 3U);
ASSERT_EQ(structs["Foo"].fields.count("x"), 1); ASSERT_EQ(structs["Foo"].fields.count("x"), 1U);
ASSERT_EQ(structs["Foo"].fields.count("y"), 1); ASSERT_EQ(structs["Foo"].fields.count("y"), 1U);
ASSERT_EQ(structs["Foo"].fields.count("z"), 1); ASSERT_EQ(structs["Foo"].fields.count("z"), 1U);
EXPECT_EQ(structs["Foo"].fields["x"].type.type, Type::integer); EXPECT_EQ(structs["Foo"].fields["x"].type.type, Type::integer);
EXPECT_EQ(structs["Foo"].fields["x"].type.size, 4); EXPECT_EQ(structs["Foo"].fields["x"].type.size, 4U);
EXPECT_EQ(structs["Foo"].fields["x"].offset, 0); EXPECT_EQ(structs["Foo"].fields["x"].offset, 0);
EXPECT_EQ(structs["Foo"].fields["y"].type.type, Type::integer); EXPECT_EQ(structs["Foo"].fields["y"].type.type, Type::integer);
EXPECT_EQ(structs["Foo"].fields["y"].type.size, 4); EXPECT_EQ(structs["Foo"].fields["y"].type.size, 4U);
EXPECT_EQ(structs["Foo"].fields["y"].offset, 4); EXPECT_EQ(structs["Foo"].fields["y"].offset, 4);
EXPECT_EQ(structs["Foo"].fields["z"].type.type, Type::integer); EXPECT_EQ(structs["Foo"].fields["z"].type.type, Type::integer);
EXPECT_EQ(structs["Foo"].fields["z"].type.size, 4); EXPECT_EQ(structs["Foo"].fields["z"].type.size, 4U);
EXPECT_EQ(structs["Foo"].fields["z"].offset, 8); EXPECT_EQ(structs["Foo"].fields["z"].offset, 8);
} }
...@@ -48,30 +48,30 @@ TEST(clang_parser, c_union) ...@@ -48,30 +48,30 @@ TEST(clang_parser, c_union)
StructMap structs; StructMap structs;
parse("union Foo { char c; short s; int i; long l; }", structs); parse("union Foo { char c; short s; int i; long l; }", structs);
ASSERT_EQ(structs.size(), 1); ASSERT_EQ(structs.size(), 1U);
ASSERT_EQ(structs.count("Foo"), 1); ASSERT_EQ(structs.count("Foo"), 1U);
EXPECT_EQ(structs["Foo"].size, 8); EXPECT_EQ(structs["Foo"].size, 8);
ASSERT_EQ(structs["Foo"].fields.size(), 4); ASSERT_EQ(structs["Foo"].fields.size(), 4U);
ASSERT_EQ(structs["Foo"].fields.count("c"), 1); ASSERT_EQ(structs["Foo"].fields.count("c"), 1U);
ASSERT_EQ(structs["Foo"].fields.count("s"), 1); ASSERT_EQ(structs["Foo"].fields.count("s"), 1U);
ASSERT_EQ(structs["Foo"].fields.count("i"), 1); ASSERT_EQ(structs["Foo"].fields.count("i"), 1U);
ASSERT_EQ(structs["Foo"].fields.count("l"), 1); ASSERT_EQ(structs["Foo"].fields.count("l"), 1U);
EXPECT_EQ(structs["Foo"].fields["c"].type.type, Type::integer); EXPECT_EQ(structs["Foo"].fields["c"].type.type, Type::integer);
EXPECT_EQ(structs["Foo"].fields["c"].type.size, 1); EXPECT_EQ(structs["Foo"].fields["c"].type.size, 1U);
EXPECT_EQ(structs["Foo"].fields["c"].offset, 0); EXPECT_EQ(structs["Foo"].fields["c"].offset, 0);
EXPECT_EQ(structs["Foo"].fields["s"].type.type, Type::integer); EXPECT_EQ(structs["Foo"].fields["s"].type.type, Type::integer);
EXPECT_EQ(structs["Foo"].fields["s"].type.size, 2); EXPECT_EQ(structs["Foo"].fields["s"].type.size, 2U);
EXPECT_EQ(structs["Foo"].fields["s"].offset, 0); EXPECT_EQ(structs["Foo"].fields["s"].offset, 0);
EXPECT_EQ(structs["Foo"].fields["i"].type.type, Type::integer); EXPECT_EQ(structs["Foo"].fields["i"].type.type, Type::integer);
EXPECT_EQ(structs["Foo"].fields["i"].type.size, 4); EXPECT_EQ(structs["Foo"].fields["i"].type.size, 4U);
EXPECT_EQ(structs["Foo"].fields["i"].offset, 0); EXPECT_EQ(structs["Foo"].fields["i"].offset, 0);
EXPECT_EQ(structs["Foo"].fields["l"].type.type, Type::integer); EXPECT_EQ(structs["Foo"].fields["l"].type.type, Type::integer);
EXPECT_EQ(structs["Foo"].fields["l"].type.size, 8); EXPECT_EQ(structs["Foo"].fields["l"].type.size, 8U);
EXPECT_EQ(structs["Foo"].fields["l"].offset, 0); EXPECT_EQ(structs["Foo"].fields["l"].offset, 0);
} }
...@@ -80,12 +80,12 @@ TEST(clang_parser, integer_ptr) ...@@ -80,12 +80,12 @@ TEST(clang_parser, integer_ptr)
StructMap structs; StructMap structs;
parse("struct Foo { int *x; }", structs); parse("struct Foo { int *x; }", structs);
ASSERT_EQ(structs.size(), 1); ASSERT_EQ(structs.size(), 1U);
ASSERT_EQ(structs.count("Foo"), 1); ASSERT_EQ(structs.count("Foo"), 1U);
EXPECT_EQ(structs["Foo"].size, 8); EXPECT_EQ(structs["Foo"].size, 8);
ASSERT_EQ(structs["Foo"].fields.size(), 1); ASSERT_EQ(structs["Foo"].fields.size(), 1U);
ASSERT_EQ(structs["Foo"].fields.count("x"), 1); ASSERT_EQ(structs["Foo"].fields.count("x"), 1U);
EXPECT_EQ(structs["Foo"].fields["x"].type.type, Type::integer); EXPECT_EQ(structs["Foo"].fields["x"].type.type, Type::integer);
EXPECT_EQ(structs["Foo"].fields["x"].type.size, sizeof(uintptr_t)); EXPECT_EQ(structs["Foo"].fields["x"].type.size, sizeof(uintptr_t));
...@@ -99,17 +99,17 @@ TEST(clang_parser, string_ptr) ...@@ -99,17 +99,17 @@ TEST(clang_parser, string_ptr)
StructMap structs; StructMap structs;
parse("struct Foo { char *str; }", structs); parse("struct Foo { char *str; }", structs);
ASSERT_EQ(structs.size(), 1); ASSERT_EQ(structs.size(), 1U);
ASSERT_EQ(structs.count("Foo"), 1); ASSERT_EQ(structs.count("Foo"), 1U);
EXPECT_EQ(structs["Foo"].size, 8); EXPECT_EQ(structs["Foo"].size, 8);
ASSERT_EQ(structs["Foo"].fields.size(), 1); ASSERT_EQ(structs["Foo"].fields.size(), 1U);
ASSERT_EQ(structs["Foo"].fields.count("str"), 1); ASSERT_EQ(structs["Foo"].fields.count("str"), 1U);
EXPECT_EQ(structs["Foo"].fields["str"].type.type, Type::integer); EXPECT_EQ(structs["Foo"].fields["str"].type.type, Type::integer);
EXPECT_EQ(structs["Foo"].fields["str"].type.size, sizeof(uintptr_t)); EXPECT_EQ(structs["Foo"].fields["str"].type.size, sizeof(uintptr_t));
EXPECT_EQ(structs["Foo"].fields["str"].type.is_pointer, true); EXPECT_EQ(structs["Foo"].fields["str"].type.is_pointer, true);
EXPECT_EQ(structs["Foo"].fields["str"].type.pointee_size, 1); EXPECT_EQ(structs["Foo"].fields["str"].type.pointee_size, 1U);
EXPECT_EQ(structs["Foo"].fields["str"].offset, 0); EXPECT_EQ(structs["Foo"].fields["str"].offset, 0);
} }
...@@ -118,15 +118,15 @@ TEST(clang_parser, string_array) ...@@ -118,15 +118,15 @@ TEST(clang_parser, string_array)
StructMap structs; StructMap structs;
parse("struct Foo { char str[32]; }", structs); parse("struct Foo { char str[32]; }", structs);
ASSERT_EQ(structs.size(), 1); ASSERT_EQ(structs.size(), 1U);
ASSERT_EQ(structs.count("Foo"), 1); ASSERT_EQ(structs.count("Foo"), 1U);
EXPECT_EQ(structs["Foo"].size, 32); EXPECT_EQ(structs["Foo"].size, 32);
ASSERT_EQ(structs["Foo"].fields.size(), 1); ASSERT_EQ(structs["Foo"].fields.size(), 1U);
ASSERT_EQ(structs["Foo"].fields.count("str"), 1); ASSERT_EQ(structs["Foo"].fields.count("str"), 1U);
EXPECT_EQ(structs["Foo"].fields["str"].type.type, Type::string); EXPECT_EQ(structs["Foo"].fields["str"].type.type, Type::string);
EXPECT_EQ(structs["Foo"].fields["str"].type.size, 32); EXPECT_EQ(structs["Foo"].fields["str"].type.size, 32U);
EXPECT_EQ(structs["Foo"].fields["str"].offset, 0); EXPECT_EQ(structs["Foo"].fields["str"].offset, 0);
} }
...@@ -135,17 +135,17 @@ TEST(clang_parser, nested_struct_named) ...@@ -135,17 +135,17 @@ TEST(clang_parser, nested_struct_named)
StructMap structs; StructMap structs;
parse("struct Bar { int x; } struct Foo { struct Bar bar; }", structs); parse("struct Bar { int x; } struct Foo { struct Bar bar; }", structs);
ASSERT_EQ(structs.size(), 2); ASSERT_EQ(structs.size(), 2U);
ASSERT_EQ(structs.count("Foo"), 1); ASSERT_EQ(structs.count("Foo"), 1U);
ASSERT_EQ(structs.count("Bar"), 1); ASSERT_EQ(structs.count("Bar"), 1U);
EXPECT_EQ(structs["Foo"].size, 4); EXPECT_EQ(structs["Foo"].size, 4);
ASSERT_EQ(structs["Foo"].fields.size(), 1); ASSERT_EQ(structs["Foo"].fields.size(), 1U);
ASSERT_EQ(structs["Foo"].fields.count("bar"), 1); ASSERT_EQ(structs["Foo"].fields.count("bar"), 1U);
EXPECT_EQ(structs["Foo"].fields["bar"].type.type, Type::cast); EXPECT_EQ(structs["Foo"].fields["bar"].type.type, Type::cast);
EXPECT_EQ(structs["Foo"].fields["bar"].type.cast_type, "Bar"); EXPECT_EQ(structs["Foo"].fields["bar"].type.cast_type, "Bar");
EXPECT_EQ(structs["Foo"].fields["bar"].type.size, 4); EXPECT_EQ(structs["Foo"].fields["bar"].type.size, 4U);
EXPECT_EQ(structs["Foo"].fields["bar"].offset, 0); EXPECT_EQ(structs["Foo"].fields["bar"].offset, 0);
} }
...@@ -154,19 +154,19 @@ TEST(clang_parser, nested_struct_ptr_named) ...@@ -154,19 +154,19 @@ TEST(clang_parser, nested_struct_ptr_named)
StructMap structs; StructMap structs;
parse("struct Bar { int x; } struct Foo { struct Bar *bar; }", structs); parse("struct Bar { int x; } struct Foo { struct Bar *bar; }", structs);
ASSERT_EQ(structs.size(), 2); ASSERT_EQ(structs.size(), 2U);
ASSERT_EQ(structs.count("Foo"), 1); ASSERT_EQ(structs.count("Foo"), 1U);
ASSERT_EQ(structs.count("Bar"), 1); ASSERT_EQ(structs.count("Bar"), 1U);
EXPECT_EQ(structs["Foo"].size, 8); EXPECT_EQ(structs["Foo"].size, 8);
ASSERT_EQ(structs["Foo"].fields.size(), 1); ASSERT_EQ(structs["Foo"].fields.size(), 1U);
ASSERT_EQ(structs["Foo"].fields.count("bar"), 1); ASSERT_EQ(structs["Foo"].fields.count("bar"), 1U);
EXPECT_EQ(structs["Foo"].fields["bar"].type.type, Type::cast); EXPECT_EQ(structs["Foo"].fields["bar"].type.type, Type::cast);
EXPECT_EQ(structs["Foo"].fields["bar"].type.cast_type, "Bar"); EXPECT_EQ(structs["Foo"].fields["bar"].type.cast_type, "Bar");
EXPECT_EQ(structs["Foo"].fields["bar"].type.size, sizeof(uintptr_t)); EXPECT_EQ(structs["Foo"].fields["bar"].type.size, sizeof(uintptr_t));
EXPECT_EQ(structs["Foo"].fields["bar"].type.is_pointer, true); EXPECT_EQ(structs["Foo"].fields["bar"].type.is_pointer, true);
EXPECT_EQ(structs["Foo"].fields["bar"].type.pointee_size, 4); EXPECT_EQ(structs["Foo"].fields["bar"].type.pointee_size, 4U);
EXPECT_EQ(structs["Foo"].fields["bar"].offset, 0); EXPECT_EQ(structs["Foo"].fields["bar"].offset, 0);
} }
...@@ -175,16 +175,16 @@ TEST(clang_parser, nested_struct_anon) ...@@ -175,16 +175,16 @@ TEST(clang_parser, nested_struct_anon)
StructMap structs; StructMap structs;
parse("struct Foo { struct { int x; } bar; }", structs); parse("struct Foo { struct { int x; } bar; }", structs);
ASSERT_EQ(structs.size(), 2); ASSERT_EQ(structs.size(), 2U);
ASSERT_EQ(structs.count("Foo"), 1); ASSERT_EQ(structs.count("Foo"), 1U);
EXPECT_EQ(structs["Foo"].size, 4); EXPECT_EQ(structs["Foo"].size, 4);
ASSERT_EQ(structs["Foo"].fields.size(), 1); ASSERT_EQ(structs["Foo"].fields.size(), 1U);
ASSERT_EQ(structs["Foo"].fields.count("bar"), 1); ASSERT_EQ(structs["Foo"].fields.count("bar"), 1U);
EXPECT_EQ(structs["Foo"].fields["bar"].type.type, Type::cast); EXPECT_EQ(structs["Foo"].fields["bar"].type.type, Type::cast);
EXPECT_EQ(structs["Foo"].fields["bar"].type.cast_type, "Foo::(anonymous at definitions.h:1:14)"); EXPECT_EQ(structs["Foo"].fields["bar"].type.cast_type, "Foo::(anonymous at definitions.h:1:14)");
EXPECT_EQ(structs["Foo"].fields["bar"].type.size, 4); EXPECT_EQ(structs["Foo"].fields["bar"].type.size, 4U);
EXPECT_EQ(structs["Foo"].fields["bar"].offset, 0); EXPECT_EQ(structs["Foo"].fields["bar"].offset, 0);
} }
...@@ -193,15 +193,15 @@ TEST(clang_parser, nested_struct_indirect_fields) ...@@ -193,15 +193,15 @@ TEST(clang_parser, nested_struct_indirect_fields)
StructMap structs; StructMap structs;
parse("struct Foo { struct { int x; int y;}; int a; struct { int z; }; }", structs); parse("struct Foo { struct { int x; int y;}; int a; struct { int z; }; }", structs);
ASSERT_EQ(structs["Foo"].fields.size(), 4); ASSERT_EQ(structs["Foo"].fields.size(), 4U);
EXPECT_EQ(structs["Foo"].fields["x"].offset, 0); EXPECT_EQ(structs["Foo"].fields["x"].offset, 0);
EXPECT_EQ(structs["Foo"].fields["x"].type.size, 4); EXPECT_EQ(structs["Foo"].fields["x"].type.size, 4U);
EXPECT_EQ(structs["Foo"].fields["y"].offset, 4); EXPECT_EQ(structs["Foo"].fields["y"].offset, 4);
EXPECT_EQ(structs["Foo"].fields["y"].type.size, 4); EXPECT_EQ(structs["Foo"].fields["y"].type.size, 4U);
EXPECT_EQ(structs["Foo"].fields["a"].offset, 8); EXPECT_EQ(structs["Foo"].fields["a"].offset, 8);
EXPECT_EQ(structs["Foo"].fields["a"].type.size, 4); EXPECT_EQ(structs["Foo"].fields["a"].type.size, 4U);
EXPECT_EQ(structs["Foo"].fields["z"].offset, 12); EXPECT_EQ(structs["Foo"].fields["z"].offset, 12);
EXPECT_EQ(structs["Foo"].fields["z"].type.size, 4); EXPECT_EQ(structs["Foo"].fields["z"].type.size, 4U);
} }
TEST(clang_parser, nested_struct_anon_union_struct) TEST(clang_parser, nested_struct_anon_union_struct)
...@@ -209,17 +209,17 @@ TEST(clang_parser, nested_struct_anon_union_struct) ...@@ -209,17 +209,17 @@ TEST(clang_parser, nested_struct_anon_union_struct)
StructMap structs; StructMap structs;
parse("struct Foo { union { long long _xy; struct { int x; int y;}; }; int a; struct { int z; }; }", structs); parse("struct Foo { union { long long _xy; struct { int x; int y;}; }; int a; struct { int z; }; }", structs);
ASSERT_EQ(structs["Foo"].fields.size(), 5); ASSERT_EQ(structs["Foo"].fields.size(), 5U);
EXPECT_EQ(structs["Foo"].fields["_xy"].offset, 0); EXPECT_EQ(structs["Foo"].fields["_xy"].offset, 0);
EXPECT_EQ(structs["Foo"].fields["_xy"].type.size, 8); EXPECT_EQ(structs["Foo"].fields["_xy"].type.size, 8U);
EXPECT_EQ(structs["Foo"].fields["x"].offset, 0); EXPECT_EQ(structs["Foo"].fields["x"].offset, 0);
EXPECT_EQ(structs["Foo"].fields["x"].type.size, 4); EXPECT_EQ(structs["Foo"].fields["x"].type.size, 4U);
EXPECT_EQ(structs["Foo"].fields["y"].offset, 4); EXPECT_EQ(structs["Foo"].fields["y"].offset, 4);
EXPECT_EQ(structs["Foo"].fields["y"].type.size, 4); EXPECT_EQ(structs["Foo"].fields["y"].type.size, 4U);
EXPECT_EQ(structs["Foo"].fields["a"].offset, 8); EXPECT_EQ(structs["Foo"].fields["a"].offset, 8);
EXPECT_EQ(structs["Foo"].fields["a"].type.size, 4); EXPECT_EQ(structs["Foo"].fields["a"].type.size, 4U);
EXPECT_EQ(structs["Foo"].fields["z"].offset, 12); EXPECT_EQ(structs["Foo"].fields["z"].offset, 12);
EXPECT_EQ(structs["Foo"].fields["z"].type.size, 4); EXPECT_EQ(structs["Foo"].fields["z"].type.size, 4U);
} }
TEST(clang_parser, builtin_headers) TEST(clang_parser, builtin_headers)
...@@ -228,24 +228,24 @@ TEST(clang_parser, builtin_headers) ...@@ -228,24 +228,24 @@ TEST(clang_parser, builtin_headers)
StructMap structs; StructMap structs;
parse("#include <stddef.h>\nstruct Foo { size_t x, y, z; }", structs); parse("#include <stddef.h>\nstruct Foo { size_t x, y, z; }", structs);
ASSERT_EQ(structs.count("Foo"), 1); ASSERT_EQ(structs.count("Foo"), 1U);
EXPECT_EQ(structs["Foo"].size, 24); EXPECT_EQ(structs["Foo"].size, 24);
ASSERT_EQ(structs["Foo"].fields.size(), 3); ASSERT_EQ(structs["Foo"].fields.size(), 3U);
ASSERT_EQ(structs["Foo"].fields.count("x"), 1); ASSERT_EQ(structs["Foo"].fields.count("x"), 1U);
ASSERT_EQ(structs["Foo"].fields.count("y"), 1); ASSERT_EQ(structs["Foo"].fields.count("y"), 1U);
ASSERT_EQ(structs["Foo"].fields.count("z"), 1); ASSERT_EQ(structs["Foo"].fields.count("z"), 1U);
EXPECT_EQ(structs["Foo"].fields["x"].type.type, Type::integer); EXPECT_EQ(structs["Foo"].fields["x"].type.type, Type::integer);
EXPECT_EQ(structs["Foo"].fields["x"].type.size, 8); EXPECT_EQ(structs["Foo"].fields["x"].type.size, 8U);
EXPECT_EQ(structs["Foo"].fields["x"].offset, 0); EXPECT_EQ(structs["Foo"].fields["x"].offset, 0);
EXPECT_EQ(structs["Foo"].fields["y"].type.type, Type::integer); EXPECT_EQ(structs["Foo"].fields["y"].type.type, Type::integer);
EXPECT_EQ(structs["Foo"].fields["y"].type.size, 8); EXPECT_EQ(structs["Foo"].fields["y"].type.size, 8U);
EXPECT_EQ(structs["Foo"].fields["y"].offset, 8); EXPECT_EQ(structs["Foo"].fields["y"].offset, 8);
EXPECT_EQ(structs["Foo"].fields["z"].type.type, Type::integer); EXPECT_EQ(structs["Foo"].fields["z"].type.type, Type::integer);
EXPECT_EQ(structs["Foo"].fields["z"].type.size, 8); EXPECT_EQ(structs["Foo"].fields["z"].type.size, 8U);
EXPECT_EQ(structs["Foo"].fields["z"].offset, 16); EXPECT_EQ(structs["Foo"].fields["z"].offset, 16);
} }
......
...@@ -32,9 +32,9 @@ TEST(codegen, populate_sections) ...@@ -32,9 +32,9 @@ TEST(codegen, populate_sections)
auto bpforc = codegen.compile(); auto bpforc = codegen.compile();
// Check sections are populated // Check sections are populated
EXPECT_EQ(bpforc->sections_.size(), 2); EXPECT_EQ(bpforc->sections_.size(), 2U);
EXPECT_EQ(bpforc->sections_.count("s_kprobe:foo_1"), 1); EXPECT_EQ(bpforc->sections_.count("s_kprobe:foo_1"), 1U);
EXPECT_EQ(bpforc->sections_.count("s_kprobe:bar_1"), 1); EXPECT_EQ(bpforc->sections_.count("s_kprobe:bar_1"), 1U);
} }
TEST(codegen, printf_offsets) TEST(codegen, printf_offsets)
...@@ -53,22 +53,22 @@ TEST(codegen, printf_offsets) ...@@ -53,22 +53,22 @@ TEST(codegen, printf_offsets)
ast::CodegenLLVM codegen(driver.root_, bpftrace); ast::CodegenLLVM codegen(driver.root_, bpftrace);
auto bpforc = codegen.compile(); auto bpforc = codegen.compile();
EXPECT_EQ(bpftrace.printf_args_.size(), 1); EXPECT_EQ(bpftrace.printf_args_.size(), 1U);
auto &fmt = std::get<0>(bpftrace.printf_args_[0]); auto &fmt = std::get<0>(bpftrace.printf_args_[0]);
auto &args = std::get<1>(bpftrace.printf_args_[0]); auto &args = std::get<1>(bpftrace.printf_args_[0]);
EXPECT_EQ(fmt, "%c %u\n"); EXPECT_EQ(fmt, "%c %u\n");
EXPECT_EQ(args.size(), 2); EXPECT_EQ(args.size(), 2U);
// NOTE (mmarchini) type.size is the original arg size, and it might be // NOTE (mmarchini) type.size is the original arg size, and it might be
// different from the actual size we use to store in memory // different from the actual size we use to store in memory
EXPECT_EQ(args[0].type.type, Type::integer); EXPECT_EQ(args[0].type.type, Type::integer);
EXPECT_EQ(args[0].type.size, 8); EXPECT_EQ(args[0].type.size, 8U);
EXPECT_EQ(args[0].offset, 8); EXPECT_EQ(args[0].offset, 8);
EXPECT_EQ(args[1].type.type, Type::integer); EXPECT_EQ(args[1].type.type, Type::integer);
EXPECT_EQ(args[1].type.size, 8); EXPECT_EQ(args[1].type.size, 8U);
EXPECT_EQ(args[1].offset, 16); EXPECT_EQ(args[1].offset, 16);
} }
......
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