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

14484
}  // namespace node