blob: 44322972ba02935ddf088f46c5b2a87abaaa3d11 [file] [log] [blame]
Tianjie Xuca948562017-02-28 12:26:29 -08001/*
2 * Copyright (C) 2017 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 agree 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#ifndef _COMPONENT_TEST_UTIL_H
18#define _COMPONENT_TEST_UTIL_H
19
20#include <string>
21
22#include <android-base/properties.h>
23#include <fs_mgr.h>
24
25// Check if the /misc entry exists in the fstab.
26static bool parse_misc() {
27 // The fstab path is "/fstab.${ro.hardware}".
28 std::string ro_hardware = android::base::GetProperty("ro.hardware", "");
29 if (ro_hardware.empty()) {
30 GTEST_LOG_(INFO) << "Failed to get ro.hardware.";
31 return false;
32 }
33
34 std::string fstab_path = "/fstab." + ro_hardware;
35 fstab* fstab = fs_mgr_read_fstab(fstab_path.c_str());
36 if (fstab == nullptr) {
37 GTEST_LOG_(INFO) << "Failed to read " << fstab_path;
38 return false;
39 }
40
41 fstab_rec* record = fs_mgr_get_entry_for_mount_point(fstab, "/misc");
42 if (record == nullptr) {
43 GTEST_LOG_(INFO) << "Failed to find /misc in fstab.";
44 return false;
45 }
46 return true;
47}
48
49#endif //_COMPONENT_TEST_UTIL_H
50