From a19ffe480bed6c6889ed5eb7b37687fef08ce277 Mon Sep 17 00:00:00 2001
From: Konstantin Shulgin <konstantin.shulgin@gmail.com>
Date: Fri, 19 Aug 2011 18:49:59 +0400
Subject: [PATCH] feature 'master-valgrind':

Test enviroment:
  - checking empty tests list was added =;
  - valgrind suppressions routine was updated.
---
 test/lib/server.py           |   3 +-
 test/lib/test_suite.py       |   7 +-
 test/share/tarantool_box.sup | 306 +++++++++++++++++++++++++++++++++++
 3 files changed, 312 insertions(+), 4 deletions(-)
 create mode 100644 test/share/tarantool_box.sup

diff --git a/test/lib/server.py b/test/lib/server.py
index 0887caa613..ae89ec143c 100644
--- a/test/lib/server.py
+++ b/test/lib/server.py
@@ -73,7 +73,7 @@ class Server(object):
         self.config = None
         self.vardir = None
         self.valgrind_log = "valgrind.log"
-        self.valgrind_sup = None
+        self.valgrind_sup = os.path.join("share/", "%s_%s.sup" % (core, module))
         self.default_suppression_name = "valgrind.sup"
         self.pidfile = None
         self.port = None
@@ -239,7 +239,6 @@ class Server(object):
         if start_and_exit != None: self.start_and_exit = start_and_exit
         if gdb != None: self.gdb = gdb
         if valgrind != None: self.valgrind = valgrind
-        if valgrind_sup != None: self.valgrind_sup = valgrind_sup
 
         self.configure(self.config)
         self.install(self.binary, self.vardir, self.mem, silent)
diff --git a/test/lib/test_suite.py b/test/lib/test_suite.py
index c4d3494208..4094e7be6e 100644
--- a/test/lib/test_suite.py
+++ b/test/lib/test_suite.py
@@ -207,7 +207,6 @@ class TestSuite:
         config.read(os.path.join(suite_path, "suite.ini"))
         self.ini.update(dict(config.items("default")))
         self.ini["config"] = os.path.join(suite_path, self.ini["config"])
-        self.ini["valgrind_suppression"] = os.path.join(suite_path, self.ini["valgrind_suppression"])
         if self.ini.has_key("disabled"):
             self.ini["disabled"] = dict.fromkeys(self.ini["disabled"].split(" "))
         else:
@@ -232,10 +231,14 @@ class TestSuite:
             raise RuntimeError("Unknown server: core = {0}, module = {1}".format(
                                self.ini["core"], self.ini["module"]))
 
+        if len(self.tests) == 0:
+            # noting to test, exit
+            return 0
+
         server.deploy(self.ini["config"],
                       server.find_exe(self.args.builddir, silent=False),
                       self.args.vardir, self.args.mem, self.args.start_and_exit, self.args.gdb,
-                      self.args.valgrind, self.ini["valgrind_suppression"], silent=False)
+                      self.args.valgrind, silent=False)
         if self.args.start_and_exit:
             print "  Start and exit requested, exiting..."
             exit(0)
diff --git a/test/share/tarantool_box.sup b/test/share/tarantool_box.sup
new file mode 100644
index 0000000000..c7c941c62e
--- /dev/null
+++ b/test/share/tarantool_box.sup
@@ -0,0 +1,306 @@
+
+##
+## obj-c leaks
+##
+
+{
+   <obj-c internals>
+   Memcheck:Leak
+   fun:malloc
+   fun:objc_malloc
+   ...
+}
+
+{
+   <obj-c internals>
+   Memcheck:Leak
+   fun:calloc
+   fun:objc_calloc
+   ...
+}
+
+{
+   <obj-c internals>
+   Memcheck:Leak
+   fun:realloc
+   fun:objc_realloc
+   ...
+}
+
+##
+## libev internals
+##
+
+{
+   <uninitialized value>
+   Memcheck:Param
+   write(buf)
+   fun:__write_nocancel
+   fun:evpipe_write
+   fun:ev_feed_signal
+   fun:ev_sighandler
+   ...
+}
+
+{
+   <0 byte free>
+   Memcheck:Leak
+   fun:malloc
+   fun:realloc
+   fun:ev_realloc_emul
+   fun:ev_realloc
+   fun:epoll_destroy
+   fun:ev_loop_destroy
+   fun:ev_default_destroy
+   fun:tarantool_free
+   ...
+}
+
+{
+   <0 byte free>
+   Memcheck:Leak
+   fun:malloc
+   fun:realloc
+   fun:ev_realloc_emul
+   fun:ev_realloc
+   fun:ev_loop_destroy
+   fun:ev_default_destroy
+   fun:tarantool_free
+   ...
+}
+
+##
+## realloc(ptr, 0)
+##
+
+{
+   <realloc with 0 byte>
+   Memcheck:Leak
+   fun:malloc
+   fun:realloc
+   fun:kh_destroy_int_ptr_map
+   ...
+}
+
+{
+   <realloc with 0 byte>
+   Memcheck:Leak
+   fun:malloc
+   fun:realloc
+   fun:tnt_xrealloc
+   fun:kh_destroy_lstr_ptr_map
+   ...
+}
+
+{
+   <realloc with 0 byte>
+   Memcheck:Leak
+   fun:malloc
+   fun:realloc
+   fun:kh_destroy_fid2fiber
+   fun:fiber_free
+   fun:tarantool_free
+   ...
+}
+
+{
+   <realloc with 0 byte>
+   Memcheck:Leak
+   fun:malloc
+   fun:realloc
+   fun:tnt_xrealloc
+   fun:kh_destroy_lstr_ptr_map
+   fun:index_hash_str_free
+   fun:index_free
+   ...
+}
+
+{
+   <realloc with 0 byte>
+   Memcheck:Leak
+   fun:malloc
+   fun:realloc
+   fun:tnt_xrealloc
+   fun:kh_resize_lstr_ptr_map
+   fun:kh_put_lstr_ptr_map
+   fun:index_replace_hash_str
+   ...
+}
+
+{
+   <realloc with 0 byte>
+   Memcheck:Leak
+   fun:malloc
+   fun:realloc
+   fun:kh_resize_int_ptr_map
+   fun:kh_put_int_ptr_map
+   fun:index_replace_hash_num
+   ...
+}
+
+{
+   <realloc with 0 byte>
+   Memcheck:Leak
+   fun:malloc
+   fun:realloc
+   fun:kh_resize_fid2fiber
+   fun:kh_put_fid2fiber
+   fun:register_fid
+   fun:fiber_create
+   fun:spawn_child
+   fun:recover_init
+   fun:mod_init
+   fun:main
+}
+
+##
+## backtrace
+##
+
+## backtrace implementation is low-level and
+## produces alot of warnings.
+
+{
+   <backtrace internals>
+   Memcheck:Cond
+   fun:backtrace
+   ...
+}
+
+{
+   <backtrace internals>
+   Memcheck:Value8
+   fun:backtrace
+   ...
+}
+
+{
+   <backtrace internals>
+   Memcheck:Cond
+   fun:vfprintf
+   fun:vsnprintf
+   fun:snprintf
+   fun:backtrace
+   ...
+}
+
+{
+   <backtrace internals>
+   Memcheck:Value8
+   fun:_itoa_word
+   fun:vfprintf
+   fun:vsnprintf
+   fun:snprintf
+   fun:backtrace
+   ...
+}
+
+{
+   <backtrace internals>
+   Memcheck:Cond
+   fun:_itoa_word
+   fun:vfprintf
+   fun:vsnprintf
+   fun:snprintf
+   fun:backtrace
+   ...
+}
+
+##
+## box allocations
+## 
+
+## we can't directly free tuple allocations.
+
+{
+   <box>
+   Memcheck:Leak
+   fun:salloc
+   fun:tuple_alloc
+   fun:prepare_update_fields
+   fun:box_dispatch
+   fun:box_process
+   fun:box_process_rw
+   fun:iproto_reply
+   fun:iproto_interact
+   fun:fiber_loop
+   fun:coro_init
+   obj:*
+}
+
+{
+   <box>
+   Memcheck:Leak
+   fun:salloc
+   fun:tuple_alloc
+   fun:prepare_update_fields
+   fun:box_dispatch
+   fun:box_process
+   fun:recover_row
+   fun:recover_wal
+   fun:recover_remaining_wals
+   fun:recover
+   fun:mod_init
+   fun:main
+}
+
+{
+   <box>
+   Memcheck:Leak
+   fun:salloc
+   fun:tuple_alloc
+   fun:prepare_replace
+   fun:box_dispatch
+   fun:box_process
+   fun:box_process_rw
+   fun:store
+   fun:memcached_dispatch
+   fun:memcached_handler
+   ...
+}
+
+{
+   <box>
+   Memcheck:Leak
+   fun:salloc
+   fun:tuple_alloc
+   fun:prepare_replace
+   fun:box_dispatch
+   fun:box_process
+   fun:box_process_rw
+   fun:iproto_reply
+   fun:iproto_interact
+   fun:fiber_loop
+   fun:coro_init
+   obj:*
+}
+
+## sptree
+##
+
+## third_party sptree implementation doesn't have
+## destroy function.
+
+{
+   <insert_a_suppression_name_here>
+   Memcheck:Leak
+   fun:malloc
+   fun:realloc
+   fun:sptree_str_t_init
+   fun:build_indexes
+   ...
+}
+
+# iterator_init_set calls realloc only if iterator value not
+# initialized or have lower depth.
+
+{
+   <insert_a_suppression_name_here>
+   Memcheck:Leak
+   fun:malloc
+   fun:realloc
+   fun:sptree_str_t_iterator_init_set
+   fun:index_iterator_init_tree_str
+   fun:process_select
+   ...
+}
-- 
GitLab