3 * Program to test cache path
5 * Eric Bollengier, March 2007
11 Bacula® - The Network Backup Solution
13 Copyright (C) 2001-2006 Free Software Foundation Europe e.V.
15 The main author of Bacula is Kern Sibbald, with contributions from
16 many others, a complete list can be found in the file AUTHORS.
17 This program is Free Software; you can redistribute it and/or
18 modify it under the terms of version two of the GNU General Public
19 License as published by the Free Software Foundation and included
22 This program is distributed in the hope that it will be useful, but
23 WITHOUT ANY WARRANTY; without even the implied warranty of
24 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
25 General Public License for more details.
27 You should have received a copy of the GNU General Public License
28 along with this program; if not, write to the Free Software
29 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
32 Bacula® is a registered trademark of Kern Sibbald.
33 The licensor of Bacula is the Free Software Foundation Europe
34 (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
35 Switzerland, email:ftf@fsfeurope.org.
39 #include "cats/cats.h"
40 #include "cats/bvfs.h"
45 static const char *db_name = "regress";
46 static const char *db_user = "regress";
47 static const char *db_password = "";
48 static const char *db_host = NULL;
54 "\nVersion: %s (%s)\n"
55 " -d <nn> set debug level to <nn>\n"
56 " -dt print timestamp in debug output\n"
57 " -n <name> specify the database name (default bacula)\n"
58 " -u <user> specify database user name (default bacula)\n"
59 " -P <password specify database password (default none)\n"
60 " -h <host> specify database host (default NULL)\n"
61 " -w <working> specify working directory\n"
63 " -? print this message\n\n"), 2001, VERSION, BDATE);
67 /* number of thread started */
69 int main (int argc, char *argv[])
72 setlocale(LC_ALL, "");
73 bindtextdomain("bacula", LOCALEDIR);
77 Dmsg0(0, "Starting bvfs_test tool\n");
79 my_name_is(argc, argv, "bvfs_test");
84 while ((ch = getopt(argc, argv, "h:c:d:n:P:Su:vf:w:?")) != -1) {
86 case 'd': /* debug level */
90 debug_level = atoi(optarg);
91 if (debug_level <= 0) {
106 working_directory = optarg;
114 db_password = optarg;
131 Pmsg0(0, _("Wrong number of arguments: \n"));
134 JCR *bjcr = new_jcr(sizeof(JCR), NULL);
135 bjcr->JobId = getpid();
136 bjcr->set_JobType(JT_CONSOLE);
137 bjcr->set_JobLevel(L_FULL);
138 bjcr->JobStatus = JS_Running;
139 bjcr->client_name = get_pool_memory(PM_FNAME);
140 pm_strcpy(bjcr->client_name, "Dummy.Client.Name");
141 bstrncpy(bjcr->Job, "bvfs_test", sizeof(bjcr->Job));
143 if ((db=db_init_database(NULL, db_name, db_user, db_password,
144 db_host, 0, NULL, 0)) == NULL) {
145 Emsg0(M_ERROR_TERM, 0, _("Could not init Bacula database\n"));
147 Dmsg1(0, "db_type=%s\n", db_get_type());
149 if (!db_open_database(NULL, db)) {
150 Emsg0(M_ERROR_TERM, 0, db_strerror(db));
152 Dmsg0(200, "Database opened\n");
154 Pmsg2(000, _("Using Database: %s, User: %s\n"), db_name, db_user);
159 db_sql_query(db, "DELETE FROM brestore_pathhierarchy", NULL, NULL);
160 db_sql_query(db, "DELETE FROM brestore_knownjobid", NULL, NULL);
161 db_sql_query(db, "DELETE FROM brestore_pathvisibility", NULL, NULL);
163 bvfs_update_cache(bjcr, db);
180 fs.ch_dir("/tmp/regress/");
185 fs.ch_dir("/tmp/regress/build/");
188 fs.ls_special_dirs();
189 fs.get_all_file_versions(1, 347, "zog4-fd");
192 strcpy(p, "/tmp/toto/rep/");
194 if(strcmp(p, "/tmp/toto/")) {
195 Pmsg0(000, "Error in bvfs_parent_dir\n");
198 if(strcmp(p, "/tmp/")) {
199 Pmsg0(000, "Error in bvfs_parent_dir\n");
203 Pmsg0(000, "Error in bvfs_parent_dir\n");
207 Pmsg0(000, "Error in bvfs_parent_dir\n");
211 Pmsg0(000, "Error in bvfs_parent_dir\n");