summaryrefslogtreecommitdiffstats
path: root/src/build_log_test.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/build_log_test.cc')
-rw-r--r--src/build_log_test.cc38
1 files changed, 24 insertions, 14 deletions
diff --git a/src/build_log_test.cc b/src/build_log_test.cc
index 3718299..12c2dc7 100644
--- a/src/build_log_test.cc
+++ b/src/build_log_test.cc
@@ -104,9 +104,11 @@ TEST_F(BuildLogTest, FirstWriteAddsSignature) {
TEST_F(BuildLogTest, DoubleEntry) {
FILE* f = fopen(kTestFilename, "wb");
- fprintf(f, "# ninja log v4\n");
- fprintf(f, "0\t1\t2\tout\tcommand abc\n");
- fprintf(f, "3\t4\t5\tout\tcommand def\n");
+ fprintf(f, "# ninja log v6\n");
+ fprintf(f, "0\t1\t2\tout\t%" PRIx64 "\n",
+ BuildLog::LogEntry::HashCommand("command abc"));
+ fprintf(f, "0\t1\t2\tout\t%" PRIx64 "\n",
+ BuildLog::LogEntry::HashCommand("command def"));
fclose(f);
string err;
@@ -133,9 +135,13 @@ TEST_F(BuildLogTest, Truncate) {
log1.RecordCommand(state_.edges_[1], 20, 25);
log1.Close();
}
-
+#ifdef __USE_LARGEFILE64
+ struct stat64 statbuf;
+ ASSERT_EQ(0, stat64(kTestFilename, &statbuf));
+#else
struct stat statbuf;
ASSERT_EQ(0, stat(kTestFilename, &statbuf));
+#endif
ASSERT_GT(statbuf.st_size, 0);
// For all possible truncations of the input file, assert that we don't
@@ -169,10 +175,11 @@ TEST_F(BuildLogTest, ObsoleteOldVersion) {
ASSERT_NE(err.find("version"), string::npos);
}
-TEST_F(BuildLogTest, SpacesInOutputV4) {
+TEST_F(BuildLogTest, SpacesInOutput) {
FILE* f = fopen(kTestFilename, "wb");
- fprintf(f, "# ninja log v4\n");
- fprintf(f, "123\t456\t456\tout with space\tcommand\n");
+ fprintf(f, "# ninja log v6\n");
+ fprintf(f, "123\t456\t456\tout with space\t%" PRIx64 "\n",
+ BuildLog::LogEntry::HashCommand("command"));
fclose(f);
string err;
@@ -193,10 +200,12 @@ TEST_F(BuildLogTest, DuplicateVersionHeader) {
// build log on Windows. This shouldn't crash, and the second version header
// should be ignored.
FILE* f = fopen(kTestFilename, "wb");
- fprintf(f, "# ninja log v4\n");
- fprintf(f, "123\t456\t456\tout\tcommand\n");
- fprintf(f, "# ninja log v4\n");
- fprintf(f, "456\t789\t789\tout2\tcommand2\n");
+ fprintf(f, "# ninja log v6\n");
+ fprintf(f, "123\t456\t456\tout\t%" PRIx64 "\n",
+ BuildLog::LogEntry::HashCommand("command"));
+ fprintf(f, "# ninja log v6\n");
+ fprintf(f, "456\t789\t789\tout2\t%" PRIx64 "\n",
+ BuildLog::LogEntry::HashCommand("command2"));
fclose(f);
string err;
@@ -243,7 +252,7 @@ struct TestDiskInterface : public DiskInterface {
TEST_F(BuildLogTest, Restat) {
FILE* f = fopen(kTestFilename, "wb");
- fprintf(f, "# ninja log v4\n"
+ fprintf(f, "# ninja log v6\n"
"1\t2\t3\tout\tcommand\n");
fclose(f);
std::string err;
@@ -271,12 +280,13 @@ 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, "# ninja log v6\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");
+ fprintf(f, "456\t789\t789\tout2\t%" PRIx64 "\n",
+ BuildLog::LogEntry::HashCommand("command2"));
fclose(f);
string err;