1a8c51b3fSopenharmony_ci 2a8c51b3fSopenharmony_ci#undef NDEBUG 3a8c51b3fSopenharmony_ci#include <cstdio> 4a8c51b3fSopenharmony_ci#include <string> 5a8c51b3fSopenharmony_ci 6a8c51b3fSopenharmony_ci#include "benchmark/benchmark.h" 7a8c51b3fSopenharmony_ci#include "output_test.h" 8a8c51b3fSopenharmony_ci 9a8c51b3fSopenharmony_ci// Ok this test is super ugly. We want to check what happens with the file 10a8c51b3fSopenharmony_ci// reporter in the presence of ReportAggregatesOnly(). 11a8c51b3fSopenharmony_ci// We do not care about console output, the normal tests check that already. 12a8c51b3fSopenharmony_ci 13a8c51b3fSopenharmony_civoid BM_SummaryRepeat(benchmark::State& state) { 14a8c51b3fSopenharmony_ci for (auto _ : state) { 15a8c51b3fSopenharmony_ci } 16a8c51b3fSopenharmony_ci} 17a8c51b3fSopenharmony_ciBENCHMARK(BM_SummaryRepeat)->Repetitions(3)->ReportAggregatesOnly(); 18a8c51b3fSopenharmony_ci 19a8c51b3fSopenharmony_ciint main(int argc, char* argv[]) { 20a8c51b3fSopenharmony_ci const std::string output = GetFileReporterOutput(argc, argv); 21a8c51b3fSopenharmony_ci 22a8c51b3fSopenharmony_ci if (SubstrCnt(output, "\"name\": \"BM_SummaryRepeat/repeats:3") != 4 || 23a8c51b3fSopenharmony_ci SubstrCnt(output, "\"name\": \"BM_SummaryRepeat/repeats:3_mean\"") != 1 || 24a8c51b3fSopenharmony_ci SubstrCnt(output, "\"name\": \"BM_SummaryRepeat/repeats:3_median\"") != 25a8c51b3fSopenharmony_ci 1 || 26a8c51b3fSopenharmony_ci SubstrCnt(output, "\"name\": \"BM_SummaryRepeat/repeats:3_stddev\"") != 27a8c51b3fSopenharmony_ci 1 || 28a8c51b3fSopenharmony_ci SubstrCnt(output, "\"name\": \"BM_SummaryRepeat/repeats:3_cv\"") != 1) { 29a8c51b3fSopenharmony_ci std::cout << "Precondition mismatch. Expected to only find four " 30a8c51b3fSopenharmony_ci "occurrences of \"BM_SummaryRepeat/repeats:3\" substring:\n" 31a8c51b3fSopenharmony_ci "\"name\": \"BM_SummaryRepeat/repeats:3_mean\", " 32a8c51b3fSopenharmony_ci "\"name\": \"BM_SummaryRepeat/repeats:3_median\", " 33a8c51b3fSopenharmony_ci "\"name\": \"BM_SummaryRepeat/repeats:3_stddev\", " 34a8c51b3fSopenharmony_ci "\"name\": \"BM_SummaryRepeat/repeats:3_cv\"\nThe entire " 35a8c51b3fSopenharmony_ci "output:\n"; 36a8c51b3fSopenharmony_ci std::cout << output; 37a8c51b3fSopenharmony_ci return 1; 38a8c51b3fSopenharmony_ci } 39a8c51b3fSopenharmony_ci 40a8c51b3fSopenharmony_ci return 0; 41a8c51b3fSopenharmony_ci} 42