diff options
author | Nico Weber <nicolasweber@gmx.de> | 2012-05-10 03:25:48 (GMT) |
---|---|---|
committer | Nico Weber <nicolasweber@gmx.de> | 2012-05-10 03:25:48 (GMT) |
commit | 4400a5864b5912028e0b748e90d5bfcc1de52f2c (patch) | |
tree | c01f03a6f4266efbcb449792677bdfa512962942 /src/build_log_test.cc | |
parent | 5cd73252cdc54f554a95ae76914758104fc51552 (diff) | |
download | Ninja-4400a5864b5912028e0b748e90d5bfcc1de52f2c.zip Ninja-4400a5864b5912028e0b748e90d5bfcc1de52f2c.tar.gz Ninja-4400a5864b5912028e0b748e90d5bfcc1de52f2c.tar.bz2 |
Add a BuildLog test that checks that very long command liens don't crash.
Diffstat (limited to 'src/build_log_test.cc')
-rw-r--r-- | src/build_log_test.cc | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/build_log_test.cc b/src/build_log_test.cc index 332a73e..199e016 100644 --- a/src/build_log_test.cc +++ b/src/build_log_test.cc @@ -216,3 +216,31 @@ TEST_F(BuildLogTest, DuplicateVersionHeader) { ASSERT_EQ(789, e->restat_mtime); ASSERT_EQ("command2", e->command); } + +TEST_F(BuildLogTest, VeryLongInputLine) { + // Ninja's build log buffer is currently 256kB. Lines longer than that are + // silently ignored, but don't affect parsing of other lines. + FILE* f = fopen(kTestFilename, "wb"); + fprintf(f, "# ninja log v4\n"); + fprintf(f, "123\t456\t456\tout\tcommand start"); + for (size_t i = 0; i < (512 << 10) / strlen(" more_command"); ++i) + fputs(" more_command", f); + fprintf(f, "\n"); + fprintf(f, "456\t789\t789\tout2\tcommand2\n"); + fclose(f); + + string err; + BuildLog log; + EXPECT_TRUE(log.Load(kTestFilename, &err)); + ASSERT_EQ("", err); + + BuildLog::LogEntry* e = log.LookupByOutput("out"); + ASSERT_EQ(NULL, e); + + e = log.LookupByOutput("out2"); + ASSERT_TRUE(e); + ASSERT_EQ(456, e->start_time); + ASSERT_EQ(789, e->end_time); + ASSERT_EQ(789, e->restat_mtime); + ASSERT_EQ("command2", e->command); +} |