storage/test/test_file_perms.cpp

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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

mercurial