tst-strsignal.c 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /* Test for strsignal.
  2. Copyright (C) 2020-2026 Free Software Foundation, Inc.
  3. This file is part of the GNU C Library.
  4. The GNU C Library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Lesser General Public
  6. License as published by the Free Software Foundation; either
  7. version 2.1 of the License, or (at your option) any later version.
  8. The GNU C Library is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public
  13. License along with the GNU C Library; if not, see
  14. <https://www.gnu.org/licenses/>. */
  15. #include <string.h>
  16. #include <stdio.h>
  17. #include <signal.h>
  18. #include <stdlib.h>
  19. #include <locale.h>
  20. #include <array_length.h>
  21. #include <support/support.h>
  22. #include <support/check.h>
  23. static int
  24. do_test (void)
  25. {
  26. unsetenv ("LANGUAGE");
  27. xsetlocale (LC_ALL, "C");
  28. TEST_COMPARE_STRING (strsignal (SIGINT), "Interrupt");
  29. TEST_COMPARE_STRING (strsignal (-1), "Unknown signal -1");
  30. #ifdef SIGRTMIN
  31. if (SIGRTMIN < SIGRTMAX)
  32. TEST_COMPARE_STRING (strsignal (SIGRTMIN), "Real-time signal 0");
  33. #endif
  34. #ifdef SIGRTMAX
  35. if (SIGRTMAX == 64)
  36. TEST_COMPARE_STRING (strsignal (SIGRTMAX+1), "Unknown signal 65");
  37. #endif
  38. xsetlocale (LC_ALL, "pt_BR.UTF-8");
  39. TEST_COMPARE_STRING (strsignal (SIGINT), "Interrup\xc3\xa7\xc3\xa3\x6f");
  40. TEST_COMPARE_STRING (strsignal (-1), "Sinal desconhecido -1");
  41. #ifdef SIGRTMI
  42. if (SIGRTMIN < SIGRTMAX)
  43. TEST_COMPARE_STRING (strsignal (SIGRTMIN), "Sinal de tempo-real 0");
  44. #endif
  45. #ifdef SIGRTMAX
  46. if (SIGRTMAX == 64)
  47. TEST_COMPARE_STRING (strsignal (SIGRTMAX+1), "Sinal desconhecido 65");
  48. #endif
  49. return 0;
  50. }
  51. #include <support/test-driver.c>