C ares test (#48)

* c-ares to be built with CMake+Ninja, c-ares version test

* remove not relevant comment
This commit is contained in:
irengrig 2018-08-21 15:04:12 +02:00 committed by GitHub
parent deffd0d10c
commit 51e2fac3d8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 27 additions and 0 deletions

View File

@ -4,6 +4,7 @@ test_suite(
"//examples/cmake:test_libgd",
"//examples/cmake:test_libpng",
"//examples/cmake:test_zlib",
"//examples/cmake_cares:test_c_ares",
"//examples/ninja:test_ninja_version",
],
)

View File

@ -17,7 +17,19 @@ cmake_external(
"CARES_SHARED": "no",
"CARES_STATIC": "on",
},
cmake_options = ["-GNinja"],
lib_source = "@cares//:all",
make_commands = [
"ninja",
"ninja install",
],
static_libraries = ["libcares.a"],
tools_deps = [":ninjatool"],
)
cc_test(
name = "test_c_ares",
srcs = ["c-ares-test.cpp"],
visibility = ["//:__pkg__"],
deps = [":cares"],
)

View File

@ -0,0 +1,14 @@
#include "ares.h"
#include <iostream>
#include <string.h>
int main(int argc, char* argv[])
{
int version = 0;
const char* strVersion = ares_version(&version);
if (strcmp(strVersion, "1.14.0") != 0) {
throw std::runtime_error("Wrong version: " + std::string(strVersion));
}
std::cout << "C-ares version: " << strVersion;
}