• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //
2 // Copyright (C) 2023 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 #include <string>
17 #include <vector>
18 
19 #include <gtest/gtest.h>
20 
21 #include "common/libs/utils/contains.h"
22 #include "host/commands/cvd/types.h"
23 #include "host/commands/cvd/unittests/server/cmd_runner.h"
24 
25 namespace cuttlefish {
26 
TEST(CvdBasic,CvdDefaultStart)27 TEST(CvdBasic, CvdDefaultStart) {
28   cvd_common::Envs envs;
29   const auto home_dir = StringFromEnv("HOME", "");
30   envs["HOME"] = home_dir;
31   CmdRunner::Run("cvd reset -y", envs);
32 
33   cvd_common::Args start_args{"cvd", "start",
34                               "--report_anonymous_usage_stats=yes", "--daemon"};
35 
36   auto cmd_start = CmdRunner::Run(start_args, envs);
37   ASSERT_TRUE(cmd_start.Success()) << cmd_start.Stderr();
38 
39   auto cmd_fleet = CmdRunner::Run("cvd fleet", envs);
40   ASSERT_TRUE(cmd_fleet.Success()) << cmd_fleet.Stderr();
41   ASSERT_TRUE(Contains(cmd_fleet.Stdout(), home_dir));
42 
43   auto cmd_stop = CmdRunner::Run("cvd stop", envs);
44   ASSERT_TRUE(cmd_stop.Success()) << cmd_stop.Stderr();
45 
46   cmd_fleet = CmdRunner::Run("cvd fleet", envs);
47   ASSERT_FALSE(Contains(cmd_fleet.Stdout(), home_dir));
48 
49   // clean up for the next test
50   CmdRunner::Run("cvd reset -y", envs);
51 }
52 
53 }  // namespace cuttlefish
54