summaryrefslogtreecommitdiffstats
path: root/perl
diff options
context:
space:
mode:
authorRichard W.M. Jones <rjones@redhat.com>2010-02-26 11:29:09 +0000
committerRichard W.M. Jones <rjones@redhat.com>2010-02-26 21:51:27 +0000
commit5e00037f5c7309a316275e44ba1e58c2630d0438 (patch)
treed22de779895faa74c125b24b2b585ed958a5a5e9 /perl
parent391fb539a705958c3cdb32568b6862ecb83b81c0 (diff)
downloadhivex-5e00037f5c7309a316275e44ba1e58c2630d0438.tar.gz
hivex-5e00037f5c7309a316275e44ba1e58c2630d0438.tar.xz
hivex-5e00037f5c7309a316275e44ba1e58c2630d0438.zip
generator: Perl bindings.
This also adds a small test suite for the Perl bindings.
Diffstat (limited to 'perl')
-rw-r--r--perl/t/005-pod.t24
-rw-r--r--perl/t/006-pod-coverage.t24
-rw-r--r--perl/t/010-load.t24
-rw-r--r--perl/t/020-open.t27
-rw-r--r--perl/t/021-close.t31
-rw-r--r--perl/t/200-write.t49
-rw-r--r--perl/typemap8
7 files changed, 183 insertions, 4 deletions
diff --git a/perl/t/005-pod.t b/perl/t/005-pod.t
new file mode 100644
index 0000000..8fef583
--- /dev/null
+++ b/perl/t/005-pod.t
@@ -0,0 +1,24 @@
+# hivex Perl bindings -*- perl -*-
+# Copyright (C) 2010 Red Hat Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+use Test::More;
+use strict;
+use warnings;
+
+eval "use Test::Pod 1.00";
+plan skip_all => "Test::Pod 1.00 required for testing POD" if $@;
+all_pod_files_ok ();
diff --git a/perl/t/006-pod-coverage.t b/perl/t/006-pod-coverage.t
new file mode 100644
index 0000000..00c13c6
--- /dev/null
+++ b/perl/t/006-pod-coverage.t
@@ -0,0 +1,24 @@
+# hivex Perl bindings -*- perl -*-
+# Copyright (C) 2009 Red Hat Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+use Test::More;
+use strict;
+use warnings;
+
+eval "use Test::Pod::Coverage 1.00";
+plan skip_all => "Test::Pod::Coverage 1.00 required for testing POD" if $@;
+all_pod_coverage_ok ({also_private => [ qr/^test0.*/ ]});
diff --git a/perl/t/010-load.t b/perl/t/010-load.t
new file mode 100644
index 0000000..9abcdc8
--- /dev/null
+++ b/perl/t/010-load.t
@@ -0,0 +1,24 @@
+# hivex Perl bindings -*- perl -*-
+# Copyright (C) 2010 Red Hat Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+use strict;
+use warnings;
+use Test::More tests => 1;
+
+BEGIN {
+ use_ok ("Win::Hivex");
+}
diff --git a/perl/t/020-open.t b/perl/t/020-open.t
new file mode 100644
index 0000000..b3c58f0
--- /dev/null
+++ b/perl/t/020-open.t
@@ -0,0 +1,27 @@
+# hivex Perl bindings -*- perl -*-
+# Copyright (C) 2010 Red Hat Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+use strict;
+use warnings;
+use Test::More tests => 1;
+
+use Win::Hivex;
+
+my $srcdir = $ENV{srcdir} || ".";
+
+my $h = Win::Hivex->open ("$srcdir/../images/minimal");
+ok ($h);
diff --git a/perl/t/021-close.t b/perl/t/021-close.t
new file mode 100644
index 0000000..f6388fc
--- /dev/null
+++ b/perl/t/021-close.t
@@ -0,0 +1,31 @@
+# hivex Perl bindings -*- perl -*-
+# Copyright (C) 2010 Red Hat Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+use strict;
+use warnings;
+use Test::More tests => 2;
+
+use Win::Hivex;
+
+my $srcdir = $ENV{srcdir} || ".";
+
+# Put it in a block so the handle gets destroyed as well.
+{
+ my $h = Win::Hivex->open ("$srcdir/../images/minimal");
+ ok ($h);
+}
+ok (1);
diff --git a/perl/t/200-write.t b/perl/t/200-write.t
new file mode 100644
index 0000000..e7fd570
--- /dev/null
+++ b/perl/t/200-write.t
@@ -0,0 +1,49 @@
+# hivex Perl bindings -*- perl -*-
+# Copyright (C) 2010 Red Hat Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+use strict;
+use warnings;
+use Test::More tests => 6;
+
+use Win::Hivex;
+
+my $srcdir = $ENV{srcdir} || ".";
+
+my $h = Win::Hivex->open ("$srcdir/../images/minimal", write => 1);
+ok ($h);
+
+my $root = $h->root ();
+ok ($root);
+
+$h->node_add_child ($root, "A");
+ok (1);
+
+$h->node_add_child ($root, "B");
+ok (1);
+
+my $b = $h->node_get_child ($root, "B");
+ok ($b);
+
+my $values = [
+ { key => "Key1", t => 3, value => "ABC" },
+ { key => "Key2", t => 3, value => "DEF" }
+ ];
+$h->node_set_values ($b, $values);
+ok (1);
+
+# don't commit because that would overwrite the original file
+# $h->commit ();
diff --git a/perl/typemap b/perl/typemap
index 752ca0d..2cc5e0c 100644
--- a/perl/typemap
+++ b/perl/typemap
@@ -1,11 +1,11 @@
TYPEMAP
char * T_PV
const char * T_PV
-guestfs_h * O_OBJECT_guestfs_h
+hive_h * O_OBJECT_hive_h
int64_t T_IV
INPUT
-O_OBJECT_guestfs_h
+O_OBJECT_hive_h
if (sv_isobject ($arg) && SvTYPE (SvRV ($arg)) == SVt_PVMG)
$var = ($type) SvIV ((SV *) SvRV ($arg));
else {
@@ -14,5 +14,5 @@ O_OBJECT_guestfs_h
}
OUTPUT
-O_OBJECT_guestfs_h
- sv_setref_pv ($arg, "Sys::Guestfs", (void *) $var);
+O_OBJECT_hive_h
+ sv_setref_pv ($arg, "Win::Hivex", (void *) $var);