blob: 0785d624880220bdcee714e25dd84735f9562a7e [file] [log] [blame]
Ryan Zuklieccd5eb92022-11-30 10:21:47 -08001/*
2 * Copyright (C) 2022 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 */
16
17#include <android-base/file.h>
18#include <android-base/macros.h>
19#include <android-base/result-gmock.h>
20#include <gmock/gmock.h>
21#include <gtest/gtest.h>
22#include <stdlib.h>
23#include <unistd.h>
24
25#include "bpf/BpfUtils.h"
26
27namespace android {
28namespace bpf {
29using ::android::base::testing::HasError;
30using ::android::base::testing::HasValue;
31using ::android::base::testing::WithMessage;
32using ::testing::HasSubstr;
33
34class BpfRingbufTest : public ::testing::Test {
35 protected:
36 BpfRingbufTest()
37 : mProgPath("/sys/fs/bpf/prog_bpfRingbufProg_skfilter_ringbuf_test"),
38 mRingbufPath("/sys/fs/bpf/map_bpfRingbufProg_test_ringbuf") {}
39
40 void SetUp() {
41 if (!android::bpf::isAtLeastKernelVersion(5, 8, 0)) {
42 GTEST_SKIP() << "BPF ring buffers not supported";
43 return;
44 }
45
46 errno = 0;
47 mProgram.reset(retrieveProgram(mProgPath.c_str()));
48 EXPECT_EQ(errno, 0);
49 ASSERT_GE(mProgram.get(), 0)
50 << mProgPath << " was either not found or inaccessible.";
51 }
52
53 std::string mProgPath;
54 std::string mRingbufPath;
55 android::base::unique_fd mProgram;
56};
57
58TEST_F(BpfRingbufTest, CheckSetUp) {}
59
60} // namespace bpf
61} // namespace android