blob: 3fee32d62fb733ca29a3a6f3773b0d41c0dd0b71 [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() {
Bowgo Tsaid13b6cf2017-03-10 16:00:40 +080027 std::unique_ptr<fstab, decltype(&fs_mgr_free_fstab)> fstab(fs_mgr_read_fstab_default(),
28 fs_mgr_free_fstab);
29 if (!fstab) {
30 GTEST_LOG_(INFO) << "Failed to read default fstab";
Tianjie Xuca948562017-02-28 12:26:29 -080031 return false;
32 }
33
Bowgo Tsaid13b6cf2017-03-10 16:00:40 +080034 fstab_rec* record = fs_mgr_get_entry_for_mount_point(fstab.get(), "/misc");
Tianjie Xuca948562017-02-28 12:26:29 -080035 if (record == nullptr) {
36 GTEST_LOG_(INFO) << "Failed to find /misc in fstab.";
37 return false;
38 }
39 return true;
40}
41
42#endif //_COMPONENT_TEST_UTIL_H
43