Mercurial > hg > orthanc
annotate UnitTestsSources/VersionsTests.cpp @ 2922:40131f0c25b5
Orthanc configuration file can use environment variables
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 07 Nov 2018 13:06:59 +0100 |
parents | 26eec77abc76 |
children | 8341256c6941 |
rev | line source |
---|---|
827
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
753
diff
changeset
|
1 /** |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
753
diff
changeset
|
2 * Orthanc - A Lightweight, RESTful DICOM Store |
1900 | 3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics |
1288
6e7e5ed91c2d
upgrade to year 2015
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
967
diff
changeset
|
4 * Department, University Hospital of Liege, Belgium |
2447
878b59270859
upgrade to year 2018
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2432
diff
changeset
|
5 * Copyright (C) 2017-2018 Osimis S.A., Belgium |
827
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
753
diff
changeset
|
6 * |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
753
diff
changeset
|
7 * This program is free software: you can redistribute it and/or |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
753
diff
changeset
|
8 * modify it under the terms of the GNU General Public License as |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
753
diff
changeset
|
9 * published by the Free Software Foundation, either version 3 of the |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
753
diff
changeset
|
10 * License, or (at your option) any later version. |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
753
diff
changeset
|
11 * |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
753
diff
changeset
|
12 * In addition, as a special exception, the copyright holders of this |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
753
diff
changeset
|
13 * program give permission to link the code of its release with the |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
753
diff
changeset
|
14 * OpenSSL project's "OpenSSL" library (or with modified versions of it |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
753
diff
changeset
|
15 * that use the same license as the "OpenSSL" library), and distribute |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
753
diff
changeset
|
16 * the linked executables. You must obey the GNU General Public License |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
753
diff
changeset
|
17 * in all respects for all of the code used other than "OpenSSL". If you |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
753
diff
changeset
|
18 * modify file(s) with this exception, you may extend this exception to |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
753
diff
changeset
|
19 * your version of the file(s), but you are not obligated to do so. If |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
753
diff
changeset
|
20 * you do not wish to do so, delete this exception statement from your |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
753
diff
changeset
|
21 * version. If you delete this exception statement from all source files |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
753
diff
changeset
|
22 * in the program, then also delete it here. |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
753
diff
changeset
|
23 * |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
753
diff
changeset
|
24 * This program is distributed in the hope that it will be useful, but |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
753
diff
changeset
|
25 * WITHOUT ANY WARRANTY; without even the implied warranty of |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
753
diff
changeset
|
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
753
diff
changeset
|
27 * General Public License for more details. |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
753
diff
changeset
|
28 * |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
753
diff
changeset
|
29 * You should have received a copy of the GNU General Public License |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
753
diff
changeset
|
30 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
753
diff
changeset
|
31 **/ |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
753
diff
changeset
|
32 |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
753
diff
changeset
|
33 |
831
84513f2ee1f3
pch for unit tests and server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
827
diff
changeset
|
34 #include "PrecompiledHeadersUnitTests.h" |
0 | 35 #include "gtest/gtest.h" |
36 | |
37 #include <stdint.h> | |
38 #include <math.h> | |
39 #include <png.h> | |
40 #include <ctype.h> | |
41 #include <zlib.h> | |
42 #include <curl/curl.h> | |
43 #include <boost/version.hpp> | |
181
2dece1526c06
simplifying db schema
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
63
diff
changeset
|
44 #include <sqlite3.h> |
382 | 45 #include <lua.h> |
1604 | 46 #include <jpeglib.h> |
2366
26f3a346226f
more consistent handling of libiconv in cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2327
diff
changeset
|
47 #include <iconv.h> |
1545 | 48 |
2136
dd609a99d39a
uniformization of the macro naming
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2097
diff
changeset
|
49 #if ORTHANC_ENABLE_SSL == 1 |
748
de9763f63510
upgrade to openssl-1.0.1g because of heartbeat exploit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
632
diff
changeset
|
50 #include <openssl/opensslv.h> |
1545 | 51 #endif |
0 | 52 |
53 | |
54 TEST(Versions, Zlib) | |
55 { | |
56 ASSERT_STREQ(zlibVersion(), ZLIB_VERSION); | |
57 } | |
58 | |
59 TEST(Versions, Curl) | |
60 { | |
61 curl_version_info_data* v = curl_version_info(CURLVERSION_NOW); | |
62 ASSERT_STREQ(LIBCURL_VERSION, v->version); | |
63 } | |
64 | |
65 TEST(Versions, Png) | |
66 { | |
67 ASSERT_EQ(PNG_LIBPNG_VER_MAJOR * 10000 + PNG_LIBPNG_VER_MINOR * 100 + PNG_LIBPNG_VER_RELEASE, | |
1492 | 68 static_cast<int>(png_access_version_number())); |
0 | 69 } |
70 | |
181
2dece1526c06
simplifying db schema
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
63
diff
changeset
|
71 TEST(Versions, SQLite) |
2dece1526c06
simplifying db schema
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
63
diff
changeset
|
72 { |
1478 | 73 #if defined(__APPLE__) |
74 // Under OS X, there might exist minor differences between the | |
75 // version of the headers and the version of the library, for the | |
76 // system-wide SQLite. Ignore these differences. | |
77 #else | |
181
2dece1526c06
simplifying db schema
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
63
diff
changeset
|
78 // http://www.sqlite.org/capi3ref.html#sqlite3_libversion |
1478 | 79 EXPECT_EQ(sqlite3_libversion_number(), SQLITE_VERSION_NUMBER); |
80 EXPECT_STREQ(sqlite3_sourceid(), SQLITE_SOURCE_ID); | |
81 EXPECT_STREQ(sqlite3_libversion(), SQLITE_VERSION); | |
82 #endif | |
181
2dece1526c06
simplifying db schema
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
63
diff
changeset
|
83 |
194
0186ac92810c
fixes for Ubuntu 10.04
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
181
diff
changeset
|
84 // Ensure that the SQLite version is above 3.7.0. |
0186ac92810c
fixes for Ubuntu 10.04
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
181
diff
changeset
|
85 // "sqlite3_create_function_v2" is not defined in previous versions. |
181
2dece1526c06
simplifying db schema
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
63
diff
changeset
|
86 ASSERT_GE(SQLITE_VERSION_NUMBER, 3007000); |
2dece1526c06
simplifying db schema
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
63
diff
changeset
|
87 } |
2dece1526c06
simplifying db schema
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
63
diff
changeset
|
88 |
0 | 89 |
382 | 90 TEST(Versions, Lua) |
91 { | |
92 // Ensure that the Lua version is above 5.1.0. This version has | |
93 // introduced some API changes. | |
94 ASSERT_GE(LUA_VERSION_NUM, 501); | |
95 } | |
96 | |
97 | |
63 | 98 #if ORTHANC_STATIC == 1 |
1502
5e9c40419fb9
Upgrade to JsonCpp 0.10.5 for static and Windows builds
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1492
diff
changeset
|
99 |
0 | 100 TEST(Versions, ZlibStatic) |
101 { | |
2509
9d9f2d088dce
upgrade to zlib 1.2.11
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2497
diff
changeset
|
102 ASSERT_STREQ("1.2.11", zlibVersion()); |
0 | 103 } |
104 | |
105 TEST(Versions, BoostStatic) | |
106 { | |
2682 | 107 ASSERT_STREQ("1_67", BOOST_LIB_VERSION); |
0 | 108 } |
109 | |
110 TEST(Versions, CurlStatic) | |
111 { | |
112 curl_version_info_data* v = curl_version_info(CURLVERSION_NOW); | |
2449
e779c11c8eb2
upgrade to curl 7.57.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
113 ASSERT_STREQ("7.57.0", v->version); |
0 | 114 } |
115 | |
116 TEST(Versions, PngStatic) | |
117 { | |
1970 | 118 ASSERT_EQ(10512u, png_access_version_number()); |
0 | 119 ASSERT_STREQ("1.5.12", PNG_LIBPNG_VER_STRING); |
120 } | |
29
042ac60f5bf9
simplified build of curl
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
8
diff
changeset
|
121 |
1604 | 122 TEST(Versions, JpegStatic) |
123 { | |
124 ASSERT_EQ(9, JPEG_LIB_VERSION_MAJOR); | |
125 ASSERT_EQ(1, JPEG_LIB_VERSION_MINOR); | |
126 } | |
127 | |
382 | 128 TEST(Versions, CurlSslStatic) |
29
042ac60f5bf9
simplified build of curl
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
8
diff
changeset
|
129 { |
042ac60f5bf9
simplified build of curl
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
8
diff
changeset
|
130 curl_version_info_data * vinfo = curl_version_info(CURLVERSION_NOW); |
042ac60f5bf9
simplified build of curl
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
8
diff
changeset
|
131 |
042ac60f5bf9
simplified build of curl
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
8
diff
changeset
|
132 // Check that SSL support is enabled when required |
1545 | 133 bool curlSupportsSsl = (vinfo->features & CURL_VERSION_SSL) != 0; |
29
042ac60f5bf9
simplified build of curl
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
8
diff
changeset
|
134 |
2136
dd609a99d39a
uniformization of the macro naming
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2097
diff
changeset
|
135 #if ORTHANC_ENABLE_SSL == 0 |
29
042ac60f5bf9
simplified build of curl
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
8
diff
changeset
|
136 ASSERT_FALSE(curlSupportsSsl); |
042ac60f5bf9
simplified build of curl
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
8
diff
changeset
|
137 #else |
042ac60f5bf9
simplified build of curl
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
8
diff
changeset
|
138 ASSERT_TRUE(curlSupportsSsl); |
042ac60f5bf9
simplified build of curl
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
8
diff
changeset
|
139 #endif |
042ac60f5bf9
simplified build of curl
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
8
diff
changeset
|
140 } |
382 | 141 |
142 TEST(Version, LuaStatic) | |
143 { | |
144 ASSERT_STREQ("Lua 5.1.5", LUA_RELEASE); | |
145 } | |
748
de9763f63510
upgrade to openssl-1.0.1g because of heartbeat exploit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
632
diff
changeset
|
146 |
2366
26f3a346226f
more consistent handling of libiconv in cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2327
diff
changeset
|
147 TEST(Version, LibIconvStatic) |
26f3a346226f
more consistent handling of libiconv in cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2327
diff
changeset
|
148 { |
26f3a346226f
more consistent handling of libiconv in cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2327
diff
changeset
|
149 static const int major = 1; |
26f3a346226f
more consistent handling of libiconv in cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2327
diff
changeset
|
150 static const int minor = 15; |
26f3a346226f
more consistent handling of libiconv in cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2327
diff
changeset
|
151 ASSERT_EQ((major << 8) + minor, _LIBICONV_VERSION); |
26f3a346226f
more consistent handling of libiconv in cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2327
diff
changeset
|
152 } |
26f3a346226f
more consistent handling of libiconv in cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2327
diff
changeset
|
153 |
1545 | 154 |
2136
dd609a99d39a
uniformization of the macro naming
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2097
diff
changeset
|
155 #if ORTHANC_ENABLE_SSL == 1 |
748
de9763f63510
upgrade to openssl-1.0.1g because of heartbeat exploit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
632
diff
changeset
|
156 TEST(Version, OpenSslStatic) |
de9763f63510
upgrade to openssl-1.0.1g because of heartbeat exploit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
632
diff
changeset
|
157 { |
2710
26eec77abc76
upgrade to openssl 1.0.2o
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2682
diff
changeset
|
158 ASSERT_EQ(0x100020ffL /* openssl-1.0.2o */, OPENSSL_VERSION_NUMBER); |
748
de9763f63510
upgrade to openssl-1.0.1g because of heartbeat exploit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
632
diff
changeset
|
159 } |
1545 | 160 #endif |
748
de9763f63510
upgrade to openssl-1.0.1g because of heartbeat exploit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
632
diff
changeset
|
161 |
1502
5e9c40419fb9
Upgrade to JsonCpp 0.10.5 for static and Windows builds
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1492
diff
changeset
|
162 |
5e9c40419fb9
Upgrade to JsonCpp 0.10.5 for static and Windows builds
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1492
diff
changeset
|
163 #include <json/version.h> |
5e9c40419fb9
Upgrade to JsonCpp 0.10.5 for static and Windows builds
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1492
diff
changeset
|
164 |
5e9c40419fb9
Upgrade to JsonCpp 0.10.5 for static and Windows builds
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1492
diff
changeset
|
165 TEST(Version, JsonCpp) |
5e9c40419fb9
Upgrade to JsonCpp 0.10.5 for static and Windows builds
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1492
diff
changeset
|
166 { |
2497
0611aa383e62
Upgrade to JsonCpp 1.8.4, and USE_LEGACY_JSONCPP option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2449
diff
changeset
|
167 #if ORTHANC_LEGACY_JSONCPP == 1 |
0611aa383e62
Upgrade to JsonCpp 1.8.4, and USE_LEGACY_JSONCPP option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2449
diff
changeset
|
168 ASSERT_STREQ("0.10.6", JSONCPP_VERSION_STRING); |
0611aa383e62
Upgrade to JsonCpp 1.8.4, and USE_LEGACY_JSONCPP option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2449
diff
changeset
|
169 #elif ORTHANC_LEGACY_JSONCPP == 0 |
0611aa383e62
Upgrade to JsonCpp 1.8.4, and USE_LEGACY_JSONCPP option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2449
diff
changeset
|
170 ASSERT_STREQ("1.8.4", JSONCPP_VERSION_STRING); |
0611aa383e62
Upgrade to JsonCpp 1.8.4, and USE_LEGACY_JSONCPP option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2449
diff
changeset
|
171 #else |
0611aa383e62
Upgrade to JsonCpp 1.8.4, and USE_LEGACY_JSONCPP option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2449
diff
changeset
|
172 # error Macro ORTHANC_LEGACY_JSONCPP should be set |
0611aa383e62
Upgrade to JsonCpp 1.8.4, and USE_LEGACY_JSONCPP option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2449
diff
changeset
|
173 #endif |
1502
5e9c40419fb9
Upgrade to JsonCpp 0.10.5 for static and Windows builds
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1492
diff
changeset
|
174 } |
5e9c40419fb9
Upgrade to JsonCpp 0.10.5 for static and Windows builds
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1492
diff
changeset
|
175 |
37 | 176 #endif |