Anonymous avatar Anonymous committed 05a5dd5

Add the valgrind test.

Thanks to the people on #gtk+ on irc.gimp.org for letting me know of:

http://live.gnome.org/Valgrind .

Comments (0)

Files changed (1)

libfilefind/c_glib_based/t/valgrind.t

+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use Test::More tests => 1;
+
+sub test_using_valgrind
+{
+    my $id = shift;
+    my $cmd_line_args = shift;
+    my $blurb = shift;
+
+    my $log_fn = "valgrind.log";
+    my $out_file = "minifind.$id.dump";
+
+    system(
+        "G_SLICE=always-malloc G_DEBUG=gc-friendly valgrind --tool=memcheck --track-origins=yes --leak-check=full --leak-resolution=high --num-callers=20 --log-file=$log_fn $ENV{FCS_PATH}/minifind . > $out_file"
+    );
+
+    open my $read_from_valgrind, "<", $log_fn
+        or die "Cannot open valgrind.log for reading";
+    my $found_error_summary = 0;
+    my $found_malloc_free = 0;
+    LINES_LOOP:
+    while (my $l = <$read_from_valgrind>)
+    {
+        if (index($l, q{ERROR SUMMARY: 0 errors from 0 contexts}) >= 0)
+        {
+            $found_error_summary = 1;
+        }
+        elsif (index($l, q{in use at exit: 0 bytes}) >= 0)
+        {
+            $found_malloc_free = 1;
+        }
+    }
+    close ($read_from_valgrind);
+
+    if (ok (($found_error_summary && $found_malloc_free), $blurb))
+    {
+        unlink($log_fn);
+        unlink($out_file);
+    }
+    elsif (!$TODO)
+    {
+        die "Valgrind failed";
+    }
+}
+
+{
+    # local $TODO = 1;
+# TEST
+test_using_valgrind(
+    "current_dir",
+    [qw(.)],
+    qq{minifind .}
+);
+}
+
+=head1 COPYRIGHT AND LICENSE
+
+Copyright (c) 2009 Shlomi Fish
+
+Permission is hereby granted, free of charge, to any person
+obtaining a copy of this software and associated documentation
+files (the "Software"), to deal in the Software without
+restriction, including without limitation the rights to use,
+copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the
+Software is furnished to do so, subject to the following
+conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+=cut
+
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.