Mercurial > hg > orthanc-databases
annotate Odbc/UnitTests/UnitTestsMain.cpp @ 445:cec6a0cd399f pg-transactions
now logging DatabaseCannotSerialize as a warning only with the details (Orthanc will log it as an error after all retries)
author | Alain Mazy <am@osimis.io> |
---|---|
date | Wed, 10 Jan 2024 15:25:03 +0100 |
parents | 3d6886f3e5b3 |
children | ecd0b719cff5 |
rev | line source |
---|---|
329
b5fb8b77ce4d
initial commit of ODBC framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1 /** |
b5fb8b77ce4d
initial commit of ODBC framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2 * Orthanc - A Lightweight, RESTful DICOM Store |
b5fb8b77ce4d
initial commit of ODBC framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics |
b5fb8b77ce4d
initial commit of ODBC framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
4 * Department, University Hospital of Liege, Belgium |
389
3d6886f3e5b3
upgrade to year 2023
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
359
diff
changeset
|
5 * Copyright (C) 2017-2023 Osimis S.A., Belgium |
3d6886f3e5b3
upgrade to year 2023
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
359
diff
changeset
|
6 * Copyright (C) 2021-2023 Sebastien Jodogne, ICTEAM UCLouvain, Belgium |
329
b5fb8b77ce4d
initial commit of ODBC framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
7 * |
b5fb8b77ce4d
initial commit of ODBC framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
8 * This program is free software: you can redistribute it and/or |
b5fb8b77ce4d
initial commit of ODBC framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
9 * modify it under the terms of the GNU Affero General Public License |
b5fb8b77ce4d
initial commit of ODBC framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
10 * as published by the Free Software Foundation, either version 3 of |
b5fb8b77ce4d
initial commit of ODBC framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
11 * the License, or (at your option) any later version. |
b5fb8b77ce4d
initial commit of ODBC framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
12 * |
b5fb8b77ce4d
initial commit of ODBC framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
13 * This program is distributed in the hope that it will be useful, but |
b5fb8b77ce4d
initial commit of ODBC framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
14 * WITHOUT ANY WARRANTY; without even the implied warranty of |
b5fb8b77ce4d
initial commit of ODBC framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
b5fb8b77ce4d
initial commit of ODBC framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
16 * Affero General Public License for more details. |
b5fb8b77ce4d
initial commit of ODBC framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
17 * |
b5fb8b77ce4d
initial commit of ODBC framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
18 * You should have received a copy of the GNU Affero General Public License |
b5fb8b77ce4d
initial commit of ODBC framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
19 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
b5fb8b77ce4d
initial commit of ODBC framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
20 **/ |
b5fb8b77ce4d
initial commit of ODBC framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
21 |
b5fb8b77ce4d
initial commit of ODBC framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
22 |
b5fb8b77ce4d
initial commit of ODBC framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
23 #include "../Plugins/OdbcIndex.h" |
b5fb8b77ce4d
initial commit of ODBC framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
24 |
b5fb8b77ce4d
initial commit of ODBC framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
25 static std::string connectionString_; |
b5fb8b77ce4d
initial commit of ODBC framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
26 |
331
674bbb9d1c83
added OdbcEnvironment::GlobalInitialization()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
329
diff
changeset
|
27 #include "../../Framework/Odbc/OdbcEnvironment.h" |
329
b5fb8b77ce4d
initial commit of ODBC framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
28 #include "../../Framework/Plugins/IndexUnitTests.h" |
b5fb8b77ce4d
initial commit of ODBC framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
29 |
b5fb8b77ce4d
initial commit of ODBC framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
30 #include <Logging.h> |
b5fb8b77ce4d
initial commit of ODBC framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
31 |
b5fb8b77ce4d
initial commit of ODBC framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
32 |
b5fb8b77ce4d
initial commit of ODBC framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
33 #if defined(_WIN32) |
b5fb8b77ce4d
initial commit of ODBC framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
34 # include <windows.h> |
b5fb8b77ce4d
initial commit of ODBC framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
35 #else |
b5fb8b77ce4d
initial commit of ODBC framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
36 # include <ltdl.h> |
b5fb8b77ce4d
initial commit of ODBC framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
37 # include <libltdl/lt_dlloader.h> |
b5fb8b77ce4d
initial commit of ODBC framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
38 #endif |
b5fb8b77ce4d
initial commit of ODBC framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
39 |
b5fb8b77ce4d
initial commit of ODBC framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
40 |
b5fb8b77ce4d
initial commit of ODBC framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
41 #if !defined(_WIN32) |
b5fb8b77ce4d
initial commit of ODBC framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
42 extern "C" |
b5fb8b77ce4d
initial commit of ODBC framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
43 { |
b5fb8b77ce4d
initial commit of ODBC framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
44 extern lt_dlvtable *dlopen_LTX_get_vtable(lt_user_data loader_data); |
b5fb8b77ce4d
initial commit of ODBC framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
45 } |
b5fb8b77ce4d
initial commit of ODBC framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
46 #endif |
b5fb8b77ce4d
initial commit of ODBC framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
47 |
b5fb8b77ce4d
initial commit of ODBC framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
48 |
b5fb8b77ce4d
initial commit of ODBC framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
49 int main(int argc, char **argv) |
b5fb8b77ce4d
initial commit of ODBC framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
50 { |
b5fb8b77ce4d
initial commit of ODBC framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
51 if (argc < 2) |
b5fb8b77ce4d
initial commit of ODBC framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
52 { |
b5fb8b77ce4d
initial commit of ODBC framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
53 std::cerr |
b5fb8b77ce4d
initial commit of ODBC framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
54 << std::endl |
b5fb8b77ce4d
initial commit of ODBC framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
55 << "Usage: " << argv[0] << " <connection string>" |
b5fb8b77ce4d
initial commit of ODBC framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
56 << std::endl << std::endl |
b5fb8b77ce4d
initial commit of ODBC framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
57 << "Example: " << argv[0] << " \"DSN=test\"" |
b5fb8b77ce4d
initial commit of ODBC framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
58 << std::endl << std::endl; |
b5fb8b77ce4d
initial commit of ODBC framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
59 return -1; |
b5fb8b77ce4d
initial commit of ODBC framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
60 } |
b5fb8b77ce4d
initial commit of ODBC framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
61 |
b5fb8b77ce4d
initial commit of ODBC framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
62 for (int i = 1; i < argc; i++) |
b5fb8b77ce4d
initial commit of ODBC framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
63 { |
b5fb8b77ce4d
initial commit of ODBC framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
64 // Ignore arguments beginning with "-" to allow passing arguments |
b5fb8b77ce4d
initial commit of ODBC framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
65 // to Google Test such as "--gtest_filter=" |
b5fb8b77ce4d
initial commit of ODBC framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
66 if (argv[i] != NULL && |
b5fb8b77ce4d
initial commit of ODBC framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
67 argv[i][0] != '-') |
b5fb8b77ce4d
initial commit of ODBC framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
68 { |
b5fb8b77ce4d
initial commit of ODBC framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
69 connectionString_ = argv[i]; |
b5fb8b77ce4d
initial commit of ODBC framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
70 } |
b5fb8b77ce4d
initial commit of ODBC framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
71 } |
b5fb8b77ce4d
initial commit of ODBC framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
72 |
b5fb8b77ce4d
initial commit of ODBC framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
73 #if !defined(_WIN32) |
b5fb8b77ce4d
initial commit of ODBC framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
74 lt_dlinit(); |
b5fb8b77ce4d
initial commit of ODBC framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
75 |
b5fb8b77ce4d
initial commit of ODBC framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
76 /** |
b5fb8b77ce4d
initial commit of ODBC framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
77 * The following call is necessary for "libltdl" to access the |
b5fb8b77ce4d
initial commit of ODBC framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
78 * "dlopen()" primitives if statically linking. Otherwise, only the |
b5fb8b77ce4d
initial commit of ODBC framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
79 * "preopen" primitives are available. |
b5fb8b77ce4d
initial commit of ODBC framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
80 **/ |
b5fb8b77ce4d
initial commit of ODBC framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
81 lt_dlloader_add(dlopen_LTX_get_vtable(NULL)); |
b5fb8b77ce4d
initial commit of ODBC framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
82 #endif |
b5fb8b77ce4d
initial commit of ODBC framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
83 |
b5fb8b77ce4d
initial commit of ODBC framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
84 ::testing::InitGoogleTest(&argc, argv); |
b5fb8b77ce4d
initial commit of ODBC framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
85 Orthanc::Logging::Initialize(); |
b5fb8b77ce4d
initial commit of ODBC framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
86 Orthanc::Logging::EnableInfoLevel(true); |
b5fb8b77ce4d
initial commit of ODBC framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
87 //Orthanc::Logging::EnableTraceLevel(true); |
b5fb8b77ce4d
initial commit of ODBC framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
88 |
331
674bbb9d1c83
added OdbcEnvironment::GlobalInitialization()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
329
diff
changeset
|
89 OrthancDatabases::OdbcEnvironment::GlobalInitialization(); |
674bbb9d1c83
added OdbcEnvironment::GlobalInitialization()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
329
diff
changeset
|
90 |
329
b5fb8b77ce4d
initial commit of ODBC framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
91 int result = RUN_ALL_TESTS(); |
b5fb8b77ce4d
initial commit of ODBC framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
92 |
b5fb8b77ce4d
initial commit of ODBC framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
93 Orthanc::Logging::Finalize(); |
b5fb8b77ce4d
initial commit of ODBC framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
94 |
b5fb8b77ce4d
initial commit of ODBC framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
95 return result; |
b5fb8b77ce4d
initial commit of ODBC framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
96 } |