Skip to content

Commit

Permalink
Add configure flag --enable-memerr-tests to toggle tests of memory fa…
Browse files Browse the repository at this point in the history
…ilures.

These tests fail on some platforms, so they are by default off from now on.

Closes #94.
  • Loading branch information
mittinatten committed Sep 9, 2023
1 parent d5898c1 commit e919188
Show file tree
Hide file tree
Showing 10 changed files with 39 additions and 8 deletions.
12 changes: 12 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,18 @@ if test "x$enable_check" = "xyes" ; then
AM_CONDITIONAL([USE_CHECK], true)
fi

# Enable memerr tests
AC_ARG_ENABLE([memerr-tests],
[AS_HELP_STRING([--enable-memerr-tests],
[Enable memory error tests that replace malloc])])
AM_CONDITIONAL([INCLUDE_MEMERR_TESTS], false)
AC_DEFINE([INCLUDE_MEMERR_TESTS],[0],[Include memory error tests that require mocking malloc])

if test "x$enable_memerr_tests" = "xyes" ; then
AC_DEFINE([INCLUDE_MEMERR_TESTS], [1])
AM_CONDITIONAL([INCLUDE_MEMERR_TESTS], true)
fi

# Enable gcov
AC_ARG_ENABLE([gcov],
[AS_HELP_STRING([--enable-gcov],
Expand Down
4 changes: 3 additions & 1 deletion tests/test_classifier.c
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,9 @@ Suite *classifier_suite()
tcase_add_test(tc_core, test_residue);
tcase_add_test(tc_core, test_user);
tcase_add_test(tc_core, test_backbone);
tcase_add_test(tc_core, test_memerr);
if (INCLUDE_MEMERR_TESTS) {
tcase_add_test(tc_core, test_memerr);
}

TCase *tc_static = test_classifier_static();

Expand Down
5 changes: 4 additions & 1 deletion tests/test_coord.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,10 @@ Suite *coord_suite()
TCase *tc_core = tcase_create("Core");
tcase_add_checked_fixture(tc_core, setup, teardown);
tcase_add_test(tc_core, test_coord);
tcase_add_test(tc_core, test_memerr);
if (INCLUDE_MEMERR_TESTS) {
tcase_add_test(tc_core, test_memerr);
}

suite_add_tcase(s, tc_core);
return s;
}
4 changes: 3 additions & 1 deletion tests/test_freesasa.c
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,9 @@ Suite *sasa_suite()
tcase_add_test(tc_basic, test_calc_errors);
tcase_add_test(tc_basic, test_user_classes);
tcase_add_test(tc_basic, test_write_pdb);
tcase_add_test(tc_basic, test_memerr);
if (INCLUDE_MEMERR_TESTS) {
tcase_add_test(tc_basic, test_memerr);
}

TCase *tc_lr_basic = tcase_create("Basic L&R");
tcase_add_checked_fixture(tc_lr_basic, setup_lr_precision, teardown_lr_precision);
Expand Down
4 changes: 3 additions & 1 deletion tests/test_nb.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ Suite *nb_suite()

TCase *tc_nb = tcase_create("Basic");
tcase_add_test(tc_nb, test_nb);
tcase_add_test(tc_nb, test_memerr);
if (INCLUDE_MEMERR_TESTS) {
tcase_add_test(tc_nb, test_memerr);
}

TCase *tc_static = test_nb_static();

Expand Down
4 changes: 3 additions & 1 deletion tests/test_node.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,9 @@ Suite *result_node_suite()

TCase *tc_core = tcase_create("Core");
tcase_add_test(tc_core, test_result_node);
tcase_add_test(tc_core, test_memerr);
if (INCLUDE_MEMERR_TESTS) {
tcase_add_test(tc_core, test_memerr);
}

suite_add_tcase(s, tc_core);

Expand Down
4 changes: 3 additions & 1 deletion tests/test_selection.c
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,9 @@ Suite *selector_suite()
tcase_add_test(tc_core, test_resn);
tcase_add_test(tc_core, test_resi);
tcase_add_test(tc_core, test_chain);
tcase_add_test(tc_core, test_memerr);
if (INCLUDE_MEMERR_TESTS) {
tcase_add_test(tc_core, test_memerr);
}

TCase *tc_static = test_selection_static();

Expand Down
4 changes: 3 additions & 1 deletion tests/test_structure.c
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,9 @@ Suite *structure_suite()
TCase *tc_core = tcase_create("Core");
tcase_add_test(tc_core, test_structure_api);
tcase_add_test(tc_core, test_add_atom);
tcase_add_test(tc_core, test_memerr);
if (INCLUDE_MEMERR_TESTS) {
tcase_add_test(tc_core, test_memerr);
}

TCase *tc_pdb = tcase_create("PDB");
tcase_add_test(tc_pdb, test_pdb);
Expand Down
5 changes: 4 additions & 1 deletion tests/test_xml.c
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,10 @@ Suite *xml_suite()
TCase *tc_core = tcase_create("Core");
tcase_add_checked_fixture(tc_core, setup, teardown);
tcase_add_test(tc_core, test_libxmlerr);
tcase_add_test(tc_core, test_memerr);

if (INCLUDE_MEMERR_TESTS) {
tcase_add_test(tc_core, test_memerr);
}

suite_add_tcase(s, tc_core);

Expand Down
1 change: 1 addition & 0 deletions tests/tools.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#ifndef TOOLS_H
#define TOOLS_H
#include "../config.h"

int
float_eq(double a, double b, double tolerance);
Expand Down

0 comments on commit e919188

Please sign in to comment.