25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.
 
 
 
 
 
 

96 satır
2.8 KiB

  1. /* Copyright (c) 2016, Google Inc.
  2. *
  3. * Permission to use, copy, modify, and/or distribute this software for any
  4. * purpose with or without fee is hereby granted, provided that the above
  5. * copyright notice and this permission notice appear in all copies.
  6. *
  7. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  8. * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  9. * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
  10. * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  11. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
  12. * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
  13. * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */
  14. #include <stdio.h>
  15. #include <string.h>
  16. #include <gtest/gtest.h>
  17. #include <openssl/cpu.h>
  18. #include <openssl/rand.h>
  19. #include "abi_test.h"
  20. #include "gtest_main.h"
  21. #include "../internal.h"
  22. #if (defined(OPENSSL_ARM) || defined(OPENSSL_AARCH64)) && \
  23. !defined(OPENSSL_STATIC_ARMCAP)
  24. #include <openssl/arm_arch.h>
  25. #define TEST_ARM_CPUS
  26. #endif
  27. int main(int argc, char **argv) {
  28. testing::InitGoogleTest(&argc, argv);
  29. bssl::SetupGoogleTest();
  30. bool unwind_tests = true;
  31. for (int i = 1; i < argc; i++) {
  32. #if !defined(OPENSSL_WINDOWS)
  33. if (strcmp(argv[i], "--fork_unsafe_buffering") == 0) {
  34. RAND_enable_fork_unsafe_buffering(-1);
  35. }
  36. #endif
  37. #if defined(TEST_ARM_CPUS)
  38. if (strncmp(argv[i], "--cpu=", 6) == 0) {
  39. const char *cpu = argv[i] + 6;
  40. uint32_t armcap;
  41. if (strcmp(cpu, "none") == 0) {
  42. armcap = 0;
  43. } else if (strcmp(cpu, "neon") == 0) {
  44. armcap = ARMV7_NEON;
  45. } else if (strcmp(cpu, "crypto") == 0) {
  46. armcap = ARMV7_NEON | ARMV8_AES | ARMV8_SHA1 | ARMV8_SHA256 | ARMV8_PMULL;
  47. } else {
  48. fprintf(stderr, "Unknown CPU: %s\n", cpu);
  49. exit(1);
  50. }
  51. uint32_t *armcap_ptr = OPENSSL_get_armcap_pointer_for_test();
  52. if ((armcap & *armcap_ptr) != armcap) {
  53. fprintf(stderr,
  54. "Host CPU does not support features for testing CPU '%s'.\n",
  55. cpu);
  56. exit(89);
  57. }
  58. printf("Simulating CPU '%s'\n", cpu);
  59. *armcap_ptr = armcap;
  60. }
  61. #endif // TEST_ARM_CPUS
  62. if (strcmp(argv[i], "--no_unwind_tests") == 0) {
  63. unwind_tests = false;
  64. }
  65. }
  66. if (unwind_tests) {
  67. abi_test::EnableUnwindTests();
  68. }
  69. // Run the entire test suite under an ABI check. This is less effective than
  70. // testing the individual assembly functions, but will catch issues with
  71. // rarely-used registers.
  72. abi_test::Result abi;
  73. int ret = abi_test::Check(&abi, RUN_ALL_TESTS);
  74. if (!abi.ok()) {
  75. fprintf(stderr, "ABI failure in test suite:\n");
  76. for (const auto &error : abi.errors) {
  77. fprintf(stderr, " %s\n", error.c_str());
  78. }
  79. exit(1);
  80. }
  81. return ret;
  82. }