Files
rocm-systems/tests/kfdtest/src/KFDBaseComponentTest.hpp
T
Eric Huang f8d19104aa Kfdtest: Change and move drm device function into KFDBaseComponentTest
It is for other test to reuse this function.

Change-Id: Ib0dbc1a267a5bbcd8078ab3265677b53531f86f3
Signed-off-by: Eric Huang <JinHuiEric.Huang@amd.com>
2018-08-03 15:43:28 -04:00

77 righe
2.9 KiB
C++

/*
* Copyright (C) 2014-2018 Advanced Micro Devices, Inc. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
*/
#ifndef __KFD_BASE_COMPONENT_TEST__H__
#define __KFD_BASE_COMPONENT_TEST__H__
#include <gtest/gtest.h>
#include "hsakmt.h"
#include "OSWrapper.hpp"
#include "KFDTestUtil.hpp"
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <xf86drm.h>
#include <amdgpu.h>
#include <amdgpu_drm.h>
#include <sys/param.h>
// @class KFDBaseComponentTest
class KFDBaseComponentTest : public testing::Test {
public:
KFDBaseComponentTest(void) { m_MemoryFlags.Value = 0; }
~KFDBaseComponentTest(void) {}
HSAuint64 GetSysMemSize();
HSAuint64 GetVramSize(int defaultGPUNode);
#define MAX_RENDER_NODES 64
struct {
int fd;
uint32_t major_version;
uint32_t minor_version;
amdgpu_device_handle device_handle;
uint32_t bdf;
} m_RenderNodes[MAX_RENDER_NODES];
// @brief Finds DRM Render node corresponding to gpuNode
// @return DRM Render Node if successful or -1 on failure
int FindDRMRenderNode(int gpuNode);
protected:
HsaVersionInfo m_VersionInfo;
HsaSystemProperties m_SystemProperties;
unsigned int m_FamilyId;
HsaMemFlags m_MemoryFlags;
HsaNodeInfo m_NodeInfo;
// @brief SetUpTestCase function run before the first test that uses KFDOpenCloseKFDTest class fixture, and opens KFD.
static void SetUpTestCase();
// @brief TearDownTestCase function run after the last test from KFDOpenCloseKFDTest class fixture and calls close KFD.
static void TearDownTestCase();
// @brief SetUp function run before every test that uses KFDOpenCloseKFDTest class fixture, sets all common settings for the tests.
virtual void SetUp();
// @brief TearDown function run after every test that uses KFDOpenCloseKFDTest class fixture.
virtual void TearDown();
};
#endif // __KFD_BASE_COMPONENT_TEST__H__