IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 9736


Ignore:
Timestamp:
Oct 24, 2006, 2:16:33 PM (20 years ago)
Author:
drobbin
Message:

Updated psMetadataCopy- an error is now skipped and allows the rest of a metadata to be copied. Added tests for psMetadataConfig. Added error check in MetaConfigPrint for NULL file input.

Location:
trunk/psLib
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/types/parse_gcov-out.c

    r9084 r9736  
    7676    N++;
    7777
    78     average = average / N;
     78    average = average / sum;
    7979
    8080    output = fopen("Coverage-Report.txt", "w");
     
    8989}
    9090
    91 void parseINT(const char *nums)
     91void parseINT(const char *nums, float percent)
    9292{
    9393    sum += atoi(nums);
     94    average += (float)((int)(percent * atoi(nums)));
    9495}
    9596
    96 void parseDBL(const char *nums)
     97float parseDBL(const char *nums)
    9798{
    9899    char temp[7];
    99100    int i = 0;
    100101    int j = 9;
     102    float out = 0.0;
    101103    while (nums[j] != '%') {
    102104        temp[i] = nums[j];
     
    104106        j++;
    105107    }
    106     average += (float)atof(temp);
     108    //    average += (float)atof(temp);
     109    out = (float)atof(temp);
     110    return out;
    107111}
    108112
     
    117121    strcat(outStr, out);
    118122    int i;
     123    float numLines = 0.0;
    119124    while ( fscanf(in, "%s", currentStr) != EOF) {
    120125        if ( strncmp(currentStr, searchStr, 99) == 0 ) {
     
    122127                if (i == 1) {
    123128                    fscanf(in, "%s", out);
    124                     parseDBL(out);
     129                    numLines = parseDBL(out);
    125130                    sprintf(currentStr, "%-16s", out);
    126131                } else if ( i == 3) {
    127132                    fscanf(in, "%s", out);
    128                     parseINT(out);
     133                    parseINT(out, numLines);
    129134                    sprintf(currentStr, "%s", out);
    130135                } else {
  • trunk/psLib/src/types/psMetadata.c

    r9720 r9736  
    1212 *  @author Ross Harman, MHPCC
    1313 *
    14  *  @version $Revision: 1.144 $ $Name: not supported by cvs2svn $
    15  *  @date $Date: 2006-10-24 01:15:47 $
     14 *  @version $Revision: 1.145 $ $Name: not supported by cvs2svn $
     15 *  @date $Date: 2006-10-25 00:16:33 $
    1616 *
    1717 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    425425        return NULL;
    426426    }
     427    bool errorOccurred = false;
    427428    bool outAlloced = false;
    428429    if (out ==  NULL) {
     
    447448            psErrorStackPrint(stderr, "Error copying %s (%s) in the metadata\n", inItem->name,
    448449                              inItem->comment);
    449             psFree(newItem);
    450             psFree(iter);
    451450            if (outAlloced) {
    452451                psFree(out);
     452                psFree(newItem);
     453                psFree(iter);
     454                return NULL;
     455            } else {
     456                errorOccurred = true;
    453457            }
    454             return NULL;
    455458        }
    456459        psFree(newItem);                // Drop reference
    457460    }
    458461    psFree(iter);
     462
     463    if (errorOccurred) {
     464        return NULL;
     465    }
     466
    459467    return out;
    460468}
    461 
    462469
    463470// may need to extend this to change the keyname in the copy
  • trunk/psLib/src/types/psMetadata.h

    r9578 r9736  
    1111*  @author Ross Harman, MHPCC
    1212*
    13 *  @version $Revision: 1.91 $ $Name: not supported by cvs2svn $
    14 *  @date $Date: 2006-10-14 03:50:28 $
     13*  @version $Revision: 1.92 $ $Name: not supported by cvs2svn $
     14*  @date $Date: 2006-10-25 00:16:33 $
    1515*
    1616*  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    385385 *
    386386 *  Creates a new copy of all the psMetadataItems in the psMetadata collection, in, and
    387  *  returns them in out, or creates a new container if out is NULL.
     387 *  returns them in out, or creates a new container if out is NULL.  If an error occurs,
     388 *  NULL is returned but out may still have been updated if it is non-NULL.
    388389 *
    389390 *  @return psMetadata*:        the copy of the psMetadata container.
  • trunk/psLib/src/types/psMetadataConfig.c

    r9730 r9736  
    1010*  @author Eric Van Alst, MHPCC
    1111*
    12 *  @version $Revision: 1.96 $ $Name: not supported by cvs2svn $
    13 *  @date $Date: 2006-10-24 22:52:56 $
     12*  @version $Revision: 1.97 $ $Name: not supported by cvs2svn $
     13*  @date $Date: 2006-10-25 00:16:33 $
    1414*
    1515*  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    2020#include <ctype.h>
    2121#include <limits.h>
    22 #include <inttypes.h>
    2322#include <strings.h>
    2423#include <sys/mman.h>
    25 #include <sys/types.h>
    26 #include <sys/stat.h>
    2724#include <fcntl.h>
    2825#include <unistd.h>
    2926
    30 #include "psAbort.h"
    31 #include "psType.h"
    32 #include "psMemory.h"
    33 #include "psError.h"
    34 #include "psString.h"
    35 #include "psList.h"
    36 #include "psHash.h"
    37 #include "psVector.h"
    38 #include "psMetadata.h"
    3927#include "psMetadataConfig.h"
    4028#include "psAssert.h"
     29//#include <sys/types.h>
     30//#include <sys/stat.h>
     31//#include <inttypes.h>
     32//#include "psHash.h"
     33//#include "psMetadata.h"
     34//#include "psAbort.h"
     35//#include "psType.h"
     36
     37//#include "psMemory.h"
     38//#include "psError.h"
     39//#include "psString.h"
     40//#include "psList.h"
     41//#include "psVector.h"
    4142
    4243
     
    11671168    if (!(fd = open(filename, O_RDONLY))) {
    11681169        // XXX really should return strerror() here
    1169         psError(PS_ERR_IO, true, _("Failed to open file '%s'. Check if it exists and it has the proper permissions."), filename);
     1170        psError(PS_ERR_IO, true,
     1171                _("Failed to open file '%s'. Check if it exists and it has the proper "
     1172                  "permissions."), filename);
    11701173        return NULL;
    11711174    }
     
    15621565    PS_ASSERT_PTR_NON_NULL(md, NULL);
    15631566    PS_ASSERT_PTR_NON_NULL(filename, NULL);
     1567    FILE *file;
     1568    if ( !(file = fopen(filename, "w")) ) {
     1569        psError(PS_ERR_IO, true,
     1570                "Failed to open specified file, %s\n", filename);
     1571        return false;
     1572    }
    15641573    psString fileString = NULL;
    15651574    fileString = psMetadataConfigFormat(md);
     
    15691578        return false;
    15701579    }
    1571     FILE *file;
    1572     if ( !(file = fopen(filename, "w")) ) {
    1573         psError(PS_ERR_IO, true,
    1574                 "Failed to open specified file, %s\n", filename);
    1575         psFree(fileString);
    1576         return false;
    1577     }
    15781580    fprintf(file, "%s", fileString);
    15791581    fclose(file);
     
    15861588{
    15871589    PS_ASSERT_PTR_NON_NULL(md, false);
     1590    PS_ASSERT_PTR_NON_NULL(stream, false);
     1591    if (fprintf(stream, "\n") <= 0) {
     1592        psError(PS_ERR_IO, false,
     1593                "Unable to write to specified file.");
     1594        return false;
     1595    }
    15881596
    15891597    psString str = psMetadataConfigFormat(md);
  • trunk/psLib/test/types/Makefile.am

    r9143 r9736  
    2929        tap_psBitSet_all \
    3030        tap_psList_all \
    31         tap_psLookupTable_all
     31        tap_psLookupTable_all \
     32        tap_psMetadataConfig_output \
     33        tap_psMetadataConfig_input
    3234
    3335if BUILD_TESTS
  • trunk/psLib/test/types/execute_tap

    r9143 r9736  
    1 make
     1make test
    22./tap_psArray_all
    33./tap_psListIterator
     
    1818./tap_psList_all
    1919./tap_psLookupTable_all
     20./tap_psMetadataConfig_output
     21./tap_psMetadataConfig_input
  • trunk/psLib/test/types/tap_psMetadata_copying.c

    r9720 r9736  
    2323int main(void)
    2424{
    25     plan_tests(34);
     25    plan_tests(35);
    2626
    2727    diag("psMetadataCopy and psMetadataItemCopy tests");
     
    5959        out = NULL;
    6060    }
    61     //Return NULL for attempt to copy item of unsupported data type
     61    //Return NULL for attempt to copy item of unsupported data type - NULL out metadata
     62    psMetadataItem *notype = NULL;
    6263    {
    6364        in = psMetadataAlloc();
    6465        psMetadataAddS32(in, PS_LIST_HEAD, "S32", 0, "", 1);
    65         psMetadataItem *notype = psMetadataGet(in, PS_LIST_HEAD);
    66         //        notype->type = PS_DATA_METADATA_MULTI + 1000;
     66        notype = psMetadataGet(in, PS_LIST_HEAD);
    6767        notype->type = -1;
    68         psFree(outTest);
    69         outTest = NULL;
     68        outTest = psMetadataCopy(out, in);
     69        ok( outTest == NULL,
     70            "psMetadataCopy:  return NULL for metadata with item of bad type.");
     71        psFree(out);
     72        out = NULL;
     73    }
     74    //Return NULL for attempt to copy item of unsupported data type - allocated out metadata
     75    {
     76        out = psMetadataAlloc();
     77        psMetadataAddS32(out, PS_LIST_TAIL, "S32", 0, "", 2);
    7078        outTest = psMetadataCopy(out, in);
    7179        ok( outTest == NULL,
    7280            "psMetadataCopy:  return NULL for metadata with item of bad type.");
    7381        notype->type = PS_DATA_S32;
     82        psFree(out);
     83        out = NULL;
    7484        psFree(in);
    7585        in = NULL;
    76         psFree(out);
    77         out = NULL;
    7886    }
    7987
Note: See TracChangeset for help on using the changeset viewer.