int main(int argc, char *argv[]) { struct xmi_archive *archive = NULL; int i,j; //init test g_assert(test_init() == 1); //download file g_assert(test_download_file(TEST_XMSA_URL_1) == 1); //read the file g_assert(xmi_read_archive_xml(TEST_XMSA_1, &archive) == 1); //some testing of the input and output for (i = 0 ; i <= archive->nsteps1 ; i++) { for (j = 0 ; j <= archive->nsteps2 ; j++) { struct xmi_output *output_copy = NULL; xmi_copy_output(archive->output[i][j], &output_copy); g_assert(xmi_validate_input(output_copy->input) == 0); g_assert(xmi_compare_input(archive->input[i][j], output_copy->input) == 0); xmi_free_output(output_copy); } } xmi_free_archive(archive); //download file g_assert(test_download_file(TEST_XMSA_URL_2) == 1); //read the file g_assert(xmi_read_archive_xml(TEST_XMSA_2, &archive) == 1); //some testing of the input and output for (i = 0 ; i <= archive->nsteps1 ; i++) { for (j = 0 ; j <= archive->nsteps2 ; j++) { struct xmi_output *output_copy = NULL; xmi_copy_output(archive->output[i][j], &output_copy); g_assert(xmi_validate_input(output_copy->input) == 0); g_assert(xmi_compare_input(archive->input[i][j], output_copy->input) == 0); xmi_free_output(output_copy); } } xmi_free_archive(archive); return 0; }
int main(int argc, char *argv[]) { char *xmimsim_hdf5_solid_angles = "xmimsim-solid-angles.h5"; xmi_input *input; xmi_inputFPtr inputFPtr; xmi_solid_angle *solid_angle_def = NULL; xmi_main_options *options; gchar *xmi_input_string; // set options options = xmi_main_options_new(); options->verbose = 1; options->use_opencl = 1; // init test g_assert(test_init() == 1); // set environment variables g_assert(g_setenv("XMIMSIM_CL_LIB", XMIMSIM_CL_LIB, TRUE) == TRUE); // download file g_assert(test_download_file(TEST_XMSI_URL) == 1); // read the file g_assert_nonnull(input = xmi_input_read_from_xml_file(TEST_XMSI, NULL)); // copy to the corresponding fortran variable xmi_input_C2F(input, &inputFPtr); // initialization g_assert(xmi_init_input(&inputFPtr) == 1); // create new solid angles file g_assert(xmi_get_solid_angle_file(&xmimsim_hdf5_solid_angles, 1) == 1); // check if solid angles are already precalculated g_assert(xmi_find_solid_angle_match(xmimsim_hdf5_solid_angles, input, &solid_angle_def, options) == 1); // check solid_angle_def is NULL g_assert(solid_angle_def == NULL); // convert input to string g_assert_true(xmi_input_write_to_xml_string(input, &xmi_input_string, NULL)); // run the actual calculation xmi_solid_angle_calculation(inputFPtr, &solid_angle_def, xmi_input_string, options); // confirm that there was no fallback to Fortran -> otherwise skip test, which is necessary for Travis-CI if (g_getenv("XMIMSIM_CL_FALLBACK") != NULL) { unlink(xmimsim_hdf5_solid_angles); return 77; } // write to hdf5 file g_assert(xmi_update_solid_angle_hdf5_file(xmimsim_hdf5_solid_angles, solid_angle_def) == 1); // free solid angles xmi_free_solid_angle(solid_angle_def); // and read them back in -> they should exist at this point g_assert(xmi_find_solid_angle_match(xmimsim_hdf5_solid_angles, input, &solid_angle_def, options) == 1); g_assert(solid_angle_def != NULL); // cleanup unlink(xmimsim_hdf5_solid_angles); xmi_input_free(input); // xmi_free_input_F(&inputFPtr); // this currently does not work since I do not read in the HDF5 data file xmi_free_solid_angle(solid_angle_def); g_free(xmi_input_string); return 0; }
int main(int argc, char *argv[]) { xmi_archive *archive = NULL; xmi_archive *archive_copy = NULL; int i,j; //init test g_assert(test_init() == 1); //download file g_assert(test_download_file(TEST_XMSA_URL_1) == 1); //read the file g_assert_nonnull(archive = xmi_archive_read_from_xml_file(TEST_XMSA_1, NULL)); //some testing of the input and output for (i = 0 ; i <= archive->nsteps1 ; i++) { for (j = 0 ; j <= archive->nsteps2 ; j++) { xmi_output *output_copy = NULL; xmi_output_copy(archive->output[i][j], &output_copy); g_assert(xmi_input_validate(output_copy->input) == 0); g_assert(xmi_input_compare(archive->input[i][j], output_copy->input) == 0); xmi_output_free(output_copy); } } //make a copy xmi_archive_copy(archive, &archive_copy); g_assert_true(xmi_archive_equals(archive, archive_copy)); xmi_archive_free(archive); xmi_archive_free(archive_copy); //download file g_assert(test_download_file(TEST_XMSA_URL_2) == 1); //read the file g_assert_nonnull(archive = xmi_archive_read_from_xml_file(TEST_XMSA_2, NULL)); //some testing of the input and output for (i = 0 ; i <= archive->nsteps1 ; i++) { for (j = 0 ; j <= archive->nsteps2 ; j++) { xmi_output *output_copy = NULL; xmi_output_copy(archive->output[i][j], &output_copy); g_assert(xmi_input_validate(output_copy->input) == 0); g_assert(xmi_input_compare(archive->input[i][j], output_copy->input) == 0); xmi_output_free(output_copy); } } //make a copy xmi_archive_copy(archive, &archive_copy); g_assert_true(xmi_archive_equals(archive, archive_copy)); xmi_archive_free(archive); xmi_archive_free(archive_copy); // now some tests that are supposed to fail GError *error = NULL; g_assert_null(archive = xmi_archive_read_from_xml_file("non-existent-file.xmsa", &error)); g_assert_true(g_error_matches(error, XMI_MSIM_ERROR, XMI_MSIM_ERROR_XML)); fprintf(stdout, "message: %s\n", error->message); g_clear_error(&error); // bad xpath1 test: enable when implemented /*g_assert(replace_xml_tag(TEST_XMSA_1, TEST_XMSA_COPY_1, "/xmimsim-archive/xpath1", "hsdhodhoosda") == 1); g_assert(xmi_read_archive_xml(TEST_XMSA_COPY_1, &archive, &error) == 0); g_assert_true(g_error_matches(error, XMI_MSIM_ERROR, XMI_MSIM_ERROR_XML)); fprintf(stdout, "message: %s\n", error->message); g_clear_error(&error); unlink(TEST_XMSA_COPY_1);*/ g_assert(remove_xml_tags(TEST_XMSA_1, TEST_XMSA_COPY_1, "/xmimsim-archive/end_value1") == 1); g_assert_null(archive = xmi_archive_read_from_xml_file(TEST_XMSA_COPY_1, &error)); g_assert_true(g_error_matches(error, XMI_MSIM_ERROR, XMI_MSIM_ERROR_XML)); fprintf(stdout, "message: %s\n", error->message); g_clear_error(&error); unlink(TEST_XMSA_COPY_1); return 0; }