test-condattr-printers.py 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. # Common tests for the ConditionVariablePrinter and
  2. # ConditionVariableAttributesPrinter classes.
  3. #
  4. # Copyright (C) 2016-2019 Free Software Foundation, Inc.
  5. # This file is part of the GNU C Library.
  6. #
  7. # The GNU C Library is free software; you can redistribute it and/or
  8. # modify it under the terms of the GNU Lesser General Public
  9. # License as published by the Free Software Foundation; either
  10. # version 2.1 of the License, or (at your option) any later version.
  11. #
  12. # The GNU C 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. #
  17. # You should have received a copy of the GNU Lesser General Public
  18. # License along with the GNU C Library; if not, see
  19. # <http://www.gnu.org/licenses/>.
  20. import sys
  21. from test_printers_common import *
  22. test_source = sys.argv[1]
  23. test_bin = sys.argv[2]
  24. printer_files = sys.argv[3:]
  25. printer_names = ['global glibc-pthread-locks']
  26. try:
  27. init_test(test_bin, printer_files, printer_names)
  28. go_to_main()
  29. check_debug_symbol('struct pthread_condattr')
  30. condvar_var = 'condvar'
  31. condvar_to_string = 'pthread_cond_t'
  32. attr_var = 'attr'
  33. attr_to_string = 'pthread_condattr_t'
  34. break_at(test_source, 'Set clock')
  35. continue_cmd() # Go to test_setclock
  36. next_cmd(2)
  37. test_printer(condvar_var, condvar_to_string, {'Clock ID': 'CLOCK_REALTIME'})
  38. test_printer(attr_var, attr_to_string, {'Clock ID': 'CLOCK_REALTIME'})
  39. break_at(test_source, 'Set shared')
  40. continue_cmd() # Go to test_setpshared
  41. next_cmd(2)
  42. test_printer(condvar_var, condvar_to_string, {'Shared': 'Yes'})
  43. test_printer(attr_var, attr_to_string, {'Shared': 'Yes'})
  44. next_cmd(2)
  45. test_printer(condvar_var, condvar_to_string, {'Shared': 'No'})
  46. test_printer(attr_var, attr_to_string, {'Shared': 'No'})
  47. continue_cmd() # Exit
  48. except (NoLineError, pexpect.TIMEOUT) as exception:
  49. print('Error: {0}'.format(exception))
  50. result = FAIL
  51. except DebugError as exception:
  52. print(exception)
  53. result = UNSUPPORTED
  54. else:
  55. print('Test succeeded.')
  56. result = PASS
  57. exit(result)