bloaty_misc_test.cc 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. // Copyright 2016 Google Inc. All Rights Reserved.
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. #include "test.h"
  15. TEST_F(BloatyTest, NoSections) {
  16. RunBloaty({"bloaty", "01-no-sections.bin"});
  17. }
  18. TEST_F(BloatyTest, SectionCountOverflow) {
  19. RunBloaty({"bloaty", "02-section-count-overflow.o"});
  20. }
  21. TEST_F(BloatyTest, InlinesOnSmallFile) {
  22. RunBloaty(
  23. {"bloaty", "-d", "compileunits", "03-small-binary-that-crashed-inlines.bin"});
  24. RunBloaty(
  25. {"bloaty", "-d", "inlines", "03-small-binary-that-crashed-inlines.bin"});
  26. EXPECT_EQ(top_row_->vmsize, 2340);
  27. }
  28. TEST_F(BloatyTest, GoBinary) {
  29. RunBloaty(
  30. {"bloaty", "-d", "compileunits", "04-go-binary-with-ref-addr.bin"});
  31. RunBloaty(
  32. {"bloaty", "-d", "inlines", "04-go-binary-with-ref-addr.bin"});
  33. }
  34. TEST_F(BloatyTest, MultiThreaded) {
  35. RunBloaty({"bloaty", "02-section-count-overflow.o"});
  36. size_t file_size = top_row_->filesize;
  37. // Bloaty doesn't know or care that you are passing the same file multiple
  38. // times.
  39. std::vector<std::string> args{"bloaty"};
  40. const int count = 100;
  41. for (int i = 0; i < count; i++) {
  42. args.push_back("02-section-count-overflow.o");
  43. }
  44. RunBloaty(args); // Heavily multithreaded test.
  45. EXPECT_EQ(top_row_->filesize, file_size * 100);
  46. }