MOAB: Mesh Oriented datABase  (version 5.4.1)
TestUtil.hpp File Reference
#include "moab/MOABConfig.h"
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <csignal>
#include <csetjmp>
#include "moab/Types.hpp"
#include "Internals.hpp"
+ Include dependency graph for TestUtil.hpp:

Go to the source code of this file.

Defines

#define STRINGIFY_(X)   #X
#define STRINGIFY(X)   STRINGIFY_( X )
#define CHECK_ERR(A)   check_equal( MB_SUCCESS, ( A ), "MB_SUCCESS", #A, __LINE__, __FILE__ )
#define CHECK(A)   check_true( ( A ), #A, __LINE__, __FILE__ )
#define CHECK_EQUAL(EXP, ACT)   check_equal( ( EXP ), ( ACT ), #EXP, #ACT, __LINE__, __FILE__ )
#define CHECK_REAL_EQUAL(EXP, ACT, EPS)   check_equal( ( EXP ), ( ACT ), ( EPS ), #EXP, #ACT, __LINE__, __FILE__ )
#define CHECK_ARRAYS_EQUAL(EXP, EXP_LEN, ACT, ACT_LEN)   check_array_equal( ( EXP ), ( EXP_LEN ), ( ACT ), ( ACT_LEN ), #EXP, #ACT, __LINE__, __FILE__ )
#define CHECK_VECREAL_EQUAL(EXP, ACT, EPS)   check_equal_cartvect( ( EXP ), ( ACT ), ( EPS ), #EXP, #ACT, __LINE__, __FILE__ )
#define RUN_TEST(FUNC)   run_test( &( ( ( ( FUNC ) ) ) ), #FUNC )
#define EXCEPTION_MODE   1
#define FORK_MODE   2
#define LONGJMP_MODE   3
#define FLAG_ERROR   siglongjmp( jmpenv, -1 )
#define EQUAL_TEST_IMPL(TEST, TYPE)

Typedefs

typedef void(* sigfunc_t )(int)
typedef void(* test_func )(void)

Functions

void sighandler (int sig)
int sethandler (int sig)
int init_signal_handlers ()
void flag_error ()
int run_test (test_func test, const char *func_name)
void check_equal (int A, int B, const char *sA, const char *sB, int line, const char *file)
void check_equal (unsigned A, unsigned B, const char *sA, const char *sB, int line, const char *file)
void check_equal (long A, long B, const char *sA, const char *sB, int line, const char *file)
void check_equal (unsigned long A, unsigned long B, const char *sA, const char *sB, int line, const char *file)
void check_equal (unsigned long long A, unsigned long long B, const char *sA, const char *sB, int line, const char *file)
void check_equal (long long A, long long B, const char *sA, const char *sB, int line, const char *file)
void check_equal (void *A, void *B, const char *sA, const char *sB, int line, const char *file)
void check_equal (const char *A, const char *B, const char *sA, const char *sB, int line, const char *file)
void check_equal (const std::string &A, const std::string &B, const char *sA, const char *sB, int line, const char *file)
void check_equal (float A, float B, float eps, const char *sA, const char *sB, int line, const char *file)
void check_equal (double A, double B, double eps, const char *sA, const char *sB, int line, const char *file)
const char * mb_error_str (moab::ErrorCode err)
void check_equal (moab::ErrorCode A, moab::ErrorCode B, const char *sA, const char *sB, int line, const char *file)
const char * mb_type_str (moab::EntityType type)
const char * mb_type_str (moab::EntityHandle a)
void check_true (bool cond, const char *str, int line, const char *file)

Variables

sigjmp_buf jmpenv
int junk_init_var = init_signal_handlers()

Define Documentation

#define CHECK (   A)    check_true( ( A ), #A, __LINE__, __FILE__ )

Ensure that A is true

Definition at line 37 of file TestUtil.hpp.

#define CHECK_ARRAYS_EQUAL (   EXP,
  EXP_LEN,
  ACT,
  ACT_LEN 
)    check_array_equal( ( EXP ), ( EXP_LEN ), ( ACT ), ( ACT_LEN ), #EXP, #ACT, __LINE__, __FILE__ )
#define CHECK_EQUAL (   EXP,
  ACT 
)    check_equal( ( EXP ), ( ACT ), #EXP, #ACT, __LINE__, __FILE__ )

Check that two values are equal

Definition at line 39 of file TestUtil.hpp.

Referenced by ahf_test(), calc_centroid(), call_find(), check_adj_ho_nodes(), check_bit_tag(), check_children(), check_geometric_set(), check_group_data(), check_handle_tag(), check_ho_element(), check_identical_mesh(), check_mesh_is_tet(), check_meshset_common(), check_node_coords(), check_num_verts(), check_quad_conn(), check_sense_data(), check_sizes(), check_tag(), check_type(), compare_tags(), const_pair_iterator_test(), create_mesh(), cube_tri_curve_coincidence_test(), cube_tris_connectivity_test(), dagmc_num_vols(), dagmc_outside_face_rayfire_history(), dagmc_outside_face_rayfire_history_fail(), dagmc_point_in(), dagmc_point_in_vol_1(), dagmc_point_in_vol_2(), dagmc_point_in_vol_3(), dagmc_point_in_vol_4(), dagmc_point_in_vol_5(), dagmc_point_in_vol_6(), dagmc_point_on_corner_1(), dagmc_point_on_corner_2(), dagmc_point_on_corner_3(), dagmc_point_on_corner_4(), dagmc_point_on_corner_5(), dagmc_point_on_corner_6(), dagmc_point_on_corner_7(), dagmc_point_on_corner_8(), dagmc_test_boundary(), do_test_side_number_1d(), do_test_side_number_2d(), do_test_sub_entity_type_2d(), do_test_sub_entity_type_3d(), erase_test(), eseq_test1a(), eseq_test1b(), find_sideset(), gather_one_cell_var(), gqt_num_vols(), gqt_outside_face_rayfire_history(), gqt_outside_face_rayfire_history_fail(), gqt_point_in(), gqt_point_in_box_1(), gqt_point_in_box_2(), gqt_point_in_box_3(), gqt_point_in_box_4(), gqt_point_in_box_5(), gqt_point_in_vol_1(), gqt_point_in_vol_2(), gqt_point_in_vol_3(), gqt_point_in_vol_4(), gqt_point_in_vol_5(), gqt_point_in_vol_6(), gqt_point_on_corner_1(), gqt_point_on_corner_2(), gqt_point_on_corner_3(), gqt_point_on_corner_4(), gqt_point_on_corner_5(), gqt_point_on_corner_6(), gqt_point_on_corner_7(), gqt_point_on_corner_8(), gqt_test_boundary(), heappermute(), identify_set(), insert_hint_test(), intersect_test(), main(), make_basic_sequence(), make_mesh(), match_tri_edges_w_curve(), mb_adjacent_create_test(), mb_bar_connectivity_test(), mb_hex_connectivity_test(), mb_quad_connectivity_test(), mb_side_number_test(), mb_tet_connectivity_test(), mb_tri_connectivity_test(), mb_vertex_coordinate_test(), merge_test(), merge_with_tag_test(), multiple_loads_of_same_file(), read_buffered_map(), read_cube_curves_test(), read_cube_surfs_test(), read_cube_tris_test(), read_cube_vertex_pos_test(), read_cube_verts_test(), read_cube_vols_test(), read_cylcube_curve_senses_test(), read_cylcube_surf_senses_test(), read_file(), read_map_from_disk(), read_mesh_parallel(), read_one_cell_var(), read_sets(), recursive_check_tree(), refine_entities(), regression_insert_set_1(), regression_mmiller_8_2010(), regression_one_entity_by_var_tag(), regression_tag_on_nonexistent_entity(), setup_mesh(), subset_by_dimension_test(), subtract_test(), swap_test(), test_0d_sub_entity_indices(), test_1d_sub_entity_indices(), test_2d_sub_entity_indices(), test_adjacencies(), test_bc_sets(), test_bit_tag_big(), test_blocks(), test_both(), test_box_iter_neighbors(), test_box_iterator(), test_box_tree_create(), test_change_to_both(), test_check_groups(), test_check_meshsets(), test_check_num_entities(), test_clear_bit(), test_construct_from_hex(), test_coords_connect_iterate(), test_create_tag(), test_create_var_len_tag(), test_cut_with_plane(), test_delete_bit_data(), test_delete_type_tag(), test_dimension(), test_dimension_pair(), test_elem_as_sub_entity(), test_element(), test_elements(), test_erase(), test_eul_check_across_files(), test_eul_check_append(), test_eul_check_T(), test_eul_check_timestep(), test_existinterface(), test_file_set(), test_find(), test_find_free_handle(), test_find_free_sequence(), test_flag_opt_long(), test_flag_opt_long_short(), test_flag_opt_short(), test_fv_check_T(), test_gather_onevar(), test_gather_sets_ranged(), test_gcrm_check_vars(), test_geometric_sets(), test_get_by_tag(), test_get_by_tag_value(), test_get_by_tag_value_dense(), test_get_entities(), test_get_ents_with_default_value(), test_get_set(), test_get_set_bit(), test_get_set_variable_length(), test_get_set_variable_length_mesh(), test_getEntArrAdj_conn(), test_getEntArrAdj_down(), test_getEntArrAdj_invalid_size(), test_getEntArrAdj_none(), test_getEntArrAdj_up(), test_getEntArrAdj_vertex(), test_global_opaque_common(), test_global_value_common(), test_has_mid_nodes(), test_ho_node_index(), test_ho_node_parent(), test_homme_check_T(), test_huge_var_length(), test_initial_inactive(), test_initial_notexist(), test_inline(), test_insert_sequence_merge(), test_insert_sequence_nomerge(), test_int_arg(), test_int_opt(), test_int_vect_arg(), test_int_vect_opt(), test_invalid_parallel_option(), test_is_free_handle(), test_is_free_sequence(), test_iterates(), test_iterator(), test_iterator_back(), test_leaf_containing_point_bounded_tree(), test_leaf_containing_point_unbounded_tree(), test_leaf_merge(), test_leaf_sibling(), test_leaf_splits_intersects(), test_list_set_with_stale_handles(), test_lower_bound(), test_merge_leaf(), test_meshset_tags_1(), test_meshset_tags_2(), test_moab_v3_poly_format(), test_mpas_check_vars(), test_multiple_files(), test_normal_linear_hex(), test_normal_linear_quad(), test_normal_linear_tet(), test_normal_linear_tri(), test_num_sub_entities(), test_opposite_side_hex(), test_opposite_side_quad(), test_opposite_side_tet(), test_opposite_side_tri(), test_optional_arg(), test_optional_args(), test_pack_bit_tag_data(), test_pack_elements(), test_pack_higher_order(), test_pack_poly(), test_pack_set_contents(), test_pack_set_parent_child(), test_pack_sets_of_sets(), test_pack_sets_simple(), test_pack_tag_data_default_value(), test_pack_tag_data_dense(), test_pack_tag_data_sparse(), test_pack_tag_handle_data(), test_pack_variable_length_tag(), test_pack_vertices(), test_point_search(), test_ranged_set_with_stale_handles(), test_read_adjacencies(), test_read_all(), test_read_alternate_coord_format(), test_read_bc_sets(), test_read_bit_tag(), test_read_conn(), test_read_coord_vars(), test_read_elements_common(), test_read_eul_nomesh(), test_read_eul_novars(), test_read_eul_onetimestep(), test_read_eul_onevar(), test_read_fgh(), test_read_fv_nomesh(), test_read_fv_novars(), test_read_fv_onetimestep(), test_read_fv_onevar(), test_read_geom_set(), test_read_global_tags(), test_read_handle_tag(), test_read_handle_tag_common(), test_read_hexes(), test_read_ids(), test_read_ids_common(), test_read_int_tag(), test_read_material_on_nodes(), test_read_material_set(), test_read_material_set1(), test_read_material_set2(), test_read_no_edges(), test_read_no_mixed_elements(), test_read_nodes(), test_read_nodes_common(), test_read_nomesh(), test_read_nothing_common(), test_read_novars(), test_read_one_set_elems(), test_read_one_set_polyhedra(), test_read_onetimestep(), test_read_onevar(), test_read_parallel(), test_read_physical_set(), test_read_prisms(), test_read_quads(), test_read_real_tag(), test_read_set_contents(), test_read_set_parent_child(), test_read_set_sets(), test_read_sets_common(), test_read_side(), test_read_sides(), test_read_tagged_elems(), test_read_tagged_nodes(), test_read_tags(), test_read_tets(), test_read_triangles(), test_read_two_sets_elems(), test_read_vertices(), test_real_opt(), test_remove_sequence(), test_replace_subsequence(), test_resize_ii(), test_resize_in(), test_resize_ni(), test_resize_nn(), test_scd_invalid(), test_set_flags(), test_sets_fileids(), test_squashed_short(), test_step_iter(), test_string_arg(), test_string_opt(), test_string_rank_subst(), test_sub_entity_nodes(), test_sub_entity_type_edge(), test_sub_entity_type_vtx(), test_tag_iterate(), test_tag_iterate_common(), test_tag_iterate_invalid(), test_tags_retrieval(), test_tempest_cs_create(), test_tempest_ico_create(), test_tempest_map_bcast(), test_tempest_mpas_create(), test_tempest_overlap_combinations(), test_tempest_rll_create(), test_tempest_to_moab_convert(), test_tet_tags_1(), test_tet_tags_2(), test_tets_1(), test_tets_2(), test_threaded_access(), test_tree(), test_tree_create(), test_triangles_1(), test_triangles_2(), test_triangles_tags_1(), test_triangles_tags_2(), test_type_names(), test_upper_bound(), test_valid_struct(), test_var_length_big_data(), test_var_length_data_common(), test_var_length_handle_tag(), test_var_length_parallel(), test_vertices(), test_vertices_1(), test_vertices_2(), test_vertices_per_entity(), test_write_different_element_types(), test_write_read_many_tags(), test_write_shared_sets(), test_write_unbalanced(), and validate_tree().

#define CHECK_ERR (   A)    check_equal( MB_SUCCESS, ( A ), "MB_SUCCESS", #A, __LINE__, __FILE__ )

Check that A is MB_SUCCESS

Definition at line 35 of file TestUtil.hpp.

Referenced by add_field_value(), adj_perf(), ahf_test(), build_mesh(), build_tree(), calc_centroid(), calculate_big_value(), call_reorder(), check_adj_ho_nodes(), check_big_meshset(), check_bit_tag(), check_children(), check_geometric_set(), check_handle_tag(), check_ho_element(), check_ho_elements(), check_identical_mesh(), check_mesh_is_tet(), check_meshset_common(), check_node_coords(), check_num_verts(), check_order(), check_order_by_sets_and_adj(), check_quad_conn(), check_set_contents(), check_sets_sizes(), check_sizes(), check_tag(), check_varlen_tag(), compare_tags(), convert_file(), count_owned_entities(), create_1d_3_sequences(), create_2d_3_sequences(), create_2dtri_3_sequences(), create_3dtri_3_sequences(), create_hex_mesh(), create_input_file(), create_mesh(), create_parallel_mesh(), create_shared_grid_2d(), create_shared_grid_3d(), create_simple_grid(), create_simple_mesh(), create_single_entity(), create_structured_quad_mesh(), create_tree(), cube_edge_adjacencies_test(), cube_tri_curve_coincidence_test(), cube_tri_vertex_test(), cube_tris_connectivity_test(), cube_verts_connectivity_test(), dagmc_build_obb(), dagmc_closest_to(), dagmc_load_file(), dagmc_load_file_dagmc(), dagmc_load_file_dagmc_build_obb(), dagmc_load_file_dagmc_internal(), dagmc_load_file_dagmc_internal_build_obb(), dagmc_load_file_dagmc_via_moab(), dagmc_load_file_dagmc_via_moab_build_obb(), dagmc_point_in(), dagmc_point_in_vol_dir(), dagmc_rayfire(), dagmc_setup_test(), dagmc_test_boundary(), dagmc_test_obb_retreval(), dagmc_test_obb_retreval_rayfire(), eseq_test1a(), eseq_test1b(), eseq_test1c(), eseq_test2a(), eseq_test2b(), eseq_test2c(), eseq_test2d(), find_block(), find_side(), find_sideset(), gather_one_cell_var(), geom_id_by_handle(), get_barycenters(), get_entities(), get_tag(), gqt_build_obb(), gqt_closest_to(), gqt_create_impl_compl(), gqt_load_file(), gqt_load_file_dagmc_build_obb(), gqt_load_file_dagmc_internal_build_obb(), gqt_load_file_dagmc_via_moab_build_obb(), gqt_point_in(), gqt_point_in_vol_dir(), gqt_rayfire(), gqt_setup_test(), gqt_test_boundary(), gqt_test_obb_retreval(), gqt_test_obb_retreval_rayfire(), identify_set(), load_and_partition(), load_file_one(), main(), make_basic_sequence(), make_mesh(), manufacture_lagrange_mesh_on_sphere(), mb_bar_connectivity_test(), mb_hex_connectivity_test(), mb_quad_connectivity_test(), mb_tet_connectivity_test(), mb_tri_connectivity_test(), mb_vertex_coordinate_test(), mb_write_mesh_test(), merge_all_test(), merge_with_tag_test(), mergesimple_test(), multiple_loads_of_same_file(), neighbors(), pack_unpack_noremoteh(), perf_inmesh(), print_partitioned_entities(), project_exact_torus(), read_cube_curves_test(), read_cube_surfs_test(), read_cube_tris_test(), read_cube_vertex_pos_test(), read_cube_verts_test(), read_cube_vols_test(), read_cylcube_curve_senses_test(), read_cylcube_groups_test(), read_cylcube_surf_senses_test(), read_file(), read_mesh_parallel(), read_multiple_test(), read_one_cell_var(), read_sets(), read_write(), read_write_file(), recursive_build_tree(), recursive_check_tree(), refine_entities(), regression_insert_set_1(), regression_one_entity_by_var_tag(), regression_svn1952(), regression_svn1958(), regression_svn1960(), regression_tag_on_nonexistent_entity(), report_sets(), save_and_load_on_root(), setup_mesh(), test_1D(), test_2D(), test_3D(), test_add_entities(), test_adjacencies(), test_bc_sets(), test_bit_tag_big(), test_blocks(), test_boolean(), test_both(), test_bound_box(), test_box_iter_neighbors(), test_box_iterator(), test_box_tree_create(), test_bvh_tree(), test_change_to_both(), test_change_to_set(), test_check_groups(), test_check_meshsets(), test_check_num_entities(), test_clear(), test_clear_bit(), test_contains_entities(), test_coords_connect_iterate(), test_correct_ghost(), test_create_tag(), test_create_var_len_tag(), test_cubit14(), test_delete_bit_data(), test_delete_tag_data(), test_delete_type_tag(), test_EigenDecomp(), test_element(), test_element_seq(), test_elements(), test_entities_by_dimension(), test_entities_by_type(), test_erase(), test_eul_read_write_across_files(), test_eul_read_write_append(), test_eul_read_write_T(), test_eul_read_write_timestep(), test_eval(), test_evals(), test_file_set(), test_filter_pstatus(), test_fv_read_write_T(), test_gather_onevar(), test_gather_sets_common(), test_gather_sets_ranged(), test_gcrm_read_write_vars(), test_geometric_sets(), test_get_by_tag(), test_get_by_tag_value(), test_get_by_tag_value_dense(), test_get_entity_tags(), test_get_ents_with_default_value(), test_get_set(), test_get_set_bit(), test_get_set_variable_length(), test_get_set_variable_length_mesh(), test_global_opaque_common(), test_global_value_common(), test_great_arc_clat_intx(), test_great_arc_intx(), test_ho_elements(), test_homme_read_write_T(), test_huge_var_length(), test_initial_inactive(), test_initial_notexist(), test_insert_sequence_merge(), test_insert_sequence_nomerge(), test_intx_mpas(), test_is_free_handle(), test_iterates(), test_iterator(), test_iterator_back(), test_iterators(), test_kd_tree(), test_leaf_containing_point_bounded_tree(), test_leaf_containing_point_unbounded_tree(), test_leaf_intersects_plane(), test_leaf_intersects_ray(), test_leaf_intersects_ray_common(), test_leaf_merge(), test_leaf_polyhedron(), test_leaf_sibling(), test_leaf_splits_intersects(), test_leaf_volume(), test_linear_hex(), test_linear_quad(), test_linear_reconstruction(), test_linear_tet(), test_list_set_with_stale_handles(), test_load_file(), test_locator(), test_merge_leaf(), test_mesh(), test_mesh_value(), test_meshset_tags_1(), test_meshset_tags_2(), test_moab_v3_poly_format(), test_mpas_read_write_vars(), test_multiple_files(), test_new_pcomm_instance(), test_normal_linear_hex(), test_normal_linear_quad(), test_normal_linear_tet(), test_normal_linear_tri(), test_pack_bit_tag_data(), test_pack_elements(), test_pack_higher_order(), test_pack_poly(), test_pack_set_contents(), test_pack_set_parent_child(), test_pack_sets_of_sets(), test_pack_sets_simple(), test_pack_shared_entities_2d(), test_pack_shared_entities_3d(), test_pack_tag_data_default_value(), test_pack_tag_data_dense(), test_pack_tag_data_sparse(), test_pack_tag_handle_data(), test_pack_variable_length_tag(), test_pack_vertices(), test_parallel_partitions(), test_periodic_seq(), test_point_search(), test_quadratic_hex(), test_ranged_set_with_stale_handles(), test_read(), test_read_adjacencies(), test_read_all(), test_read_alternate_coord_format(), test_read_and_ghost_after(), test_read_bc_sets(), test_read_bit_tag(), test_read_conn(), test_read_containing_sets(), test_read_coord_vars(), test_read_domain(), test_read_double_tag(), test_read_elements(), test_read_elements_common(), test_read_eul_all(), test_read_eul_nomesh(), test_read_eul_novars(), test_read_eul_onetimestep(), test_read_eul_onevar(), test_read_fgh(), test_read_fv_all(), test_read_fv_nomesh(), test_read_fv_novars(), test_read_fv_onetimestep(), test_read_fv_onevar(), test_read_geom_set(), test_read_global_tags(), test_read_handle_tag(), test_read_handle_tag_common(), test_read_hexes(), test_read_ids(), test_read_ids_common(), test_read_int_tag(), test_read_material_on_nodes(), test_read_material_set(), test_read_material_set1(), test_read_material_set2(), test_read_no_edges(), test_read_no_mixed_elements(), test_read_nodes(), test_read_nodes_common(), test_read_nomesh(), test_read_non_adjs_side(), test_read_nothing_common(), test_read_novars(), test_read_one_set_elems(), test_read_one_set_polyhedra(), test_read_onetimestep(), test_read_onevar(), test_read_opaque_tag(), test_read_parallel(), test_read_partial(), test_read_partial_ids(), test_read_physical_set(), test_read_polygons(), test_read_polyhedra(), test_read_prisms(), test_read_quads(), test_read_real_tag(), test_read_scrip(), test_read_set_contents(), test_read_set_parent_child(), test_read_set_sets(), test_read_sets_common(), test_read_side(), test_read_sides(), test_read_tagged_elems(), test_read_tagged_nodes(), test_read_tags(), test_read_tets(), test_read_time(), test_read_triangles(), test_read_two_sets_elems(), test_read_vertices(), test_read_with_ghost(), test_read_with_ghost_no_augment(), test_read_with_thin_ghost_layer(), test_read_write(), test_remove_entities(), test_remove_sequence(), test_replace_subsequence(), test_scd_invalid(), test_set_flags(), test_sets_fileids(), test_sqijk(), test_tag_iterate_common(), test_tag_iterate_invalid(), test_tempest_to_moab_convert(), test_tet_tags_1(), test_tet_tags_2(), test_tets_1(), test_tets_2(), test_threaded_access(), test_tree(), test_tree_create(), test_tree_delete(), test_tree_readwrite(), test_triangles_1(), test_triangles_2(), test_triangles_tags_1(), test_triangles_tags_2(), test_var_length_big_data(), test_var_length_data_common(), test_var_length_handle_tag(), test_var_length_no_data(), test_var_length_parallel(), test_vertex_seq(), test_vertices(), test_vertices_1(), test_vertices_2(), test_write(), test_write_dense_tags(), test_write_different_element_types(), test_write_elements(), test_write_invalid_elem(), test_write_polygons(), test_write_polyhedra(), test_write_read_many_tags(), test_write_shared_sets(), test_write_unbalanced(), umr_perf_test(), validate_tree(), verdict_test1(), write_and_read(), and write_id_test_file().

#define CHECK_REAL_EQUAL (   EXP,
  ACT,
  EPS 
)    check_equal( ( EXP ), ( ACT ), ( EPS ), #EXP, #ACT, __LINE__, __FILE__ )

Check that two real (float or double) values are equal within EPS

Definition at line 41 of file TestUtil.hpp.

Referenced by check_ho_element(), dagmc_closest_to(), dagmc_origin_face_rayfire(), dagmc_outside_face_rayfire(), dagmc_outside_face_rayfire_orient_entrance(), dagmc_outside_face_rayfire_orient_exit(), dagmc_rayfire(), dagmc_test_obb_retreval_rayfire(), gather_one_cell_var(), gqt_closest_to(), gqt_origin_face_rayfire(), gqt_outside_face_rayfire(), gqt_outside_face_rayfire_orient_entrance(), gqt_outside_face_rayfire_orient_exit(), gqt_rayfire(), gqt_test_obb_retreval_rayfire(), mb_vertex_coordinate_test(), multiple_loads_of_same_file(), read_one_cell_var(), test_bound_box(), test_coords_connect_iterate(), test_EigenDecomp(), test_elements(), test_eul_check_across_files(), test_eul_check_append(), test_eul_check_T(), test_eul_check_timestep(), test_eval(), test_evals(), test_fv_check_T(), test_gather_onevar(), test_gcrm_check_vars(), test_global_value_common(), test_hex_nat_coords(), test_homme_check_T(), test_huge_var_length(), test_iterator_back(), test_leaf_merge(), test_leaf_volume(), test_moab_v3_poly_format(), test_mpas_check_vars(), test_pack_elements(), test_pack_higher_order(), test_pack_poly(), test_pack_tag_data_dense(), test_point_search(), test_read_all(), test_read_coord_vars(), test_read_double_tag(), test_read_elements_common(), test_read_eul_onevar(), test_read_fv_onevar(), test_read_no_mixed_elements(), test_read_nodes(), test_read_nodes_common(), test_read_novars(), test_read_onevar(), test_read_opaque_tag(), test_read_sets_common(), test_read_tags(), test_read_vertices(), test_real_arg(), test_real_opt(), test_set_plane(), test_squashed_short(), test_tempest_cs_create(), test_tempest_ico_create(), test_tempest_map_bcast(), test_tempest_mpas_create(), test_tempest_overlap_combinations(), test_tempest_rll_create(), test_vertices(), test_volume(), and validate_tree().

#define CHECK_VECREAL_EQUAL (   EXP,
  ACT,
  EPS 
)    check_equal_cartvect( ( EXP ), ( ACT ), ( EPS ), #EXP, #ACT, __LINE__, __FILE__ )

Check that two CartVect objects contain same values

Definition at line 46 of file TestUtil.hpp.

#define EQUAL_TEST_IMPL (   TEST,
  TYPE 
)
Value:
if( !( TEST ) )                                           \
    {                                                         \
        printf( "Equality Test Failed: %s == %s\n", sA, sB ); \
        printf( "  at line %d of '%s'\n", line, file );       \
        printf( "  Expected value: %" #TYPE "\n", A );        \
        printf( "  Actual value:   %" #TYPE "\n", B );        \
        printf( "\n" );                                       \
        flag_error();                                         \
    }

Definition at line 391 of file TestUtil.hpp.

Referenced by check_equal().

#define EXCEPTION_MODE   1

Definition at line 56 of file TestUtil.hpp.

#define FLAG_ERROR   siglongjmp( jmpenv, -1 )

Definition at line 124 of file TestUtil.hpp.

Referenced by assert_vectors_equal(), check_equal(), and flag_error().

#define FORK_MODE   2

Definition at line 61 of file TestUtil.hpp.

#define LONGJMP_MODE   3

Definition at line 70 of file TestUtil.hpp.

#define RUN_TEST (   FUNC)    run_test( &( ( ( ( FUNC ) ) ) ), #FUNC )

Run a test Argument should be a function with the signature: void func(void) Evaluates to zero if test is successful, one otherwise.

Definition at line 52 of file TestUtil.hpp.

#define STRINGIFY (   X)    STRINGIFY_( X )

Definition at line 16 of file TestUtil.hpp.

#define STRINGIFY_ (   X)    #X

Definition at line 15 of file TestUtil.hpp.


Typedef Documentation

typedef void( * sigfunc_t)(int)

Definition at line 149 of file TestUtil.hpp.

typedef void( * test_func)(void)

Definition at line 273 of file TestUtil.hpp.


Function Documentation

void check_equal ( int  A,
int  B,
const char *  sA,
const char *  sB,
int  line,
const char *  file 
)

Definition at line 402 of file TestUtil.hpp.

References EQUAL_TEST_IMPL.

{
    EQUAL_TEST_IMPL( A == B, d )
}
void check_equal ( unsigned  A,
unsigned  B,
const char *  sA,
const char *  sB,
int  line,
const char *  file 
)

Definition at line 407 of file TestUtil.hpp.

References EQUAL_TEST_IMPL, and u.

{
    EQUAL_TEST_IMPL( A == B, u )
}
void check_equal ( long  A,
long  B,
const char *  sA,
const char *  sB,
int  line,
const char *  file 
)

Definition at line 412 of file TestUtil.hpp.

References EQUAL_TEST_IMPL.

{
    EQUAL_TEST_IMPL( A == B, ld )
}
void check_equal ( unsigned long  A,
unsigned long  B,
const char *  sA,
const char *  sB,
int  line,
const char *  file 
)

Definition at line 417 of file TestUtil.hpp.

References EQUAL_TEST_IMPL.

{
    EQUAL_TEST_IMPL( A == B, lu )
}
void check_equal ( unsigned long long  A,
unsigned long long  B,
const char *  sA,
const char *  sB,
int  line,
const char *  file 
)

Definition at line 422 of file TestUtil.hpp.

References EQUAL_TEST_IMPL.

{
    EQUAL_TEST_IMPL( A == B, llu )
}
void check_equal ( long long  A,
long long  B,
const char *  sA,
const char *  sB,
int  line,
const char *  file 
)

Definition at line 432 of file TestUtil.hpp.

References EQUAL_TEST_IMPL.

{
    EQUAL_TEST_IMPL( A == B, lld )
}
void check_equal ( void *  A,
void *  B,
const char *  sA,
const char *  sB,
int  line,
const char *  file 
)

Definition at line 437 of file TestUtil.hpp.

References EQUAL_TEST_IMPL.

{
    EQUAL_TEST_IMPL( A == B, p )
}
void check_equal ( const char *  A,
const char *  B,
const char *  sA,
const char *  sB,
int  line,
const char *  file 
)

Definition at line 442 of file TestUtil.hpp.

References EQUAL_TEST_IMPL.

{
    EQUAL_TEST_IMPL( !strcmp( ( A ), ( B ) ), s )
}
void check_equal ( const std::string &  A,
const std::string &  B,
const char *  sA,
const char *  sB,
int  line,
const char *  file 
)

Definition at line 447 of file TestUtil.hpp.

References check_equal().

{
    check_equal( A.c_str(), B.c_str(), sA, sB, line, file );
}
void check_equal ( float  A,
float  B,
float  eps,
const char *  sA,
const char *  sB,
int  line,
const char *  file 
)

Definition at line 457 of file TestUtil.hpp.

References EQUAL_TEST_IMPL.

{
    EQUAL_TEST_IMPL( fabsf( A - B ) <= eps, f )
}
void check_equal ( double  A,
double  B,
double  eps,
const char *  sA,
const char *  sB,
int  line,
const char *  file 
)

Definition at line 462 of file TestUtil.hpp.

References EQUAL_TEST_IMPL.

{
    EQUAL_TEST_IMPL( fabs( A - B ) <= eps, f )
}
void check_equal ( moab::ErrorCode  A,
moab::ErrorCode  B,
const char *  sA,
const char *  sB,
int  line,
const char *  file 
)

Definition at line 512 of file TestUtil.hpp.

References flag_error(), and mb_error_str().

{
    if( A == B ) return;

    printf( "ErrorCode Test Failed: %s == %s\n", sA, sB );
    printf( "  at line %d of '%s'\n", line, file );
    printf( "  Expected value: %s (%d)\n", mb_error_str( A ), (int)A );
    printf( "  Actual value:   %s (%d)\n", mb_error_str( B ), (int)B );
    printf( "\n" );
    flag_error();
}
void check_true ( bool  cond,
const char *  str,
int  line,
const char *  file 
)

Definition at line 585 of file TestUtil.hpp.

References flag_error().

{
    if( !cond )
    {
        printf( "Test Failed: %s\n", str );
        printf( "  at line %d of '%s'\n", line, file );
        printf( "\n" );
        flag_error();
    }
}
void flag_error ( ) [inline]

Definition at line 253 of file TestUtil.hpp.

References FLAG_ERROR.

Referenced by check_equal(), check_equal_eigvect(), and check_true().

Definition at line 166 of file TestUtil.hpp.

References sethandler().

{
    int result = 0;
    /* Don't trap these.  It is unlikely that a test would ever generate such
       a signal on its own and trapping them interfers with a user's ability
       to stop a test.  SIGHUP implies that the controlling terminal was closed.
       If the user does ctrl-C or ctrl-\ (SIGINT and SIGQUIT, respectively) and
       we trap these then just the current test stops.  If we leave the default
       behavior for them then the whole test suite stops.  The latter is likely
       the desired behavior.  SIGTERM is the default signal sent by the 'kill'
       command.
    #ifdef SIGHUP
      result += sethandler( SIGHUP );
    #endif
    #ifdef SIGINT
      result += sethandler( SIGINT );
    #endif
    #ifdef SIGQUIT
      result += sethandler( SIGQUIT );
    #endif
    #ifdef SIGTERM
      result += sethandler( SIGTERM );
    #endif
    */

#ifdef SIGILL
    result += sethandler( SIGILL );
#endif
#ifdef SIGTRAP
    result += sethandler( SIGTRAP );
#endif
#ifdef SIGABRT
    result += sethandler( SIGABRT );
#endif
#ifdef SIGBUS
    result += sethandler( SIGBUS );
#endif
#ifdef SIGFPE
    result += sethandler( SIGFPE );
#endif
#ifdef SIGSEGV
    result += sethandler( SIGSEGV );
#endif

    /* Catching these causes problems with mpich2 1.3.1p1 and a
       test should never receive such a signal anyway.
    #ifdef SIGUSR1
      result += sethandler( SIGUSR1 );
    #endif
    #ifdef SIGUSR2
      result += sethandler( SIGUSR2 );
    #endif
    */

    /* Don't trap SIGCHLD.  The only way a test should receive
       such a signal is if it actually forked a child process.
       That is unlikely, but if it does happen the test probably
       wants to handle the signal itself.
    #ifdef SIGCHLD
      result += sethandler( SIGCHLD );
    #endif
    */

#ifdef SIGPIPE
    result += sethandler( SIGPIPE );
#endif
#ifdef SIGIO
    result += sethandler( SIGIO );
#endif
#ifdef SIGSYS
    result += sethandler( SIGSYS );
#endif
    return result;
}
const char* mb_error_str ( moab::ErrorCode  err)

Definition at line 467 of file TestUtil.hpp.

References MB_ALREADY_ALLOCATED, MB_ENTITY_NOT_FOUND, MB_FILE_DOES_NOT_EXIST, MB_FILE_WRITE_ERROR, MB_INDEX_OUT_OF_RANGE, MB_INVALID_SIZE, MB_MEMORY_ALLOCATION_FAILED, MB_MULTIPLE_ENTITIES_FOUND, MB_NOT_IMPLEMENTED, MB_STRUCTURED_MESH, MB_SUCCESS, MB_TAG_NOT_FOUND, MB_TYPE_OUT_OF_RANGE, MB_UNHANDLED_OPTION, MB_UNSUPPORTED_OPERATION, and MB_VARIABLE_DATA_LENGTH.

Referenced by check_equal().

{
    switch( err )
    {
        case moab::MB_SUCCESS:
            return "Success";
        case moab::MB_INDEX_OUT_OF_RANGE:
            return "Index Out of Range";
        case moab::MB_TYPE_OUT_OF_RANGE:
            return "Type Out of Range";
        case moab::MB_MEMORY_ALLOCATION_FAILED:
            return "Memory Alloc. Failed";
        case moab::MB_ENTITY_NOT_FOUND:
            return "Entity Not Found";
        case moab::MB_MULTIPLE_ENTITIES_FOUND:
            return "Multiple Entities Found";
        case moab::MB_TAG_NOT_FOUND:
            return "Tag Not Found";
        case moab::MB_FILE_DOES_NOT_EXIST:
            return "File Not Found";
        case moab::MB_FILE_WRITE_ERROR:
            return "File Write Error";
        case moab::MB_NOT_IMPLEMENTED:
            return "Not Implemented";
        case moab::MB_ALREADY_ALLOCATED:
            return "Already Allocated";
        case moab::MB_VARIABLE_DATA_LENGTH:
            return "Variable Data Length";
        case moab::MB_INVALID_SIZE:
            return "Invalid Size";
        case moab::MB_UNSUPPORTED_OPERATION:
            return "Unsupported Operation";
        case moab::MB_UNHANDLED_OPTION:
            return "Unhandled Option";
        case moab::MB_STRUCTURED_MESH:
            return "Structured Mesh";
        case moab::MB_FAILURE:
            return "Failure";
        default:
            return "(unknown)";
    }
}
const char* mb_type_str ( moab::EntityType  type)

Definition at line 524 of file TestUtil.hpp.

References MBEDGE, MBENTITYSET, MBHEX, MBKNIFE, MBMAXTYPE, MBPOLYGON, MBPOLYHEDRON, MBPRISM, MBPYRAMID, MBQUAD, MBTET, MBTRI, and MBVERTEX.

Referenced by mb_type_str().

{
    switch( type )
    {
        case moab::MBVERTEX:
            return "Vertex";
        case moab::MBEDGE:
            return "Edge";
        case moab::MBTRI:
            return "Triangle";
        case moab::MBQUAD:
            return "Quadrilateral";
        case moab::MBPOLYGON:
            return "Polygon";
        case moab::MBTET:
            return "Tetrahedron";
        case moab::MBPYRAMID:
            return "Pyramid";
        case moab::MBPRISM:
            return "Prism (wedge)";
        case moab::MBKNIFE:
            return "Knife";
        case moab::MBHEX:
            return "Hexahedron";
        case moab::MBPOLYHEDRON:
            return "Polyhedron";
        case moab::MBENTITYSET:
            return "Entity (Mesh) Set";
        case moab::MBMAXTYPE:
            return "(max type)";
        default:
            return "(unknown)";
    }
}
const char* mb_type_str ( moab::EntityHandle  a)

Definition at line 559 of file TestUtil.hpp.

References mb_type_str(), and moab::TYPE_FROM_HANDLE().

{
    return mb_type_str( moab::TYPE_FROM_HANDLE( a ) );
}
int run_test ( test_func  test,
const char *  func_name 
)

Definition at line 274 of file TestUtil.hpp.

References jmpenv, MPI_COMM_WORLD, and rank.

{
    // check if we are running parallel MPI tests
    int rank = 0;
#ifdef MOAB_HAVE_MPI
    int isInit;
    MPI_Initialized( &isInit );
    if( isInit )
    {
        MPI_Comm_rank( MPI_COMM_WORLD, &rank );
    }
#endif

    if( rank == 0 ) printf( "Running %s ...\n", func_name );

#if MODE == EXCEPTION_MODE
    /* On Windows, run all tests in same process.
       Flag errors by throwing an exception.
     */
    try
    {
        ( *test )();
        return 0;
    }
    catch( ErrorExcept )
    {
        printf( "[%d]  %s: FAILED\n", rank, func_name );
        return 1;
    }
    catch( ... )
    {
        printf( "[%d]  %s: UNCAUGHT EXCEPTION\n", rank, func_name );
        return 1;
    }

#elif MODE == FORK_MODE
    /* For non-Windows OSs, fork() and run test in child process. */
    pid_t pid = fork();
    int status;

    /* Fork failed? */
    if( pid == -1 )
    {
        perror( "fork()" );
        abort(); /* abort all tests (can't fork child processes) */
    }

    /* If child process*/
    if( pid == 0 )
    {
        ( *test )(); /* call test function */
        exit( 0 );   /* if function returned, then it succeeded */
    }

    /* If here, then parent process */

    /* Wait until child process exits */
    waitpid( pid, &status, 0 );

    /* Check child exit status */
    if( WIFSIGNALED( status ) )
    {
        if( WTERMSIG( status ) ) printf( "  %s: TERMINATED (signal %d)\n", func_name, (int)WTERMSIG( status ) );
        if( WCOREDUMP( status ) ) printf( "  %s: CORE DUMP\n", func_name );
        return 1;
    }
    else if( WEXITSTATUS( status ) )
    {
        printf( "  %s: FAILED\n", func_name );
        return 1;
    }
    else
    {
        return 0;
    }

#elif MODE == LONGJMP_MODE
    // Save stack state at this location.
    int rval = sigsetjmp( jmpenv, 1 );
    // If rval is zero, then we haven't run the test yet.
    // If rval is non-zero then
    // a) we ran the test
    // b) the test failed
    // c) we did a longjmp back to the location where we called setsigjmp.

    // run test
    if( !rval )
    {
        ( *test )();
        return 0;
    }
    // some check failed
    else if( rval == -1 )
    {
        printf( "  %s: FAILED\n", func_name );
        return 1;
    }
    // a signal was raised (e.g. segfault)
    else
    {
        printf( "  %s: TERMINATED (signal %d)\n", func_name, rval );
        return 1;
    }
#else
#error "MODE not set"
#endif  // MODE
}
int sethandler ( int  sig)

Definition at line 153 of file TestUtil.hpp.

References sighandler().

Referenced by init_signal_handlers().

{
    sigfunc_t h = signal( sig, &sighandler );
    if( h == SIG_ERR ) return 1;
    // If user-defined signal handler (or signal is ignored),
    // than unregister our handler.
    else if( h != SIG_DFL )
        signal( sig, h );
    return 0;
}
void sighandler ( int  sig)

Definition at line 142 of file TestUtil.hpp.

References jmpenv.

Referenced by sethandler().

{
    signal( sig, sighandler );
    siglongjmp( jmpenv, sig );
    // should never return from longjmp
    exit( 1 );
}

Variable Documentation

sigjmp_buf jmpenv

Definition at line 136 of file TestUtil.hpp.

Referenced by run_test(), and sighandler().

Definition at line 243 of file TestUtil.hpp.

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines