test-mutexattr-printers.py 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. # Common tests for the MutexPrinter and MutexAttributesPrinter classes.
  2. #
  3. # Copyright (C) 2016-2019 Free Software Foundation, Inc.
  4. # This file is part of the GNU C Library.
  5. #
  6. # The GNU C Library is free software; you can redistribute it and/or
  7. # modify it under the terms of the GNU Lesser General Public
  8. # License as published by the Free Software Foundation; either
  9. # version 2.1 of the License, or (at your option) any later version.
  10. #
  11. # The GNU C Library is distributed in the hope that it will be useful,
  12. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. # Lesser General Public License for more details.
  15. #
  16. # You should have received a copy of the GNU Lesser General Public
  17. # License along with the GNU C Library; if not, see
  18. # <http://www.gnu.org/licenses/>.
  19. import sys
  20. from test_printers_common import *
  21. test_source = sys.argv[1]
  22. test_bin = sys.argv[2]
  23. printer_files = sys.argv[3:]
  24. printer_names = ['global glibc-pthread-locks']
  25. PRIOCEILING = 42
  26. try:
  27. init_test(test_bin, printer_files, printer_names)
  28. go_to_main()
  29. check_debug_symbol('struct pthread_mutexattr')
  30. mutex_var = 'mutex'
  31. mutex_to_string = 'pthread_mutex_t'
  32. attr_var = 'attr'
  33. attr_to_string = 'pthread_mutexattr_t'
  34. break_at(test_source, 'Set type')
  35. continue_cmd() # Go to test_settype
  36. next_cmd(2)
  37. test_printer(attr_var, attr_to_string, {'Type': 'Error check'})
  38. test_printer(mutex_var, mutex_to_string, {'Type': 'Error check'})
  39. next_cmd(2)
  40. test_printer(attr_var, attr_to_string, {'Type': 'Recursive'})
  41. test_printer(mutex_var, mutex_to_string, {'Type': 'Recursive'})
  42. next_cmd(2)
  43. test_printer(attr_var, attr_to_string, {'Type': 'Normal'})
  44. test_printer(mutex_var, mutex_to_string, {'Type': 'Normal'})
  45. break_at(test_source, 'Set robust')
  46. continue_cmd() # Go to test_setrobust
  47. next_cmd(2)
  48. test_printer(attr_var, attr_to_string, {'Robust': 'Yes'})
  49. test_printer(mutex_var, mutex_to_string, {'Robust': 'Yes'})
  50. next_cmd(2)
  51. test_printer(attr_var, attr_to_string, {'Robust': 'No'})
  52. test_printer(mutex_var, mutex_to_string, {'Robust': 'No'})
  53. break_at(test_source, 'Set shared')
  54. continue_cmd() # Go to test_setpshared
  55. next_cmd(2)
  56. test_printer(attr_var, attr_to_string, {'Shared': 'Yes'})
  57. test_printer(mutex_var, mutex_to_string, {'Shared': 'Yes'})
  58. next_cmd(2)
  59. test_printer(attr_var, attr_to_string, {'Shared': 'No'})
  60. test_printer(mutex_var, mutex_to_string, {'Shared': 'No'})
  61. break_at(test_source, 'Set protocol')
  62. continue_cmd() # Go to test_setprotocol
  63. next_cmd(2)
  64. test_printer(attr_var, attr_to_string, {'Protocol': 'Priority inherit'})
  65. test_printer(mutex_var, mutex_to_string, {'Protocol': 'Priority inherit'})
  66. next_cmd(2)
  67. test_printer(attr_var, attr_to_string, {'Protocol': 'Priority protect'})
  68. test_printer(mutex_var, mutex_to_string, {'Protocol': 'Priority protect'})
  69. next_cmd(2)
  70. test_printer(mutex_var, mutex_to_string, {'Priority ceiling':
  71. str(PRIOCEILING)})
  72. next_cmd()
  73. test_printer(attr_var, attr_to_string, {'Protocol': 'None'})
  74. test_printer(mutex_var, mutex_to_string, {'Protocol': 'None'})
  75. continue_cmd() # Exit
  76. except (NoLineError, pexpect.TIMEOUT) as exception:
  77. print('Error: {0}'.format(exception))
  78. result = FAIL
  79. except DebugError as exception:
  80. print(exception)
  81. result = UNSUPPORTED
  82. else:
  83. print('Test succeeded.')
  84. result = PASS
  85. exit(result)