/** @file  tst_psTime_04.c
 *
 *  @brief Test driver for psTime functions
 *
 *  This test driver contains the following tests for psTime:
 *      Test A - Initialize time
 *      Test B - Attempt to open non-existant time config file
 *      Test C - Attempt to open non-existant time data files
 *      Test D - Attempt to read incorrect number of files
 *      Test E - Attempt to read incorrect number of from values
 *      Test F - Attempt to read data file with typo in number
 *      Test G - Free data
 *
 *  @author  Ross Harman, MHPCC
 *  @author  Eric Van Alst, MHPCC
 *
 *  @version $Revision: 1.4 $  $Name: not supported by cvs2svn $
 *  @date  $Date: 2005-10-01 02:22:20 $
 *
 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
 *
 */
#include "config.h"

#include "pslib_strict.h"
#include "psTest.h"

static psS32 testTimeInit1(void);
static psS32 testTimeInit2(void);
static psS32 testTimeInit3(void);
static psS32 testTimeInit4(void);
static psS32 testTimeInit5(void);
static psS32 testTimeInit6(void);
static psS32 testTimer1(void);

testDescription tests[] = {
                              {testTimeInit1,-1,"p_psTimeInit",0,false},
                              {testTimeInit2,-2,"p_psTimeInit",0,false},
                              {testTimeInit3,-3,"p_psTimeInit",0,false},
                              {testTimeInit4,-4,"p_psTimeInit",0,false},
                              {testTimeInit5,-5,"p_psTimeInit",0,false},
                              {testTimeInit6,-6,"p_psTimeInit",0,false},
                              {testTimer1,-7,"psTimer",0,false},
                              {NULL}
                          };

psS32 main(psS32 argc, char* argv[])
{
    if(!runTestSuite(stderr,"psTime",tests,argc,argv)) {
        return 1;
    }

    return 0;
}

psS32 testTimeInit1(void)
{
    // Test A - Initialize time
    psLibInit("pslib.config");
    psLibFinalize();

    return 0;
}

psS32 testTimeInit2(void)
{
    // Test B - Attempt to open non-existant time config file
    psLibInit("zzz");

    return 0;
}

psS32 testTimeInit3(void)
{
    // Test C - Attempt to open non-existant time data files
    psLibInit("test.psTime.config1");
    psLibFinalize();

    return 0;
}

psS32 testTimeInit4(void)
{
    // Test D - Attempt to read incorrect number of files
    psLibInit("test.psTime.config2");
    psLibFinalize();

    return 0;
}

psS32 testTimeInit5(void)
{
    // Test E - Attempt to read incorrect number of from values
    psLibInit("test.psTime.config3");
    psLibFinalize();

    return 0;
}

psS32 testTimeInit6(void)
{
    // Test F - Attempt to read data file with typo in number
    psLibInit("test.psTime.config4");
    psLibFinalize();

    return 0;
}

psS32 testTimer1(void)
{
    psF64 testTime = 0.0;
    psF64 testTime2 = 0.0;
    psF64 testTime3 = 0.0;

    if ( !psTimerStart("newTime") ) {
        printf("TimerStart Failed\n");
        return 1;
    }
    testTime = psTimerMark("newTime");
    if (testTime == 0.0) {
        printf("TimerMark Failed\n");
        return 2;
    }
    testTime2 = psTimerClear("newTime");
    if (testTime2 == 0.0) {
        printf("TimerClear Failed\n");
        return 3;
    }
    psTimerStart("newTime");
    testTime3 = psTimerStop();
    if (testTime3 == 0.0) {
        printf("TimerStop Failed\n");
        return 4;
    }
    return 0;
}

