selftest.m4 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. dnl Copyright (C) 2018-2022 Free Software Foundation, Inc.
  2. dnl
  3. dnl This file is part of GDB.
  4. dnl
  5. dnl This program is free software; you can redistribute it and/or modify
  6. dnl it under the terms of the GNU General Public License as published by
  7. dnl the Free Software Foundation; either version 3 of the License, or
  8. dnl (at your option) any later version.
  9. dnl
  10. dnl This program is distributed in the hope that it will be useful,
  11. dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. dnl GNU General Public License for more details.
  14. dnl
  15. dnl You should have received a copy of the GNU General Public License
  16. dnl along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. dnl GDB_AC_SELFTEST(ACTION-IF-ENABLED)
  18. dnl
  19. dnl Enable the unit/self tests if needed. If they are enabled, AC_DEFINE
  20. dnl the GDB_SELF_TEST macro, and execute ACTION-IF-ENABLED.
  21. AC_DEFUN([GDB_AC_SELFTEST],[
  22. # Check whether we will enable the inclusion of unit tests when
  23. # compiling GDB.
  24. #
  25. # The default value of this option changes depending whether we're on
  26. # development mode (in which case it's "true") or not (in which case
  27. # it's "false"). The $development variable is set by the GDB_AC_COMMON
  28. # macro, which must therefore be used before GDB_AC_SELFTEST.
  29. AS_IF([test "x$development" != xtrue && test "x$development" != xfalse],
  30. [AC_MSG_ERROR([Invalid value for \$development, got "$development", expecting "true" or "false".])])
  31. AC_ARG_ENABLE(unit-tests,
  32. AS_HELP_STRING([--enable-unit-tests],
  33. [Enable the inclusion of unit tests when compiling GDB]),
  34. [case "${enableval}" in
  35. yes) enable_unittests=true ;;
  36. no) enable_unittests=false ;;
  37. *) AC_MSG_ERROR(
  38. [bad value ${enableval} for --{enable,disable}-unit-tests option]) ;;
  39. esac], [enable_unittests=$development])
  40. if $enable_unittests; then
  41. AC_DEFINE(GDB_SELF_TEST, 1,
  42. [Define if self-testing features should be enabled])
  43. $1
  44. fi
  45. ])