tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

ssl_gtest.cc (1220B)


      1 #include "nspr.h"
      2 #include "nss.h"
      3 #include "prenv.h"
      4 #include "ssl.h"
      5 
      6 #include <cstdlib>
      7 
      8 #include "test_io.h"
      9 #include "databuffer.h"
     10 
     11 #define GTEST_HAS_RTTI 0
     12 #include "gtest/gtest.h"
     13 
     14 std::string g_working_dir_path;
     15 bool g_ssl_gtest_verbose;
     16 
     17 int main(int argc, char** argv) {
     18  // Start the tests
     19  ::testing::InitGoogleTest(&argc, argv);
     20  g_working_dir_path = ".";
     21  g_ssl_gtest_verbose = false;
     22 
     23  char* workdir = PR_GetEnvSecure("NSS_GTEST_WORKDIR");
     24  if (workdir) g_working_dir_path = workdir;
     25 
     26  for (int i = 0; i < argc; i++) {
     27    if (!strcmp(argv[i], "-d")) {
     28      g_working_dir_path = argv[i + 1];
     29      ++i;
     30    } else if (!strcmp(argv[i], "-v")) {
     31      g_ssl_gtest_verbose = true;
     32      nss_test::DataBuffer::SetLogLimit(16384);
     33    }
     34  }
     35 
     36  if (NSS_Initialize(g_working_dir_path.c_str(), "", "", SECMOD_DB,
     37                     NSS_INIT_READONLY) != SECSuccess) {
     38    return 1;
     39  }
     40  if (NSS_SetDomesticPolicy() != SECSuccess) {
     41    return 1;
     42  }
     43  if (NSS_SetAlgorithmPolicy(SEC_OID_XYBER768D00, NSS_USE_ALG_IN_SSL_KX, 0) !=
     44      SECSuccess) {
     45    return 1;
     46  }
     47  int rv = RUN_ALL_TESTS();
     48 
     49  if (NSS_Shutdown() != SECSuccess) {
     50    return 1;
     51  }
     52 
     53  nss_test::Poller::Shutdown();
     54 
     55  return rv;
     56 }