Wei Wang | b72a15a | 2017-03-02 13:46:37 -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 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 | */ |
Tao Bao | ed13819 | 2017-05-01 22:30:39 -0700 | [diff] [blame] | 16 | |
Wei Wang | b72a15a | 2017-03-02 13:46:37 -0800 | [diff] [blame] | 17 | #include <unistd.h> |
Tao Bao | ed13819 | 2017-05-01 22:30:39 -0700 | [diff] [blame] | 18 | |
Wei Wang | b72a15a | 2017-03-02 13:46:37 -0800 | [diff] [blame] | 19 | #include <gtest/gtest.h> |
| 20 | |
Tao Bao | ed13819 | 2017-05-01 22:30:39 -0700 | [diff] [blame] | 21 | #include "fuse_sideload.h" |
| 22 | |
| 23 | TEST(SideloadTest, fuse_device) { |
| 24 | ASSERT_EQ(0, access("/dev/fuse", R_OK | W_OK)); |
| 25 | } |
| 26 | |
| 27 | TEST(SideloadTest, run_fuse_sideload_wrong_parameters) { |
| 28 | provider_vtab vtab; |
| 29 | vtab.close = [](void*) {}; |
| 30 | |
| 31 | ASSERT_EQ(-1, run_fuse_sideload(&vtab, nullptr, 4096, 4095)); |
| 32 | ASSERT_EQ(-1, run_fuse_sideload(&vtab, nullptr, 4096, (1 << 22) + 1)); |
| 33 | |
| 34 | // Too many blocks. |
| 35 | ASSERT_EQ(-1, run_fuse_sideload(&vtab, nullptr, ((1 << 18) + 1) * 4096, 4096)); |
Wei Wang | b72a15a | 2017-03-02 13:46:37 -0800 | [diff] [blame] | 36 | } |