Skip to content

Commit f713ce0

Browse files
committed
poke at valgrind test
1 parent e1b58b4 commit f713ce0

File tree

4 files changed

+19
-23
lines changed

4 files changed

+19
-23
lines changed

c/test_valgrind.pl

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
use strict;
44
use warnings;
5+
use Test::More tests => 45;
56

6-
7-
print "Testing good files\n";
7+
## good data
88
foreach my $file (qw(co_metal_rt.xdi
99
cu_metal_10K.xdi
1010
cu_metal_rt.xdi
@@ -23,28 +23,15 @@
2323
)) {
2424
my $command = "valgrind --track-origins=yes --leak-check=full --show-leak-kinds=all ./xdi_reader ../baddata/$file 2>&1";
2525
my $x = `$command`;
26-
printf "\t%-17s: ", $file;
27-
if ($x =~ m{All heap blocks were freed}) {
28-
print "ok\n";
29-
} else {
30-
print "not ok\n";
31-
};
32-
26+
ok(($x =~ m{All heap blocks were freed}), $file);
3327
};
3428

35-
36-
print "\nTesting bad files\n";
29+
## bad data
3730
foreach my $i (0 .. 29) {
3831
my $n = sprintf("%2.2d", $i);
3932
my $command = "valgrind --track-origins=yes --leak-check=full --show-leak-kinds=all ./xdi_reader ../baddata/bad_$n.xdi 2>&1";
40-
#print $command, $/;
4133
my $x = `$command`;
42-
printf "\tbad_%s.xdi: ", $n;
43-
if ($x =~ m{All heap blocks were freed}) {
44-
print "ok\n";
45-
} else {
46-
print "not ok\n";
47-
};
34+
ok(($x =~ m{All heap blocks were freed}), "bad_$n.xdi");
4835
};
4936

5037

c/xdifile.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
#include "xdifile.h"
1919

2020
/* error string interpretation */
21-
_EXPORT(char*) XDI_errorstring(int errcode) {
21+
_EXPORT(char*)
22+
XDI_errorstring(int errcode) {
2223
if (errcode == 0) { return ""; }
2324
if (errcode == ERR_NOTXDI) {
2425
return "not an XDI file";
@@ -530,7 +531,8 @@ XDI_readfile(char *filename, XDIFile *xdifile) {
530531

531532
}
532533

533-
_EXPORT(int) XDI_get_array_index(XDIFile *xdifile, long n, double *out) {
534+
_EXPORT(int)
535+
XDI_get_array_index(XDIFile *xdifile, long n, double *out) {
534536
/* get array by index (starting at 0) from an XDIFile structure */
535537
long j;
536538
if (n < xdifile->narrays) {
@@ -542,7 +544,8 @@ _EXPORT(int) XDI_get_array_index(XDIFile *xdifile, long n, double *out) {
542544
return ERR_NOARR_INDEX;
543545
}
544546

545-
_EXPORT(int) XDI_get_array_name(XDIFile *xdifile, char *name, double *out) {
547+
_EXPORT(int)
548+
XDI_get_array_name(XDIFile *xdifile, char *name, double *out) {
546549
/* get array by name from an XDIFile structure */
547550
long i;
548551
for (i = 0; i < xdifile->narrays; i++) {

perl/lib/Xray/XDI.pm

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ with 'MooseX::Clone';
99

1010
use List::MoreUtils qw(any uniq);
1111

12-
our $VERSION = '1.00'; # Inline::MakeMake uses /^\d.\d\d$/ as the pattern for the version number -- note the two digits to the right of the dot
12+
our $VERSION = '1.00'; # Inline::MakeMake uses /^\d.\d\d$/ as the
13+
# pattern for the version number -- note the
14+
# two digits to the right of the dot
1315

1416
has 'file' => (is => 'rw', isa => 'Str', traits => [qw(Clone)], default => q{},
1517
trigger => sub{$_[0]->_build_object});

perl/lib/Xray/XDIFile.pm

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ Xray::XDIFile - Inline::C interface to libxdifile
3232
=head1 SYNOPSIS
3333
3434
This is a slight rewrite of the xdi_reader example that comes with the
35-
linxdifile source code. It uses L<Inline> to map perl scalars onto
35+
libxdifile source code. It uses L<Inline> to map perl scalars onto
3636
the data structures in libxdifile.
3737
3838
Import an XDI file:
@@ -148,6 +148,10 @@ SV* new(char* class, char* file, SV* errcode) {
148148
return obj_ref;
149149
}
150150
151+
void _cleanup(SV* obj, long err) {
152+
XDI_cleanup((INT2PTR(XDIFile*, SvIV(SvRV(obj)))), err);
153+
}
154+
151155
char* _errorstring(SV* obj, int code) {
152156
return XDI_errorstring(code);
153157
}

0 commit comments

Comments
 (0)