blob: 40cfc6975129ce05f1b99088878c371c0e2dc4c1 [file] [log] [blame]
Wei Wangb72a15a2017-03-02 13:46:37 -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 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 Baoed138192017-05-01 22:30:39 -070016
Wei Wangb72a15a2017-03-02 13:46:37 -080017#include <unistd.h>
Tao Baoed138192017-05-01 22:30:39 -070018
Wei Wangb72a15a2017-03-02 13:46:37 -080019#include <gtest/gtest.h>
20
Tao Baoed138192017-05-01 22:30:39 -070021#include "fuse_sideload.h"
22
23TEST(SideloadTest, fuse_device) {
24 ASSERT_EQ(0, access("/dev/fuse", R_OK | W_OK));
25}
26
27TEST(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 Wangb72a15a2017-03-02 13:46:37 -080036}