From Fedora Project Wiki

(Another script oops.)
(Add category for squashfs-tools)
(13 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{QA/Test_Case
{{QA/Test_Case
|description=Test that compression is reversible for squashfs-tools.
|description=Test that compression is reversible for {{package|squashfs-tools}}. The compression types tested will be those expected to work with the version of squashfs-tools you have installed and the kernel you are running.  These tests are used to make sure squashfs-tools will work as expected for live images.
 
A test script is available to provide a consistent test result.  The test script needs to be run as the ''root'' user so that squashfs images can be mounted and to prevent warnings about setting selinux extended attributes when running unsquashfs.  The test script will also create a directory in the current working directory named {{filename|test-squashfs}}.  When run, the script will check if {{filename|test-squashfs/data}} is already created and if so won't recreate the test data.
|setup=
# Install the required {{package|squashfs-tools}} and {{package|rpmdevtools}} packages: <pre>yum install squashfs-tools rpmdevtools</pre>
|actions=
|actions=
# You need to have squashfs-tools and rpmdevtools installed.
# Download the test script [https://fedoraproject.org/w/uploads/2/25/Squashfs-compression-test.sh Squashfs-compression-test.sh]
# Run the provided script as root and note any failure messages. The script needs to be run as root so that squashfs images can be mounted and to prevent warnings about setting selinux extended attributes when running unsquashfs.
# As root, execute the test script using the command: {{command|bash Squashfs-compression-test.sh}}.  Note any failure messages.
 
|results=
The compression types tested will be those expected to work with the version of squashfs-tools you have installed and the kernel you are running.
<ol>
 
<li>The test script should exit cleanly and not abort early because it was unable to create some file or free disc space running out. There should be no messages with the string <code>failed</code> in them. Typically you might run this using script and then grep <code>typescript</code> for <code>failed</code>.  Successful test output is included below:
The script will create a directory in the current working directory named "test-squashfs". When run, the script will check if "test-squashf/data" is already created and if so won't recreate the test data.
 
<pre><nowiki>
<pre><nowiki>
#!/bin/bash
Building data directory.
 
Building squashfs image using gzip compression.
# We need rpmdev-vercmp
Parallel mksquashfs: Using 2 processors
rpm -q rpmdevtools > /dev/null 2>&1 || (echo 'rpmdev-vercmp from rpmdevtools is needed to run this script, aborting.'; exit 1)
Creating 4.0 filesystem on ./test-squashfs/sq.img, block size 131072.
[=============================================================|] 2316/2316 100%
Exportable Squashfs 4.0 filesystem, gzip compressed, data block size 131072
compressed data, compressed metadata, compressed fragments, compressed xattrs
duplicates are removed
Filesystem size 107770.89 Kbytes (105.25 Mbytes)
38.79% of uncompressed filesystem size (277839.40 Kbytes)
Inode table size 2185 bytes (2.13 Kbytes)
11.16% of uncompressed inode table size (19586 bytes)
Directory table size 1442 bytes (1.41 Kbytes)
21.57% of uncompressed directory table size (6684 bytes)
Xattr table size 54 bytes (0.05 Kbytes)
100.00% of uncompressed xattr table size (54 bytes)
Number of duplicate files found 42
Number of inodes 189
Number of files 188
Number of fragments 6
Number of symbolic links  0
Number of device nodes 0
Number of fifo nodes 0
Number of socket nodes 0
Number of directories 1
Number of ids (unique uids + gids) 1
Number of uids 1
root (0)
Number of gids 1
root (0)
Testing unmounted extract using gzip compression.
Parallel unsquashfs: Using 2 processors
188 inodes (2316 blocks) to write


# Define block sizes
[=============================================================-] 2316/2316 100%
blocks=(4K 1M)
created 188 files
created 1 directories
created 0 symlinks
created 0 devices
created 0 fifos
Testing mounted image using gzip compression.
Building squashfs image using lzo compression.
Parallel mksquashfs: Using 2 processors
Creating 4.0 filesystem on ./test-squashfs/sq.img, block size 131072.
[=============================================================/] 2316/2316 100%
Exportable Squashfs 4.0 filesystem, lzo compressed, data block size 131072
compressed data, compressed metadata, compressed fragments, compressed xattrs
duplicates are removed
Filesystem size 107764.62 Kbytes (105.24 Mbytes)
38.79% of uncompressed filesystem size (277839.40 Kbytes)
Inode table size 2553 bytes (2.49 Kbytes)
13.03% of uncompressed inode table size (19586 bytes)
Directory table size 1732 bytes (1.69 Kbytes)
25.91% of uncompressed directory table size (6684 bytes)
Xattr table size 54 bytes (0.05 Kbytes)
100.00% of uncompressed xattr table size (54 bytes)
Number of duplicate files found 42
Number of inodes 189
Number of files 188
Number of fragments 6
Number of symbolic links  0
Number of device nodes 0
Number of fifo nodes 0
Number of socket nodes 0
Number of directories 1
Number of ids (unique uids + gids) 1
Number of uids 1
root (0)
Number of gids 1
root (0)
Testing unmounted extract using lzo compression.
Parallel unsquashfs: Using 2 processors
188 inodes (2316 blocks) to write


# Define fill files
[=============================================================/] 2316/2316 100%
fill=(/dev/zero /dev/urandom)
created 188 files
created 1 directories
created 0 symlinks
created 0 devices
created 0 fifos
Testing mounted image using lzo compression.
Building squashfs image using lzma compression.
Parallel mksquashfs: Using 2 processors
Creating 4.0 filesystem on ./test-squashfs/sq.img, block size 131072.
[=============================================================|] 2316/2316 100%
Exportable Squashfs 4.0 filesystem, lzma compressed, data block size 131072
compressed data, compressed metadata, compressed fragments, compressed xattrs
duplicates are removed
Filesystem size 107750.75 Kbytes (105.23 Mbytes)
38.78% of uncompressed filesystem size (277839.40 Kbytes)
Inode table size 1747 bytes (1.71 Kbytes)
8.92% of uncompressed inode table size (19586 bytes)
Directory table size 1209 bytes (1.18 Kbytes)
18.09% of uncompressed directory table size (6684 bytes)
Xattr table size 54 bytes (0.05 Kbytes)
100.00% of uncompressed xattr table size (54 bytes)
Number of duplicate files found 42
Number of inodes 189
Number of files 188
Number of fragments 6
Number of symbolic links  0
Number of device nodes 0
Number of fifo nodes 0
Number of socket nodes 0
Number of directories 1
Number of ids (unique uids + gids) 1
Number of uids 1
root (0)
Number of gids 1
root (0)
Testing unmounted extract using lzma compression.
Parallel unsquashfs: Using 2 processors
188 inodes (2316 blocks) to write


# Define number of iterations
[=============================================================-] 2316/2316 100%
iter=5
created 188 files
 
created 1 directories
# Define fragment sizes
created 0 symlinks
frags=(0 1 2047 4095)
created 0 devices
 
created 0 fifos
# Define test directory
Building squashfs image using xz compression.
testdir=./test-squashfs
Parallel mksquashfs: Using 2 processors
 
Creating 4.0 filesystem on ./test-squashfs/sq.img, block size 131072.
# Define mount point
[=============================================================/] 2316/2316 100%
mp=${testdir}/mnt
Exportable Squashfs 4.0 filesystem, xz compressed, data block size 131072
 
compressed data, compressed metadata, compressed fragments, compressed xattrs
# Define data directory
duplicates are removed
datadir=${testdir}/data
Filesystem size 107751.25 Kbytes (105.23 Mbytes)
 
38.78% of uncompressed filesystem size (277839.40 Kbytes)
# Check for squashfs-tools version and set compression types to test
Inode table size 1874 bytes (1.83 Kbytes)
sqfsver=`rpm -q --qf '%{EVR}' squashfs-tools`
9.57% of uncompressed inode table size (19586 bytes)
if rpmdev-vercmp 4.1 ${sqfsver} > /dev/null; [ $? == '11' ]; then
Directory table size 1262 bytes (1.23 Kbytes)
  ucomp=('gzip')
18.88% of uncompressed directory table size (6684 bytes)
elif rpmdev-vercmp 4.2 ${sqfsver} > /dev/null; [ $? == '11' ]; then
Xattr table size 54 bytes (0.05 Kbytes)
  ucomp=(gzip lzo lzma)
100.00% of uncompressed xattr table size (54 bytes)
else
Number of duplicate files found 42
  ucomp=(gzip lzo lzma xz)
Number of inodes 189
fi
Number of files 188
 
Number of fragments 6
# Check for kernel verion and set mount test compression types
Number of symbolic links  0
kernel=`uname -r`
Number of device nodes 0
if rpmdev-vercmp 2.6.36 ${kernel} > /dev/null; [ $? == '11' ]; then
Number of fifo nodes 0
  mcomp=('gzip')
Number of socket nodes 0
elif rpmdev-vercmp 2.6.38 ${kernel} > /dev/null; [ $? == '11' ]; then
Number of directories 1
  mcomp=(gzip lzo)
Number of ids (unique uids + gids) 1
else
Number of uids 1
  mcomp=(gzip lzo xz)
root (0)
fi
Number of gids 1
 
root (0)
# Check for uid 0 and print a warning if not
Testing unmounted extract using xz compression.
[ ${UID} -ne 0 ] && echo 'Mount tests will not be performed when not running as root'
Parallel unsquashfs: Using 2 processors
 
188 inodes (2316 blocks) to write
# Check if test directory exists and make if not
[ -d ${testdir} ] || mkdir ${testdir}
[ -d ${testdir} ] || (echo "Unable to make '${testdir}', aborting."; exit 1)
 
# Check if mount point directory exists and make if not
[ -d ${mp} ] || mkdir ${mp}
[ -d ${mp} ] || (echo "Unable to make '${mp}', aborting."; exit 1)
 
# Check if data directory exists and make if not
if [ -d ${datadir} ]; then
  echo "Using existing data directory."
else
  echo "Building data directory."
  mkdir ${datadir}
  [ -d ${datadir} ] || (echo "Unable to make '${datadir}', aborting."; exit 1)
  for size in ${frags[*]}; do
    for file in ${fill[*]}; do
      dd if=${file} of=${datadir}/frag-`basename ${file}`-${size} bs=1 count=${size} > /dev/null 2>&1
    done
  done
  for size in ${blocks[*]}; do
    for ((count=1;${count}<=${iter};count++)); do
      for file in ${fill[*]}; do
        dd if=${file} of=${datadir}/file-`basename ${file}`-${size}-${count} bs=${size} count=${count} > /dev/null 2>&1
      done
    done
  done
  for size1 in ${frags[*]}; do
    for file1 in ${fill[*]}; do
      for size2 in ${blocks[*]}; do
        for ((count=1;${count}<=${iter};count++)); do
          for file2 in ${fill[*]}; do
            cat ${datadir}/file-`basename ${file2}`-${size2}-${count} ${datadir}/frag-`basename ${file1}`-${size1} > ${datadir}/combined-`basename ${file2}`-${size2}-${count}-`basename ${file1}`-${size1}
          done
        done
      done
    done
  done
fi
 
# Run unmounted tests
for comp in ${ucomp[*]}; do
  echo "Building squashfs image using ${comp} compression."
  if [ "${comp}" == gzip ]; then
    mksquashfs ${datadir} ${testdir}/sq.img || (echo "mksquashfs failed for ${comp} compression."; continue)
  else
    mksquashfs ${datadir} ${testdir}/sq.img -comp ${comp} || (echo "mksquashfs failed for ${comp} compression."; continue)
  fi
  echo "Testing unmounted extract using ${comp} compression."
  unsquashfs -d ${testdir}/sq ${testdir}/sq.img  || echo "unsquashfs failed for ${comp} compression."
  diff -r -q ${testdir}/sq ${datadir} || echo "Extract test failed for ${comp} compression."
  rm -rf ${testdir}/sq
  if [ ${UID} == 0 ]; then
    for kern in ${mcomp[*]}; do
      if [ ${kern} == ${comp} ]; then
        echo "Testing mounted image using ${comp} compression."
        mount -o loop ${testdir}/sq.img ${mp} || echo "Mount failed.";
        diff -r -q ${mp} ${datadir} || echo "Mounted test failed for ${comp} compression."
        umount ${mp}
        break
      fi
    done
  fi
  rm -f ${testdir}/sq ${testdir}/sq.img
done


[=============================================================/] 2316/2316 100%
created 188 files
created 1 directories
created 0 symlinks
created 0 devices
created 0 fifos
</nowiki></pre>
</nowiki></pre>
 
</li></ol>
|results=
# The test should not abort early because it was unable to create some file or free disc space running out. There should be no messages with the string "failed" in them.
}}
}}
[[Category:Critical_path_test_cases]]
[[Category:Critical_path_test_cases]]
[[Category:Package_squashfs-tools_test_cases]]

Revision as of 21:02, 5 January 2011

Description

Test that compression is reversible for Package-x-generic-16.pngsquashfs-tools. The compression types tested will be those expected to work with the version of squashfs-tools you have installed and the kernel you are running. These tests are used to make sure squashfs-tools will work as expected for live images.

A test script is available to provide a consistent test result. The test script needs to be run as the root user so that squashfs images can be mounted and to prevent warnings about setting selinux extended attributes when running unsquashfs. The test script will also create a directory in the current working directory named test-squashfs. When run, the script will check if test-squashfs/data is already created and if so won't recreate the test data.

Setup

  1. Install the required Package-x-generic-16.pngsquashfs-tools and Package-x-generic-16.pngrpmdevtools packages:
    yum install squashfs-tools rpmdevtools

How to test

  1. Download the test script Squashfs-compression-test.sh
  2. As root, execute the test script using the command: bash Squashfs-compression-test.sh. Note any failure messages.

Expected Results

  1. The test script should exit cleanly and not abort early because it was unable to create some file or free disc space running out. There should be no messages with the string failed in them. Typically you might run this using script and then grep typescript for failed. Successful test output is included below:
    Building data directory.
    Building squashfs image using gzip compression.
    Parallel mksquashfs: Using 2 processors
    Creating 4.0 filesystem on ./test-squashfs/sq.img, block size 131072.
    [=============================================================|] 2316/2316 100%
    Exportable Squashfs 4.0 filesystem, gzip compressed, data block size 131072
    	compressed data, compressed metadata, compressed fragments, compressed xattrs
    	duplicates are removed
    Filesystem size 107770.89 Kbytes (105.25 Mbytes)
    	38.79% of uncompressed filesystem size (277839.40 Kbytes)
    Inode table size 2185 bytes (2.13 Kbytes)
    	11.16% of uncompressed inode table size (19586 bytes)
    Directory table size 1442 bytes (1.41 Kbytes)
    	21.57% of uncompressed directory table size (6684 bytes)
    Xattr table size 54 bytes (0.05 Kbytes)
    	100.00% of uncompressed xattr table size (54 bytes)
    Number of duplicate files found 42
    Number of inodes 189
    Number of files 188
    Number of fragments 6
    Number of symbolic links  0
    Number of device nodes 0
    Number of fifo nodes 0
    Number of socket nodes 0
    Number of directories 1
    Number of ids (unique uids + gids) 1
    Number of uids 1
    	root (0)
    Number of gids 1
    	root (0)
    Testing unmounted extract using gzip compression.
    Parallel unsquashfs: Using 2 processors
    188 inodes (2316 blocks) to write
    
    [=============================================================-] 2316/2316 100%
    created 188 files
    created 1 directories
    created 0 symlinks
    created 0 devices
    created 0 fifos
    Testing mounted image using gzip compression.
    Building squashfs image using lzo compression.
    Parallel mksquashfs: Using 2 processors
    Creating 4.0 filesystem on ./test-squashfs/sq.img, block size 131072.
    [=============================================================/] 2316/2316 100%
    Exportable Squashfs 4.0 filesystem, lzo compressed, data block size 131072
    	compressed data, compressed metadata, compressed fragments, compressed xattrs
    	duplicates are removed
    Filesystem size 107764.62 Kbytes (105.24 Mbytes)
    	38.79% of uncompressed filesystem size (277839.40 Kbytes)
    Inode table size 2553 bytes (2.49 Kbytes)
    	13.03% of uncompressed inode table size (19586 bytes)
    Directory table size 1732 bytes (1.69 Kbytes)
    	25.91% of uncompressed directory table size (6684 bytes)
    Xattr table size 54 bytes (0.05 Kbytes)
    	100.00% of uncompressed xattr table size (54 bytes)
    Number of duplicate files found 42
    Number of inodes 189
    Number of files 188
    Number of fragments 6
    Number of symbolic links  0
    Number of device nodes 0
    Number of fifo nodes 0
    Number of socket nodes 0
    Number of directories 1
    Number of ids (unique uids + gids) 1
    Number of uids 1
    	root (0)
    Number of gids 1
    	root (0)
    Testing unmounted extract using lzo compression.
    Parallel unsquashfs: Using 2 processors
    188 inodes (2316 blocks) to write
    
    [=============================================================/] 2316/2316 100%
    created 188 files
    created 1 directories
    created 0 symlinks
    created 0 devices
    created 0 fifos
    Testing mounted image using lzo compression.
    Building squashfs image using lzma compression.
    Parallel mksquashfs: Using 2 processors
    Creating 4.0 filesystem on ./test-squashfs/sq.img, block size 131072.
    [=============================================================|] 2316/2316 100%
    Exportable Squashfs 4.0 filesystem, lzma compressed, data block size 131072
    	compressed data, compressed metadata, compressed fragments, compressed xattrs
    	duplicates are removed
    Filesystem size 107750.75 Kbytes (105.23 Mbytes)
    	38.78% of uncompressed filesystem size (277839.40 Kbytes)
    Inode table size 1747 bytes (1.71 Kbytes)
    	8.92% of uncompressed inode table size (19586 bytes)
    Directory table size 1209 bytes (1.18 Kbytes)
    	18.09% of uncompressed directory table size (6684 bytes)
    Xattr table size 54 bytes (0.05 Kbytes)
    	100.00% of uncompressed xattr table size (54 bytes)
    Number of duplicate files found 42
    Number of inodes 189
    Number of files 188
    Number of fragments 6
    Number of symbolic links  0
    Number of device nodes 0
    Number of fifo nodes 0
    Number of socket nodes 0
    Number of directories 1
    Number of ids (unique uids + gids) 1
    Number of uids 1
    	root (0)
    Number of gids 1
    	root (0)
    Testing unmounted extract using lzma compression.
    Parallel unsquashfs: Using 2 processors
    188 inodes (2316 blocks) to write
    
    [=============================================================-] 2316/2316 100%
    created 188 files
    created 1 directories
    created 0 symlinks
    created 0 devices
    created 0 fifos
    Building squashfs image using xz compression.
    Parallel mksquashfs: Using 2 processors
    Creating 4.0 filesystem on ./test-squashfs/sq.img, block size 131072.
    [=============================================================/] 2316/2316 100%
    Exportable Squashfs 4.0 filesystem, xz compressed, data block size 131072
    	compressed data, compressed metadata, compressed fragments, compressed xattrs
    	duplicates are removed
    Filesystem size 107751.25 Kbytes (105.23 Mbytes)
    	38.78% of uncompressed filesystem size (277839.40 Kbytes)
    Inode table size 1874 bytes (1.83 Kbytes)
    	9.57% of uncompressed inode table size (19586 bytes)
    Directory table size 1262 bytes (1.23 Kbytes)
    	18.88% of uncompressed directory table size (6684 bytes)
    Xattr table size 54 bytes (0.05 Kbytes)
    	100.00% of uncompressed xattr table size (54 bytes)
    Number of duplicate files found 42
    Number of inodes 189
    Number of files 188
    Number of fragments 6
    Number of symbolic links  0
    Number of device nodes 0
    Number of fifo nodes 0
    Number of socket nodes 0
    Number of directories 1
    Number of ids (unique uids + gids) 1
    Number of uids 1
    	root (0)
    Number of gids 1
    	root (0)
    Testing unmounted extract using xz compression.
    Parallel unsquashfs: Using 2 processors
    188 inodes (2316 blocks) to write
    
    [=============================================================/] 2316/2316 100%
    created 188 files
    created 1 directories
    created 0 symlinks
    created 0 devices
    created 0 fifos