From 37bd54f698397e3ba98a6cf84dc74dea94d1de4f Mon Sep 17 00:00:00 2001 From: Matthias Maier Date: Tue, 16 Apr 2013 14:42:52 +0000 Subject: [PATCH] Adjust the testsuite to the changes in Exception handling git-svn-id: https://svn.dealii.org/trunk@29301 0785d39b-7218-0410-832d-ea1e28bc413d --- tests/base/log_crash_01.cc | 20 +++++++---- tests/base/reference.cc | 9 ++--- tests/base/reference/cmp/generic | 2 +- tests/base/slice_vector.cc | 5 +-- tests/bits/accessor_equality.cc | 4 ++- tests/bits/distorted_cells_07.cc | 4 ++- tests/bits/distorted_mapped_cells_01.cc | 9 ++--- tests/bits/distorted_mapped_cells_02.cc | 9 ++--- tests/bits/sparse_matrix_add_entries_01.cc | 9 +++-- tests/deal.II/fe_values_view_invalid_01.cc | 7 ++-- tests/deal.II/fe_values_view_invalid_02.cc | 7 ++-- tests/deal.II/fe_values_view_invalid_03.cc | 7 ++-- tests/deal.II/memory_consumption_01.cc | 1 + tests/deal.II/user_data_01.cc | 4 ++- tests/deal.II/user_data_01/cmp/generic | 2 -- tests/distributed_grids/anisotropic.cc | 11 +++--- tests/fe/block_mask_02.cc | 4 ++- tests/fe/block_mask_06.cc | 7 ++-- tests/fe/block_mask_07.cc | 6 ++-- tests/fe/component_mask_02.cc | 4 ++- tests/fe/component_mask_06.cc | 3 +- tests/fe/component_mask_07.cc | 6 ++-- tests/fe/component_mask_14.cc | 5 +-- tests/hp/fe_collection_04.cc | 3 +- tests/lac/constraints_c1.cc | 9 +++-- tests/lac/constraints_c1_02.cc | 7 ++-- tests/mpi/ghost_03.cc | 39 ++++++++++++++-------- tests/mpi/trilinos_ghost_03.cc | 10 +++--- tests/mpi/trilinos_ghost_03_linfty.cc | 5 +-- tests/tests.h | 6 ++-- 30 files changed, 137 insertions(+), 87 deletions(-) diff --git a/tests/base/log_crash_01.cc b/tests/base/log_crash_01.cc index ddeb38d72b..d32a28772d 100644 --- a/tests/base/log_crash_01.cc +++ b/tests/base/log_crash_01.cc @@ -24,11 +24,17 @@ int main() { - deal_II_exceptions::disable_abort_on_exception (); - - std::ofstream logfile("log_crash_01/output"); - deallog.attach(logfile); - deallog << "OK" << std::endl; - - deallog << "no newline here!"; + deal_II_exceptions::disable_abort_on_exception(); + + try + { + std::ofstream logfile("log_crash_01/output"); + deallog.attach(logfile); + deallog << "OK" << std::endl; + deallog << "no newline here!"; + } + catch (ExceptionBase &e) + { + deallog << e.get_exc_name() << std::endl; + } } diff --git a/tests/base/reference.cc b/tests/base/reference.cc index b77606cdfe..417781bb57 100644 --- a/tests/base/reference.cc +++ b/tests/base/reference.cc @@ -45,6 +45,7 @@ class Test : public Subscriptor int main() { deal_II_exceptions::disable_abort_on_exception(); + std::ofstream logfile("reference/output"); deallog.attach(logfile); deallog.depth_console(0); @@ -81,12 +82,12 @@ int main() r = &c; Test d("D"); r = &d; - // Destruction of "Test R" will - // cause a spurious ExcNotUsed - // here, since D was deleted first + // Destruction of "Test R" will cause a spurious ExcNotUsed here, + // since D was deleted first } - catch (...) + catch (ExceptionBase &e) { + deallog << e.get_exc_name() << std::endl; } } diff --git a/tests/base/reference/cmp/generic b/tests/base/reference/cmp/generic index 1970a44da5..c109e39248 100644 --- a/tests/base/reference/cmp/generic +++ b/tests/base/reference/cmp/generic @@ -10,7 +10,7 @@ DEAL::u const DEAL::Construct C DEAL::Construct D DEAL::Destruct D -DEAL::ExcInUse (counter, object_info->name(), infostring) DEAL::Destruct C DEAL::Destruct B DEAL::Destruct A +DEAL::ExcInUse (counter, object_info->name(), infostring) diff --git a/tests/base/slice_vector.cc b/tests/base/slice_vector.cc index 02584a3b7c..95b9166c24 100644 --- a/tests/base/slice_vector.cc +++ b/tests/base/slice_vector.cc @@ -34,6 +34,7 @@ void f(const std::vector& v) int main() { deal_II_exceptions::disable_abort_on_exception(); + std::ofstream logfile("slice_vector/output"); deallog.attach(logfile); deallog.depth_console(0); @@ -59,8 +60,8 @@ int main() { make_slice(v, 3, 5); } - catch(...) + catch (ExceptionBase &e) { + deallog << e.get_exc_name() << std::endl; } - } diff --git a/tests/bits/accessor_equality.cc b/tests/bits/accessor_equality.cc index 0aa09409be..45b3bdbb41 100644 --- a/tests/bits/accessor_equality.cc +++ b/tests/bits/accessor_equality.cc @@ -92,8 +92,9 @@ void test () { (dof_handler.begin_active() != dof_handler2.begin_active()); } - catch (...) + catch (ExceptionBase &e) { + deallog << e.get_exc_name() << std::endl; } } } @@ -102,6 +103,7 @@ void test () int main () { deal_II_exceptions::disable_abort_on_exception(); + std::ofstream logfile("accessor_equality/output"); deallog.attach(logfile); deallog.depth_console(0); diff --git a/tests/bits/distorted_cells_07.cc b/tests/bits/distorted_cells_07.cc index 5d65d87f75..b03f6b30a8 100644 --- a/tests/bits/distorted_cells_07.cc +++ b/tests/bits/distorted_cells_07.cc @@ -80,8 +80,9 @@ void check (const unsigned int testcase) { fe_values.reinit(coarse_grid.begin()); } - catch (...) + catch (ExceptionBase &e) { + deallog << e.get_exc_name() << std::endl; } } @@ -89,6 +90,7 @@ void check (const unsigned int testcase) int main () { deal_II_exceptions::disable_abort_on_exception(); + std::ofstream logfile("distorted_cells_07/output"); deallog.attach(logfile); deallog.depth_console(0); diff --git a/tests/bits/distorted_mapped_cells_01.cc b/tests/bits/distorted_mapped_cells_01.cc index db272f3690..009dc53b1d 100644 --- a/tests/bits/distorted_mapped_cells_01.cc +++ b/tests/bits/distorted_mapped_cells_01.cc @@ -66,10 +66,10 @@ void test() for (unsigned int q=0; q& tr, { fe_values[extr]; // invalid access } - catch (const std::exception &exc) + catch (ExceptionBase &e) { + deallog << e.get_exc_name() << std::endl; goto ok; } @@ -71,6 +72,8 @@ void test() int main() { + deal_II_exceptions::disable_abort_on_exception(); + std::ofstream logfile ("fe_values_view_invalid_01/output"); deallog << std::setprecision (2); @@ -78,8 +81,6 @@ int main() deallog.depth_console (0); deallog.threshold_double(1.e-7); - deal_II_exceptions::disable_abort_on_exception(); - test<1>(); test<2>(); test<3>(); diff --git a/tests/deal.II/fe_values_view_invalid_02.cc b/tests/deal.II/fe_values_view_invalid_02.cc index f5b8e980d9..5a746ea049 100644 --- a/tests/deal.II/fe_values_view_invalid_02.cc +++ b/tests/deal.II/fe_values_view_invalid_02.cc @@ -45,8 +45,9 @@ void test (const Triangulation& tr, { fe_values[extr]; // invalid access } - catch (const std::exception &exc) + catch (ExceptionBase &e) { + deallog << e.get_exc_name() << std::endl; goto ok; } @@ -71,6 +72,8 @@ void test() int main() { + deal_II_exceptions::disable_abort_on_exception(); + std::ofstream logfile ("fe_values_view_invalid_02/output"); deallog << std::setprecision (2); @@ -78,8 +81,6 @@ int main() deallog.depth_console (0); deallog.threshold_double(1.e-7); - deal_II_exceptions::disable_abort_on_exception(); - test<1>(); test<2>(); test<3>(); diff --git a/tests/deal.II/fe_values_view_invalid_03.cc b/tests/deal.II/fe_values_view_invalid_03.cc index 15057948aa..de5b366603 100644 --- a/tests/deal.II/fe_values_view_invalid_03.cc +++ b/tests/deal.II/fe_values_view_invalid_03.cc @@ -45,8 +45,9 @@ void test (const Triangulation& tr, { fe_values[extr]; // invalid access } - catch (const std::exception &exc) + catch (ExceptionBase &e) { + deallog << e.get_exc_name() << std::endl; goto ok; } @@ -71,6 +72,8 @@ void test() int main() { + deal_II_exceptions::disable_abort_on_exception(); + std::ofstream logfile ("fe_values_view_invalid_03/output"); deallog << std::setprecision (2); @@ -78,8 +81,6 @@ int main() deallog.depth_console (0); deallog.threshold_double(1.e-7); - deal_II_exceptions::disable_abort_on_exception(); - test<1>(); test<2>(); test<3>(); diff --git a/tests/deal.II/memory_consumption_01.cc b/tests/deal.II/memory_consumption_01.cc index 6c2fd84d83..cfab6c7e57 100644 --- a/tests/deal.II/memory_consumption_01.cc +++ b/tests/deal.II/memory_consumption_01.cc @@ -381,6 +381,7 @@ void Step6::run () int main() { deal_II_exceptions::disable_abort_on_exception(); + std::ofstream logfile("memory_consumption_01/output"); deallog.attach(logfile); deallog.depth_console(0); diff --git a/tests/deal.II/user_data_01.cc b/tests/deal.II/user_data_01.cc index c334786c9b..d27da1e6c4 100644 --- a/tests/deal.II/user_data_01.cc +++ b/tests/deal.II/user_data_01.cc @@ -249,8 +249,9 @@ user_indices(Triangulation& tr) { tr.begin()->user_pointer(); } - catch (...) + catch (ExceptionBase &e) { + deallog << e.get_exc_name() << std::endl; } tr.begin()->user_index(); @@ -283,6 +284,7 @@ void check() int main() { deal_II_exceptions::disable_abort_on_exception(); + std::ofstream logfile("user_data_01/output"); deallog.attach(logfile); deallog.depth_console(0); diff --git a/tests/deal.II/user_data_01/cmp/generic b/tests/deal.II/user_data_01/cmp/generic index ddcba3194a..18b02bdcbd 100644 --- a/tests/deal.II/user_data_01/cmp/generic +++ b/tests/deal.II/user_data_01/cmp/generic @@ -3,7 +3,6 @@ DEAL::Pointers2D DEAL::.....................cells DEAL::........................................................faces DEAL::lines -DEAL::ExcPointerIndexClash() DEAL::Save2D DEAL::Load2D DEAL::.....................cells @@ -23,7 +22,6 @@ DEAL::Pointers3D DEAL::.........................................................................cells DEAL::..........................................................................................................................................................................................................................................................................................faces DEAL::..............................................................................................................................................................................................................................................................................................................................................................................lines -DEAL::ExcPointerIndexClash() DEAL::Save3D DEAL::Load3D DEAL::.........................................................................cells diff --git a/tests/distributed_grids/anisotropic.cc b/tests/distributed_grids/anisotropic.cc index c5079160da..6ce61b972b 100644 --- a/tests/distributed_grids/anisotropic.cc +++ b/tests/distributed_grids/anisotropic.cc @@ -41,8 +41,9 @@ void test(std::ostream& /*out*/) { tr.execute_coarsening_and_refinement (); } - catch (...) + catch (ExceptionBase &e) { + deallog << e.get_exc_name() << std::endl; } } @@ -50,6 +51,8 @@ void test(std::ostream& /*out*/) int main(int argc, char *argv[]) { + deal_II_exceptions::disable_abort_on_exception(); + #ifdef DEAL_II_WITH_MPI Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv, 1); #else @@ -62,16 +65,10 @@ int main(int argc, char *argv[]) deallog.depth_console(0); deallog.threshold_double(1.e-10); - // we want to catch exceptions - // instead of aborting the program - deal_II_exceptions::disable_abort_on_exception(); - deallog.push("2d"); test<2>(logfile); deallog.pop(); deallog.push("2d"); test<3>(logfile); deallog.pop(); - - } diff --git a/tests/fe/block_mask_02.cc b/tests/fe/block_mask_02.cc index e0f69cf13d..1aeeec4dbb 100644 --- a/tests/fe/block_mask_02.cc +++ b/tests/fe/block_mask_02.cc @@ -43,8 +43,9 @@ void test () { m[v.size()]; } - catch (...) + catch (ExceptionBase &e) { + deallog << e.get_exc_name() << std::endl; } deallog << "OK" << std::endl; @@ -54,6 +55,7 @@ void test () int main() { deal_II_exceptions::disable_abort_on_exception(); + std::ofstream logfile ("block_mask_02/output"); deallog << std::setprecision (4); diff --git a/tests/fe/block_mask_06.cc b/tests/fe/block_mask_06.cc index db9d79c139..a5db6fe7f2 100644 --- a/tests/fe/block_mask_06.cc +++ b/tests/fe/block_mask_06.cc @@ -28,6 +28,8 @@ void test () { + deal_II_exceptions::disable_abort_on_exception(); + // test for an initialized mask Assert (BlockMask(12,true).n_selected_blocks() == 12, ExcInternalError()); @@ -49,8 +51,9 @@ void test () Assert (BlockMask(12,true).n_selected_blocks(13) == 12, ExcInternalError()); } - catch (...) + catch (ExceptionBase &e) { + deallog << e.get_exc_name() << std::endl; } } @@ -58,8 +61,6 @@ void test () int main() { - deal_II_exceptions::disable_abort_on_exception(); - std::ofstream logfile ("block_mask_06/output"); deallog << std::setprecision (4); diff --git a/tests/fe/block_mask_07.cc b/tests/fe/block_mask_07.cc index 65d3af7b22..d25c959a0d 100644 --- a/tests/fe/block_mask_07.cc +++ b/tests/fe/block_mask_07.cc @@ -50,8 +50,9 @@ void test () Assert (BlockMask(12,true).first_selected_block(13) == 0, ExcInternalError()); } - catch (...) + catch (ExceptionBase &e) { + deallog << e.get_exc_name() << std::endl; } // as should this: @@ -60,8 +61,9 @@ void test () Assert (BlockMask(12,false).first_selected_block() == 0, ExcInternalError()); } - catch (...) + catch (ExceptionBase &e) { + deallog << e.get_exc_name() << std::endl; } } diff --git a/tests/fe/component_mask_02.cc b/tests/fe/component_mask_02.cc index f814f7a677..52389e7b0d 100644 --- a/tests/fe/component_mask_02.cc +++ b/tests/fe/component_mask_02.cc @@ -43,8 +43,9 @@ void test () { m[v.size()]; } - catch (...) + catch (ExceptionBase &e) { + deallog << e.get_exc_name() << std::endl; } deallog << "OK" << std::endl; @@ -54,6 +55,7 @@ void test () int main() { deal_II_exceptions::disable_abort_on_exception(); + std::ofstream logfile ("component_mask_02/output"); deallog << std::setprecision (4); diff --git a/tests/fe/component_mask_06.cc b/tests/fe/component_mask_06.cc index c95d4ffc92..9b76ecfe29 100644 --- a/tests/fe/component_mask_06.cc +++ b/tests/fe/component_mask_06.cc @@ -49,8 +49,9 @@ void test () Assert (ComponentMask(12,true).n_selected_components(13) == 12, ExcInternalError()); } - catch (...) + catch (ExceptionBase &e) { + deallog << e.get_exc_name() << std::endl; } } diff --git a/tests/fe/component_mask_07.cc b/tests/fe/component_mask_07.cc index 016638bb20..ea254812d3 100644 --- a/tests/fe/component_mask_07.cc +++ b/tests/fe/component_mask_07.cc @@ -50,8 +50,9 @@ void test () Assert (ComponentMask(12,true).first_selected_component(13) == 0, ExcInternalError()); } - catch (...) + catch (ExceptionBase &e) { + deallog << e.get_exc_name() << std::endl; } // as should this: @@ -60,8 +61,9 @@ void test () Assert (ComponentMask(12,false).first_selected_component() == 0, ExcInternalError()); } - catch (...) + catch (ExceptionBase &e) { + deallog << e.get_exc_name() << std::endl; } } diff --git a/tests/fe/component_mask_14.cc b/tests/fe/component_mask_14.cc index a7fb80f369..e72c664e26 100644 --- a/tests/fe/component_mask_14.cc +++ b/tests/fe/component_mask_14.cc @@ -51,9 +51,10 @@ void test () { deallog << fe.block_mask (component_mask) << std::endl; } - catch (...) + catch (ExceptionBase &e) { - } + deallog << e.get_exc_name() << std::endl; + } } deallog << "OK" << std::endl; diff --git a/tests/hp/fe_collection_04.cc b/tests/hp/fe_collection_04.cc index 5826b58e01..d6abf87512 100644 --- a/tests/hp/fe_collection_04.cc +++ b/tests/hp/fe_collection_04.cc @@ -47,8 +47,9 @@ void test () { fe_collection.n_blocks(); } - catch (...) + catch (ExceptionBase &e) { + deallog << e.get_exc_name() << std::endl; } deallog << "OK" << std::endl; diff --git a/tests/lac/constraints_c1.cc b/tests/lac/constraints_c1.cc index 338eb1eef5..4fd245ced9 100644 --- a/tests/lac/constraints_c1.cc +++ b/tests/lac/constraints_c1.cc @@ -125,14 +125,14 @@ setup_constraints(const DoFHandler& dof_handler) } deallog << "Closing" << std::endl; - deal_II_exceptions::disable_abort_on_exception(); try { constraints.close(); } - catch (...) + catch (ExceptionBase &e) { - } + deallog << e.get_exc_name() << std::endl; + } deallog << "Closed" << std::endl; } @@ -157,9 +157,12 @@ run(const FiniteElement& fe) int main() { + deal_II_exceptions::disable_abort_on_exception(); + const std::string logname = JobIdentifier::base_name(__FILE__) + std::string("/output"); std::ofstream logfile(logname.c_str()); deallog.attach(logfile); + deallog.depth_console(0); FE_Q<2> fe(3); run(fe); diff --git a/tests/lac/constraints_c1_02.cc b/tests/lac/constraints_c1_02.cc index a26fb1519a..e096cde3de 100644 --- a/tests/lac/constraints_c1_02.cc +++ b/tests/lac/constraints_c1_02.cc @@ -48,14 +48,14 @@ run() } deallog << "Closing" << std::endl; - deal_II_exceptions::disable_abort_on_exception(); try { constraints.close(); } - catch (...) + catch (ExceptionBase &e) { + deallog << e.get_exc_name() << std::endl; } deallog << "Closed" << std::endl; @@ -65,9 +65,12 @@ run() int main() { + deal_II_exceptions::disable_abort_on_exception(); + const std::string logname = JobIdentifier::base_name(__FILE__) + std::string("/output"); std::ofstream logfile(logname.c_str()); deallog.attach(logfile); + deallog.depth_console(0); run(); } diff --git a/tests/mpi/ghost_03.cc b/tests/mpi/ghost_03.cc index a46c5d08a6..57a8cb9a77 100644 --- a/tests/mpi/ghost_03.cc +++ b/tests/mpi/ghost_03.cc @@ -52,29 +52,40 @@ void test () Assert(!vb.has_ghost_elements(), ExcInternalError()); Assert(v.has_ghost_elements(), ExcInternalError()); - - deal_II_exceptions::disable_abort_on_exception(); - try + + try { v(0)=1.0; } - catch (...){} - try + catch (ExceptionBase &e) + { + deallog << e.get_exc_name() << std::endl; + } + try + { + v(0)*=2.0; + } + catch (ExceptionBase &e) { - v(0)*=2.0; + deallog << e.get_exc_name() << std::endl; } - catch (...){} - try + try { v=0.0; } - catch (...){} - try + catch (ExceptionBase &e) { - v+=v; + deallog << e.get_exc_name() << std::endl; } - catch (...){} - + try + { + v+=v; + } + catch (ExceptionBase &e) + { + deallog << e.get_exc_name() << std::endl; + } + // done if (myid==0) deallog << "OK" << std::endl; @@ -84,6 +95,8 @@ void test () int main (int argc, char **argv) { + deal_II_exceptions::disable_abort_on_exception(); + Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv); unsigned int myid = Utilities::MPI::this_mpi_process (MPI_COMM_WORLD); diff --git a/tests/mpi/trilinos_ghost_03.cc b/tests/mpi/trilinos_ghost_03.cc index 007a77d848..bf2037d1ec 100644 --- a/tests/mpi/trilinos_ghost_03.cc +++ b/tests/mpi/trilinos_ghost_03.cc @@ -54,21 +54,21 @@ void test () Assert (v_tmp.has_ghost_elements(), ExcInternalError()); - deal_II_exceptions::disable_abort_on_exception(); - try { v_tmp.l2_norm(); } - catch (...) + catch (ExceptionBase &e) { + deallog << e.get_exc_name() << std::endl; } try { v_tmp(0)=3.0; } - catch (...) + catch (ExceptionBase &e) { + deallog << e.get_exc_name() << std::endl; } if (Utilities::MPI::this_mpi_process (MPI_COMM_WORLD) == 0) @@ -79,6 +79,8 @@ void test () int main (int argc, char **argv) { + deal_II_exceptions::disable_abort_on_exception(); + Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv); unsigned int myid = Utilities::MPI::this_mpi_process (MPI_COMM_WORLD); diff --git a/tests/mpi/trilinos_ghost_03_linfty.cc b/tests/mpi/trilinos_ghost_03_linfty.cc index 08eb65c424..079ba6dd8f 100644 --- a/tests/mpi/trilinos_ghost_03_linfty.cc +++ b/tests/mpi/trilinos_ghost_03_linfty.cc @@ -52,8 +52,6 @@ void test () v_tmp.reinit(v,false,true); - deal_II_exceptions::disable_abort_on_exception(); - bool exc = false; double norm; try @@ -62,6 +60,7 @@ void test () } catch (TrilinosWrappers::VectorBase::ExcTrilinosError e) { + deallog << e.get_exc_name() << std::endl; exc = true; } @@ -79,6 +78,8 @@ void test () int main (int argc, char **argv) { + deal_II_exceptions::disable_abort_on_exception(); + Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv); unsigned int myid = Utilities::MPI::this_mpi_process (MPI_COMM_WORLD); diff --git a/tests/tests.h b/tests/tests.h index b5cb18da1a..d61bccee46 100644 --- a/tests/tests.h +++ b/tests/tests.h @@ -156,10 +156,8 @@ struct DeadlockKiller } } else - // environment variable is - // not set, so assume - // infinite wait time and - // simply quit this thread + // environment variable is not set, so assume infinite wait time + // and simply quit this thread { } } -- 2.39.5