chromium/sandbox/linux/seccomp-bpf/bpf_tests_unittest.cc

// Copyright 2014 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "sandbox/linux/seccomp-bpf/bpf_tests.h"

#include <errno.h>
#include <sys/ptrace.h>
#include <sys/syscall.h>
#include <sys/types.h>
#include <unistd.h>

#include <memory>

#include "base/logging.h"
#include "build/build_config.h"
#include "sandbox/linux/bpf_dsl/bpf_dsl.h"
#include "sandbox/linux/bpf_dsl/policy.h"
#include "sandbox/linux/seccomp-bpf/sandbox_bpf.h"
#include "sandbox/linux/services/syscall_wrappers.h"
#include "sandbox/linux/system_headers/linux_syscalls.h"
#include "sandbox/linux/tests/unit_tests.h"
#include "testing/gtest/include/gtest/gtest.h"

Allow;
Error;
ResultExpr;

namespace sandbox {

namespace {

class FourtyTwo {};

class EmptyClassTakingPolicy : public bpf_dsl::Policy {};

BPF_TEST(BPFTest,
         BPFAUXPointsToClass,
         EmptyClassTakingPolicy,
         FourtyTwo /* *BPF_AUX */) {

void DummyTestFunction(FourtyTwo *fourty_two) {}

TEST(BPFTest, BPFTesterCompatibilityDelegateLeakTest) {}

class EnosysPtracePolicy : public bpf_dsl::Policy {};

class BasicBPFTesterDelegate : public BPFTesterDelegate {};

// This is the most powerful and complex way to create a BPF test, but it
// requires a full class definition (BasicBPFTesterDelegate).
BPF_TEST_D(BPFTest, BPFTestWithDelegateClass, BasicBPFTesterDelegate)

// This is the simplest form of BPF tests.
BPF_TEST_C(BPFTest, BPFTestWithInlineTest, EnosysPtracePolicy) {}

const char kHelloMessage[] =;

BPF_DEATH_TEST_C(BPFTest,
                 BPFDeathTestWithInlineTest,
                 DEATH_MESSAGE(kHelloMessage),
                 EnosysPtracePolicy) {}

}  // namespace

}  // namespace sandbox