1 // 2 // Copyright (C) 2022 The Android Open Source Project 3 // 4 // Licensed under the Apache License, Version 2.0 (the "License"); 5 // you may not use this file except in compliance with the License. 6 // You may obtain a copy of the License at 7 // 8 // http://www.apache.org/licenses/LICENSE-2.0 9 // 10 // Unless required by applicable law or agreed to in writing, software 11 // distributed under the License is distributed on an "AS IS" BASIS, 12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 // See the License for the specific language governing permissions and 14 // limitations under the License. 15 16 #pragma once 17 18 #include <sys/types.h> 19 #include <unistd.h> 20 21 #include <optional> 22 #include <string> 23 #include <unordered_map> 24 #include <vector> 25 26 #include <gtest/gtest.h> 27 28 #include "host/commands/cvd/selector/creation_analyzer.h" 29 30 namespace cuttlefish { 31 namespace selector { 32 33 struct OutputInfo { 34 std::string home; 35 std::string host_artifacts_path; ///< e.g. out/host/linux-x86 36 std::string group_name; 37 std::vector<unsigned> instances; 38 std::vector<std::string> args; 39 std::unordered_map<std::string, std::string> envs; 40 }; 41 42 struct Expected { 43 OutputInfo output; 44 bool is_success; 45 }; 46 47 struct InputOutput { 48 // inputs 49 std::string selector_args; 50 std::string cmd_args; 51 std::string home; 52 std::string android_host_out; 53 54 // output 55 Expected expected_output; 56 }; 57 58 class CreationInfoGenTest : public testing::TestWithParam<InputOutput> { 59 protected: 60 CreationInfoGenTest(); 61 void Init(); 62 63 std::vector<std::string> selector_args_; 64 std::string sub_cmd_; 65 std::vector<std::string> cmd_args_; 66 std::unordered_map<std::string, std::string> envs_; 67 ucred credential_; 68 OutputInfo expected_output_; 69 bool expected_success_; 70 InstanceDatabase instance_db_; 71 InstanceLockFileManager instance_lock_file_manager_; 72 }; 73 74 class HomeTest : public CreationInfoGenTest {}; 75 class HostArtifactsTest : public CreationInfoGenTest {}; 76 class InvalidSubCmdTest : public CreationInfoGenTest {}; 77 class ValidSubCmdTest : public CreationInfoGenTest {}; 78 79 } // namespace selector 80 } // namespace cuttlefish 81