コード例 #1
0
ファイル: h5test.c プロジェクト: zlongshen/hdf5
/*-------------------------------------------------------------------------
 * Function:  h5_cleanup
 *
 * Purpose:  Cleanup temporary test files.
 *    base_name contains the list of test file names.
 *    The file access property list is also closed.
 *
 * Return:  Non-zero if cleanup actions were performed; zero otherwise.
 *
 * Programmer:  Albert Cheng
 *              May 28, 1998
 *
 *-------------------------------------------------------------------------
 */
int
h5_cleanup(const char *base_name[], hid_t fapl)
{
    int    retval = 0;

    if(GetTestCleanup()) {
        /* Clean up files in base_name, and the FAPL */
        h5_clean_files(base_name, fapl);

        retval = 1;
    } /* end if */

    /* Restore the original error reporting routine */
    h5_restore_err();

    return retval;
} /* end h5_cleanup() */
コード例 #2
0
ファイル: perf_meta.c プロジェクト: Starlink/hdf5
/*-------------------------------------------------------------------------
 * Function:	main
 *
 * Purpose:	Tests
 *
 * Return:	Success:	exit(0)
 *
 *		Failure:	exit(1)
 *
 * Programmer:	Raymond Lu
 *		Friday, Oct 3, 2003
 *
 * Modifications:
 *
 *-------------------------------------------------------------------------
 */
int
main(int argc, char **argv)
{
#ifdef H5_HAVE_PARALLEL
    int mpi_size, mpi_rank;				/* mpi variables */
#endif /*H5_HAVE_PARALLEL*/

    if(parse_options(argc, argv) != 0) {
       usage();
       return 0;
    }

#ifdef H5_HAVE_PARALLEL
    if(facc_type == FACC_MPIO) {
        MPI_Init(&argc, &argv);
        MPI_Comm_size(MPI_COMM_WORLD, &mpi_size);
        MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank);
    }
#endif /*H5_HAVE_PARALLEL*/

#ifdef H5_HAVE_PARALLEL
    if (facc_type == FACC_DEFAULT || (facc_type != FACC_DEFAULT && MAINPROCESS))
#endif /*H5_HAVE_PARALLEL*/
        fprintf(stderr, "\t\tPerformance result of metadata for datasets and attributes\n\n");

    fapl = H5Pcreate (H5P_FILE_ACCESS);
#ifdef H5_HAVE_PARALLEL
    if(facc_type == FACC_MPIO)
        H5Pset_fapl_mpio(fapl, MPI_COMM_WORLD, MPI_INFO_NULL);
#endif /*H5_HAVE_PARALLEL*/

    nerrors += create_dspace() < 0 	?1:0;

    if((RUN_TEST & TEST_1) || !RUN_TEST)
        nerrors += create_attrs_1() < 0 	?1:0;
    if((RUN_TEST & TEST_2) || !RUN_TEST)
        nerrors += create_attrs_2() < 0 	?1:0;
    if(((RUN_TEST & TEST_3) || !RUN_TEST) && BATCH_ATTRS && NUM_ATTRS)
        nerrors += create_attrs_3() < 0 	?1:0;

    if (H5Sclose(space) < 0) goto error;
    if (H5Sclose(small_space) < 0) goto error;

    h5_clean_files(FILENAME, fapl);

#ifdef H5_HAVE_PARALLEL
    if(facc_type == FACC_MPIO)
        /* MPI_Finalize must be called AFTER H5close which may use MPI calls */
        MPI_Finalize();
#endif /*H5_HAVE_PARALLEL*/

    if (nerrors) goto error;
#ifdef H5_HAVE_PARALLEL
    if (facc_type != FACC_DEFAULT && MAINPROCESS)
#endif /*H5_HAVE_PARALLEL*/
        printf("All metadata performance tests passed.\n");

    return 0;

 error:
    nerrors = MAX(1, nerrors);
#ifdef H5_HAVE_PARALLEL
    if (facc_type != FACC_DEFAULT && MAINPROCESS)
#endif /*H5_HAVE_PARALLEL*/
        printf("***** %d PERFORMANCE TEST%s FAILED! *****\n",
	   nerrors, 1 == nerrors ? "" : "S");

    return 1;
}
コード例 #3
0
ファイル: error_test.c プロジェクト: adasworks/hdf5
/*-------------------------------------------------------------------------
 * Function:	main
 *
 * Purpose:	Test error API.
 *
 * Programmer:	Raymond Lu
 *		July 10, 2003
 *
 *-------------------------------------------------------------------------
 */
int
main(void)
{
    hid_t		file, fapl;
    hid_t               estack_id;
    char		filename[1024];
    const char          *FUNC_main = "main";

    HDfprintf(stderr, "   This program tests the Error API.  There're supposed to be some error messages\n");

    /* Initialize errors */
    if(init_error() < 0)
        TEST_ERROR;

    fapl = h5_fileaccess();

    h5_fixname(FILENAME[0], fapl, filename, sizeof filename);
    if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0)
	TEST_ERROR;

    /* Test error stack */
    if(error_stack() < 0) {
        /* Push an error onto error stack */
        if(H5Epush(ERR_STACK, __FILE__, FUNC_main, __LINE__, ERR_CLS, ERR_MAJ_TEST, ERR_MIN_ERRSTACK,
                "Error stack test failed") < 0) TEST_ERROR;

        /* Delete an error from the top of error stack */
        H5Epop(ERR_STACK, 1);

        /* Make sure we can use other class's major or minor errors. */
        H5Epush(ERR_STACK, __FILE__, FUNC_main, __LINE__, ERR_CLS2, ERR_MAJ_TEST, ERR_MIN_ERRSTACK,
                "Error stack test failed");

        /* Print out the errors on stack */
        dump_error(ERR_STACK);

        /* Empty error stack */
        H5Eclear2(ERR_STACK);

        /* Close error stack */
        H5Eclose_stack(ERR_STACK);
    } /* end if */

    /* Test error API */
    if(test_error(file) < 0) {
        H5Epush(H5E_DEFAULT, __FILE__, FUNC_main, __LINE__, ERR_CLS, ERR_MAJ_TEST, ERR_MIN_SUBROUTINE,
                "Error test failed, %s", "it's wrong");
        estack_id = H5Eget_current_stack();
        H5Eprint2(estack_id, stderr);
        H5Eclose_stack(estack_id);
    } /* end if */

    /* Test pushing a very long error description */
    if(test_long_desc() < 0) TEST_ERROR;

    /* Test creating a new error stack */
    if(test_create() < 0) TEST_ERROR;

    /* Test copying a new error stack */
    if(test_copy() < 0) TEST_ERROR;

    if(H5Fclose(file) < 0) TEST_ERROR;

    /* Close error information */
    if(close_error() < 0)
        TEST_ERROR;

    /* Test error message during data reading when filter isn't registered 
     * Use default FAPL to avoid some VFD drivers by the check-vfd test because
     * the test file was pre-generated. */
    h5_fixname(DATAFILE, H5P_DEFAULT, filename, sizeof filename);
    if(test_filter_error(filename) < 0)
        TEST_ERROR;

    h5_clean_files(FILENAME, fapl);

    HDfprintf(stderr, "\nAll error API tests passed.\n");
    return 0;

error:
    HDfprintf(stderr, "\n***** ERROR TEST FAILED (real problem)! *****\n");
    return 1;
}