You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by zw...@apache.org on 2019/04/16 00:30:58 UTC

[trafficserver] branch master updated: Adds basic version feature for traffic_layout info

This is an automated email from the ASF dual-hosted git repository.

zwoop pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git


The following commit(s) were added to refs/heads/master by this push:
     new 03490d0  Adds basic version feature for traffic_layout info
03490d0 is described below

commit 03490d09912e045e7a11abada651da82975af485
Author: Leif Hedstrom <zw...@apache.org>
AuthorDate: Fri Apr 5 17:51:44 2019 -0600

    Adds basic version feature for traffic_layout info
---
 src/traffic_layout/Makefile.inc      |  2 +-
 src/traffic_layout/engine.cc         |  2 ++
 src/traffic_layout/info.cc           | 65 ++++++++++++++++++++++++++++++++++--
 src/traffic_layout/info.h            |  2 +-
 src/traffic_layout/traffic_layout.cc |  1 +
 5 files changed, 67 insertions(+), 5 deletions(-)

diff --git a/src/traffic_layout/Makefile.inc b/src/traffic_layout/Makefile.inc
index 7664fe3..afdc314 100644
--- a/src/traffic_layout/Makefile.inc
+++ b/src/traffic_layout/Makefile.inc
@@ -47,4 +47,4 @@ traffic_layout_traffic_layout_LDADD = \
 	$(top_builddir)/iocore/eventsystem/libinkevent.a \
 	$(top_builddir)/src/tscore/libtscore.la \
 	$(top_builddir)/src/tscpp/util/libtscpputil.la \
-	@HWLOC_LIBS@ @YAMLCPP_LIBS@
+	@HWLOC_LIBS@ @YAMLCPP_LIBS@ @LIBLZMA@
diff --git a/src/traffic_layout/engine.cc b/src/traffic_layout/engine.cc
index e6a2703..3838d63 100644
--- a/src/traffic_layout/engine.cc
+++ b/src/traffic_layout/engine.cc
@@ -162,6 +162,8 @@ LayoutEngine::info()
 
   if (arguments.get("features")) {
     produce_features(json);
+  } else if (arguments.get("versions")) {
+    produce_versions(json);
   } else {
     produce_layout(json);
   }
diff --git a/src/traffic_layout/info.cc b/src/traffic_layout/info.cc
index 94060cf..74af91f 100644
--- a/src/traffic_layout/info.cc
+++ b/src/traffic_layout/info.cc
@@ -21,11 +21,25 @@
   limitations under the License.
  */
 
+#include <openssl/crypto.h>
 #include "tscore/I_Layout.h"
+#include "tscore/BufferWriter.h"
 #include "records/I_RecProcess.h"
 #include "RecordsConfig.h"
 #include "info.h"
 
+#if HAVE_ZLIB_H
+#include <zlib.h>
+#endif
+
+#if HAVE_LZMA_H
+#include <lzma.h>
+#endif
+
+#if HAVE_BROTLI_ENCODE_H
+#include <brotli/encode.h>
+#endif
+
 // Produce output about compile time features, useful for checking how things were built, as well
 // as for our TSQA test harness.
 static void
@@ -59,17 +73,17 @@ produce_features(bool json)
   print_feature("BUILD_PERSON", BUILD_PERSON, json);
   print_feature("BUILD_GROUP", BUILD_GROUP, json);
   print_feature("BUILD_NUMBER", BUILD_NUMBER, json);
-#ifdef HAVE_ZLIB_H
+#if HAVE_ZLIB_H
   print_feature("TS_HAS_LIBZ", 1, json);
 #else
   print_feature("TS_HAS_LIBZ", 0, json);
 #endif
-#ifdef HAVE_LZMA_H
+#if HAVE_LZMA_H
   print_feature("TS_HAS_LZMA", 1, json);
 #else
   print_feature("TS_HAS_LZMA", 0, json);
 #endif
-#ifdef HAVE_BROTLI_ENCODE_H
+#if HAVE_BROTLI_ENCODE_H
   print_feature("TS_HAS_BROTLI", 1, json);
 #else
   print_feature("TS_HAS_BROTLI", 0, json);
@@ -152,3 +166,48 @@ produce_layout(bool json)
     printf("}\n");
   }
 }
+
+void
+produce_versions(bool json)
+{
+  using LBW = ts::LocalBufferWriter<128>;
+  static const std::string_view undef{"undef"};
+
+  if (json) {
+    printf("{\n");
+  }
+
+  print_var("openssl", LBW().print("{:#x}", OPENSSL_VERSION_NUMBER).view(), json);
+  print_var("openssl_str", LBW().print(OPENSSL_VERSION_TEXT).view(), json);
+  print_var("pcre", LBW().print("{}.{}", PCRE_MAJOR, PCRE_MINOR).view(), json);
+  // These are optional, for now at least.
+#if TS_USE_HWLOC
+  print_var("hwloc", LBW().print("{:#x}", HWLOC_API_VERSION).view(), json);
+  print_var("hwloc.run", LBW().print("{:#x}", hwloc_get_api_version()).view(), json);
+#else
+  print_var("hwloc", undef, json);
+#endif
+#if HAVE_ZLIB_H
+  print_var("libz", LBW().print("{}", ZLIB_VERSION).view(), json);
+#else
+  print_var("libz", undef, json);
+#endif
+#if HAVE_LZMA_H
+  print_var("lzma", LBW().print("{}", LZMA_VERSION_STRING).view(), json);
+  print_var("lzma.run", LBW().print("{}", lzma_version_string()).view(), json);
+#else
+  print_var("lzma", undef, json);
+#endif
+#if HAVE_BROTLI_ENCODE_H
+  print_var("lzma", LBW().print("{}", BrotliEncoderVersion).view(), json);
+#else
+  print_var("brotli", undef, json);
+#endif
+
+  // This should always be last
+  print_var("traffic-server", LBW().print(TS_VERSION_STRING).view(), json, true);
+
+  if (json) {
+    printf("}\n");
+  }
+}
diff --git a/src/traffic_layout/info.h b/src/traffic_layout/info.h
index c70f0ec..fc3831c 100644
--- a/src/traffic_layout/info.h
+++ b/src/traffic_layout/info.h
@@ -24,5 +24,5 @@
 // the original traffic_layout
 
 void produce_features(bool json);
-
 void produce_layout(bool json);
+void produce_versions(bool json);
diff --git a/src/traffic_layout/traffic_layout.cc b/src/traffic_layout/traffic_layout.cc
index fb26e34..935a6a7 100644
--- a/src/traffic_layout/traffic_layout.cc
+++ b/src/traffic_layout/traffic_layout.cc
@@ -47,6 +47,7 @@ main(int argc, const char **argv)
   // info command
   engine.parser.add_command("info", "Show the layout as default", [&]() { engine.info(); })
     .add_option("--features", "", "Show the compiled features")
+    .add_option("--versions", "", "Show various library and other versioning information")
     .add_option("--json", "-j", "Produce output in JSON format (when supported)")
     .set_default();
   // init command