2014-11-24 02:06:10 +00:00
|
|
|
// -*- mode: C++; c-file-style: "cc-mode" -*-
|
|
|
|
//*************************************************************************
|
|
|
|
// DESCRIPTION: verilator_coverage: Test/coverage file container
|
|
|
|
//
|
2019-11-08 03:33:59 +00:00
|
|
|
// Code available from: https://verilator.org
|
2014-11-24 02:06:10 +00:00
|
|
|
//
|
|
|
|
//*************************************************************************
|
|
|
|
//
|
2020-03-21 15:24:24 +00:00
|
|
|
// Copyright 2003-2020 by Wilson Snyder. This program is free software; you
|
|
|
|
// can redistribute it and/or modify it under the terms of either the GNU
|
2014-11-24 02:06:10 +00:00
|
|
|
// Lesser General Public License Version 3 or the Perl Artistic License
|
|
|
|
// Version 2.0.
|
2020-03-21 15:24:24 +00:00
|
|
|
// SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
|
2014-11-24 02:06:10 +00:00
|
|
|
//
|
|
|
|
//*************************************************************************
|
2019-10-05 00:17:11 +00:00
|
|
|
|
2014-11-24 02:06:10 +00:00
|
|
|
#ifndef _VLCTEST_H_
|
|
|
|
#define _VLCTEST_H_ 1
|
|
|
|
|
|
|
|
#include "config_build.h"
|
|
|
|
#include "verilatedos.h"
|
2018-10-14 17:43:24 +00:00
|
|
|
|
2014-11-24 02:06:10 +00:00
|
|
|
#include "VlcPoint.h"
|
|
|
|
#include "VlcBucket.h"
|
2018-10-14 17:43:24 +00:00
|
|
|
|
2014-11-24 02:06:10 +00:00
|
|
|
#include <map>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
//********************************************************************
|
|
|
|
// VlcTest - a single testrun i.e. a file containing coverage data
|
|
|
|
|
|
|
|
class VlcTest {
|
|
|
|
private:
|
|
|
|
// MEMBERS
|
2019-05-08 03:00:52 +00:00
|
|
|
string m_name; //< Name of the test
|
|
|
|
double m_computrons; //< Runtime for the test
|
|
|
|
vluint64_t m_testrun; //< Test run number, for database use
|
|
|
|
vluint64_t m_rank; //< Execution rank suggestion
|
|
|
|
vluint64_t m_rankPoints; //< Ranked additional points
|
|
|
|
vluint64_t m_user; //< User data for algorithms (not persisted in .dat file)
|
2019-11-10 01:35:12 +00:00
|
|
|
VlcBuckets m_buckets; //< Coverage data for each coverage point
|
2014-11-24 02:06:10 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
// CONSTRUCTORS
|
|
|
|
VlcTest(const string& name, vluint64_t testrun, double comp) {
|
2019-05-08 03:00:52 +00:00
|
|
|
m_name = name;
|
|
|
|
m_computrons = comp;
|
|
|
|
m_testrun = testrun;
|
|
|
|
m_rank = 0;
|
|
|
|
m_rankPoints = 0;
|
|
|
|
m_user = 0;
|
2014-11-24 02:06:10 +00:00
|
|
|
}
|
|
|
|
~VlcTest() {}
|
|
|
|
|
|
|
|
// ACCESSORS
|
|
|
|
const string& name() const { return m_name; }
|
|
|
|
double computrons() const { return m_computrons; }
|
|
|
|
vluint64_t testrun() const { return m_testrun; }
|
|
|
|
VlcBuckets& buckets() { return m_buckets; }
|
|
|
|
vluint64_t bucketsCovered() const { return m_buckets.bucketsCovered(); }
|
|
|
|
vluint64_t rank() const { return m_rank; }
|
|
|
|
void rank(vluint64_t flag) { m_rank = flag; }
|
|
|
|
vluint64_t rankPoints() const { return m_rankPoints; }
|
|
|
|
void rankPoints(vluint64_t flag) { m_rankPoints = flag; }
|
|
|
|
vluint64_t user() const { return m_user; }
|
|
|
|
void user(vluint64_t flag) { m_user = flag; }
|
|
|
|
|
|
|
|
// METHODS
|
|
|
|
static void dumpHeader() {
|
2020-03-16 03:20:33 +00:00
|
|
|
cout << "Tests:\n";
|
|
|
|
// cout<<" Testrun, Computrons,"; // Currently not loaded
|
|
|
|
cout << " Covered, Rank, RankPts, Filename" << endl;
|
2014-11-24 02:06:10 +00:00
|
|
|
}
|
|
|
|
void dump(bool bucketsToo) {
|
2020-03-16 03:20:33 +00:00
|
|
|
if (testrun() || computrons() != 0.0) { // currently unused // LCOV_EXCL_LINE
|
|
|
|
cout << " " << std::setw(8) << std::setfill('0') << testrun() // LCOV_EXCL_LINE
|
2020-05-17 15:06:14 +00:00
|
|
|
<< ", " << std::setw(7) << std::setfill(' ') << computrons() // LCOV_EXCL_LINE
|
2020-03-16 03:20:33 +00:00
|
|
|
<< ","; // LCOV_EXCL_LINE
|
2019-05-08 03:00:52 +00:00
|
|
|
}
|
2020-03-16 03:20:33 +00:00
|
|
|
cout << " " << std::setw(7) << std::setfill(' ') << bucketsCovered();
|
|
|
|
cout << ", " << std::setw(7) << std::setfill(' ') << rank();
|
|
|
|
cout << ", " << std::setw(7) << std::setfill(' ') << rankPoints();
|
|
|
|
cout << ", \"" << name() << "\"" << endl;
|
2019-05-08 03:00:52 +00:00
|
|
|
if (bucketsToo) m_buckets.dump();
|
2014-11-24 02:06:10 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
//********************************************************************
|
|
|
|
// VlcTests - Container of all tests
|
|
|
|
|
|
|
|
class VlcTests {
|
|
|
|
public:
|
|
|
|
// TYPES
|
2018-02-02 02:24:41 +00:00
|
|
|
typedef std::vector<VlcTest*> ByName;
|
2020-03-16 03:20:33 +00:00
|
|
|
|
2014-11-24 02:06:10 +00:00
|
|
|
private:
|
|
|
|
// MEMBERS
|
2019-05-08 03:00:52 +00:00
|
|
|
ByName m_tests; //< List of all tests
|
2014-11-24 02:06:10 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
// ITERATORS
|
|
|
|
typedef ByName::iterator iterator;
|
|
|
|
ByName::iterator begin() { return m_tests.begin(); }
|
|
|
|
ByName::iterator end() { return m_tests.end(); }
|
|
|
|
|
|
|
|
// CONSTRUCTORS
|
|
|
|
VlcTests() {}
|
|
|
|
~VlcTests() {
|
2020-03-16 03:20:33 +00:00
|
|
|
for (VlcTests::ByName::iterator it = begin(); it != end(); ++it) {
|
|
|
|
VL_DO_CLEAR(delete *it, *it = NULL);
|
2019-05-08 03:00:52 +00:00
|
|
|
}
|
2014-11-24 02:06:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// METHODS
|
|
|
|
void dump(bool bucketsToo) {
|
2020-03-16 03:20:33 +00:00
|
|
|
UINFO(2, "dumpTests...\n");
|
2019-05-08 03:00:52 +00:00
|
|
|
VlcTest::dumpHeader();
|
2020-03-15 22:34:09 +00:00
|
|
|
for (VlcTests::ByName::const_iterator it = begin(); it != end(); ++it) {
|
2019-05-08 03:00:52 +00:00
|
|
|
(*it)->dump(bucketsToo);
|
|
|
|
}
|
2014-11-24 02:06:10 +00:00
|
|
|
}
|
|
|
|
VlcTest* newTest(const string& name, vluint64_t testrun, double comp) {
|
2019-05-08 03:00:52 +00:00
|
|
|
VlcTest* testp = new VlcTest(name, testrun, comp);
|
|
|
|
m_tests.push_back(testp);
|
|
|
|
return testp;
|
2014-11-24 02:06:10 +00:00
|
|
|
}
|
|
|
|
void clearUser() {
|
2020-04-14 02:51:35 +00:00
|
|
|
for (ByName::iterator it = m_tests.begin(); it != m_tests.end(); ++it) (*it)->user(0);
|
2014-11-24 02:06:10 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
//######################################################################
|
|
|
|
|
2019-05-08 03:00:52 +00:00
|
|
|
#endif // Guard
|