File: test_stats.h

package info (click to toggle)
intel-compute-runtime 26.05.37020.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 83,596 kB
  • sloc: cpp: 976,037; lisp: 2,096; sh: 704; makefile: 162
file content (44 lines) | stat: -rw-r--r-- 2,119 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/*
 * Copyright (C) 2021-2025 Intel Corporation
 *
 * SPDX-License-Identifier: MIT
 *
 */

#pragma once
#include "gtest/gtest.h"

#include <sstream>
#include <string>

std::string getTestStats() {
    std::stringstream stream;

    stream << "Total test count:               " << ::testing::UnitTest::GetInstance()->total_test_count() << std::endl;
    stream << "Test to run count:              " << ::testing::UnitTest::GetInstance()->test_to_run_count() << std::endl;
    stream << "Successful test count:          " << ::testing::UnitTest::GetInstance()->successful_test_count() << std::endl;
    stream << "Skipped test count:             " << ::testing::UnitTest::GetInstance()->skipped_test_count() << std::endl;
    stream << "Failed test count:              " << ::testing::UnitTest::GetInstance()->failed_test_count() << std::endl;
    stream << "Disabled test count:            " << ::testing::UnitTest::GetInstance()->disabled_test_count() << std::endl;
    stream << "Elapsed time:                   " << ::testing::UnitTest::GetInstance()->elapsed_time() << std::endl;

    return stream.str();
}

std::string getTestStatsJson() {
    std::stringstream stream;

    stream << "{" << std::endl;

    stream << "  \"total_test_count\": " << ::testing::UnitTest::GetInstance()->total_test_count() << "," << std::endl;
    stream << "  \"test_to_run_count\": " << ::testing::UnitTest::GetInstance()->test_to_run_count() << "," << std::endl;
    stream << "  \"successful_test_count\": " << ::testing::UnitTest::GetInstance()->successful_test_count() << "," << std::endl;
    stream << "  \"skipped_test_count\": " << ::testing::UnitTest::GetInstance()->skipped_test_count() << "," << std::endl;
    stream << "  \"failed_test_count\": " << ::testing::UnitTest::GetInstance()->failed_test_count() << "," << std::endl;
    stream << "  \"disabled_test_count\": " << ::testing::UnitTest::GetInstance()->disabled_test_count() << "," << std::endl;
    stream << "  \"elapsed_time\": " << ::testing::UnitTest::GetInstance()->elapsed_time() << std::endl;

    stream << "}" << std::endl;

    return stream.str();
}