1 # Win::Hivex::Regedit test -*- perl -*-
2 # Copyright (C) 2010 Red Hat Inc.
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 2 of the License, or
7 # (at your option) any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 use Encode qw(from_to);
24 use Test::More tests => 16;
27 use Win::Hivex::Regedit qw(reg_import reg_export);
29 my $srcdir = $ENV{srcdir} || ".";
31 my $h = Win::Hivex->open ("$srcdir/../images/minimal", write => 1);
34 my ($data, $expected);
36 # Note that we don't clear the hive between tests, so results of
37 # next test depend on the previous test.
45 "Key1"=hex(2):48,00,65,00,6c,00,6c,00,6f,00
47 "Key3"=hex:48,00,65,00,6c,00,6c,00,6f,00,\
48 48,00,65,00,6c,00,6c,00,6f,00
49 "Key4"=dword:ff123456';
57 "Key1"=hex(2):48,00,65,00,6c,00,6c,00,6f,00
58 "Key2"=hex(2):48,00,65,00,6c,00,6c,00,6f,00
59 "Key3"=hex(3):48,00,65,00,6c,00,6c,00,6f,00,48,00,65,00,6c,00,6c,00,6f,00
64 run_test ($data, $expected);
75 @=hex(1):48,00,65,00,6c,00,6c,00,6f,00
78 "Key1"=hex(2):48,00,65,00,6c,00,6c,00,6f,00
79 "Key2"=hex(2):48,00,65,00,6c,00,6c,00,6f,00
80 "Key3"=hex(3):48,00,65,00,6c,00,6c,00,6f,00,48,00,65,00,6c,00,6c,00,6f,00
85 run_test ($data, $expected);
103 run_test ($data, $expected);
110 "Key\"Containing\"Quotes"=hex(0):
117 "Key\"Containing\"Quotes"=hex(0):
121 run_test ($data, $expected);
125 "Key\"Containing\"Quotes"=-
133 run_test ($data, $expected);
135 #----------------------------------------------------------------------
139 my $expected = shift;
141 my $fh = new IO::Scalar \$data;
142 reg_import ($fh, $h);
145 $fh = new IO::Scalar;
146 reg_export ($h, "\\", $fh);
149 my $actual = ${$fh->sref};
150 warn "\n\n----- ACTUAL -----\n$actual\n----- EXPECTED -----\n$expected\n\n"
151 if $actual ne $expected;
153 ok ($actual eq $expected)