tests/api_backend.cc

Go to the documentation of this file.
00001 
00004 /* Copyright (C) 2008 Olly Betts
00005  *
00006  * This program is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU General Public License as
00008  * published by the Free Software Foundation; either version 2 of the
00009  * License, or (at your option) any later version.
00010  *
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License
00017  * along with this program; if not, write to the Free Software
00018  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301
00019  * USA
00020  */
00021 
00022 #include <config.h>
00023 
00024 #include "api_backend.h"
00025 
00026 #include <xapian.h>
00027 
00028 #include "testsuite.h"
00029 #include "testutils.h"
00030 #include "utils.h"
00031 
00032 #include "apitest.h"
00033 
00034 using namespace std;
00035 
00037 DEFINE_TESTCASE(lockfileumask1, flint) {
00038 #ifndef __WIN32__
00039     mode_t old_umask = umask(022);
00040     try {
00041         Xapian::WritableDatabase db = get_named_writable_database("lockfileumask1");
00042 
00043         string path;
00044         const string & dbtype = get_dbtype();
00045         if (dbtype == "flint") {
00046             // Hardcodeed path for 1.0.x backport:
00047             path = ".flint/dbw__lockfileumask1/flintlock";
00048         } else {
00049             SKIP_TEST("Test only supported for flint backend");
00050         }
00051 
00052         struct stat statbuf;
00053         TEST(stat(path, &statbuf) == 0);
00054         TEST_EQUAL(statbuf.st_mode & 0777, 0644);
00055     } catch (...) {
00056         umask(old_umask);
00057         throw;
00058     }
00059 
00060     umask(old_umask);
00061 #endif
00062 
00063     return true;
00064 }

Documentation for Xapian (version 1.0.10).
Generated on 24 Dec 2008 by Doxygen 1.5.2.