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