avro-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject [avro] branch master updated: [AVRO-2026] Add valgrind to c tests This closes #218
Date Mon, 10 Dec 2018 19:17:04 GMT
This is an automated email from the ASF dual-hosted git repository.

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


The following commit(s) were added to refs/heads/master by this push:
     new 7fbedbb  [AVRO-2026] Add valgrind to c tests This closes #218
7fbedbb is described below

commit 7fbedbb8923bb203409f5d5576a38ac70aba9f4b
Author: John Gill <king2bgill@gmail.com>
AuthorDate: Sat Apr 15 15:32:20 2017 -0700

    [AVRO-2026] Add valgrind to c tests
    This closes #218
    
    Squashed merge of:
    Don't clean after test. Allow review of memcheck files
    
    Add valgrind to tests
    
    Correct memory leaks in tests
---
 lang/c/build.sh               |  1 -
 lang/c/tests/CMakeLists.txt   | 66 +++++++++++++++++++++++++++----------------
 lang/c/tests/test_avro_1034.c | 13 +++++----
 lang/c/tests/test_avro_1087.c |  8 ++++--
 lang/c/tests/test_avro_1379.c |  6 ++++
 lang/c/tests/test_avro_1691.c |  6 ++++
 share/docker/Dockerfile       |  3 +-
 7 files changed, 68 insertions(+), 35 deletions(-)

diff --git a/lang/c/build.sh b/lang/c/build.sh
index f76f035..cf05c13 100755
--- a/lang/c/build.sh
+++ b/lang/c/build.sh
@@ -61,7 +61,6 @@ case "$1" in
     prepare_build
     make -C $build_dir
     make -C $build_dir test
-    clean
     ;;
 
   dist)
diff --git a/lang/c/tests/CMakeLists.txt b/lang/c/tests/CMakeLists.txt
index 589185c..55ad6b6 100644
--- a/lang/c/tests/CMakeLists.txt
+++ b/lang/c/tests/CMakeLists.txt
@@ -40,31 +40,49 @@ macro(add_avro_test name)
     )
 endmacro(add_avro_test)
 
+macro(add_avro_test_checkmem name)
+    add_avro_test(${name} ${ARGN})
+    if(UNIX)
+        find_program(MEMORYCHECK_COMMAND valgrind )
+        if(MEMORYCHECK_COMMAND)
+            add_test(memcheck_${name}
+                ${CMAKE_COMMAND} -E chdir ${AvroC_SOURCE_DIR}/tests
+                ${MEMORYCHECK_COMMAND}
+                    --log-file=${CMAKE_CURRENT_BINARY_DIR}/memcheck_${name}.log
+                    --leak-check=full
+                    --show-reachable=yes
+                    --error-exitcode=1
+                    ${exec_name}
+            )
+        endif(MEMORYCHECK_COMMAND)
+    endif (UNIX)
+endmacro(add_avro_test_checkmem)
+
 add_avro_executable(generate_interop_data)
 add_avro_executable(performance)
 add_avro_executable(test_interop_data)
 
-add_avro_test(test_data_structures)
-add_avro_test(test_avro_schema)
-add_avro_test(test_avro_schema_names)
-add_avro_test(test_avro_values)
-add_avro_test(test_avro_766)
-add_avro_test(test_avro_968)
-add_avro_test(test_avro_984)
-add_avro_test(test_avro_1034)
-add_avro_test(test_avro_1084)
-add_avro_test(test_avro_1087)
-add_avro_test(test_avro_1165)
-add_avro_test(test_avro_1167)
-add_avro_test(test_avro_1237)
-add_avro_test(test_avro_1238)
-add_avro_test(test_avro_1279)
-add_avro_test(test_avro_1405)
-add_avro_test(test_avro_1572)
-add_avro_test(test_avro_data)
-add_avro_test(test_refcount)
-add_avro_test(test_cpp test_cpp.cpp)
-add_avro_test(test_avro_1379)
-add_avro_test(test_avro_1691)
-add_avro_test(test_avro_1906)
-add_avro_test(test_avro_1904)
+add_avro_test_checkmem(test_data_structures)
+add_avro_test_checkmem(test_avro_schema)
+add_avro_test_checkmem(test_avro_schema_names)
+add_avro_test_checkmem(test_avro_values)
+add_avro_test_checkmem(test_avro_766)
+add_avro_test_checkmem(test_avro_968)
+add_avro_test_checkmem(test_avro_984)
+add_avro_test_checkmem(test_avro_1034)
+add_avro_test_checkmem(test_avro_1084)
+add_avro_test_checkmem(test_avro_1087)
+add_avro_test_checkmem(test_avro_1165)
+add_avro_test_checkmem(test_avro_1167)
+add_avro_test_checkmem(test_avro_1237)
+add_avro_test_checkmem(test_avro_1238)
+add_avro_test_checkmem(test_avro_1279)
+add_avro_test_checkmem(test_avro_1405)
+add_avro_test_checkmem(test_avro_1572)
+add_avro_test(test_avro_data) # Skip memory check for datum. Deprecated and has a lot of
memory issues
+add_avro_test_checkmem(test_refcount)
+add_avro_test_checkmem(test_cpp test_cpp.cpp)
+add_avro_test_checkmem(test_avro_1379)
+add_avro_test_checkmem(test_avro_1691)
+add_avro_test_checkmem(test_avro_1906)
+add_avro_test_checkmem(test_avro_1904)
diff --git a/lang/c/tests/test_avro_1034.c b/lang/c/tests/test_avro_1034.c
index 036337a..957f301 100644
--- a/lang/c/tests/test_avro_1034.c
+++ b/lang/c/tests/test_avro_1034.c
@@ -37,18 +37,18 @@
  * resolved_reader_class and a corresponding resolved_record instance
  * is created (using identical "writer" and "reader" schemas for
  * simplicity), and an attempt is made to "read" the resolved avro
- * value. 
- * 
+ * value.
+ *
  * Once the resolved value has been read, the source value (nested)
  * and the resolved value (resolved_record) are both reset using
  * avro_value_reset(). Then the source value (nested) is populated
  * with another (larger) nested array. Then an attempt is made to read
  * the resolved avro value again.
- * 
+ *
  * This second attempt to read the resolved value results in a
- * segmentation fault under Linux, using the patch in 
+ * segmentation fault under Linux, using the patch in
  * https://issues.apache.org/jira/secure/attachment/12516487/0001-AVRO-1034.-C-Resolved-reader-initializes-child-array.patch.
- * 
+ *
  * However, the program does not seg fault, using the patch in
  * https://issues.apache.org/jira/secure/attachment/12515544/AVRO-1034.patch
  *
@@ -281,11 +281,12 @@ int add_array( avro_writer_t writer,
 
     try ( avro_value_write( writer, &resolved_record ),
           "Unable to write record into memory using writer_record" );
-    
+
     print_array_fields( &resolved_record );
 
     avro_value_decref( &resolved_record );
     avro_value_iface_decref( writer_class );
+    avro_value_iface_decref( resolved_reader_class );
   }
   else
   {
diff --git a/lang/c/tests/test_avro_1087.c b/lang/c/tests/test_avro_1087.c
index c6aa807..4639a29 100644
--- a/lang/c/tests/test_avro_1087.c
+++ b/lang/c/tests/test_avro_1087.c
@@ -30,9 +30,9 @@ avro_schema_t schema;
 
 void add_record (avro_file_writer_t writer)
 {
-	avro_datum_t main_datum = avro_record(schema);		
+	avro_datum_t main_datum = avro_record(schema);
 	avro_datum_t id_datum = avro_int32(1);
-	
+
 	if (avro_record_set (main_datum, "ID", id_datum))
 	{
 		printf ("Unable to create datum");
@@ -76,10 +76,12 @@ int main()
 
 	avro_file_writer_open (dbname, &writer);
 	add_record (writer);
-	
+
 	avro_file_writer_flush (writer);
 	avro_file_writer_close (writer);
 
+    avro_schema_decref(schema);
+
 	remove (dbname);
 
 	return EXIT_SUCCESS;
diff --git a/lang/c/tests/test_avro_1379.c b/lang/c/tests/test_avro_1379.c
index 738a0bd..eeeac5a 100644
--- a/lang/c/tests/test_avro_1379.c
+++ b/lang/c/tests/test_avro_1379.c
@@ -119,5 +119,11 @@ int main(void)
 	check(rval, avro_file_reader_close(file_reader));
 	remove(outpath);
 
+	avro_writer_free(writer);
+	avro_value_decref(&out);
+	avro_value_decref(&val);
+	avro_value_iface_decref(iface);
+	avro_schema_decref(schema);
+
 	exit(EXIT_SUCCESS);
 }
diff --git a/lang/c/tests/test_avro_1691.c b/lang/c/tests/test_avro_1691.c
index 455f2cb..2d0c99f 100644
--- a/lang/c/tests/test_avro_1691.c
+++ b/lang/c/tests/test_avro_1691.c
@@ -88,6 +88,12 @@ int main(void)
                 fprintf(stderr, "pass %d: ok: schema %s\n", pass, json_schema);
                 check(rval, avro_file_reader_close(file_reader));
                 remove(outpath);
+                
+                avro_writer_free(writer);
+                avro_value_decref(&out);
+                avro_value_decref(&val);
+                avro_value_iface_decref(iface);
+                avro_schema_decref(schema);
         }
 
 	exit(EXIT_SUCCESS);
diff --git a/share/docker/Dockerfile b/share/docker/Dockerfile
index ec8ac34..bbf675c 100644
--- a/share/docker/Dockerfile
+++ b/share/docker/Dockerfile
@@ -63,7 +63,8 @@ RUN apt-get -qq update && \
     ruby \
     ruby-dev \
     source-highlight \
-    subversion && \
+    subversion \
+    valgrind && \
   apt-get -qq clean && \
   rm -rf /var/lib/apt/lists/*
 


Mime
View raw message