From a7ea3b577f9bde78ca7d120017de68c8f55b88eb Mon Sep 17 00:00:00 2001 From: Matteo Cafasso Date: Tue, 1 Mar 2016 00:05:37 +0200 Subject: [PATCH] tests: Added test for ntfscat_i. Test is based on file signature, it checks whether the extracted file is the $MFT. Signed-off-by: Matteo Cafasso --- Makefile.am | 1 + configure.ac | 1 + tests/ntfscat/Makefile.am | 26 +++++++++++++++++ tests/ntfscat/test-ntfscat.sh | 53 +++++++++++++++++++++++++++++++++++ 4 files changed, 81 insertions(+) create mode 100644 tests/ntfscat/Makefile.am create mode 100755 tests/ntfscat/test-ntfscat.sh diff --git a/Makefile.am b/Makefile.am index ba99feb30..1ab85e8b3 100644 --- a/Makefile.am +++ b/Makefile.am @@ -66,6 +66,7 @@ SUBDIRS += tests/luks SUBDIRS += tests/md SUBDIRS += tests/selinux SUBDIRS += tests/ntfsclone +SUBDIRS += tests/ntfscat SUBDIRS += tests/btrfs SUBDIRS += tests/xfs SUBDIRS += tests/charsets diff --git a/configure.ac b/configure.ac index dcfb4ed87..0a759fefe 100644 --- a/configure.ac +++ b/configure.ac @@ -272,6 +272,7 @@ AC_CONFIG_FILES([Makefile tests/nbd/Makefile tests/network/Makefile tests/ntfsclone/Makefile + tests/ntfscat/Makefile tests/parallel/Makefile tests/protocol/Makefile tests/qemu/Makefile diff --git a/tests/ntfscat/Makefile.am b/tests/ntfscat/Makefile.am new file mode 100644 index 000000000..dc64c3d90 --- /dev/null +++ b/tests/ntfscat/Makefile.am @@ -0,0 +1,26 @@ +# libguestfs +# Copyright (C) 2016 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +include $(top_srcdir)/subdir-rules.mk + +TESTS = \ + test-ntfscat.sh + +TESTS_ENVIRONMENT = $(top_builddir)/run --test + +EXTRA_DIST = \ + $(TESTS) diff --git a/tests/ntfscat/test-ntfscat.sh b/tests/ntfscat/test-ntfscat.sh new file mode 100755 index 000000000..5cfdd9562 --- /dev/null +++ b/tests/ntfscat/test-ntfscat.sh @@ -0,0 +1,53 @@ +#!/bin/bash - +# libguestfs +# Copyright (C) 2016 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +# Test the ntfscat-i command. + +set -e + +if [ -n "$SKIP_TEST_NTFSCAT_SH" ]; then + echo "$0: test skipped because environment variable is set." + exit 77 +fi + +rm -f test-mft.bin + +# Skip if ntfs-3g is not supported by the appliance. +if ! guestfish add /dev/null : run : available "ntfs3g"; then + echo "$0: skipped because ntfs-3g is not supported by the appliance" + exit 77 +fi + +if [ ! -s ../../test-data/phony-guests/windows.img ]; then + echo "$0: skipped because windows.img is zero-sized" + exit 77 +fi + +# download Master File Table ($MFT). +guestfish --ro -a ../../test-data/phony-guests/windows.img <