]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/tools/cats_test.c
Backport from BEE
[bacula/bacula] / bacula / src / tools / cats_test.c
index 76a09e0814f894aee27450609b54218e175fa2f6..9e350766a0322b14046e553cd27e3a36ff67c0a5 100644 (file)
@@ -1,34 +1,22 @@
 /*
    Bacula® - The Network Backup Solution
 
-   Copyright (C) 2011-2011 Free Software Foundation Europe e.V.
+   Copyright (C) 2011-2014 Free Software Foundation Europe e.V.
 
-   The main author of Bacula is Kern Sibbald, with contributions from
-   many others, a complete list can be found in the file AUTHORS.
-   This program is Free Software; you can redistribute it and/or
-   modify it under the terms of version three of the GNU Affero General Public
-   License as published by the Free Software Foundation and included
-   in the file LICENSE.
+   The main author of Bacula is Kern Sibbald, with contributions from many
+   others, a complete list can be found in the file AUTHORS.
 
-   This program is distributed in the hope that it will be useful, but
-   WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-   General Public License for more details.
-
-   You should have received a copy of the GNU Affero General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-   02110-1301, USA.
+   You may use this file and others of this release according to the
+   license defined in the LICENSE file, which includes the Affero General
+   Public License, v3.0 ("AGPLv3") and some additional permissions and
+   terms pursuant to its AGPLv3 Section 7.
 
    Bacula® is a registered trademark of Kern Sibbald.
-   The licensor of Bacula is the Free Software Foundation Europe
-   (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
-   Switzerland, email:ftf@fsfeurope.org.
 */
 /*
  *  Program to test CATS DB routines
  *
- *  
+ *
  */
 #define _BDB_PRIV_INTERFACE_
 
@@ -38,7 +26,7 @@
 #include "cats/sql_glue.h"
 #include "cats/bvfs.h"
 #include "findlib/find.h"
+
 /* Local variables */
 static B_DB *db;
 static const char *file = "COPYRIGHT";
@@ -163,7 +151,7 @@ static void cmp_client(CLIENT_DBR &cr, CLIENT_DBR &cr2)
    ok(!strcmp(cr2.Name, cr.Name),           "  Check Client Name");
    ok(!strcmp(cr2.Uname, cr.Uname),         "  Check Client Uname");
    ok(cr.AutoPrune == cr2.AutoPrune,        "  Check Client Autoprune");
-   ok(cr.JobRetention == cr2.JobRetention,  "  Check Client JobRetention");   
+   ok(cr.JobRetention == cr2.JobRetention,  "  Check Client JobRetention");
    ok(cr.FileRetention == cr2.FileRetention,"  Check Client FileRetention");
 }
 
@@ -239,7 +227,7 @@ int main (int argc, char *argv[])
    pid = getpid();
 
    Pmsg0(0, "Starting cats_test tool" PLINE);
-   
+
    my_name_is(argc, argv, "");
    init_msg(NULL, NULL);
 
@@ -346,7 +334,7 @@ int main (int argc, char *argv[])
    Pmsg1(0, PLINE "Test DB connection \"%s\"" PLINE, db_name);
 
    if (full_test) {
-      db = db_init_database(jcr /* JCR */, 
+      db = db_init_database(jcr /* JCR */,
                    NULL /* dbi driver */,
                    db_name, db_user, db_password, db_address, db_port + 100,
                    NULL /* db_socket */,
@@ -360,7 +348,7 @@ int main (int argc, char *argv[])
       db_close_database(jcr, db);
    }
 
-   db = db_init_database(jcr /* JCR */, 
+   db = db_init_database(jcr /* JCR */,
                 NULL /* dbi driver */,
                 db_name, db_user, db_password, db_address, db_port,
                 NULL /* db_socket */,
@@ -386,7 +374,7 @@ int main (int argc, char *argv[])
    /* Check if the SQL library is thread-safe */
    //db_check_backend_thread_safe();
    ok(check_tables_version(jcr, db), "Check table version");
-   ok(db_sql_query(db, "SELECT VersionId FROM Version", 
+   ok(db_sql_query(db, "SELECT VersionId FROM Version",
                    db_int_handler, &j), "SELECT VersionId");
 
    ok(UPDATE_DB(jcr, db, (char*)"UPDATE Version SET VersionId = 1"),
@@ -399,15 +387,15 @@ int main (int argc, char *argv[])
       ok(db_check_max_connections(jcr, db, 1), "Test min Max Connexion");
       nok(db_check_max_connections(jcr, db, 10000), "Test max Max Connexion");
    }
-   
+
    ok(db_open_batch_connexion(jcr, db), "Opening batch connection");
    db_close_database(jcr, jcr->db_batch);
    jcr->db_batch = NULL;
 
    /* ---------------------------------------------------------------- */
-   
+
    uint32_t storageid=0;
-   ok(db_sql_query(db, "SELECT MIN(StorageId) FROM Storage", 
+   ok(db_sql_query(db, "SELECT MIN(StorageId) FROM Storage",
                    db_int_handler, &storageid), "Get StorageId");
    ok(storageid > 0, "Check StorageId");
    if (!storageid) {
@@ -419,7 +407,7 @@ int main (int argc, char *argv[])
    Pmsg0(0, PLINE "Doing Basic SQL tests" PLINE);
    ok(db_sql_query(db, "SELECT 1,2,3,4,5", count_col, &j), "Count 5 rows");
    ok(j == 5, "Check number of columns");
-   ok(db_sql_query(db, "SELECT 1,2,3,4,5,'a','b','c','d','e'", 
+   ok(db_sql_query(db, "SELECT 1,2,3,4,5,'a','b','c','d','e'",
                    count_col, &j), "Count 10 rows");
    ok(j == 10, "Check number of columns");
 
@@ -427,7 +415,7 @@ int main (int argc, char *argv[])
    ok(db_sql_query(db, "SELECT 2", db_int_handler, &j), "Good SELECT query");
    ok(db_sql_query(db, "SELECT 1 FROM Media WHERE VolumeName='missing'",
                    db_int_handler, &j), "Good empty SELECT query");
-   
+
    db_int64_ctx i64;
    i64.value = 0; i64.count = 0;
    ok(db_sql_query(db, "SELECT 1",db_int64_handler, &i64),"db_int64_handler");
@@ -466,10 +454,10 @@ int main (int argc, char *argv[])
    Mmsg(buf, "DELETE FROM %s", temp);
    ok(DELETE_DB(jcr, db, buf), "DELETE query");
    nok(DELETE_DB(jcr, db, buf), "Empty DELETE query"); /* TODO bug ? */
-      
+
    Mmsg(buf, "DELETE FROM aaa%s", temp);
    ok(DELETE_DB(jcr, db, buf), "Bad DELETE query"); /* TODO bug ? */
-   
+
    Mmsg(buf, "DROP TABLE %s", temp);
    ok(QUERY_DB(jcr, db, buf), "DROP query");
    nok(QUERY_DB(jcr, db, buf), "Empty DROP query");
@@ -483,7 +471,7 @@ int main (int argc, char *argv[])
    ok(db_sql_query(db, buf, NULL, NULL), "Inserting quoted string");
 
    /* ---------------------------------------------------------------- */
-   Pmsg0(0, PLINE "Doing Job tests" PLINE);   
+   Pmsg0(0, PLINE "Doing Job tests" PLINE);
 
    JOB_DBR jr, jr2;
    memset(&jr, 0, sizeof(jr));
@@ -491,7 +479,7 @@ int main (int argc, char *argv[])
    jr.JobId = 1;
    ok(db_get_job_record(jcr, db, &jr), "Get Job record for JobId=1");
    ok(jr.JobFiles > 10, "Check number of files");
-   
+
    jr.JobId = (JobId_t)pid;
    Mmsg(buf, "%s-%lld", jr.Job, pid);
    strcpy(jr.Job, buf);
@@ -566,7 +554,7 @@ int main (int argc, char *argv[])
 
    ok(db_get_client_record(jcr, db, &cr2), "Search client by ClientId");
    cmp_client(cr, cr2);
-   
+
    Pmsg0(0, "Search client by Name\n");
    memset(&cr2, 0, sizeof(cr2));
    strcpy(cr2.Name, cr.Name);
@@ -603,7 +591,7 @@ int main (int argc, char *argv[])
    POOL_DBR pr, pr2;
    memset(&pr, 0, sizeof(pr));
    memset(&pr2, 0, sizeof(pr2));
-   
+
    bsnprintf(pr.Name, sizeof(pr.Name), "pool-%lld", pid);
    pr.MaxVols = 10;
    pr.UseOnce = 0;
@@ -622,10 +610,10 @@ int main (int argc, char *argv[])
    pr.RecyclePoolId = 0;
    pr.ScratchPoolId = 0;
    pr.ActionOnPurge = 1;
-   
+
    ok(db_create_pool_record(jcr, db, &pr), "db_create_pool_record()");
    ok(pr.PoolId > 0, "Check PoolId");
-   
+
    pr2.PoolId = pr.PoolId;
    pr.PoolId = 0;
 
@@ -661,11 +649,11 @@ int main (int argc, char *argv[])
 
    /* ---------------------------------------------------------------- */
    Pmsg0(0, PLINE "Doing Media tests" PLINE);
-   
+
    MEDIA_DBR mr, mr2;
    memset(&mr, 0, sizeof(mr));
    memset(&mr2, 0, sizeof(mr2));
-   
+
    bsnprintf(mr.VolumeName, sizeof(mr.VolumeName), "media-%lld", pid);
    bsnprintf(mr.MediaType, sizeof(mr.MediaType), "type-%lld", pid);
 
@@ -700,7 +688,7 @@ int main (int argc, char *argv[])
 
    /* ---------------------------------------------------------------- */
    Pmsg0(0, PLINE "Doing ... tests" PLINE);
-   
+
    db_close_database(jcr, db);
    report();
    free_pool_memory(buf);