tst-signal-numbers.py 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #!/usr/bin/python3
  2. # Test that glibc's signal numbers match the kernel's.
  3. # Copyright (C) 2018-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 argparse
  20. import sys
  21. import glibcextract
  22. def main():
  23. """The main entry point."""
  24. parser = argparse.ArgumentParser(
  25. description="Test that glibc's signal numbers match the kernel's.")
  26. parser.add_argument('--cc', metavar='CC',
  27. help='C compiler (including options) to use')
  28. args = parser.parse_args()
  29. sys.exit(glibcextract.compare_macro_consts(
  30. '#define _GNU_SOURCE 1\n'
  31. '#include <signal.h>\n',
  32. '#define _GNU_SOURCE 1\n'
  33. '#include <stddef.h>\n'
  34. '#include <asm/signal.h>\n',
  35. args.cc,
  36. # Filter out constants that aren't signal numbers.
  37. 'SIG[A-Z]+',
  38. # Discard obsolete signal numbers and unrelated constants:
  39. # SIGCLD, SIGIOT, SIGSWI, SIGUNUSED.
  40. # SIGSTKSZ, SIGRTMIN, SIGRTMAX.
  41. 'SIG(CLD|IOT|RT(MIN|MAX)|STKSZ|SWI|UNUSED)'))
  42. if __name__ == '__main__':
  43. main()