GCC Code Coverage Report
Directory: ../ Exec Total Coverage
File: /home/iojs/build/workspace/node-test-commit-linux-coverage-daily/nodes/benchmark/out/../src/node_metadata.cc Lines: 42 42 100.0 %
Date: 2019-02-23 22:23:05 Branches: 4 8 50.0 %

Line Branch Exec Source
1
#include "node_metadata.h"
2
#include "ares.h"
3
#include "brotli/encode.h"
4
#include "nghttp2/nghttp2ver.h"
5
#include "node.h"
6
#include "util.h"
7
#include "uv.h"
8
#include "v8.h"
9
#include "zlib.h"
10
11
#if HAVE_OPENSSL
12
#include <openssl/opensslv.h>
13
#endif  // HAVE_OPENSSL
14
15
#ifdef NODE_HAVE_I18N_SUPPORT
16
#include <unicode/timezone.h>
17
#include <unicode/ulocdata.h>
18
#include <unicode/uvernum.h>
19
#include <unicode/uversion.h>
20
#endif  // NODE_HAVE_I18N_SUPPORT
21
22
namespace node {
23
24
namespace per_process {
25
4288
Metadata metadata;
26
}
27
28
#if HAVE_OPENSSL
29
constexpr int search(const char* s, int n, int c) {
30
  return *s == c ? n : search(s + 1, n + 1, c);
31
}
32
33
4288
std::string GetOpenSSLVersion() {
34
  // sample openssl version string format
35
  // for reference: "OpenSSL 1.1.0i 14 Aug 2018"
36
  char buf[128];
37
4288
  const int start = search(OPENSSL_VERSION_TEXT, 0, ' ') + 1;
38
4288
  const int end = search(OPENSSL_VERSION_TEXT + start, start, ' ');
39
4288
  const int len = end - start;
40
4288
  snprintf(buf, sizeof(buf), "%.*s", len, &OPENSSL_VERSION_TEXT[start]);
41
4288
  return std::string(buf);
42
}
43
#endif  // HAVE_OPENSSL
44
45
#ifdef NODE_HAVE_I18N_SUPPORT
46
4243
void Metadata::Versions::InitializeIntlVersions() {
47
4243
  UErrorCode status = U_ZERO_ERROR;
48
49
4243
  const char* tz_version = icu::TimeZone::getTZDataVersion(status);
50
4243
  if (U_SUCCESS(status)) {
51
4243
    tz = tz_version;
52
  }
53
54
  char buf[U_MAX_VERSION_STRING_LENGTH];
55
  UVersionInfo versionArray;
56
4243
  ulocdata_getCLDRVersion(versionArray, &status);
57
4243
  if (U_SUCCESS(status)) {
58
4243
    u_versionToString(versionArray, buf);
59
4243
    cldr = buf;
60
  }
61
4243
}
62
#endif  // NODE_HAVE_I18N_SUPPORT
63
64
4288
Metadata::Versions::Versions() {
65
4288
  node = NODE_VERSION_STRING;
66
4288
  v8 = v8::V8::GetVersion();
67
4288
  uv = uv_version_string();
68
4288
  zlib = ZLIB_VERSION;
69
4288
  ares = ARES_VERSION_STR;
70
4288
  modules = NODE_STRINGIFY(NODE_MODULE_VERSION);
71
4288
  nghttp2 = NGHTTP2_VERSION;
72
4288
  napi = NODE_STRINGIFY(NAPI_VERSION);
73
4288
  llhttp = per_process::llhttp_version;
74
4288
  http_parser = per_process::http_parser_version;
75
76
4288
  brotli =
77
8576
    std::to_string(BrotliEncoderVersion() >> 24) +
78
17152
    "." +
79
12864
    std::to_string((BrotliEncoderVersion() & 0xFFF000) >> 12) +
80
17152
    "." +
81
8576
    std::to_string(BrotliEncoderVersion() & 0xFFF);
82
83
#if HAVE_OPENSSL
84
4288
  openssl = GetOpenSSLVersion();
85
#endif
86
87
#ifdef NODE_HAVE_I18N_SUPPORT
88
4288
  icu = U_ICU_VERSION;
89
4288
  unicode = U_UNICODE_VERSION;
90
#endif  // NODE_HAVE_I18N_SUPPORT
91
4288
}
92
93
4288
Metadata::Release::Release() : name(NODE_RELEASE) {
94
#if NODE_VERSION_IS_LTS
95
  lts = NODE_VERSION_LTS_CODENAME;
96
#endif  // NODE_VERSION_IS_LTS
97
98
#ifdef NODE_HAS_RELEASE_URLS
99
#define NODE_RELEASE_URLPFX NODE_RELEASE_URLBASE "v" NODE_VERSION_STRING "/"
100
#define NODE_RELEASE_URLFPFX NODE_RELEASE_URLPFX "node-v" NODE_VERSION_STRING
101
102
  source_url = NODE_RELEASE_URLFPFX ".tar.gz";
103
  headers_url = NODE_RELEASE_URLFPFX "-headers.tar.gz";
104
#ifdef _WIN32
105
  lib_url = strcmp(NODE_ARCH, "ia32") ? NODE_RELEASE_URLPFX "win-" NODE_ARCH
106
                                                           "/node.lib"
107
                                     : NODE_RELEASE_URLPFX "win-x86/node.lib";
108
#endif  // _WIN32
109
110
#endif  // NODE_HAS_RELEASE_URLS
111
4288
}
112
113
4288
Metadata::Metadata() : arch(NODE_ARCH), platform(NODE_PLATFORM) {}
114
115

12864
}  // namespace node