kfdtest: Re-factor dynamic packet allocation into BasePacket
Avoids unnecessary and error-prone duplication of dynamic packet allocation in many packet classes. Change-Id: Icec981ae2cd7a3d88cdf9213298940d85627f853 Signed-off-by: Felix Kuehling <Felix.Kuehling@amd.com>
Этот коммит содержится в:
@@ -25,10 +25,15 @@
|
||||
#include "KFDTestUtil.hpp"
|
||||
#include "KFDBaseComponentTest.hpp"
|
||||
|
||||
BasePacket::BasePacket(void) {
|
||||
BasePacket::BasePacket(void): m_packetAllocation(NULL) {
|
||||
m_FamilyId = g_baseTest->GetFamilyIdFromDefaultNode();
|
||||
}
|
||||
|
||||
BasePacket::~BasePacket(void) {
|
||||
if (m_packetAllocation)
|
||||
free(m_packetAllocation);
|
||||
}
|
||||
|
||||
void BasePacket::Dump() const {
|
||||
unsigned int size = SizeInDWords();
|
||||
const HSAuint32 *packet = (const HSAuint32 *)GetPacket();
|
||||
@@ -40,3 +45,16 @@ void BasePacket::Dump() const {
|
||||
log << " " << std::setw(8) << std::setfill('0') << packet[i];
|
||||
log << std::endl;
|
||||
}
|
||||
|
||||
void *BasePacket::AllocPacket(void) {
|
||||
unsigned int size = SizeInBytes();
|
||||
|
||||
EXPECT_NE(0, size);
|
||||
if (!size)
|
||||
return NULL;
|
||||
|
||||
m_packetAllocation = calloc(1, size);
|
||||
EXPECT_NOTNULL(m_packetAllocation);
|
||||
|
||||
return m_packetAllocation;
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user