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

Side by Side Diff: sql/test/test_helpers.h

Issue 1176653002: mandoline filesystem: add a sqlite3 vfs to proxy filesystem usage. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Patch cleanup now that gn check passes. Created 5 years, 6 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 #ifndef SQL_TEST_TEST_HELPERS_H_ 5 #ifndef SQL_TEST_TEST_HELPERS_H_
6 #define SQL_TEST_TEST_HELPERS_H_ 6 #define SQL_TEST_TEST_HELPERS_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
11 #include "base/files/file_path.h" 11 #include "base/files/file_path.h"
12 12
13 // Collection of test-only convenience functions. 13 // Collection of test-only convenience functions.
14 14
15 namespace base { 15 namespace base {
16 class FilePath; 16 class FilePath;
17 } 17 }
18 18
19 namespace sql { 19 namespace sql {
20 class Connection; 20 class Connection;
21 } 21 }
22 22
23 namespace sql { 23 namespace sql {
24 namespace test { 24 namespace test {
25 25
26 // SQLite stores the database size in the header, and if the actual 26 unsigned ReadBigEndian(unsigned char* buf, size_t bytes);
27 // OS-derived size is smaller, the database is considered corrupt. 27 void WriteBigEndian(unsigned val, unsigned char* buf, size_t bytes);
28 // [This case is actually a common form of corruption in the wild.] 28
29 // This helper sets the in-header size to one page larger than the 29 // Raw version of CorruptSizeInHeader that operates on local files. This is
30 // actual file size. The resulting file will return SQLITE_CORRUPT 30 // exposed because there's a lot of code outside of //sql/ which uses this.
31 // for most operations unless PRAGMA writable_schema is turned ON.
32 //
33 // Returns false if any error occurs accessing the file.
34 bool CorruptSizeInHeader(const base::FilePath& db_path) WARN_UNUSED_RESULT; 31 bool CorruptSizeInHeader(const base::FilePath& db_path) WARN_UNUSED_RESULT;
35 32
36 // Frequently corruption is a result of failure to atomically update 33 // Frequently corruption is a result of failure to atomically update
37 // pages in different structures. For instance, if an index update 34 // pages in different structures. For instance, if an index update
38 // takes effect but the corresponding table update does not. This 35 // takes effect but the corresponding table update does not. This
39 // helper restores the prior version of a b-tree root after running an 36 // helper restores the prior version of a b-tree root after running an
40 // update which changed that b-tree. The named b-tree must exist and 37 // update which changed that b-tree. The named b-tree must exist and
41 // must be a leaf node (either index or table). Returns true if the 38 // must be a leaf node (either index or table). Returns true if the
42 // on-disk file is successfully modified, and the restored page 39 // on-disk file is successfully modified, and the restored page
43 // differs from the updated page. 40 // differs from the updated page.
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 74
78 // Return the results of running "PRAGMA integrity_check" on |db|. 75 // Return the results of running "PRAGMA integrity_check" on |db|.
79 // TODO(shess): sql::Connection::IntegrityCheck() is basically the 76 // TODO(shess): sql::Connection::IntegrityCheck() is basically the
80 // same, but not as convenient for testing. Maybe combine. 77 // same, but not as convenient for testing. Maybe combine.
81 std::string IntegrityCheck(sql::Connection* db) WARN_UNUSED_RESULT; 78 std::string IntegrityCheck(sql::Connection* db) WARN_UNUSED_RESULT;
82 79
83 } // namespace test 80 } // namespace test
84 } // namespace sql 81 } // namespace sql
85 82
86 #endif // SQL_TEST_TEST_HELPERS_H_ 83 #endif // SQL_TEST_TEST_HELPERS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698