[trafficserver] branch master updated: Unifdef test code for MMH and moved it into its own test file (#7841)
This is an automated email from the ASF dual-hosted git repository. bcall 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 bed49e4 Unifdef test code for MMH and moved it into its own test file (#7841) bed49e4 is described below commit bed49e4dc5534257e7b00a153e7c75cd7713ff55 Author: Bryan Call AuthorDate: Tue May 18 16:12:08 2021 -0700 Unifdef test code for MMH and moved it into its own test file (#7841) Fixed issues with the test and got it passing --- include/tscore/MMH.h | 3 + src/tscore/MMH.cc | 129 +-- src/tscore/Makefile.am| 3 +- src/tscore/unit_tests/test_MMH.cc | 139 ++ 4 files changed, 145 insertions(+), 129 deletions(-) diff --git a/include/tscore/MMH.h b/include/tscore/MMH.h index 6ab5bbd..877eb33 100644 --- a/include/tscore/MMH.h +++ b/include/tscore/MMH.h @@ -27,6 +27,9 @@ #include "tscore/ink_defs.h" #include "tscore/CryptoHash.h" +#define MMH_X_SIZE 512 +extern uint64_t MMH_x[MMH_X_SIZE + 8]; + struct MMH_CTX { uint64_t state[4]; unsigned char buffer[32]; diff --git a/src/tscore/MMH.cc b/src/tscore/MMH.cc index 64c40f6..b0ed146 100644 --- a/src/tscore/MMH.cc +++ b/src/tscore/MMH.cc @@ -27,10 +27,8 @@ #include "tscore/ink_platform.h" #include "tscore/MMH.h" -#define MMH_X_SIZE 512 - /* BUG: INKqa11504: need it be to 64 bits...otherwise it overflows */ -static uint64_t MMH_x[MMH_X_SIZE + 8] = { +uint64_t MMH_x[MMH_X_SIZE + 8] = { 0x3ee18b32, 0x746d0d6b, 0x591be6a3, 0x760bd17f, 0x363c765d, 0x4bf3d5c5, 0x10f0510a, 0x39a84605, 0x2282b48f, 0x6903652e, 0x1b491170, 0x1ab8407a, 0x776b8aa8, 0x5b126ffe, 0x5095db1a, 0x565fe90c, 0x3ae1f068, 0x73fdf0cb, 0x72f39a81, 0x6a40a4a3, 0x4ef557fe, 0x360c1a2c, 0x4579b0ea, 0x61dfd174, 0x269b242f, 0x752d6298, 0x15f10fa3, 0x618b7ab3, 0x6699171f, 0x488f2c6c, @@ -84,18 +82,6 @@ static uint64_t MMH_x[MMH_X_SIZE + 8] = { 0x721a2a75, 0x13427ca9, 0x20e03cc9, 0x5f884596, 0x19dc210f, 0x066c954d, 0x52f43f40, 0x5d9c256f, 0x7f0acaae, 0x1e186b81, 0x55e9920f, 0x0e4f77b2, 0x6700ec53, 0x268837c0, 0x554ce08b, 0x4284e695, 0x2127e806, 0x384cb53b, 0x51076b2f, 0x23f9eb15}; -// We don't need this generator in release. -#ifdef TEST -// generator for above -static void -ink_init_MMH() -{ - srand48(13); // must remain the same! - for (int i = 0; i < MMH_X_SIZE; i++) -MMH_x[i] = lrand48(); -} -#endif /* TEST */ - int ink_code_incr_MMH_init(MMH_CTX *ctx) { @@ -380,116 +366,3 @@ MMHContext::finalize(CryptoHash ) { return 0 == ink_code_incr_MMH_final(hash.u8, &_ctx); } - -#ifdef TEST - -#define TEST_COLLISIONS 1000 - -static int -xxcompar(uint32_t **x, uint32_t **y) -{ - for (int i = 0; i < 4; i++) { -if (x[i] > y[i]) - return 1; -if (x[i] < y[i]) - return -1; - } - return 0; -} - -typedef uint32_t i4_t[4]; -i4_t *xxh; -double *xf; - -main() -{ - union { -unsigned char hash[16]; -uint32_t h[4]; - } h; - - xxh = (i4_t *)ats_malloc(4 * sizeof(uint32_t) * TEST_COLLISIONS); - xf = (double *)ats_malloc(sizeof(double) * TEST_COLLISIONS); - - printf("test collisions\n"); - char *sc1 = "http://npdev:19080/1.666400/4000;; - char *sc2 = "http://npdev:19080/1.866600/4000;; - char *sc3 = "http://:@npdev/1.666400/4000;?;; - char *sc4 = "http://:@npdev/1.866600/4000;?;; - ink_code_MMH((unsigned char *)sc1, strlen(sc1), h.hash); - printf("%X %X %X %X\n", h.h[0], h.h[1], h.h[2], h.h[3]); - ink_code_MMH((unsigned char *)sc2, strlen(sc2), h.hash); - printf("%X %X %X %X\n", h.h[0], h.h[1], h.h[2], h.h[3]); - ink_code_MMH((unsigned char *)sc3, strlen(sc3), h.hash); - printf("%X %X %X %X\n", h.h[0], h.h[1], h.h[2], h.h[3]); - ink_code_MMH((unsigned char *)sc4, strlen(sc4), h.hash); - printf("%X %X %X %X\n", h.h[0], h.h[1], h.h[2], h.h[3]); - - srand48(time(nullptr)); - for (int xx = 0; xx < TEST_COLLISIONS; xx++) { -char xs[256]; -xf[xx] = drand48(); -sprintf(xs, "http://@npdev/%16.14f/4000;?;, xf[xx]); -ink_code_MMH((unsigned char *)xs, strlen(xs), (unsigned char *)[xx]); - } - qsort(xxh, TEST_COLLISIONS, 16, xxcompar); - for (int xy = 0; xy < TEST_COLLISIONS - 1; xy++) { -if (xxh[xy][0] == xxh[xy + 1][0] && xxh[xy][1] == xxh[xy + 1][1] && xxh[xy][2] == xxh[xy + 1][2] && -xxh[xy][3] == xxh[xy + 1][3]) - printf("** collision %d\n", xy); - } - - unsigned char *s = (unsigned char *)MMH_x; - int l = sizeof(MMH_x); - unsigned char *s1 = (unsigned char *)ats_malloc(l + 3); - s1 += 1; - memcpy(s1, s, l); - unsigned char *s2 = (unsigned char *)ats_malloc(l + 3); - s2 += 2; - memcpy(s2, s, l); - unsigned char *s3 = (unsigned char *)ats_malloc(l + 3); - s3 += 3; - memcpy(s3, s, l); - - printf("test alignment\n"); - ink_code_MMH(s, l, h.hash); - printf("%X %X %X %X\n",
[trafficserver-ci] branch main updated: Add openssl-quic to our centos:8 image. (#11)
This is an automated email from the ASF dual-hosted git repository. bneradt pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/trafficserver-ci.git The following commit(s) were added to refs/heads/main by this push: new dd1a2d9 Add openssl-quic to our centos:8 image. (#11) dd1a2d9 is described below commit dd1a2d92e0576bee0f221240532148c994fde3c3 Author: Brian Neradt AuthorDate: Tue May 18 14:40:22 2021 -0500 Add openssl-quic to our centos:8 image. (#11) This builds openssl-quic and the corresponding HTTP/3 tools into the ATS centos:8 Docker image. To do this, the centos Dockerfile runs a slightly modified version of tools/build_h3_tools.sh from the apache/trafficserver.git repo. This also modifies /etc/profile to prepend /opt/bin to the PATH for users so that the built version of curl with --http3 support is used for the AuTests. --- docker/centos/Dockerfile| 10 +++ docker/centos/build_h3_tools.sh | 134 2 files changed, 144 insertions(+) diff --git a/docker/centos/Dockerfile b/docker/centos/Dockerfile index 0ae4e59..ae1fa6f 100644 --- a/docker/centos/Dockerfile +++ b/docker/centos/Dockerfile @@ -23,6 +23,16 @@ RUN if [ ! -z "$(grep -i centos /etc/redhat-release)" ]; then \ yum -y install gcc-toolset-9 gcc-toolset-9-libasan-devel; \ fi +# Install openssl-quic +RUN yum install -y python38-devel +RUN alternatives --set python /usr/bin/python3.8 +RUN yum -y install libev-devel jemalloc-devel libxml2-devel \ +c-ares-devel libevent-devel jansson-devel zlib-devel systemd-devel +COPY /build_h3_tools.sh /var/tmp/build_h3_tools.sh +RUN bash /var/tmp/build_h3_tools.sh +# Make sure we pick up this built version of curl, which is in /opt/bin. +RUN echo 'PATH=/opt/bin:$PATH' | tee -a /etc/profile.d/curl_http3.sh + RUN update-crypto-policies --set LEGACY RUN echo 'export GOROOT=/usr/local/go' | tee -a /etc/profile RUN echo 'export PATH=$PATH:/usr/local/go/bin' | tee -a /etc/profile diff --git a/docker/centos/build_h3_tools.sh b/docker/centos/build_h3_tools.sh new file mode 100755 index 000..d04a7b2 --- /dev/null +++ b/docker/centos/build_h3_tools.sh @@ -0,0 +1,134 @@ +#!/usr/bin/env bash +# +# Simple script to build OpenSSL and various tools with H3 and QUIC support. +# This probably needs to be modified based on platform. +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + + +# This is a slightly modified version of: +# https://github.com/apache/trafficserver/blob/19dfdd4753232d0b77ca555f7ef5f5ba3d2ccae1/tools/build_h3_tools.sh +# +# This present script been modified from the latter in the following ways: +# +# * This version checks out specific commits of the repos so that people +# creating images from the corresponding Dockerfile do not get different +# versions of these over time. +# +# * It also doesn't run sudo since the Dockerfile will run this as root. + + +set -e + +# Update this as the draft we support updates. +OPENSSL_BRANCH=${OPENSSL_BRANCH:-"OpenSSL_1_1_1k+quic"} + +# Set these, if desired, to change these to your preferred installation +# directory +BASE=${BASE:-"/opt"} +OPENSSL_BASE=${OPENSSL_BASE:-"${BASE}/openssl-quic"} +OPENSSL_PREFIX=${OPENSSL_PREFIX:-"${OPENSSL_BASE}-${OPENSSL_BRANCH}"} +MAKE="make" + +# These are for Linux like systems, specially the LDFLAGS, also depends on dirs above +CFLAGS=${CFLAGS:-"-O3 -g"} +CXXFLAGS=${CXXFLAGS:-"-O3 -g"} +LDFLAGS=${LDFLAGS:-"-Wl,-rpath=${OPENSSL_PREFIX}/lib"} + +if [ -e /etc/redhat-release ]; then +MAKE="gmake" +echo "+-+" +echo "| You probably need to run this, or something like this, for your system: |" +echo "| |" +echo "| sudo yum -y install libev-devel jemalloc-devel python2-devel |" +echo "| sudo yum -y install libxml2-devel c-ares-devel libevent-devel |" +echo "| sudo yum -y install jansson-devel zlib-devel systemd-devel |" +echo "+-+" +echo +