OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <sys/types.h> | 5 #include <sys/types.h> |
6 #include <sys/stat.h> | 6 #include <sys/stat.h> |
7 #include <fcntl.h> | 7 #include <fcntl.h> |
8 #include <unistd.h> | 8 #include <unistd.h> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 EXPECT_EQ(0, System(StringPrintf("rm -f '%s/dir/subdir/fifo'", base_c))); | 76 EXPECT_EQ(0, System(StringPrintf("rm -f '%s/dir/subdir/fifo'", base_c))); |
77 EXPECT_EQ(0, System(StringPrintf("mkfifo '%s/dir/subdir/fifo'", base_c))); | 77 EXPECT_EQ(0, System(StringPrintf("mkfifo '%s/dir/subdir/fifo'", base_c))); |
78 EXPECT_EQ(0, System(StringPrintf("ln -f -s /target '%s/dir/subdir/link'", | 78 EXPECT_EQ(0, System(StringPrintf("ln -f -s /target '%s/dir/subdir/link'", |
79 base_c))); | 79 base_c))); |
80 EXPECT_EQ(0, System(StringPrintf("rm -f '%s/hard_link'", base_c))); | 80 EXPECT_EQ(0, System(StringPrintf("rm -f '%s/hard_link'", base_c))); |
81 EXPECT_EQ(0, System(StringPrintf("ln '%s/hi' '%s/hard_link'", | 81 EXPECT_EQ(0, System(StringPrintf("ln '%s/hi' '%s/hard_link'", |
82 base_c, base_c))); | 82 base_c, base_c))); |
83 EXPECT_EQ(0, System(StringPrintf( | 83 EXPECT_EQ(0, System(StringPrintf( |
84 "ln -f -s '%s' '%s/compress_link'", kWellCompressingFilename, base_c))); | 84 "ln -f -s '%s' '%s/compress_link'", kWellCompressingFilename, base_c))); |
85 | 85 |
86 // Things that will encode differently: | 86 // Things that will encode differently: |
87 EXPECT_EQ(0, System(StringPrintf("mkdir -p '%s/encoding'", base_c))); | 87 EXPECT_EQ(0, System(StringPrintf("mkdir -p '%s/encoding'", base_c))); |
88 EXPECT_EQ(0, System(StringPrintf("echo nochange > '%s/encoding/nochange'", | 88 EXPECT_EQ(0, System(StringPrintf("echo nochange > '%s/encoding/nochange'", |
89 base_c))); | 89 base_c))); |
90 EXPECT_EQ(0, System(StringPrintf("echo -n > '%s/encoding/onebyte'", base_c))); | 90 EXPECT_EQ(0, System(StringPrintf("echo -n > '%s/encoding/onebyte'", base_c))); |
91 EXPECT_EQ(0, System(StringPrintf("echo -n > '%s/encoding/long_new'", | 91 EXPECT_EQ(0, System(StringPrintf("echo -n > '%s/encoding/long_new'", |
92 base_c))); | 92 base_c))); |
93 // Random 1 MiB byte length file | 93 // Random 1 MiB byte length file |
94 EXPECT_TRUE(WriteFile((base + | 94 EXPECT_TRUE(utils::WriteFile((base + |
95 "/encoding/long_small_change").c_str(), | 95 "/encoding/long_small_change").c_str(), |
96 reinterpret_cast<const char*>(kRandomString), | 96 reinterpret_cast<const char*>(kRandomString), |
97 sizeof(kRandomString))); | 97 sizeof(kRandomString))); |
98 } | 98 } |
99 // base points to a folder that was passed to GenerateFilesAtPath(). | 99 // base points to a folder that was passed to GenerateFilesAtPath(). |
100 // This edits some, so that one can make a diff from the original data | 100 // This edits some, so that one can make a diff from the original data |
101 // and the edited data. | 101 // and the edited data. |
102 void EditFilesAtPath(const string& base) { | 102 void EditFilesAtPath(const string& base) { |
103 CHECK_EQ(0, System(string("echo hello > ") + base + "/dir/hello")); | 103 CHECK_EQ(0, System(string("echo hello > ") + base + "/dir/hello")); |
104 CHECK_EQ(0, System(string("echo -n > ") + base + "/dir/newempty")); | 104 CHECK_EQ(0, System(string("echo -n > ") + base + "/dir/newempty")); |
105 CHECK_EQ(0, System(string("echo newhi > ") + base + "/hi")); | 105 CHECK_EQ(0, System(string("echo newhi > ") + base + "/hi")); |
106 CHECK_EQ(0, System(string("echo -n h >> ") + base + | 106 CHECK_EQ(0, System(string("echo -n h >> ") + base + |
107 "/encoding/onebyte")); | 107 "/encoding/onebyte")); |
(...skipping 814 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
922 { | 922 { |
923 vector<char> data(14); | 923 vector<char> data(14); |
924 memcpy(&data[0], "CrAU\0\0\0\0\0\0\0\x0cxx", 12); | 924 memcpy(&data[0], "CrAU\0\0\0\0\0\0\0\x0cxx", 12); |
925 WriteFileVector("diff-gen-test/baddelta", data); | 925 WriteFileVector("diff-gen-test/baddelta", data); |
926 DeltaDiffParser parser("diff-gen-test/baddelta"); | 926 DeltaDiffParser parser("diff-gen-test/baddelta"); |
927 EXPECT_FALSE(parser.valid()); | 927 EXPECT_FALSE(parser.valid()); |
928 } | 928 } |
929 } | 929 } |
930 | 930 |
931 } // namespace chromeos_update_engine | 931 } // namespace chromeos_update_engine |
OLD | NEW |