diff Odbc/UnitTests/UnitTestsMain.cpp @ 329:b5fb8b77ce4d

initial commit of ODBC framework
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 10 Aug 2021 20:08:53 +0200
parents
children 674bbb9d1c83
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Odbc/UnitTests/UnitTestsMain.cpp	Tue Aug 10 20:08:53 2021 +0200
@@ -0,0 +1,93 @@
+/**
+ * Orthanc - A Lightweight, RESTful DICOM Store
+ * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
+ * Department, University Hospital of Liege, Belgium
+ * Copyright (C) 2017-2021 Osimis S.A., Belgium
+ *
+ * This program is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU Affero General Public License
+ * as published by the Free Software Foundation, either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Affero General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ **/
+
+
+#include "../Plugins/OdbcIndex.h"
+
+static std::string connectionString_;
+
+#include "../../Framework/Plugins/IndexUnitTests.h"
+
+#include <Logging.h>
+
+
+#if defined(_WIN32)
+#  warning Strings have not been tested on Windows (UTF16 issues ahead)!
+#  include <windows.h>
+#else
+#  include <ltdl.h>
+#  include <libltdl/lt_dlloader.h>
+#endif
+
+
+#if !defined(_WIN32)
+extern "C"
+{
+  extern lt_dlvtable *dlopen_LTX_get_vtable(lt_user_data loader_data);
+}
+#endif
+
+
+int main(int argc, char **argv)
+{
+  if (argc < 2)
+  {
+    std::cerr
+      << std::endl
+      << "Usage:    " << argv[0] << " <connection string>"
+      << std::endl << std::endl
+      << "Example:  " << argv[0] << " \"DSN=test\""
+      << std::endl << std::endl;
+    return -1;
+  }
+
+  for (int i = 1; i < argc; i++)
+  {
+    // Ignore arguments beginning with "-" to allow passing arguments
+    // to Google Test such as "--gtest_filter="
+    if (argv[i] != NULL &&
+        argv[i][0] != '-')
+    {
+      connectionString_ = argv[i];
+    }
+  }
+
+#if !defined(_WIN32)
+  lt_dlinit();
+
+  /**
+   * The following call is necessary for "libltdl" to access the
+   * "dlopen()" primitives if statically linking. Otherwise, only the
+   * "preopen" primitives are available.
+   **/
+  lt_dlloader_add(dlopen_LTX_get_vtable(NULL));
+#endif
+
+  ::testing::InitGoogleTest(&argc, argv);
+  Orthanc::Logging::Initialize();
+  Orthanc::Logging::EnableInfoLevel(true);
+  //Orthanc::Logging::EnableTraceLevel(true);
+
+  int result = RUN_ALL_TESTS();
+  
+  Orthanc::Logging::Finalize();
+
+  return result;
+}