log.scm 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. ;;; log.scm -- Testing of the logging callback
  2. ;; Copyright (C) 2014 Artyom V. Poptsov <poptsov.artyom@gmail.com>
  3. ;;
  4. ;; This file is a part of Guile-SSH.
  5. ;;
  6. ;; Guile-SSH is free software: you can redistribute it and/or
  7. ;; modify it under the terms of the GNU General Public License as
  8. ;; published by the Free Software Foundation, either version 3 of the
  9. ;; License, or (at your option) any later version.
  10. ;;
  11. ;; Guile-SSH is distributed in the hope that it will be useful, but
  12. ;; WITHOUT ANY WARRANTY; without even the implied warranty of
  13. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. ;; General Public License for more details.
  15. ;;
  16. ;; You should have received a copy of the GNU General Public License
  17. ;; along with Guile-SSH. If not, see <http://www.gnu.org/licenses/>.
  18. (use-modules (srfi srfi-64)
  19. (ssh log))
  20. (test-begin "log")
  21. (test-equal "current-logging-callback"
  22. %default-log-printer
  23. (current-logging-callback))
  24. (define (custom-logging-callback priority function message useradata)
  25. (display "Hello Scheme World!"))
  26. (test-equal "set-logging-callback!, custom"
  27. custom-logging-callback
  28. (begin
  29. (set-logging-callback! custom-logging-callback)
  30. (current-logging-callback)))
  31. (test-equal "set-logging-callback!, default (libssh)"
  32. %default-libssh-log-printer
  33. (begin
  34. (set-logging-callback! %default-libssh-log-printer)
  35. (current-logging-callback)))
  36. (test-equal "set-logging-callback!, default"
  37. %default-log-printer
  38. (begin
  39. (set-logging-callback! %default-log-printer)
  40. (current-logging-callback)))
  41. (test-assert "set-log-verbosity!"
  42. (begin
  43. (set-log-verbosity! 'functions)
  44. (catch #t
  45. (lambda ()
  46. (set-log-verbosity! 'wrong-verbosity)
  47. #f)
  48. (lambda (key . args)
  49. #t))))
  50. (test-equal "get-log-verbosity"
  51. 'functions
  52. (get-log-verbosity))
  53. (test-end "log")
  54. (exit (= (test-runner-fail-count (test-runner-current)) 0))
  55. ;;; log.scm ends here