summaryrefslogtreecommitdiffstats
path: root/tests/m_roottar
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--tests/m_roottar/expect208
-rw-r--r--tests/m_roottar/mktar.pl62
-rw-r--r--tests/m_roottar/output.sed5
-rw-r--r--tests/m_roottar/script57
4 files changed, 332 insertions, 0 deletions
diff --git a/tests/m_roottar/expect b/tests/m_roottar/expect
new file mode 100644
index 0000000..ea96478
--- /dev/null
+++ b/tests/m_roottar/expect
@@ -0,0 +1,208 @@
+Filesystem volume name: <none>
+Last mounted on: <not available>
+Filesystem magic number: 0xEF53
+Filesystem revision #: 1 (dynamic)
+Filesystem features: has_journal ext_attr resize_inode dir_index filetype extent 64bit flex_bg sparse_super huge_file dir_nlink extra_isize metadata_csum
+Default mount options: (none)
+Filesystem state: clean
+Errors behavior: Continue
+Filesystem OS type: Linux
+Inode count: 1024
+Block count: 16384
+Reserved block count: 819
+Overhead clusters: 1543
+Free blocks: 14824
+Free inodes: 998
+First block: 1
+Block size: 1024
+Fragment size: 1024
+Group descriptor size: 64
+Reserved GDT blocks: 127
+Blocks per group: 8192
+Fragments per group: 8192
+Inodes per group: 512
+Inode blocks per group: 128
+Flex block group size: 16
+Mount count: 0
+Check interval: 15552000 (6 months)
+Reserved blocks uid: 0
+Reserved blocks gid: 0
+First inode: 11
+Inode size: 256
+Required extra isize: 32
+Desired extra isize: 32
+Journal inode: 8
+Default directory hash: half_md4
+Journal backup: inode blocks
+Checksum type: crc32c
+Journal features: (none)
+Total journal size: 1024k
+Total journal blocks: 1024
+Max transaction length: 1024
+Fast commit length: 0
+Journal sequence: 0x00000001
+Journal start: 0
+
+
+Group 0: (Blocks 1-8192)
+ Primary superblock at 1, Group descriptors at 2-2
+ Reserved GDT blocks at 3-129
+ Block bitmap at 130 (+129)
+ Inode bitmap at 132 (+131)
+ Inode table at 134-261 (+133)
+ 7786 free blocks, 486 free inodes, 5 directories, 486 unused inodes
+ Free blocks: 407-8192
+ Free inodes: 27-512
+Group 1: (Blocks 8193-16383) [INODE_UNINIT]
+ Backup superblock at 8193, Group descriptors at 8194-8194
+ Reserved GDT blocks at 8195-8321
+ Block bitmap at 131 (bg #0 + 130)
+ Inode bitmap at 133 (bg #0 + 132)
+ Inode table at 262-389 (bg #0 + 261)
+ 7038 free blocks, 512 free inodes, 0 directories, 512 unused inodes
+ Free blocks: 9346-16383
+ Free inodes: 513-1024
+debugfs: stat /dev/
+Inode: III Type: directory
+Generation: 0 Version: 0x00000000:00000000
+Size: 1024
+File ACL: 0
+Links: 4 Blockcount: 2
+Fragment: Address: 0 Number: 0 Size: 0
+Size of extra inode fields: 32
+EXTENTS:
+(0):404
+debugfs: stat /dev/console
+Inode: III Type: character special
+Generation: 0 Version: 0x00000000:00000000
+Size: 0
+File ACL: 0
+Links: 1 Blockcount: 0
+Fragment: Address: 0 Number: 0 Size: 0
+Size of extra inode fields: 32
+Device major/minor number: 05:01 (hex 05:01)
+debugfs: stat /dev/fd
+Inode: III Type: symlink
+Generation: 0 Version: 0x00000000:00000000
+Size: 13
+File ACL: 0
+Links: 1 Blockcount: 0
+Fragment: Address: 0 Number: 0 Size: 0
+Size of extra inode fields: 32
+Fast link dest: "/proc/self/fd"
+debugfs: stat /dev/full
+Inode: III Type: character special
+Generation: 0 Version: 0x00000000:00000000
+Size: 0
+File ACL: 0
+Links: 1 Blockcount: 0
+Fragment: Address: 0 Number: 0 Size: 0
+Size of extra inode fields: 32
+Device major/minor number: 01:07 (hex 01:07)
+debugfs: stat /dev/null
+Inode: III Type: character special
+Generation: 0 Version: 0x00000000:00000000
+Size: 0
+File ACL: 0
+Links: 1 Blockcount: 0
+Fragment: Address: 0 Number: 0 Size: 0
+Size of extra inode fields: 32
+Device major/minor number: 01:03 (hex 01:03)
+debugfs: stat /dev/ptmx
+Inode: III Type: character special
+Generation: 0 Version: 0x00000000:00000000
+Size: 0
+File ACL: 0
+Links: 1 Blockcount: 0
+Fragment: Address: 0 Number: 0 Size: 0
+Size of extra inode fields: 32
+Device major/minor number: 05:02 (hex 05:02)
+debugfs: stat /dev/pts/
+Inode: III Type: directory
+Generation: 0 Version: 0x00000000:00000000
+Size: 1024
+File ACL: 0
+Links: 2 Blockcount: 2
+Fragment: Address: 0 Number: 0 Size: 0
+Size of extra inode fields: 32
+EXTENTS:
+(0):405
+debugfs: stat /dev/random
+Inode: III Type: character special
+Generation: 0 Version: 0x00000000:00000000
+Size: 0
+File ACL: 0
+Links: 1 Blockcount: 0
+Fragment: Address: 0 Number: 0 Size: 0
+Size of extra inode fields: 32
+Device major/minor number: 01:08 (hex 01:08)
+debugfs: stat /dev/shm/
+Inode: III Type: directory
+Generation: 0 Version: 0x00000000:00000000
+Size: 1024
+File ACL: 0
+Links: 2 Blockcount: 2
+Fragment: Address: 0 Number: 0 Size: 0
+Size of extra inode fields: 32
+EXTENTS:
+(0):406
+debugfs: stat /dev/stderr
+Inode: III Type: symlink
+Generation: 0 Version: 0x00000000:00000000
+Size: 15
+File ACL: 0
+Links: 1 Blockcount: 0
+Fragment: Address: 0 Number: 0 Size: 0
+Size of extra inode fields: 32
+Fast link dest: "/proc/self/fd/2"
+debugfs: stat /dev/stdin
+Inode: III Type: symlink
+Generation: 0 Version: 0x00000000:00000000
+Size: 15
+File ACL: 0
+Links: 1 Blockcount: 0
+Fragment: Address: 0 Number: 0 Size: 0
+Size of extra inode fields: 32
+Fast link dest: "/proc/self/fd/0"
+debugfs: stat /dev/stdout
+Inode: III Type: symlink
+Generation: 0 Version: 0x00000000:00000000
+Size: 15
+File ACL: 0
+Links: 1 Blockcount: 0
+Fragment: Address: 0 Number: 0 Size: 0
+Size of extra inode fields: 32
+Fast link dest: "/proc/self/fd/1"
+debugfs: stat /dev/tty
+Inode: III Type: character special
+Generation: 0 Version: 0x00000000:00000000
+Size: 0
+File ACL: 0
+Links: 1 Blockcount: 0
+Fragment: Address: 0 Number: 0 Size: 0
+Size of extra inode fields: 32
+Device major/minor number: 05:00 (hex 05:00)
+debugfs: stat /dev/urandom
+Inode: III Type: character special
+Generation: 0 Version: 0x00000000:00000000
+Size: 0
+File ACL: 0
+Links: 1 Blockcount: 0
+Fragment: Address: 0 Number: 0 Size: 0
+Size of extra inode fields: 32
+Device major/minor number: 01:09 (hex 01:09)
+debugfs: stat /dev/zero
+Inode: III Type: character special
+Generation: 0 Version: 0x00000000:00000000
+Size: 0
+File ACL: 0
+Links: 1 Blockcount: 0
+Fragment: Address: 0 Number: 0 Size: 0
+Size of extra inode fields: 32
+Device major/minor number: 01:05 (hex 01:05)
+Pass 1: Checking inodes, blocks, and sizes
+Pass 2: Checking directory structure
+Pass 3: Checking directory connectivity
+Pass 4: Checking reference counts
+Pass 5: Checking group summary information
+test.img: 26/1024 files (0.0% non-contiguous), 1560/16384 blocks
diff --git a/tests/m_roottar/mktar.pl b/tests/m_roottar/mktar.pl
new file mode 100644
index 0000000..0e8843c
--- /dev/null
+++ b/tests/m_roottar/mktar.pl
@@ -0,0 +1,62 @@
+#!/usr/bin/env perl
+
+use strict;
+use warnings;
+
+# type codes:
+# 0 -> normal file
+# 1 -> hardlink
+# 2 -> symlink
+# 3 -> character special
+# 4 -> block special
+# 5 -> directory
+my @devfiles = (
+ # filename mode type link target major minor
+ ["", oct(755), 5, '', undef, undef],
+ ["console", oct(666), 3, '', 5, 1],
+ ["fd", oct(777), 2, '/proc/self/fd', undef, undef],
+ ["full", oct(666), 3, '', 1, 7],
+ ["null", oct(666), 3, '', 1, 3],
+ ["ptmx", oct(666), 3, '', 5, 2],
+ ["pts/", oct(755), 5, '', undef, undef],
+ ["random", oct(666), 3, '', 1, 8],
+ ["shm/", oct(755), 5, '', undef, undef],
+ ["stderr", oct(777), 2, '/proc/self/fd/2', undef, undef],
+ ["stdin", oct(777), 2, '/proc/self/fd/0', undef, undef],
+ ["stdout", oct(777), 2, '/proc/self/fd/1', undef, undef],
+ ["tty", oct(666), 3, '', 5, 0],
+ ["urandom", oct(666), 3, '', 1, 9],
+ ["zero", oct(666), 3, '', 1, 5],
+);
+
+my $mtime = time;
+if (exists $ENV{SOURCE_DATE_EPOCH}) {
+ $mtime = $ENV{SOURCE_DATE_EPOCH} + 0;
+}
+
+foreach my $file (@devfiles) {
+ my ($fname, $mode, $type, $linkname, $devmajor, $devminor) = @{$file};
+ my $entry = pack(
+ 'a100 a8 a8 a8 a12 a12 A8 a1 a100 a8 a32 a32 a8 a8 a155 x12',
+ "./dev/$fname",
+ sprintf('%07o', $mode),
+ sprintf('%07o', 0), # uid
+ sprintf('%07o', 0), # gid
+ sprintf('%011o', 0), # size
+ sprintf('%011o', $mtime),
+ '', # checksum
+ $type,
+ $linkname,
+ "ustar ",
+ '', # username
+ '', # groupname
+ defined($devmajor) ? sprintf('%07o', $devmajor) : '',
+ defined($devminor) ? sprintf('%07o', $devminor) : '',
+ '', # prefix
+ );
+
+ # compute and insert checksum
+ substr($entry, 148, 7)
+ = sprintf("%06o\0", unpack("%16C*", $entry));
+ print $entry;
+}
diff --git a/tests/m_roottar/output.sed b/tests/m_roottar/output.sed
new file mode 100644
index 0000000..2e76967
--- /dev/null
+++ b/tests/m_roottar/output.sed
@@ -0,0 +1,5 @@
+s/^[[:space:]]*\([0-9]*\)\/[[:space:]]*\([0-9]*\)[[:space:]]*\([0-9]*\)\/[[:space:]]*\([0-9]*\)[[:space:]]*\([0-9]*\)[[:space:]]*-[[:space:]]*\([0-9]*\)[[:space:]]*[0-9]*[[:space:]]*-[[:space:]]*[0-9]*[[:space:]]*\([0-9]*\)/X \1\/\2 \3\/\4 \5-\6 AAA-BBB \7/g
+s/^[[:space:]]*\([0-9]*\)\/[[:space:]]*\([0-9]*\)[[:space:]]*\([0-9]*\)\/[[:space:]]*\([0-9]*\)[[:space:]]*\([0-9]*\)[[:space:]]*-[[:space:]]*\([0-9]*\)[[:space:]]*[0-9]*[[:space:]]*\([0-9]*\)/Y \1\/\2 \3\/\4 \5-\6 AAA \7/g
+s/Mode:.*$//g
+s/User:.*Size:/Size:/g
+s/^Inode: [0-9]*/Inode: III/g
diff --git a/tests/m_roottar/script b/tests/m_roottar/script
new file mode 100644
index 0000000..701e8c8
--- /dev/null
+++ b/tests/m_roottar/script
@@ -0,0 +1,57 @@
+# vim: filetype=sh
+
+test_description="create fs image from tarball"
+if ! test -x "$DEBUGFS_EXE"; then
+ echo "$test_name: $test_description: skipped (no debugfs)"
+ return 0
+fi
+if [ "$(grep -c 'define HAVE_ARCHIVE_H' ../lib/config.h)" -eq 0 ]; then
+ echo "$test_name: skipped (no libarchive)"
+ exit 0
+fi
+
+OUT="$test_name.log"
+EXP="$test_dir/expect"
+
+perl "$test_dir/mktar.pl" \
+ | $MKE2FS -q -F -o Linux -T ext4 -O metadata_csum,64bit -E lazy_itable_init=1 -b 1024 -d - "$TMPFILE" 16384 > "$OUT" 2>&1
+
+$DUMPE2FS "$TMPFILE" >> "$OUT" 2>&1
+cat > "$TMPFILE.cmd" << 'ENDL'
+stat /dev/
+stat /dev/console
+stat /dev/fd
+stat /dev/full
+stat /dev/null
+stat /dev/ptmx
+stat /dev/pts/
+stat /dev/random
+stat /dev/shm/
+stat /dev/stderr
+stat /dev/stdin
+stat /dev/stdout
+stat /dev/tty
+stat /dev/urandom
+stat /dev/zero
+ENDL
+$DEBUGFS -f "$TMPFILE.cmd" "$TMPFILE" 2>&1 | grep -E -v "(time|checksum):" >> "$OUT"
+
+$FSCK -f -n "$TMPFILE" >> "$OUT" 2>&1
+
+sed -f "$cmd_dir/filter.sed" -f "$test_dir/output.sed" -e "s;$TMPFILE;test.img;" < "$OUT" > "$OUT.tmp"
+mv "$OUT.tmp" "$OUT"
+
+# Do the verification
+cmp -s "$OUT" "$EXP"
+status=$?
+
+if [ "$status" = 0 ] ; then
+ echo "$test_name: $test_description: ok"
+ touch "$test_name.ok"
+else
+ echo "$test_name: $test_description: failed"
+ diff $DIFF_OPTS "$EXP" "$OUT" > "$test_name.failed"
+fi
+
+rm -rf "$TMPFILE.cmd"
+unset OUT EXP