IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 5950


Ignore:
Timestamp:
Jan 6, 2006, 6:46:10 PM (21 years ago)
Author:
jhoblitt
Message:

fix tests to work with per table data
minor pslib 0.9.0 compatibility fixes

Location:
trunk/glueforge/templates/psdb
Files:
16 edited

Legend:

Unmodified
Added
Removed
  • trunk/glueforge/templates/psdb/alloc_c.tt

    r5907 r5950  
    99int main ()
    1010{
    11     [% indented(table.object_name, "*object") %];
     11[% FOREACH table = tables -%]
     12    {
     13        [% indented(table.object_name, "*object") %];
    1214
    13     object = [% table.object_name %]Alloc(
     15        object = [% table.object_name %]Alloc(
    1416[%- SET i = 0 -%]
    1517[%- FOREACH item = table.columns -%]
    16     [%- IF i == 0 -%][%- i = 1 -%][%- ELSE -%], [% END -%] [%- item.test -%]
     18        [%- IF i == 0 -%][%- i = 1 -%][%- ELSE -%], [% END -%] [%- item.test -%]
    1719[%- END -%]
    18 );
     20    );
    1921
    20     if (!object) {
    21         exit(EXIT_FAILURE);
    22     }
     22        if (!object) {
     23            exit(EXIT_FAILURE);
     24        }
    2325
    2426[% FOREACH item = table.columns -%]
    2527[% IF item.type == "S32" or item.type == "F32" or item.type == "F64" or item.type == "BOOL" -%]
    26     if (!object->[% item.name %] == [% item.test %]) {
     28        if (!object->[% item.name %] == [% item.test %]) {
    2729[% ELSIF item.type == "STR" -%]
    28     if (strncmp(object->[% item.name %], [% item.test %], MAX_STRING_LENGTH)) {
     30        if (strncmp(object->[% item.name %], [% item.test %], MAX_STRING_LENGTH)) {
    2931[% END -%]
    30         psFree(object);
    31         exit(EXIT_FAILURE);
    32     }
     32            psFree(object);
     33            exit(EXIT_FAILURE);
     34        }
    3335[% END -%]
    3436
    35     psFree(object);
     37        psFree(object);
     38    }
    3639
     40[% END -%]
    3741    exit(EXIT_SUCCESS);
    3842}
  • trunk/glueforge/templates/psdb/cleanup_c.tt

    r5907 r5950  
    1212    }
    1313
    14     [% table.namespace %]Cleanup(dbh);
     14    [% pkg_namespace %]Cleanup(dbh);
    1515
    1616    exit(EXIT_SUCCESS);
  • trunk/glueforge/templates/psdb/createtable_c.tt

    r5907 r5950  
    55int main ()
    66{
    7     psDB            *dbh;
     7[% FOREACH table = tables -%]
     8    {
     9        psDB            *dbh;
    810
    9     dbh = psDBInit("localhost", "test", NULL, "test");
    10     if (!dbh) {
    11         exit(EXIT_FAILURE);
     11        dbh = psDBInit("localhost", "test", NULL, "test");
     12        if (!dbh) {
     13            exit(EXIT_FAILURE);
     14        }
     15
     16        if(![% table.namespace %]CreateTable(dbh)) {
     17            exit(EXIT_FAILURE);
     18        }
     19
     20        psDBCleanup(dbh);
    1221    }
    1322
    14     if(![% table.namespace %]CreateTable(dbh)) {
    15         exit(EXIT_FAILURE);
    16     }
    17 
    18     psDBCleanup(dbh);
    19 
     23[% END -%]
    2024    exit(EXIT_SUCCESS);
    2125}
  • trunk/glueforge/templates/psdb/dbcleanup_c.tt

    r5907 r5950  
    1111    }
    1212
     13[% FOREACH table = tables -%]
    1314    p_psDBRunQuery(dbh, "DROP TABLE IF EXISTS [% table.name %]");
     15[% END -%]
    1416
    1517    psDBCleanup(dbh);
  • trunk/glueforge/templates/psdb/dbsetup_c.tt

    r5907 r5950  
    1313
    1414    // remove the table if it already exists
     15[% FOREACH table = tables -%]
    1516    p_psDBRunQuery(dbh, "DROP TABLE IF EXISTS [% table.name %]");
    1617    [% table.namespace %]CreateTable(dbh);
    1718
     19[% END -%]
    1820    psDBCleanup(dbh);
    1921
  • trunk/glueforge/templates/psdb/droptable_c.tt

    r5907 r5950  
    55int main ()
    66{
    7     psDB            *dbh;
     7[% FOREACH table = tables -%]
     8    {
     9        psDB            *dbh;
    810
    9     dbh = psDBInit("localhost", "test", NULL, "test");
    10     if (!dbh) {
    11         exit(EXIT_FAILURE);
     11        dbh = psDBInit("localhost", "test", NULL, "test");
     12        if (!dbh) {
     13            exit(EXIT_FAILURE);
     14        }
     15
     16        if (![% table.namespace %]DropTable(dbh)) {
     17            exit(EXIT_FAILURE);
     18        }
     19
     20        psDBCleanup(dbh);
    1221    }
    1322
    14     if (![% table.namespace %]DropTable(dbh)) {
    15         exit(EXIT_FAILURE);
    16     }
    17 
    18     psDBCleanup(dbh);
    19 
     23[% END -%]
    2024    exit(EXIT_SUCCESS);
    2125}
  • trunk/glueforge/templates/psdb/init_c.tt

    r5907 r5950  
    77    psDB            *dbh;
    88
    9     dbh = [% table.namespace %]Init("localhost", "test", NULL, "test");
     9    dbh = [% pkg_namespace %]Init("localhost", "test", NULL, "test");
    1010    if (!dbh) {
    1111        exit(EXIT_FAILURE);
  • trunk/glueforge/templates/psdb/insert_c.tt

    r5907 r5950  
    77int main ()
    88{
    9     psDB            *dbh;
     9[% FOREACH table = tables -%]
     10    {
     11        psDB            *dbh;
    1012
    11     dbh = psDBInit("localhost", "test", NULL, "test");
    12     if (!dbh) {
    13         exit(EXIT_FAILURE);
    14     }
     13        dbh = psDBInit("localhost", "test", NULL, "test");
     14        if (!dbh) {
     15            exit(EXIT_FAILURE);
     16        }
    1517
    16     if (![% table.namespace %]Insert(dbh,
     18        if (![% table.namespace %]Insert(dbh,
    1719[%- SET i = 0 -%]
    1820[%- FOREACH item = table.columns -%]
     
    2022[%- END -%]
    2123)) {
    22         exit(EXIT_FAILURE);
     24            exit(EXIT_FAILURE);
     25        }
     26
     27        psDBCleanup(dbh);
    2328    }
    2429
    25     psDBCleanup(dbh);
    26 
     30[% END -%]
    2731    exit(EXIT_SUCCESS);
    2832}
  • trunk/glueforge/templates/psdb/insertfits_c.tt

    r5907 r5950  
    55int main ()
    66{
    7     psDB            *dbh;
    8     psFits          *fits;
     7[% FOREACH table = tables -%]
     8    {
     9        psDB            *dbh;
     10        psFits          *fits;
    911
    10     dbh = psDBInit("localhost", "test", NULL, "test");
    11     if (!dbh) {
    12         exit(EXIT_FAILURE);
     12        dbh = psDBInit("localhost", "test", NULL, "test");
     13        if (!dbh) {
     14            exit(EXIT_FAILURE);
     15        }
     16
     17        // open a temp
     18        fits = psFitsOpen("./blargh", "rw");
     19        if (!fits) {
     20            exit(EXIT_FAILURE);
     21        }
     22
     23        if (![% table.namespace %]InsertFits(dbh, fits)) {
     24            exit(EXIT_FAILURE);
     25        }
     26
     27        psFree(fits);
     28        psDBCleanup(dbh);
    1329    }
    1430
    15     // open a temp
    16     fits = psFitsAlloc("./blargh");
    17     if (!fits) {
    18         exit(EXIT_FAILURE);
    19     }
    20 
    21     if (![% table.namespace %]InsertFits(dbh, fits)) {
    22         exit(EXIT_FAILURE);
    23     }
    24 
    25     psFree(fits);
    26     psDBCleanup(dbh);
    27 
     31[% END -%]
    2832    exit(EXIT_SUCCESS);
    2933}
  • trunk/glueforge/templates/psdb/insertobject_c.tt

    r5907 r5950  
    77int main ()
    88{
    9     psDB            *dbh;
    10     [% indented(table.object_name, "*object") %];
     9[% FOREACH table = tables -%]
     10    {
     11        psDB            *dbh;
     12        [% indented(table.object_name, "*object") %];
    1113
    12     dbh = psDBInit("localhost", "test", NULL, "test");
    13     if (!dbh) {
    14         exit(EXIT_FAILURE);
    15     }
     14        dbh = psDBInit("localhost", "test", NULL, "test");
     15        if (!dbh) {
     16            exit(EXIT_FAILURE);
     17        }
    1618
    17     object = [% table.object_name %]Alloc(
     19        object = [% table.object_name %]Alloc(
    1820[%- SET i = 0 -%]
    1921[%- FOREACH item = table.columns -%]
     
    2123[%- END -%]
    2224);
    23     if (!object) {
    24         exit(EXIT_FAILURE);
     25        if (!object) {
     26            exit(EXIT_FAILURE);
     27        }
     28
     29        if (![% table.namespace %]InsertObject(dbh, object)) {
     30            exit(EXIT_FAILURE);
     31        }
     32
     33        psFree(object);
     34        psDBCleanup(dbh);
    2535    }
    2636
    27     if (![% table.namespace %]InsertObject(dbh, object)) {
    28         exit(EXIT_FAILURE);
    29     }
    30 
    31     psFree(object);
    32     psDBCleanup(dbh);
    33 
     37[% END -%]
    3438    exit(EXIT_SUCCESS);
    3539}
  • trunk/glueforge/templates/psdb/metadatafromobject_c.tt

    r5907 r5950  
    1010int main ()
    1111{
    12     psMetadata      *md;
    13     [% indented(table.object_name, "*object") %];
    14     bool            status;
     12[% FOREACH table = tables -%]
     13    {
     14        psMetadata      *md;
     15        [% indented(table.object_name, "*object") %];
     16        bool            status;
    1517
    16     object = [% table.object_name %]Alloc(
     18        object = [% table.object_name %]Alloc(
    1719[%- SET i = 0 -%]
    1820[%- FOREACH item = table.columns -%]
     
    2022[%- END -%]
    2123);
    22     if (!object) {
    23         exit(EXIT_FAILURE);
    24     }
     24        if (!object) {
     25            exit(EXIT_FAILURE);
     26        }
    2527
    26     md = [% table.namespace %]MetadataFromObject(object);
    27     if (!md) {
    28         exit(EXIT_FAILURE);
    29     }
     28        md = [% table.namespace %]MetadataFromObject(object);
     29        if (!md) {
     30            exit(EXIT_FAILURE);
     31        }
    3032
    31     psFree(object);
     33        psFree(object);
    3234
    3335[% FOREACH item = table.columns -%]
    3436[% IF item.type == "S32" or item.type == "F32" or item.type == "F64" -%]
    35     if (!psMetadataLookup[% item.type %](&status, md, "[% item.name %]") == [% item.test %]) {
     37        if (!psMetadataLookup[% item.type %](&status, md, "[% item.name %]") == [% item.test %]) {
    3638[% ELSIF item.type == "STR" -%]
    37     if (strncmp(psMetadataLookupPtr(&status, md, "[% item.name %]"), [% item.test %], MAX_STRING_LENGTH)) {
     39        if (strncmp(psMetadataLookupPtr(&status, md, "[% item.name %]"), [% item.test %], MAX_STRING_LENGTH)) {
    3840[% ELSIF item.type == "BOOL" -%]
    39     if (!psMetadataLookupBool(&status, md, "[% item.name %]") == [% item.test %]) {
     41        if (!psMetadataLookupBool(&status, md, "[% item.name %]") == [% item.test %]) {
    4042[% END -%]
    41         psFree(md);
    42         exit(EXIT_FAILURE);
    43     }
     43            psFree(md);
     44            exit(EXIT_FAILURE);
     45        }
    4446[% END -%]
    4547
    46     psFree(md);
     48        psFree(md);
     49    }
    4750
     51[% END -%]
    4852    exit(EXIT_SUCCESS);
    4953}
  • trunk/glueforge/templates/psdb/objectfrommetadata_c.tt

    r5907 r5950  
    1010int main ()
    1111{
    12     psMetadata      *md;
    13     [% indented(table.object_name, "*object") %];
     12[% FOREACH table = tables -%]
     13    {
     14        psMetadata      *md;
     15        [% indented(table.object_name, "*object") %];
    1416
    15     md = psMetadataAlloc();
     17        md = psMetadataAlloc();
    1618[% FOREACH item = table.columns -%]
    1719[% IF item.type == "S32" or item.type == "F32" or item.type == "F64" -%]
    18     if (!psMetadataAdd[% item.type %](md, PS_LIST_TAIL, "[% item.name %]", NULL, [% item.test %])) {
     20        if (!psMetadataAdd[% item.type %](md, PS_LIST_TAIL, "[% item.name %]", 0, NULL, [% item.test %])) {
    1921[% ELSIF item.type == "STR" -%]
    20     if (!psMetadataAddStr(md, PS_LIST_TAIL, "[% item.name %]", NULL, [% item.test %])) {
     22        if (!psMetadataAddStr(md, PS_LIST_TAIL, "[% item.name %]", 0, NULL, [% item.test %])) {
    2123[% ELSIF item.type == "BOOL" -%]
    22     if (!psMetadataAdd(md, PS_LIST_TAIL, "[% item.name %]", PS_DATA_BOOL, NULL, [% item.test %])) {
     24        if (!psMetadataAdd(md, PS_LIST_TAIL, "[% item.name %]", PS_DATA_BOOL, NULL, [% item.test %])) {
    2325[% END -%]
    24         psFree(md);
    25         exit(EXIT_FAILURE);
    26     }
     26            psFree(md);
     27            exit(EXIT_FAILURE);
     28        }
    2729[% END -%]
    2830
    29     object = [% table.namespace %]ObjectFromMetadata(md);
    30     if (!object) {
     31        object = [% table.namespace %]ObjectFromMetadata(md);
     32        if (!object) {
     33            psFree(md);
     34            exit(EXIT_FAILURE);
     35        }
     36
    3137        psFree(md);
    32         exit(EXIT_FAILURE);
    33     }
    34 
    35     psFree(md);
    3638
    3739[% FOREACH item = table.columns -%]
    3840[% IF item.type == "S32" or item.type == "F32" or item.type == "F64" or item.type == "BOOL" -%]
    39     if (!object->[% item.name %] == [% item.test %]) {
     41        if (!object->[% item.name %] == [% item.test %]) {
    4042[% ELSIF item.type == "STR" -%]
    41     if (strncmp(object->[% item.name %], [% item.test %], MAX_STRING_LENGTH)) {
     43        if (strncmp(object->[% item.name %], [% item.test %], MAX_STRING_LENGTH)) {
    4244[% END -%]
    43         psFree(object);
    44         exit(EXIT_FAILURE);
    45     }
     45            psFree(object);
     46            exit(EXIT_FAILURE);
     47        }
    4648[% END -%]
    4749
    48     psFree(object);
     50        psFree(object);
     51    }
    4952
     53[% END -%]
    5054    exit(EXIT_SUCCESS);
    5155}
  • trunk/glueforge/templates/psdb/pop_c.tt

    r5907 r5950  
    77int main ()
    88{
    9     psDB            *dbh;
     9[% FOREACH table = tables -%]
     10    {
     11        psDB            *dbh;
    1012[% FOREACH item = table.columns -%]
    1113[% IF item.type == "STR" -%]
    12     [% indented("char", "$item.name[256]") %];
     14        [% indented("char", "$item.name[256]") %];
    1315[% ELSE-%]
    14     [% indented("$item.ctype", "$item.name") %];
     16        [% indented("$item.ctype", "$item.name") %];
    1517[% END -%]
    1618[% END -%]
    1719
    18     dbh = psDBInit("localhost", "test", NULL, "test");
    19     if (!dbh) {
    20         exit(EXIT_FAILURE);
    21     }
     20        dbh = psDBInit("localhost", "test", NULL, "test");
     21        if (!dbh) {
     22            exit(EXIT_FAILURE);
     23        }
    2224
    23     if (![% table.namespace %]Pop(dbh,
     25        if (![% table.namespace %]Pop(dbh,
    2426[%- SET i = 0 -%]
    2527[% FOREACH item = table.columns -%]
     
    3133[% END -%]
    3234[% END %])) {
    33         exit(EXIT_FAILURE);
     35            exit(EXIT_FAILURE);
     36        }
     37
     38        psDBCleanup(dbh);
    3439    }
    3540
    36     psDBCleanup(dbh);
    37 
     41[% END -%]
    3842    exit(EXIT_SUCCESS);
    3943}
  • trunk/glueforge/templates/psdb/popfits_c.tt

    r5907 r5950  
    55int main ()
    66{
    7     psDB            *dbh;
    8     psFits          *fits;
     7[% FOREACH table = tables -%]
     8    {
     9        psDB            *dbh;
     10        psFits          *fits;
    911
    10     dbh = psDBInit("localhost", "test", NULL, "test");
    11     if (!dbh) {
    12         exit(EXIT_FAILURE);
     12        dbh = psDBInit("localhost", "test", NULL, "test");
     13        if (!dbh) {
     14            exit(EXIT_FAILURE);
     15        }
     16
     17        // allocate a temp
     18        fits = psFitsOpen("./blargh", "rw");
     19        if (!fits) {
     20            exit(EXIT_FAILURE);
     21        }
     22
     23        if (![% table.namespace %]PopFits(dbh, fits, 1)) {
     24            exit(EXIT_FAILURE);
     25        }
     26
     27        psFree(fits);
     28        psDBCleanup(dbh);
    1329    }
    1430
    15     // allocate a temp
    16     fits = psFitsAlloc("./blargh");
    17     if (!fits) {
    18         exit(EXIT_FAILURE);
    19     }
    20 
    21     if (![% table.namespace %]PopFits(dbh, fits, 1)) {
    22         exit(EXIT_FAILURE);
    23     }
    24 
    25     psFree(fits);
    26     psDBCleanup(dbh);
    27 
     31[% END -%]
    2832    exit(EXIT_SUCCESS);
    2933}
  • trunk/glueforge/templates/psdb/popobject_c.tt

    r5907 r5950  
    77int main ()
    88{
    9     psDB            *dbh;
    10     [% indented(table.object_name, "*object") %];
     9[% FOREACH table = tables -%]
     10    {
     11        psDB            *dbh;
     12        [% indented(table.object_name, "*object") %];
    1113
    12     dbh = psDBInit("localhost", "test", NULL, "test");
    13     if (!dbh) {
    14         exit(EXIT_FAILURE);
     14        dbh = psDBInit("localhost", "test", NULL, "test");
     15        if (!dbh) {
     16            exit(EXIT_FAILURE);
     17        }
     18
     19        object = [% table.namespace %]PopObject(dbh);
     20        if (!object) {
     21            exit(EXIT_FAILURE);
     22        }
     23
     24        psFree(object);
     25        psDBCleanup(dbh);
    1526    }
    1627
    17     object = [% table.namespace %]PopObject(dbh);
    18     if (!object) {
    19         exit(EXIT_FAILURE);
    20     }
    21 
    22     psFree(object);
    23     psDBCleanup(dbh);
    24 
     28[% END -%]
    2529    exit(EXIT_SUCCESS);
    2630}
  • trunk/glueforge/templates/psdb/selectrowsfits_c.tt

    r5907 r5950  
    55int main ()
    66{
    7     psDB            *dbh;
    8     psFits          *fits;
     7[% FOREACH table = tables -%]
     8    {
     9        psDB            *dbh;
     10        psFits          *fits;
    911
    10     dbh = psDBInit("localhost", "test", NULL, "test");
    11     if (!dbh) {
    12         exit(EXIT_FAILURE);
     12        dbh = psDBInit("localhost", "test", NULL, "test");
     13        if (!dbh) {
     14            exit(EXIT_FAILURE);
     15        }
     16
     17        // FIXME: open a temp file and pass it as a FD
     18        fits = psFitsOpen("./blargh", "rw");
     19        if (!fits) {
     20            exit(EXIT_FAILURE);
     21        }
     22
     23        if (![% table.namespace %]SelectRowsFits(dbh, fits, NULL, 1)) {
     24            exit(EXIT_FAILURE);
     25        }
     26
     27        psFree(fits);
     28        psDBCleanup(dbh);
    1329    }
    1430
    15     // FIXME: open a temp file and pass it as a FD
    16     fits = psFitsAlloc("./blargh");
    17     if (!fits) {
    18         exit(EXIT_FAILURE);
    19     }
    20 
    21     if (![% table.namespace %]SelectRowsFits(dbh, fits, NULL, 1)) {
    22         exit(EXIT_FAILURE);
    23     }
    24 
    25     psFree(fits);
    26     psDBCleanup(dbh);
    27 
     31[% END -%]
    2832    exit(EXIT_SUCCESS);
    2933}
Note: See TracChangeset for help on using the changeset viewer.