2017-12-21 07:45:38 +08:00
|
|
|
/*
|
2022-06-30 03:17:47 +08:00
|
|
|
* Copyright (C) 2018-2022 Intel Corporation
|
2017-12-21 07:45:38 +08:00
|
|
|
*
|
2018-09-18 15:11:08 +08:00
|
|
|
* SPDX-License-Identifier: MIT
|
2017-12-21 07:45:38 +08:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2021-01-21 20:10:13 +08:00
|
|
|
#include "shared/test/common/cmd_parse/gen_cmd_parse.h"
|
2021-12-21 02:16:04 +08:00
|
|
|
#include "shared/test/common/fixtures/device_fixture.h"
|
2022-06-30 03:17:47 +08:00
|
|
|
#include "shared/test/common/test_macros/hw_test.h"
|
2020-03-31 13:43:07 +08:00
|
|
|
|
2019-03-26 18:59:46 +08:00
|
|
|
using namespace NEO;
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2022-08-11 22:01:11 +08:00
|
|
|
using CommandParse = Test<DeviceFixture>;
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2020-01-14 04:55:55 +08:00
|
|
|
HWTEST_F(CommandParse, WhenGeneratingCommandBufferThenIsNotNull) {
|
2017-12-21 07:45:38 +08:00
|
|
|
typedef typename FamilyType::PARSE PARSE;
|
|
|
|
GenCmdList cmds;
|
|
|
|
EXPECT_FALSE(PARSE::parseCommandBuffer(cmds, nullptr, sizeof(void *)));
|
|
|
|
}
|
|
|
|
|
2020-01-14 04:55:55 +08:00
|
|
|
HWTEST_F(CommandParse, WhenGeneratingCommandBufferThenDoesNotContainGarbage) {
|
2017-12-21 07:45:38 +08:00
|
|
|
typedef typename FamilyType::PARSE PARSE;
|
2019-04-04 16:32:08 +08:00
|
|
|
uint32_t buffer[30] = {0xbaadf00d};
|
2017-12-21 07:45:38 +08:00
|
|
|
GenCmdList cmds;
|
|
|
|
|
2019-04-04 16:32:08 +08:00
|
|
|
EXPECT_FALSE(PARSE::parseCommandBuffer(cmds, buffer, sizeof(uint32_t)));
|
2017-12-21 07:45:38 +08:00
|
|
|
}
|
|
|
|
|
2020-01-14 04:55:55 +08:00
|
|
|
HWTEST_F(CommandParse, GivenGarbageWhenGeneratingCommandBufferThenLengthIsZero) {
|
2017-12-21 07:45:38 +08:00
|
|
|
typedef typename FamilyType::PARSE PARSE;
|
2019-04-04 16:32:08 +08:00
|
|
|
uint32_t buffer[30] = {0xbaadf00d};
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2019-04-04 16:32:08 +08:00
|
|
|
EXPECT_EQ(0u, PARSE::getCommandLength(buffer));
|
2017-12-21 07:45:38 +08:00
|
|
|
}
|
|
|
|
|
2020-01-14 04:55:55 +08:00
|
|
|
HWTEST_F(CommandParse, WhenGeneratingCommandBufferThenBufferIsCorrect) {
|
2017-12-21 07:45:38 +08:00
|
|
|
typedef typename FamilyType::PARSE PARSE;
|
2018-10-01 17:57:36 +08:00
|
|
|
typedef typename FamilyType::WALKER_TYPE WALKER_TYPE;
|
2017-12-21 07:45:38 +08:00
|
|
|
GenCmdList cmds;
|
2018-10-01 17:57:36 +08:00
|
|
|
WALKER_TYPE buffer = FamilyType::cmdInitGpgpuWalker;
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
EXPECT_TRUE(PARSE::parseCommandBuffer(cmds, &buffer, 0));
|
|
|
|
EXPECT_FALSE(PARSE::parseCommandBuffer(cmds, &buffer, 1));
|
|
|
|
EXPECT_FALSE(PARSE::parseCommandBuffer(cmds, &buffer, 2));
|
|
|
|
EXPECT_FALSE(PARSE::parseCommandBuffer(cmds, &buffer, 3));
|
|
|
|
EXPECT_FALSE(PARSE::parseCommandBuffer(cmds, &buffer, 4));
|
|
|
|
EXPECT_TRUE(PARSE::parseCommandBuffer(cmds, &buffer, sizeof(buffer)));
|
|
|
|
}
|