tap-interface.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /*
  2. Unix SMB/CIFS implementation.
  3. Simplistic implementation of tap interface.
  4. Copyright (C) Rusty Russell 2012
  5. ** NOTE! The following LGPL license applies to the talloc
  6. ** library. This does NOT imply that all of Samba is released
  7. ** under the LGPL
  8. This library is free software; you can redistribute it and/or
  9. modify it under the terms of the GNU Lesser General Public
  10. License as published by the Free Software Foundation; either
  11. version 3 of the License, or (at your option) any later version.
  12. This library is distributed in the hope that it will be useful,
  13. but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. Lesser General Public License for more details.
  16. You should have received a copy of the GNU Lesser General Public
  17. License along with this library; if not, see <http://www.gnu.org/licenses/>.
  18. */
  19. #include <stdio.h>
  20. #include <ccan/err/err.h>
  21. #include "no-fsync.h"
  22. #ifndef __location__
  23. #define __TAP_STRING_LINE1__(s) #s
  24. #define __TAP_STRING_LINE2__(s) __TAP_STRING_LINE1__(s)
  25. #define __TAP_STRING_LINE3__ __TAP_STRING_LINE2__(__LINE__)
  26. #define __location__ __FILE__ ":" __TAP_STRING_LINE3__
  27. #endif
  28. extern unsigned tap_ok_count, tap_ok_target;
  29. #define plan_tests(num) do { tap_ok_target = (num); } while(0)
  30. #define ok(e, ...) ((e) ? (printf("."), tap_ok_count++, true) : (warnx(__VA_ARGS__), false))
  31. #define ok1(e) ok((e), "%s:%s", __location__, #e)
  32. #define pass(...) (printf("."), tap_ok_count++)
  33. #define fail(...) warnx(__VA_ARGS__)
  34. #define diag(...) do { printf(__VA_ARGS__); printf("\n"); } while(0)
  35. #define exit_status() (tap_ok_count == tap_ok_target ? 0 : 1)