// Copyright 2017 The Crashpad Authors // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. #include "util/linux/scoped_ptrace_attach.h" #include <errno.h> #include <sys/ptrace.h> #include <unistd.h> #include "gtest/gtest.h" #include "test/errors.h" #include "test/multiprocess.h" #include "util/file/file_io.h" #include "util/linux/scoped_pr_set_ptracer.h" namespace crashpad { namespace test { namespace { // If Yama is not enabled, the default ptrace restrictions should be // sufficient for these tests. // // If Yama is enabled, then /proc/sys/kernel/yama/ptrace_scope must be 0 // (YAMA_SCOPE_DISABLED) or 1 (YAMA_SCOPE_RELATIONAL) for these tests to // succeed. If it is 2 (YAMA_SCOPE_CAPABILITY) then the test requires // CAP_SYS_PTRACE, and if it is 3 (YAMA_SCOPE_NO_ATTACH), these tests will fail. class AttachTest : public Multiprocess { … }; class AttachToChildTest : public AttachTest { … }; TEST(ScopedPtraceAttach, AttachChild) { … } class AttachToParentResetTest : public AttachTest { … }; TEST(ScopedPtraceAttach, AttachParentReset) { … } class AttachToParentDestructorTest : public AttachTest { … }; TEST(ScopedPtraceAttach, AttachParentDestructor) { … } } // namespace } // namespace test } // namespace crashpad