Go to the documentation of this file.
15 #ifndef BLOATY_TESTS_TEST_H_
16 #define BLOATY_TESTS_TEST_H_
21 #include <unordered_set>
24 #include "absl/strings/numbers.h"
25 #include "absl/strings/str_split.h"
26 #include "gmock/gmock.h"
27 #include "google/protobuf/text_format.h"
28 #include "gtest/gtest.h"
32 #include "bloaty.pb.h"
41 std::cerr <<
"Couldn't get file size for: " <<
filename <<
"\n";
51 char pathbuf[PATH_MAX];
52 if (!getcwd(pathbuf,
sizeof(pathbuf))) {
66 #define NONE_STRING "[None]"
75 bool diff_mode,
int*
count) {
78 std::unordered_set<std::string>
names;
84 vmtotal +=
child.vmsize;
85 filetotal +=
child.filesize;
106 std::ostringstream
stream;
121 for (
const auto& row : rows) {
125 std::vector<std::string> expected_headers(
output_->source_names());
126 expected_headers.push_back(
"vmsize");
127 expected_headers.push_back(
"filesize");
144 size_t total_input_size = 0;
148 total_input_size +=
size;
161 for (
size_t i = 1;
i < strings.size();
i++) {
162 ret +=
" " + strings[
i];
175 output_->Print(output_options, &std::cerr);
178 std::cerr <<
"Bloaty returned error:" <<
error <<
"\n";
188 int argc = strings.size();
189 char** argv = str_arr.
get();
191 &output_options, &
error);
193 std::cerr <<
"Error parsing options: " <<
error;
200 void RunBloaty(
const std::vector<std::string>& strings) {
201 std::cerr <<
"Running bloaty: " <<
JoinStrings(strings) <<
"\n";
224 const std::vector<std::tuple<std::string, int, int>>&
children) {
228 int expected_vm, expected_file;
241 if (
child.name[0] ==
'[' ||
child.name[0] ==
'_') {
250 }
else if (expected_vm > 0) {
259 expected_file =
child.vmsize;
288 std::unique_ptr<bloaty::RollupOutput>
output_;
295 #endif // BLOATY_TESTS_TEST_H_
strings_internal::Splitter< typename strings_internal::SelectDelimiter< Delimiter >::type, AllowEmpty, absl::string_view > StrSplit(strings_internal::ConvertibleToStringView text, Delimiter d)
std::string GetTestDirectory()
void AssertBloatyFails(const std::vector< std::string > &strings, const std::string &)
#define ASSERT_NE(val1, val2)
bool TryRunBloaty(const std::vector< std::string > &strings)
void CheckConsistencyForRow(const bloaty::RollupRow &row, bool is_toplevel, bool diff_mode, int *count)
std::string DebugString(const google::protobuf::Message &message)
bool BloatyMain(const Options &options, const InputFileFactory &file_factory, RollupOutput *output, std::string *error)
static constexpr int kSameAsVM
#define EXPECT_LE(val1, val2)
void CheckCSVConsistency(int row_count)
ABSL_NAMESPACE_BEGIN ABSL_MUST_USE_RESULT bool SimpleAtoi(absl::string_view str, int_type *out)
const bloaty::RollupRow * FindRow(const std::string &name)
bool ParseOptions(bool skip_unknown, int *argc, char **argv[], Options *options, OutputOptions *output_options, std::string *error)
unsigned __int64 uint64_t
void AssertChildren(const bloaty::RollupRow &row, const std::vector< std::tuple< std::string, int, int >> &children)
std::vector< RollupRow > sorted_children
static constexpr int kUnknown
const bloaty::RollupRow * top_row_
void CheckConsistency(const bloaty::Options &options)
bool GetFileSize(const std::string &filename, uint64_t *size)
UniquePtr< SSL_SESSION > ret
static bool PrintToString(const Message &message, std::string *output)
void RunBloaty(const std::vector< std::string > &strings)
#define ASSERT_TRUE(condition)
#define ASSERT_FALSE(condition)
#define EXPECT_GE(val1, val2)
#define EXPECT_TRUE(condition)
std::string JoinStrings(const std::vector< std::string > &strings)
bool TryRunBloatyWithOptions(const bloaty::Options &options, const bloaty::OutputOptions &output_options)
#define ASSERT_GT(val1, val2)
void RunBloatyWithOptions(const bloaty::Options &options, const bloaty::OutputOptions &output_options)
std::unique_ptr< bloaty::RollupOutput > output_
std::map< std::string, Node * > children
#define ASSERT_EQ(val1, val2)
grpc
Author(s):
autogenerated on Fri May 16 2025 03:00:27