Tianjie Xu | ca94856 | 2017-02-28 12:26:29 -0800 | [diff] [blame] | 1 | /* |
| 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. |
| 26 | static bool parse_misc() { |
Bowgo Tsai | d13b6cf | 2017-03-10 16:00:40 +0800 | [diff] [blame] | 27 | 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 Xu | ca94856 | 2017-02-28 12:26:29 -0800 | [diff] [blame] | 31 | return false; |
| 32 | } |
| 33 | |
Bowgo Tsai | d13b6cf | 2017-03-10 16:00:40 +0800 | [diff] [blame] | 34 | fstab_rec* record = fs_mgr_get_entry_for_mount_point(fstab.get(), "/misc"); |
Tianjie Xu | ca94856 | 2017-02-28 12:26:29 -0800 | [diff] [blame] | 35 | 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 | |