testfrmw.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. /*
  2. * Copyright (c) 2004, Bull S.A.. All rights reserved.
  3. * Created by: Sebastien Decugis
  4. *
  5. * This program is free software; you can redistribute it and/or modify it
  6. * under the terms of version 2 of the GNU General Public License as
  7. * published by the Free Software Foundation.
  8. *
  9. * This program is distributed in the hope that it would be useful, but
  10. * WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  12. *
  13. * You should have received a copy of the GNU General Public License along
  14. * with this program; if not, write the Free Software Foundation, Inc.,
  15. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  16. *
  17. * This file is a wrapper to use the tests from the NPTL Test & Trace Project
  18. * with either the Linux Test Project or the Open POSIX Test Suite.
  19. *
  20. * The following macros are defined here:
  21. * UNRESOLVED(ret, descr);
  22. * where descr is a description of the error and ret is
  23. * an int (error code for example)
  24. * FAILED(descr);
  25. * where descr is a short text saying why the test has failed.
  26. * PASSED();
  27. * No parameter.
  28. *
  29. * Both three macros shall terminate the calling process.
  30. * The testcase shall not terminate without calling one of those macros.
  31. */
  32. #include "posixtest.h"
  33. #include <string.h>
  34. #ifdef __GNUC__
  35. #define UNRESOLVED(x, s) \
  36. { \
  37. output("Test %s unresolved: got %i (%s) on line %i (%s)\n", \
  38. __FILE__, x, strerror(x), __LINE__, s); \
  39. output_fini(); \
  40. exit(PTS_UNRESOLVED); \
  41. }
  42. #define FAILED(s) \
  43. { \
  44. output("Test %s FAILED: %s\n", __FILE__, s); \
  45. output_fini(); \
  46. exit(PTS_FAIL); \
  47. }
  48. #define PASSED \
  49. { \
  50. output_fini(); \
  51. exit(PTS_PASS); \
  52. }
  53. #define UNTESTED(s) \
  54. { \
  55. output("File %s cannot test: %s\n", __FILE__, s); \
  56. output_fini(); \
  57. exit(PTS_UNTESTED); \
  58. }
  59. #else
  60. #define UNRESOLVED(x, s) \
  61. { \
  62. output("Test unresolved: got %i (%s) on line %i (%s)\n", \
  63. x, strerror(x), __LINE__, s); \
  64. output_fini(); \
  65. exit(PTS_UNRESOLVED); \
  66. }
  67. #define FAILED(s) \
  68. { \
  69. output("Test FAILED: %s\n", s); \
  70. output_fini(); \
  71. exit(PTS_FAIL); \
  72. }
  73. #define PASSED \
  74. { \
  75. output_fini(); \
  76. exit(PTS_PASS); \
  77. }
  78. #define UNTESTED(s) \
  79. { \
  80. output("Unable to test: %s\n", s); \
  81. output_fini(); \
  82. exit(PTS_UNTESTED); \
  83. }
  84. #endif