| 1 | // SPDX-License-Identifier: GPL-3.0-or-later |
| 2 | // Copyright 2019 Juan Palacios <[email protected]> |
| 3 | |
| 4 | #include <catch2/catch_all.hpp> |
| 5 | |
| 6 | #include "common/commandqueuestub.h" |
| 7 | #include "common/stringdatasourcestub.h" |
| 8 | #include "core/components/controls/amd/pm/auto/pmautor600.h" |
| 9 | |
| 10 | namespace Tests::AMD::PMAutoR600 { |
| 11 | |
| 12 | class PMAutoR600TestAdapter : public ::AMD::PMAutoR600 |
| 13 | { |
| 14 | public: |
| 15 | using ::AMD::PMAutoR600::PMAutoR600; |
| 16 | |
| 17 | using ::AMD::PMAutoR600::cleanControl; |
| 18 | using ::AMD::PMAutoR600::syncControl; |
| 19 | }; |
| 20 | |
| 21 | TEST_CASE("AMD PMAutoR600 tests", "[GPU][AMD][PM][PMAuto][R600]") |
| 22 | { |
| 23 | std::string const perfLevelPath{"power_dpm_force_performance_level"}; |
| 24 | CommandQueueStub ctlCmds; |
| 25 | |
| 26 | SECTION("Does not generate clean control commands") |
| 27 | { |
| 28 | PMAutoR600TestAdapter ts(std::make_unique<StringDataSourceStub>()); |
| 29 | ts.cleanControl(ctlCmds); |
| 30 | |
| 31 | REQUIRE(ctlCmds.commands().empty()); |
| 32 | } |
| 33 | |
| 34 | SECTION("Does not generate sync control commands when is synced") |
| 35 | { |
| 36 | PMAutoR600TestAdapter ts( |
| 37 | std::make_unique<StringDataSourceStub>(perfLevelPath, "auto")); |
| 38 | ts.syncControl(ctlCmds); |
| 39 | |
| 40 | REQUIRE(ctlCmds.commands().empty()); |
| 41 | } |
| 42 | |
| 43 | SECTION("Does generate sync control commands when is out of sync") |
| 44 | { |
| 45 | PMAutoR600TestAdapter ts( |
| 46 | std::make_unique<StringDataSourceStub>(perfLevelPath, "_other_")); |
| 47 | ts.syncControl(ctlCmds); |
| 48 | |
| 49 | REQUIRE(ctlCmds.commands().size() == 1); |
| 50 | auto &[path, value] = ctlCmds.commands().front(); |
| 51 | REQUIRE(path == perfLevelPath); |
| 52 | REQUIRE(value == "auto"); |
| 53 | } |
| 54 | } |
| 55 | |
| 56 | } // namespace Tests::AMD::PMAutoR600 |