示例#1
0
/*-------------------------------------------------------------------------
 * Function:	main
 *
 * Purpose:	
 *
 * Return:	Success:	
 *
 *		Failure:	
 *
 * Programmer:	Robb Matzke
 *              Tuesday, February  9, 1999
 *
 * Modifications:
 *    Eric Brugger, Fri Apr 14 09:30:47 PDT 2000
 *    I modified the routine to not perform some tests that are not valid
 *    when using the PDB driver.  There was already code to not do those
 *    tests when using the pdb driver but it wasn't quite correct.
 *
 *-------------------------------------------------------------------------
 */
int
main(int argc, char *argv[])
{
    DBfile		*dbfile;
    int			i, nerrors=0,  driver=DB_PDB;
    char		*filename="sami.pdb";
    
    for (i=1; i<argc; i++) {
	if (!strcmp(argv[i], "DB_PDB")) {
	    driver = DB_PDB;
	    filename = "sami.pdb";
	} else if (!strcmp(argv[i], "DB_HDF5")) {
	    driver = DB_HDF5;
	    filename = "sami.h5";
	} else if (!strcmp(argv[i], "DB_LOCAL")) {
	    arch_g = DB_LOCAL;
	} else if (!strcmp(argv[i], "DB_SUN3")) {
	    arch_g = DB_SUN3;
	} else if (!strcmp(argv[i], "DB_SUN4")) {
	    arch_g = DB_SUN4;
	} else if (!strcmp(argv[i], "DB_SGI")) {
	    arch_g = DB_SGI;
	} else if (!strcmp(argv[i], "DB_RS6000")) {
	    arch_g = DB_RS6000;
	} else if (!strcmp(argv[i], "DB_CRAY")) {
	    arch_g = DB_CRAY;
	} else {
	    fprintf(stderr, "%s: ignored argument `%s'\n", argv[0], argv[i]);
	}
    }
    
    
    /* turn of deprecate warnings */
    DBSetDeprecateWarnings(0);

    /*
     * Create a new file (clobbering any old file), write some variables to
     * the file, then read them and compare with what was written.
     */
    puts("=== Creating file ===");
    if (NULL==(dbfile=DBCreate(filename, DB_CLOBBER, arch_g,
			       "testing SAMI HDF5 silo driver", driver))) {
	puts("DBCreate() failed");
	nerrors++;
    }

    /* Write the first time, creating variables */
    nerrors += test_write_all(dbfile);
    nerrors += test_read_all(dbfile);
    
    nerrors += test_get_all(dbfile);
    nerrors += test_inqvar(dbfile);

    /* Write a second time, writing new values to existing variables */
    nerrors += test_write_all(dbfile);
    nerrors += test_read_all(dbfile);

    /* Rewrite with different memory data type and verify results */
    if (DB_PDB != driver)
    {
        nerrors += test_type_conv(dbfile);
    }

    /*
     * Do some illegal things to make sure they fail. Make sure we can still
     * read data.
     */
    if (DB_PDB != driver)
    {
        nerrors += test_write_bad(dbfile);
        nerrors += test_read_all(dbfile);
    }
    
    if (DBClose(dbfile)<0) {
	puts("DBClose() failed");
	nerrors++;
    }

    /* Open the file for read only and read all variables */
    puts("=== Opening for read-only ===");
    if (NULL==(dbfile=DBOpen(filename, DB_UNKNOWN, DB_READ))) {
	puts("DBOpen() failed for read-only access");
	nerrors++;
    }
    nerrors += test_read_all(dbfile);
    if (DBClose(dbfile)<0) {
	puts("DBClose() failed");
	nerrors++;
    }
    
    /* Open the file for read-write and test slicing */
    puts("=== Opening for read-write ===");
    if (NULL==(dbfile=DBOpen(filename, driver, DB_APPEND))) {
	puts("DBOpen() failed for read-write access");
	nerrors++;
    }
    
    nerrors += test_read_all(dbfile);
    nerrors += test_write_slice(dbfile);
    nerrors += test_read_all(dbfile);
    nerrors += test_read_slice(dbfile);
    nerrors += test_dirs(dbfile);
    nerrors += test_curve(dbfile);
    nerrors += test_quadmesh(dbfile);
    nerrors += test_ucdmesh(dbfile);

    if (DBClose(dbfile)<0) {
	puts("DBClose() failed");
	nerrors++;
    }

    if (nerrors) {
	printf("*** %d error%s detected ***\n", nerrors, 1==nerrors?"":"s");
    } else {
	puts("All sami tests passed.");
    }
    return nerrors?1:0;
}
示例#2
0
const Directories& dirs() {
    static const Directories dirs = test_dirs();
    return dirs;
}