Mercurial > hg > orthanc
comparison OrthancServer/UnitTestsSources/VersionsTests.cpp @ 4044:d25f4c0fa160 framework
splitting code into OrthancFramework and OrthancServer
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 10 Jun 2020 20:30:34 +0200 |
parents | UnitTestsSources/VersionsTests.cpp@05a363186da6 |
children | 0953b3dc3261 |
comparison
equal
deleted
inserted
replaced
4043:6c6239aec462 | 4044:d25f4c0fa160 |
---|---|
1 /** | |
2 * Orthanc - A Lightweight, RESTful DICOM Store | |
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics | |
4 * Department, University Hospital of Liege, Belgium | |
5 * Copyright (C) 2017-2020 Osimis S.A., Belgium | |
6 * | |
7 * This program is free software: you can redistribute it and/or | |
8 * modify it under the terms of the GNU General Public License as | |
9 * published by the Free Software Foundation, either version 3 of the | |
10 * License, or (at your option) any later version. | |
11 * | |
12 * In addition, as a special exception, the copyright holders of this | |
13 * program give permission to link the code of its release with the | |
14 * OpenSSL project's "OpenSSL" library (or with modified versions of it | |
15 * that use the same license as the "OpenSSL" library), and distribute | |
16 * the linked executables. You must obey the GNU General Public License | |
17 * in all respects for all of the code used other than "OpenSSL". If you | |
18 * modify file(s) with this exception, you may extend this exception to | |
19 * your version of the file(s), but you are not obligated to do so. If | |
20 * you do not wish to do so, delete this exception statement from your | |
21 * version. If you delete this exception statement from all source files | |
22 * in the program, then also delete it here. | |
23 * | |
24 * This program is distributed in the hope that it will be useful, but | |
25 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
27 * General Public License for more details. | |
28 * | |
29 * You should have received a copy of the GNU General Public License | |
30 * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
31 **/ | |
32 | |
33 | |
34 #include "PrecompiledHeadersUnitTests.h" | |
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> | |
44 #include <sqlite3.h> | |
45 #include <lua.h> | |
46 #include <jpeglib.h> | |
47 | |
48 #if BUILDING_LIBICONV == 1 | |
49 # include <iconv.h> | |
50 #endif | |
51 | |
52 #if ORTHANC_ENABLE_SSL == 1 | |
53 # include <openssl/opensslv.h> | |
54 #endif | |
55 | |
56 #if (ORTHANC_ENABLE_CIVETWEB == 1 && \ | |
57 ORTHANC_UNIT_TESTS_LINK_FRAMEWORK != 1) | |
58 # include <civetweb.h> | |
59 #endif | |
60 | |
61 #if ORTHANC_ENABLE_PUGIXML == 1 | |
62 # include <pugixml.hpp> | |
63 #endif | |
64 | |
65 | |
66 TEST(Versions, Zlib) | |
67 { | |
68 ASSERT_STREQ(zlibVersion(), ZLIB_VERSION); | |
69 } | |
70 | |
71 TEST(Versions, Curl) | |
72 { | |
73 curl_version_info_data* v = curl_version_info(CURLVERSION_NOW); | |
74 ASSERT_STREQ(LIBCURL_VERSION, v->version); | |
75 } | |
76 | |
77 TEST(Versions, Png) | |
78 { | |
79 ASSERT_EQ(PNG_LIBPNG_VER_MAJOR * 10000 + PNG_LIBPNG_VER_MINOR * 100 + PNG_LIBPNG_VER_RELEASE, | |
80 static_cast<int>(png_access_version_number())); | |
81 } | |
82 | |
83 TEST(Versions, SQLite) | |
84 { | |
85 #if defined(__APPLE__) | |
86 // Under OS X, there might exist minor differences between the | |
87 // version of the headers and the version of the library, for the | |
88 // system-wide SQLite. Ignore these differences. | |
89 #else | |
90 // http://www.sqlite.org/capi3ref.html#sqlite3_libversion | |
91 EXPECT_EQ(sqlite3_libversion_number(), SQLITE_VERSION_NUMBER); | |
92 EXPECT_STREQ(sqlite3_libversion(), SQLITE_VERSION); | |
93 | |
94 /** | |
95 * On Orthanc > 1.5.8, we comment out the following test, that is | |
96 * too strict for some GNU/Linux distributions to apply their own | |
97 * security fixes. Checking the main version macros is sufficient. | |
98 * https://bugzilla.suse.com/show_bug.cgi?id=1154550#c2 | |
99 **/ | |
100 // EXPECT_STREQ(sqlite3_sourceid(), SQLITE_SOURCE_ID); | |
101 #endif | |
102 | |
103 // Ensure that the SQLite version is above 3.7.0. | |
104 // "sqlite3_create_function_v2" is not defined in previous versions. | |
105 ASSERT_GE(SQLITE_VERSION_NUMBER, 3007000); | |
106 } | |
107 | |
108 | |
109 TEST(Versions, Lua) | |
110 { | |
111 // Ensure that the Lua version is above 5.1.0. This version has | |
112 // introduced some API changes. | |
113 ASSERT_GE(LUA_VERSION_NUM, 501); | |
114 } | |
115 | |
116 | |
117 #if (ORTHANC_ENABLE_CIVETWEB == 1 && \ | |
118 ORTHANC_UNIT_TESTS_LINK_FRAMEWORK != 1) | |
119 TEST(Version, CivetwebCompression) | |
120 { | |
121 ASSERT_TRUE(mg_check_feature(MG_FEATURES_COMPRESSION)); | |
122 } | |
123 #endif | |
124 | |
125 | |
126 #if ORTHANC_STATIC == 1 | |
127 | |
128 TEST(Versions, ZlibStatic) | |
129 { | |
130 ASSERT_STREQ("1.2.11", zlibVersion()); | |
131 } | |
132 | |
133 TEST(Versions, BoostStatic) | |
134 { | |
135 ASSERT_STREQ("1_69", BOOST_LIB_VERSION); | |
136 } | |
137 | |
138 TEST(Versions, CurlStatic) | |
139 { | |
140 curl_version_info_data* v = curl_version_info(CURLVERSION_NOW); | |
141 ASSERT_STREQ("7.64.0", v->version); | |
142 } | |
143 | |
144 TEST(Versions, PngStatic) | |
145 { | |
146 ASSERT_EQ(10636u, png_access_version_number()); | |
147 ASSERT_STREQ("1.6.36", PNG_LIBPNG_VER_STRING); | |
148 } | |
149 | |
150 TEST(Versions, JpegStatic) | |
151 { | |
152 ASSERT_EQ(9, JPEG_LIB_VERSION_MAJOR); | |
153 ASSERT_EQ(3, JPEG_LIB_VERSION_MINOR); | |
154 } | |
155 | |
156 TEST(Versions, CurlSslStatic) | |
157 { | |
158 curl_version_info_data * vinfo = curl_version_info(CURLVERSION_NOW); | |
159 | |
160 // Check that SSL support is enabled when required | |
161 bool curlSupportsSsl = (vinfo->features & CURL_VERSION_SSL) != 0; | |
162 | |
163 #if ORTHANC_ENABLE_SSL == 0 | |
164 ASSERT_FALSE(curlSupportsSsl); | |
165 #else | |
166 ASSERT_TRUE(curlSupportsSsl); | |
167 #endif | |
168 } | |
169 | |
170 TEST(Version, LuaStatic) | |
171 { | |
172 ASSERT_STREQ("Lua 5.3.5", LUA_RELEASE); | |
173 } | |
174 | |
175 | |
176 #if BUILDING_LIBICONV == 1 | |
177 TEST(Version, LibIconvStatic) | |
178 { | |
179 static const int major = 1; | |
180 static const int minor = 15; | |
181 ASSERT_EQ((major << 8) + minor, _LIBICONV_VERSION); | |
182 } | |
183 #endif | |
184 | |
185 | |
186 #if ORTHANC_ENABLE_SSL == 1 | |
187 TEST(Version, OpenSslStatic) | |
188 { | |
189 ASSERT_TRUE(OPENSSL_VERSION_NUMBER == 0x1000210fL /* openssl-1.0.2p */ || | |
190 OPENSSL_VERSION_NUMBER == 0x1010107fL /* openssl-1.1.1g */); | |
191 } | |
192 #endif | |
193 | |
194 | |
195 #include <json/version.h> | |
196 | |
197 TEST(Version, JsonCpp) | |
198 { | |
199 #if ORTHANC_LEGACY_JSONCPP == 1 | |
200 ASSERT_STREQ("0.10.6", JSONCPP_VERSION_STRING); | |
201 #elif ORTHANC_LEGACY_JSONCPP == 0 | |
202 ASSERT_STREQ("1.8.4", JSONCPP_VERSION_STRING); | |
203 #else | |
204 # error Macro ORTHANC_LEGACY_JSONCPP should be set | |
205 #endif | |
206 } | |
207 | |
208 | |
209 #if ORTHANC_ENABLE_CIVETWEB == 1 | |
210 TEST(Version, Civetweb) | |
211 { | |
212 ASSERT_EQ(1, CIVETWEB_VERSION_MAJOR); | |
213 ASSERT_EQ(12, CIVETWEB_VERSION_MINOR); | |
214 ASSERT_EQ(0, CIVETWEB_VERSION_PATCH); | |
215 } | |
216 #endif | |
217 | |
218 | |
219 #if ORTHANC_ENABLE_PUGIXML == 1 | |
220 TEST(Version, Pugixml) | |
221 { | |
222 ASSERT_EQ(190, PUGIXML_VERSION); | |
223 } | |
224 #endif | |
225 | |
226 | |
227 #endif |