blob: 4a45a93b3e14beac8349963ae04562d59febfc02 [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
Maciej Żenczykowski6776e3b2022-12-10 12:18:23 +000025#include "BpfSyscallWrappers.h"
Ryan Zuklieccd5eb92022-11-30 10:21:47 -080026#include "bpf/BpfUtils.h"
27
28namespace android {
29namespace bpf {
30using ::android::base::testing::HasError;
31using ::android::base::testing::HasValue;
32using ::android::base::testing::WithMessage;
33using ::testing::HasSubstr;
34
35class BpfRingbufTest : public ::testing::Test {
36 protected:
37 BpfRingbufTest()
38 : mProgPath("/sys/fs/bpf/prog_bpfRingbufProg_skfilter_ringbuf_test"),
39 mRingbufPath("/sys/fs/bpf/map_bpfRingbufProg_test_ringbuf") {}
40
41 void SetUp() {
42 if (!android::bpf::isAtLeastKernelVersion(5, 8, 0)) {
43 GTEST_SKIP() << "BPF ring buffers not supported";
44 return;
45 }
46
47 errno = 0;
48 mProgram.reset(retrieveProgram(mProgPath.c_str()));
49 EXPECT_EQ(errno, 0);
50 ASSERT_GE(mProgram.get(), 0)
51 << mProgPath << " was either not found or inaccessible.";
52 }
53
54 std::string mProgPath;
55 std::string mRingbufPath;
56 android::base::unique_fd mProgram;
57};
58
59TEST_F(BpfRingbufTest, CheckSetUp) {}
60
61} // namespace bpf
62} // namespace android