Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- |
michael@0 | 2 | * vim: sw=2 ts=2 et lcs=trail\:.,tab\:>~ : |
michael@0 | 3 | * This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 4 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 5 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 6 | |
michael@0 | 7 | #include "storage_test_harness.h" |
michael@0 | 8 | #include "nsIFile.h" |
michael@0 | 9 | #include "prio.h" |
michael@0 | 10 | |
michael@0 | 11 | /** |
michael@0 | 12 | * This file tests that the file permissions of the sqlite files match what |
michael@0 | 13 | * we request they be |
michael@0 | 14 | */ |
michael@0 | 15 | |
michael@0 | 16 | void |
michael@0 | 17 | test_file_perms() |
michael@0 | 18 | { |
michael@0 | 19 | nsCOMPtr<mozIStorageConnection> db(getDatabase()); |
michael@0 | 20 | nsCOMPtr<nsIFile> dbFile; |
michael@0 | 21 | do_check_success(db->GetDatabaseFile(getter_AddRefs(dbFile))); |
michael@0 | 22 | |
michael@0 | 23 | uint32_t perms = 0; |
michael@0 | 24 | do_check_success(dbFile->GetPermissions(&perms)); |
michael@0 | 25 | |
michael@0 | 26 | // This reflexts the permissions defined by SQLITE_DEFAULT_FILE_PERMISSIONS in |
michael@0 | 27 | // db/sqlite3/src/Makefile.in and must be kept in sync with that |
michael@0 | 28 | #ifdef ANDROID |
michael@0 | 29 | do_check_true(perms == (PR_IRUSR | PR_IWUSR)); |
michael@0 | 30 | #elif defined(XP_WIN) |
michael@0 | 31 | do_check_true(perms == (PR_IRUSR | PR_IWUSR | PR_IRGRP | PR_IWGRP | PR_IROTH | PR_IWOTH)); |
michael@0 | 32 | #else |
michael@0 | 33 | do_check_true(perms == (PR_IRUSR | PR_IWUSR | PR_IRGRP | PR_IROTH)); |
michael@0 | 34 | #endif |
michael@0 | 35 | } |
michael@0 | 36 | |
michael@0 | 37 | void (*gTests[])(void) = { |
michael@0 | 38 | test_file_perms, |
michael@0 | 39 | }; |
michael@0 | 40 | |
michael@0 | 41 | const char *file = __FILE__; |
michael@0 | 42 | #define TEST_NAME "file perms" |
michael@0 | 43 | #define TEST_FILE file |
michael@0 | 44 | #include "storage_test_harness_tail.h" |