// Copyright 2014 the V8 project authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // // Tests the sampling API in include/v8.h #include <map> #include <string> #include "include/v8-isolate.h" #include "include/v8-local-handle.h" #include "include/v8-template.h" #include "include/v8-unwinder.h" #include "src/flags/flags.h" #include "test/cctest/cctest.h" namespace { class Sample { … }; class SamplingTestHelper { … }; SamplingTestHelper* SamplingTestHelper::instance_; } // namespace // A JavaScript function which takes stack depth // (minimum value 2) as an argument. // When at the bottom of the recursion, // the JavaScript code calls into C++ test code, // waiting for the sampler to take a sample. static const char* test_function = …; TEST(StackDepthIsConsistent) { … } TEST(StackDepthDoesNotExceedMaxValue) { … } static const char* test_function_call_builtin = …; TEST(BuiltinsInSamples) { … } // The captured sample should have three pc values. // They should fall in the range where the compiled code resides. // The expected stack is: // bottom of stack [{anon script}, outer, inner] top of stack // ^ ^ ^ // sample.stack indices 2 1 0 TEST(StackFramesConsistent) { … }