-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathpm4_factory_tests.cpp
More file actions
41 lines (35 loc) · 1.25 KB
/
pm4_factory_tests.cpp
File metadata and controls
41 lines (35 loc) · 1.25 KB
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
#include <gtest/gtest.h>
#include "core/pm4_factory.h"
using namespace aql_profile;
namespace {
// Helper to create a valid agent info struct
aqlprofile_agent_info_v1_t makeTestAgentInfo(const char* gfxip = "gfx900") {
aqlprofile_agent_info_v1_t info{};
info.agent_gfxip = strdup(gfxip);
info.cu_num = 64;
info.se_num = 4;
info.xcc_num = 1;
info.shader_arrays_per_se = 2;
info.domain = 0;
info.location_id = 0x1234;
return info;
}
} // namespace
// Test: Register agent and retrieve info (happy path)
TEST(Pm4FactoryTest, RegisterAgentAndGetAgentInfo) {
auto agentInfo = makeTestAgentInfo();
aqlprofile_agent_handle_t handle = RegisterAgent(&agentInfo);
const AgentInfo* info = GetAgentInfo(handle);
ASSERT_NE(info, nullptr) << "AgentInfo should not be null";
EXPECT_EQ(info->cu_num, 64u);
EXPECT_EQ(info->se_num, 4u);
EXPECT_EQ(info->xcc_num, 1u);
EXPECT_EQ(info->shader_arrays_per_se, 2u);
}
// Test: GetAgentInfo returns nullptr for invalid handle
TEST(Pm4FactoryTest, GetAgentInfoInvalidHandleReturnsNull) {
aqlprofile_agent_handle_t invalidHandle{};
invalidHandle.handle = 99999; // unlikely to exist
const AgentInfo* info = GetAgentInfo(invalidHandle);
EXPECT_EQ(info, nullptr);
}