You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@thrift.apache.org by jk...@apache.org on 2017/02/15 19:13:01 UTC

thrift git commit: THRIFT-4091 - revert THRIFT-4045 and remove unused test code in test/cpp Client: C++

Repository: thrift
Updated Branches:
  refs/heads/master ec50ae0ed -> ab8ff1abf


THRIFT-4091 - revert THRIFT-4045 and remove unused test code in test/cpp
Client: C++

This closes #1192


Project: http://git-wip-us.apache.org/repos/asf/thrift/repo
Commit: http://git-wip-us.apache.org/repos/asf/thrift/commit/ab8ff1ab
Tree: http://git-wip-us.apache.org/repos/asf/thrift/tree/ab8ff1ab
Diff: http://git-wip-us.apache.org/repos/asf/thrift/diff/ab8ff1ab

Branch: refs/heads/master
Commit: ab8ff1abf74320f23bb692ca9ae83062503b2518
Parents: ec50ae0
Author: James E. King, III <jk...@apache.org>
Authored: Wed Feb 15 14:12:37 2017 -0500
Committer: James E. King, III <jk...@apache.org>
Committed: Wed Feb 15 14:12:37 2017 -0500

----------------------------------------------------------------------
 configure.ac                    |   2 +
 test/cpp/Makefile.am            |   4 +-
 test/cpp/realloc/Makefile       |  40 -------------
 test/cpp/realloc/realloc_test.c | 107 -----------------------------------
 4 files changed, 3 insertions(+), 150 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/thrift/blob/ab8ff1ab/configure.ac
----------------------------------------------------------------------
diff --git a/configure.ac b/configure.ac
index 09c6d9e..a889f75 100755
--- a/configure.ac
+++ b/configure.ac
@@ -660,7 +660,9 @@ AC_CHECK_DECL([AI_ADDRCONFIG], [],
 
 AC_FUNC_ALLOCA
 AC_FUNC_FORK
+AC_FUNC_MALLOC
 AC_FUNC_MEMCMP
+AC_FUNC_REALLOC
 AC_FUNC_SELECT_ARGTYPES
 AC_FUNC_STAT
 AC_FUNC_STRERROR_R

http://git-wip-us.apache.org/repos/asf/thrift/blob/ab8ff1ab/test/cpp/Makefile.am
----------------------------------------------------------------------
diff --git a/test/cpp/Makefile.am b/test/cpp/Makefile.am
index d825bdd..82dc518 100755
--- a/test/cpp/Makefile.am
+++ b/test/cpp/Makefile.am
@@ -120,6 +120,4 @@ EXTRA_DIST = \
 	src/TestClient.cpp \
 	src/TestServer.cpp \
 	src/StressTest.cpp \
-	src/StressTestNonBlocking.cpp \
-	realloc/realloc_test.c \
-	realloc/Makefile
+	src/StressTestNonBlocking.cpp

http://git-wip-us.apache.org/repos/asf/thrift/blob/ab8ff1ab/test/cpp/realloc/Makefile
----------------------------------------------------------------------
diff --git a/test/cpp/realloc/Makefile b/test/cpp/realloc/Makefile
deleted file mode 100644
index f89bbb3..0000000
--- a/test/cpp/realloc/Makefile
+++ /dev/null
@@ -1,40 +0,0 @@
-#
-# 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 probably should not go into "make check", because it is an experiment,
-# not a test.  Specifically, it is meant to determine how likely realloc is
-# to avoid a copy.  This is poorly documented.
-
-run: realloc_test
-	for it in 1 4 64 ; do \
-		for nb in 1 8 64 512 ; do \
-			for mins in 64 512 ; do \
-				for maxs in 2048 262144 ; do \
-					for db in 8 64 ; do \
-						./realloc_test $$nb $$mins $$maxs $$db $$it \
-					; done \
-				; done \
-			; done \
-		; done \
-	; done \
-	> raw_stats
-
-CFLAGS = -Wall -g -std=c99
-LDLIBS = -ldl
-realloc_test: realloc_test.c

http://git-wip-us.apache.org/repos/asf/thrift/blob/ab8ff1ab/test/cpp/realloc/realloc_test.c
----------------------------------------------------------------------
diff --git a/test/cpp/realloc/realloc_test.c b/test/cpp/realloc/realloc_test.c
deleted file mode 100644
index f9763ad..0000000
--- a/test/cpp/realloc/realloc_test.c
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * 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.
- */
-
-#define _GNU_SOURCE
-#include <stdlib.h>
-#include <stdio.h>
-#include <time.h>
-#include <dlfcn.h>
-
-int copies;
-int non_copies;
-
-void *realloc(void *ptr, size_t size) {
-  static void *(*real_realloc)(void*, size_t) = NULL;
-  if (real_realloc == NULL) {
-    real_realloc = (void* (*) (void*, size_t)) dlsym(RTLD_NEXT, "realloc");
-  }
-
-  void *ret_ptr = (*real_realloc)(ptr, size);
-
-  if (ret_ptr == ptr) {
-    non_copies++;
-  } else {
-    copies++;
-  }
-
-  return ret_ptr;
-}
-
-
-struct TMemoryBuffer {
-  void* ptr;
-  int size;
-};
-
-int main(int argc, char *argv[]) {
-  int num_buffers;
-  int init_size;
-  int max_size;
-  int doublings;
-  int iterations;
-
-  if (argc < 6 ||
-      argc > 7 ||
-      (num_buffers = atoi(argv[1])) == 0 ||
-      (init_size = atoi(argv[2])) == 0 ||
-      (max_size = atoi(argv[3])) == 0 ||
-      init_size > max_size ||
-      (iterations = atoi(argv[4])) == 0 ||
-      (doublings = atoi(argv[5])) == 0 ||
-      (argc == 7 && atoi(argv[6]) == 0)) {
-    fprintf(stderr, "usage: realloc_test <num_buffers> <init_size> <max_size> <doublings> <iterations> [seed]\n");
-    exit(EXIT_FAILURE);
-  }
-
-  for ( int i = 0 ; i < argc ; i++ ) {
-    printf("%s ", argv[i]);
-  }
-  printf("\n");
-
-  if (argc == 7) {
-    srand(atoi(argv[6]));
-  } else {
-    srand(time(NULL));
-  }
-
-  struct TMemoryBuffer* buffers = calloc(num_buffers, sizeof(*buffers));
-  if (buffers == NULL) abort();
-
-  for ( int i = 0 ; i < num_buffers ; i++ ) {
-    buffers[i].size = max_size;
-  }
-
-  while (iterations --> 0) {
-    for ( int i = 0 ; i < doublings * num_buffers ; i++ ) {
-      struct TMemoryBuffer* buf = &buffers[rand() % num_buffers];
-      buf->size *= 2;
-      if (buf->size <= max_size) {
-        buf->ptr = realloc(buf->ptr, buf->size);
-      } else {
-        free(buf->ptr);
-        buf->size = init_size;
-        buf->ptr = malloc(buf->size);
-      }
-      if (buf->ptr == NULL) abort();
-    }
-  }
-
-  printf("Non-copied %d/%d (%.2f%%)\n", non_copies, copies + non_copies, 100.0 * non_copies / (copies + non_copies));
-  return 0;
-}