blob: 9602283e1888292cc8b80e03fc2c1360f1cdb237 [file] [log] [blame]
David Brazdil49f8a4d2021-03-04 09:57:33 +00001/*
2 * Copyright (C) 2021 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
17#include "virt/VirtualizationTest.h"
18
Jiyong Parkaaf32f22021-08-30 19:11:19 +090019namespace {
20
21bool isVmSupported() {
22 const std::array<const char *, 4> needed_files = {
23 "/dev/kvm",
24 "/dev/vhost-vsock",
25 "/apex/com.android.virt/bin/crosvm",
26 "/apex/com.android.virt/bin/virtualizationservice",
27 };
28 return std::all_of(needed_files.begin(), needed_files.end(),
29 [](const char *file) { return access(file, F_OK) == 0; });
30}
31
32} // namespace
33
David Brazdil49f8a4d2021-03-04 09:57:33 +000034namespace virt {
35
36void VirtualizationTest::SetUp() {
Jiyong Parkaaf32f22021-08-30 19:11:19 +090037 if (!isVmSupported()) {
38 GTEST_SKIP() << "Device doesn't support KVM.";
39 }
40
Andrew Walbranf1453802021-03-29 17:12:54 +000041 mVirtualizationService = waitForService<IVirtualizationService>(
42 String16("android.system.virtualizationservice"));
43 ASSERT_NE(mVirtualizationService, nullptr);
David Brazdil49f8a4d2021-03-04 09:57:33 +000044}
45
46} // namespace virt