/src/mongo/dbtests/dbtests.cpp

https://github.com/tadmarshall/mongo · C++ · 59 lines · 32 code · 5 blank · 22 comment · 0 complexity · ff4f72e94bc22790a3a5c39ee9d69865 MD5 · raw file

  1. // #file dbtests.cpp : Runs db unit tests.
  2. //
  3. /**
  4. * Copyright (C) 2008 10gen Inc.
  5. *
  6. * This program is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU Affero General Public License, version 3,
  8. * as published by the Free Software Foundation.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU Affero General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU Affero General Public License
  16. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. #include "mongo/pch.h"
  19. #include "mongo/base/initializer.h"
  20. #include "mongo/db/commands.h"
  21. #include "mongo/db/auth/authorization_manager.h"
  22. #include "mongo/db/auth/authorization_manager_global.h"
  23. #include "mongo/db/auth/authz_manager_external_state_mock.h"
  24. #include "mongo/dbtests/dbtests.h"
  25. #include "mongo/dbtests/framework.h"
  26. #include "mongo/util/exception_filter_win32.h"
  27. #include "mongo/util/startup_test.h"
  28. #include "mongo/util/text.h"
  29. int dbtestsMain( int argc, char** argv, char** envp ) {
  30. static StaticObserver StaticObserver;
  31. setWindowsUnhandledExceptionFilter();
  32. setGlobalAuthorizationManager(new AuthorizationManager(new AuthzManagerExternalStateMock()));
  33. Command::testCommandsEnabled = 1;
  34. mongo::runGlobalInitializersOrDie(argc, argv, envp);
  35. StartupTest::runTests();
  36. return mongo::dbtests::runDbTests( argc, argv, "/tmp/unittest" );
  37. }
  38. #if defined(_WIN32)
  39. // In Windows, wmain() is an alternate entry point for main(), and receives the same parameters
  40. // as main() but encoded in Windows Unicode (UTF-16); "wide" 16-bit wchar_t characters. The
  41. // WindowsCommandLine object converts these wide character strings to a UTF-8 coded equivalent
  42. // and makes them available through the argv() and envp() members. This enables dbtestsMain()
  43. // to process UTF-8 encoded arguments and environment variables without regard to platform.
  44. int wmain(int argc, wchar_t* argvW[], wchar_t* envpW[]) {
  45. WindowsCommandLine wcl(argc, argvW, envpW);
  46. int exitCode = dbtestsMain(argc, wcl.argv(), wcl.envp());
  47. ::_exit(exitCode);
  48. }
  49. #else
  50. int main(int argc, char* argv[], char** envp) {
  51. int exitCode = dbtestsMain(argc, argv, envp);
  52. ::_exit(exitCode);
  53. }
  54. #endif