Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1250)

Unified Diff: test/cctest/test-heap-profiler.cc

Issue 3409002: Add support for abortion in v8::OutputStream. (Closed)
Patch Set: Created 10 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/profile-generator.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/test-heap-profiler.cc
diff --git a/test/cctest/test-heap-profiler.cc b/test/cctest/test-heap-profiler.cc
index 2bc52db4e22c78bf6eea2fb6efe2f9ecc91390da..5e570f34de3dc97a3eb8974ae24932de36e3fc44 100644
--- a/test/cctest/test-heap-profiler.cc
+++ b/test/cctest/test-heap-profiler.cc
@@ -993,13 +993,18 @@ namespace {
class TestJSONStream : public v8::OutputStream {
public:
- TestJSONStream() : eos_signaled_(0) {}
+ TestJSONStream() : eos_signaled_(0), abort_countdown_(-1) {}
+ explicit TestJSONStream(int abort_countdown)
+ : eos_signaled_(0), abort_countdown_(abort_countdown) {}
virtual ~TestJSONStream() {}
virtual void EndOfStream() { ++eos_signaled_; }
- virtual void WriteAsciiChunk(char* buffer, int chars_written) {
+ virtual WriteResult WriteAsciiChunk(char* buffer, int chars_written) {
+ if (abort_countdown_ > 0) --abort_countdown_;
+ if (abort_countdown_ == 0) return kAbort;
CHECK_GT(chars_written, 0);
i::Vector<char> chunk = buffer_.AddBlock(chars_written, '\0');
memcpy(chunk.start(), buffer, chars_written);
+ return kContinue;
}
void WriteTo(i::Vector<char> dest) { buffer_.WriteTo(dest); }
int eos_signaled() { return eos_signaled_; }
@@ -1007,6 +1012,7 @@ class TestJSONStream : public v8::OutputStream {
private:
i::Collector<char> buffer_;
int eos_signaled_;
+ int abort_countdown_;
};
class AsciiResource: public v8::String::ExternalAsciiStringResource {
@@ -1123,4 +1129,16 @@ TEST(HeapSnapshotJSONSerialization) {
*v8::String::Utf8Value(string));
}
+
+TEST(HeapSnapshotJSONSerializationAborting) {
+ v8::HandleScope scope;
+ LocalContext env;
+ const v8::HeapSnapshot* snapshot =
+ v8::HeapProfiler::TakeSnapshot(v8::String::New("abort"));
+ TestJSONStream stream(5);
+ snapshot->Serialize(&stream, v8::HeapSnapshot::kJSON);
+ CHECK_GT(stream.size(), 0);
+ CHECK_EQ(0, stream.eos_signaled());
+}
+
#endif // ENABLE_LOGGING_AND_PROFILING
« no previous file with comments | « src/profile-generator.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698