Add cases to test raw image
authorjianzhong.fang <jz.fang@samsung.com>
Sat, 14 May 2016 06:13:59 +0000 (14:13 +0800)
committerjianzhong.fang <jz.fang@samsung.com>
Sat, 14 May 2016 08:10:24 +0000 (16:10 +0800)
Change-Id: I522a548b8402433ce0feb3ed312aa7d2db4d21ba

24 files changed:
cases/create/func_cases/mic_cr_auto_raw.case [new file with mode: 0755]
cases/create/func_cases/mic_cr_auto_raw_gpt.case [new file with mode: 0755]
cases/create/func_cases/mic_cr_raw_generate-bmap_cp-knl_compress_runtime_local-pkgs_conf_armv7l.case [new file with mode: 0755]
cases/create/func_cases/mic_cr_raw_gpt-part-type.case [new file with mode: 0755]
cases/create/func_cases/mic_cr_raw_release_logfile_local-pkg-pth_record-pkg_gen-bmap_ia32.case [new file with mode: 0755]
cases/create/mixed_cases/mic_cr_createrepo_issue.case [new file with mode: 0644]
cases/create/mixed_cases/mic_cr_raw_active_partition.case [new file with mode: 0755]
cases/create/mixed_cases/mic_cr_raw_broken_bootstrap.case [new file with mode: 0755]
cases/create/mixed_cases/mic_cr_raw_installerfw_extlinux.case [new file with mode: 0755]
cases/create/mixed_cases/mic_cr_raw_invliad_mic-bootstrap.case [new file with mode: 0755]
cases/create/mixed_cases/mic_cr_raw_ivi_partition_size_compute_ia32.case [new file with mode: 0755]
cases/create/mixed_cases/mic_cr_raw_locale.case [new file with mode: 0755]
cases/create/mixed_cases/mic_cr_raw_multi_partition_gpt.case [new file with mode: 0755]
cases/create/mixed_cases/mic_cr_raw_multi_partition_mbr.case [new file with mode: 0755]
cases/create/mixed_cases/mic_cr_raw_no_mountpoint.case [new file with mode: 0755]
cases/create/mixed_cases/mic_cr_raw_no_partition.case [new file with mode: 0755]
cases/create/mixed_cases/mic_cr_raw_unicode.case [new file with mode: 0755]
cases/create/mixed_cases/mic_cr_raw_without_conf_bootstrap_ia32.case [new file with mode: 0755]
cases/create/opt_cases/mic_cr_raw_compress-image-bz2_ia32.case [new file with mode: 0755]
cases/create/opt_cases/mic_cr_raw_compress-image-gz_ia32.case [new file with mode: 0755]
cases/create/opt_cases/mic_cr_raw_compress-image-invalid_ia32.case [new file with mode: 0755]
cases/create/opt_cases/mic_cr_raw_fstab-entry-name.case [new file with mode: 0755]
cases/create/opt_cases/mic_cr_raw_fstab-entry-uuid.case [new file with mode: 0755]
cases/create/opt_cases/mic_cr_raw_generate-bmap_ia32.case [new file with mode: 0755]

diff --git a/cases/create/func_cases/mic_cr_auto_raw.case b/cases/create/func_cases/mic_cr_auto_raw.case
new file mode 100755 (executable)
index 0000000..6eba292
--- /dev/null
@@ -0,0 +1,99 @@
+<testcase>
+  <summary>test 'mic cr auto ks' for raw  type
+if we run command with 'auto', mic will use the first line in ks file,
+which called magic line, and magic line in this ks file is:
+ -*-mic2-options-*- -f raw --copy-kernel --compress-disk-image=bz2 --generate-bmap -*-mic2-options-*-
+  </summary>
+  <fixtures>
+    <copy src="ks_files/ivi.ks" />
+    <content target="parse_manifest.py">
+import sys
+import json
+img_file = sys.argv[1]
+mic_version = sys.argv[2]
+bmap_file = sys.argv[3]
+manifest_file=open('mic-output/manifest.json')
+manifest=json.load(manifest_file)
+assert manifest['format'] == 'raw'
+assert manifest['version'] == mic_version
+assert manifest['raw']['compress'] == 'bz2'
+assert img_file in manifest['raw']['image_files']
+assert 'sdb' in manifest['raw']['disks']
+assert manifest['raw']['sdb']['bmap'] == bmap_file
+assert manifest['raw']['sdb']['image'] == img_file
+    </content>
+  </fixtures>
+  <steps><![CDATA[
+losetup_path=$(sudo which losetup)
+sudo $losetup_path -a
+sudo $losetup_path -a | wc -l | xargs test 0 -eq
+sudo mic -d -v cr auto ivi.ks --logfile=log.file
+grep "Finished" log.file
+sudo $losetup_path -a
+sudo $losetup_path -a | wc -l | xargs test 0 -eq
+ls mic-output/ | grep 'ivi-.*-sdb.bmap'
+ls mic-output/ | grep 'ivi-.*-sdb.raw.bz2'
+ls mic-output/ | grep 'ivi-.*-vmlinuz-*'
+bz2img=$(ls mic-output/ | grep 'ivi-.*-sdb.raw.bz2')
+bmap=$(ls mic-output/ | grep 'ivi-.*-sdb.bmap')
+sudo bunzip2 -d mic-output/$bz2img
+raw_image=$(ls mic-output/ivi-*-sdb.raw)
+sudo mkdir -p mic-output/ivi_dir/boot
+kpartx_path=$(sudo which kpartx)
+loop_device=$(sudo $losetup_path -f)
+sudo $losetup_path $loop_device $raw_image
+for i in {1..5}
+do
+    kpartx_output=$(sudo $kpartx_path -av $loop_device)
+    if [ -n "$kpartx_output" ]; then
+        first_part=$(echo "$kpartx_output" | awk '{print $3}' | sed -n '1p')
+        second_part=$(echo "$kpartx_output" | awk '{print $3}' | sed -n '2p')
+        if [ -n "$first_part" ] && [ -n "$second_part" ];then
+            for j in {1..5}
+            do
+                ls /dev/mapper/
+                if [ -e "/dev/mapper/$first_part" ] && [ -e "/dev/mapper/$second_part" ];then
+                    sudo mount /dev/mapper/$first_part  mic-output/ivi_dir/boot/ -t ext4
+                    sudo mount /dev/mapper/$second_part  mic-output/ivi_dir/ -t ext4
+                    (! sudo chroot mic-output/ivi_dir/ cat /etc/fstab | grep /dev/sdb)
+                    sudo chroot mic-output/ivi_dir/ cat /etc/fstab | grep -i 'uuid'
+                    mic_version=$(mic --version  2>&1 | awk -F ' ' '{print $2}')
+                    python parse_manifest.py $bz2img $mic_version $bmap
+                    exit 0
+                else
+                    sleep 2
+                fi
+            done
+        fi
+    fi
+    sleep 3
+done
+echo "can not get kpartx output: $kpartx_path -av $raw_image"
+exit 1
+]]></steps>
+  <teardown><![CDATA[
+echo "cleaning..."
+sudo test -f log.file && sudo rm -f log.file
+losetup_path=$(sudo which losetup)
+sudo $losetup_path -a
+loop_devices=$(sudo $losetup_path -a | awk -F ":" '{print $1}')
+raw_image=$(ls mic-output/ivi-*-sdb.raw)
+for i in {1..5}
+do
+    for loop_device in $loop_devices
+    do
+        test -d mic-output/ivi_dir && sudo umount -l mic-output/ivi_dir
+        test -d mic-output/ivi_dir/boot && sudo umount -l mic-output/ivi_dir/boot
+        kpartx_path=$(sudo which kpartx)
+        sudo $kpartx_path -d $loop_device
+        sudo $losetup_path -d $loop_device
+    done
+    if sudo $losetup_path -a | grep 'ivi'; then
+        sleep 2
+    else
+        test -d mic-output && sudo rm -rf ./mic-output
+        break
+    fi
+done
+]]></teardown>
+</testcase>
diff --git a/cases/create/func_cases/mic_cr_auto_raw_gpt.case b/cases/create/func_cases/mic_cr_auto_raw_gpt.case
new file mode 100755 (executable)
index 0000000..cf2aec6
--- /dev/null
@@ -0,0 +1,76 @@
+<testcase>
+    <summary>create raw image with  gpt table and --part-type for partition</summary>
+    <fixtures>
+        <copy src="ks_files/ivi_with_installerfw.ks" />
+    </fixtures>
+    <steps><![CDATA[
+losetup_path=$(sudo which losetup)
+sudo $losetup_path -a
+sudo $losetup_path -a | wc -l | xargs test 0 -eq
+sudo mic -d -v cr auto ivi_with_installerfw.ks --logfile=log.file
+grep "Finished" log.file
+sudo $losetup_path -a
+sudo $losetup_path -a | wc -l | xargs test 0 -eq
+ls mic-output/ | grep 'ivi_with_installerfw-.*-sdb.bmap'
+ls mic-output/ | grep 'ivi_with_installerfw-.*-sdb.raw.bz2'
+ls mic-output/ | grep 'ivi_with_installerfw-.*-vmlinuz-*'
+bz2img=$(ls mic-output/ | grep 'ivi_with_installerfw-.*-sdb.raw.bz2')
+sudo bunzip2 -d mic-output/$bz2img
+raw_image=$(ls mic-output/ivi_with_installerfw-*-sdb.raw)
+sudo mkdir -p mic-output/ivi_dir/boot
+kpartx_path=$(sudo which kpartx)
+loop_device=$(sudo $losetup_path -f)
+sudo $losetup_path $loop_device $raw_image
+for i in {1..5}
+do
+    kpartx_output=$(sudo $kpartx_path -av $loop_device)
+    if [ -n "$kpartx_output" ]; then
+        first_part=$(echo "$kpartx_output" | awk '{print $3}' | sed -n '1p')
+        second_part=$(echo "$kpartx_output" | awk '{print $3}' | sed -n '2p')
+        if [ -n "$first_part" ] && [ -n "$second_part" ];then
+            for j in {1..5}
+            do
+                ls /dev/mapper/
+                if [ -e "/dev/mapper/$first_part" ] && [ -e "/dev/mapper/$second_part" ];then
+                    sudo mount /dev/mapper/$first_part  mic-output/ivi_dir/boot/ -t ext3
+                    sudo mount /dev/mapper/$second_part  mic-output/ivi_dir/ -t ext4
+                    sudo chroot mic-output/ivi_dir/ cat /etc/fstab | grep /dev/sdb
+                    (! sudo chroot mic-output/ivi_dir/ cat /etc/fstab | grep -i 'uuid')
+                    exit 0
+                else
+                    sleep 2
+                fi
+            done
+        fi
+    fi
+    sleep 3
+done
+echo "can not get kpartx output: $kpartx_path -av $raw_image"
+exit 1
+]]></steps>
+  <teardown><![CDATA[
+echo "cleaning..."
+test -f log.file && sudo rm log.file
+raw_image=$(ls mic-output/ivi_with_installerfw-*-sdb.raw)
+losetup_path=$(sudo which losetup)
+sudo $losetup_path -a
+loop_devices=$(sudo $losetup_path -a | awk -F ":" '{print $1}')
+for i in {1..5}
+do
+    for loop_device in $loop_devices
+    do
+       test -d mic-output/ivi_dir && sudo umount -l mic-output/ivi_dir
+       test -d mic-output/ivi_dir/boot && sudo umount -l mic-output/ivi_dir/boot
+       kpartx_path=$(sudo which kpartx)
+       sudo $kpartx_path -d $loop_device
+       sudo $losetup_path -d $loop_device
+    done
+    if sudo $losetup_path -a | grep 'ivi_with_installerfw'; then
+       sleep 3
+    else
+       test -d mic-output && sudo rm -rf ./mic-output
+       break
+    fi
+done
+]]></teardown>
+</testcase>
diff --git a/cases/create/func_cases/mic_cr_raw_generate-bmap_cp-knl_compress_runtime_local-pkgs_conf_armv7l.case b/cases/create/func_cases/mic_cr_raw_generate-bmap_cp-knl_compress_runtime_local-pkgs_conf_armv7l.case
new file mode 100755 (executable)
index 0000000..b7a9e71
--- /dev/null
@@ -0,0 +1,48 @@
+<testcase>
+  <summary>create raw image with "--generate-bmap --compress-disk-image=bz2 --copy-kernel --runtime=zypp --local-pkgs-path=rpm -c conf/mic.conf"</summary>
+  <fixtures>
+    <copy src="ks_files/ivi.ks" />
+    <copy src="conf/mic.conf" />
+    <copydir src="rpm" />
+  </fixtures>
+  <steps><![CDATA[
+losetup_path=$(sudo which losetup)
+sudo $losetup_path -a
+sudo $losetup_path -a | wc -l | xargs test 0 -eq
+sudo mic -d -v cr raw ivi.ks \
+  --generate-bmap \
+  --compress-disk-image=bz2 \
+  --copy-kernel \
+  --runtime=bootstrap \
+  --local-pkgs-path=rpm \
+  -c mic.conf \
+  --logfile=log.file
+
+grep "Finished" log.file
+
+sudo $losetup_path -a
+sudo $losetup_path -a | wc -l | xargs test 0 -eq
+grep 'Marking .*.rpm to be installed' log.file
+
+ls -l ./my_mic-output | grep 'ivi.*-vmlinuz-*'
+
+test -f ./my_mic-output/ivi*.raw.bz2
+
+ls -al ./my_mic-output | grep 'ivi-.*-sdb.bmap'
+
+cd my_mic-output
+
+sudo bunzip2 ivi-*-sdb.raw.bz2
+
+test -f ivi*.raw
+]]></steps>
+  <teardown><![CDATA[
+echo "clean space...."
+
+sudo rm log.file
+
+sudo rm -rf ./my_mic-output
+
+echo "finish clean space...."
+]]></teardown>
+</testcase>
diff --git a/cases/create/func_cases/mic_cr_raw_gpt-part-type.case b/cases/create/func_cases/mic_cr_raw_gpt-part-type.case
new file mode 100755 (executable)
index 0000000..5dcb9a5
--- /dev/null
@@ -0,0 +1,29 @@
+<testcase>
+  <summary>create raw image with  gpt table and --part-type for partition</summary>
+  <fixtures>
+    <copy src="ks_files/ivi_gpt_with_part-type.ks" />
+  </fixtures>
+  <steps><![CDATA[
+losetup_path=$(sudo which losetup)
+sudo $losetup_path -a
+sudo $losetup_path -a | wc -l | xargs test 0 -eq
+
+sudo mic -d -v cr raw ivi_gpt_with_part-type.ks --logfile=mic1.log
+
+grep 'Finished' mic1.log
+
+sudo $losetup_path -a
+sudo $losetup_path -a | wc -l | xargs test 0 -eq
+
+test -f ./mic-output/ivi_gpt_with_part-type-*.raw
+]]></steps>
+  <teardown><![CDATA[
+echo "cleaning..."
+
+test -d ./mic-output && sudo rm -rf ./mic-output/
+
+test -f mic1.log && sudo rm mic1.log
+
+echo 'finish cleaning'
+]]></teardown>
+</testcase>
diff --git a/cases/create/func_cases/mic_cr_raw_release_logfile_local-pkg-pth_record-pkg_gen-bmap_ia32.case b/cases/create/func_cases/mic_cr_raw_release_logfile_local-pkg-pth_record-pkg_gen-bmap_ia32.case
new file mode 100755 (executable)
index 0000000..704a5b5
--- /dev/null
@@ -0,0 +1,46 @@
+<testcase>
+  <summary>This test case is used to test the option "--logfile",
+  if a file name is given to it, images should be created successfully.
+  There is no need to give an existed file name, mic will create a new
+  file with the given name if the file does not exist at present.
+  </summary>
+  <fixtures>
+    <copy src="ks_files/ivi.ks" />
+    <copydir src="rpm" />
+  </fixtures>
+  <steps><![CDATA[
+losetup_path=$(sudo which losetup)
+sudo $losetup_path -a
+sudo $losetup_path -a | wc -l | xargs test 0 -eq
+sudo mic -d -v cr raw ivi.ks \
+  --local-pkgs-path=./rpm \
+  --record-pkgs=name,content,license \
+  --release=tizen_20121223.1 \
+  --generate-bmap \
+  --logfile=log.file
+
+grep "Finished" log.file && echo 'mic command execution finished'
+
+sudo $losetup_path -a
+sudo $losetup_path -a | wc -l | xargs test 0 -eq
+grep 'Marking .*.rpm to be installed' log.file
+
+sudo test -e ./log.file
+sudo test -d ./mic-output/tizen_20121223.1/images
+sudo test -f ./mic-output/tizen_20121223.1/images/ivi/tizen_20121223.1_ivi.packages
+sudo test -f ./mic-output/tizen_20121223.1/images/ivi/tizen_20121223.1_ivi.license
+sudo test -f ./mic-output/tizen_20121223.1/images/ivi/tizen_20121223.1_ivi.files
+sudo test -f ./mic-output/tizen_20121223.1/images/ivi/tizen_20121223.1_ivi-sdb.raw
+sudo test -f ./mic-output/tizen_20121223.1/images/ivi/tizen_20121223.1_ivi-sdb.bmap
+sudo test -f ./mic-output/tizen_20121223.1/images/ivi/MD5SUMS
+]]></steps>
+  <teardown><![CDATA[
+echo "clean space...."
+
+sudo rm log.file
+
+sudo rm -rf ./mic-output
+
+echo "finish clean space...."
+]]></teardown>
+</testcase>
diff --git a/cases/create/mixed_cases/mic_cr_createrepo_issue.case b/cases/create/mixed_cases/mic_cr_createrepo_issue.case
new file mode 100644 (file)
index 0000000..9ee0eec
--- /dev/null
@@ -0,0 +1,51 @@
+<testcase>
+  <summary>Test whether repo created by 'createrepo' locally can be used by mic</summary>
+  <tracking>
+    <ticket>2261</ticket>
+  </tracking>
+  <fixtures>
+    <copy src="ks_files/createrepo_issue.ks" />
+    <copy src="rpm/sed-4.2.1-1.3.i686.rpm" />
+  </fixtures>
+  <steps><![CDATA[
+createrepo --version || True
+distro=$(python -c 'import platform;print platform.linux_distribution()[0].lower().rstrip()')
+echo $distro
+if [ "$distro" = "opensuse" ]; then
+ sudo zypper install -y --oldpackage createrepo-0.9.8
+fi
+
+
+if [ "$distro" = "fedora" ] || [ "$distro" = "centos" ]; then
+ sudo yum clean all
+ sudo yum install -y createrepo-0.9.8 --setopt=protected_multilib=false --nogpgcheck
+ sudo yum clean all
+ sudo rpm --rebuilddb
+ sudo yum install -y wget --nogpgcheck
+fi
+
+if [ "$distro" = "ubuntu" ] || [ "$distro" = "debian" ]; then
+  sudo apt-get install -y --force-yes createrepo=0.9.8
+fi
+
+createrepo --version || True
+mkdir -p /var/tmp/temp_repo
+mkdir -p /var/tmp/temp_repo/repodata
+mv sed-4.2.1-1.3.i686.rpm /var/tmp/temp_repo/
+wget http://download.tizen.org/snapshots/tizen/common/latest/repos/ia32-wayland/packages/repodata/group.xml
+mv group.xml /var/tmp/temp_repo/repodata
+wget http://download.tizen.org/snapshots/tizen/common/latest/repos/ia32-wayland/packages/repodata/patterns.xml
+mv patterns.xml /var/tmp/temp_repo
+createrepo -g /var/tmp/temp_repo/repodata/group.xml --database --unique-md-filenames /var/tmp/temp_repo
+(! sudo mic -d -v cr auto createrepo_issue.ks --logfile=mic1.log)
+grep -i "Failed to download" mic1.log
+
+]]></steps>
+  <teardown><![CDATA[
+echo "cleaning..."
+test -d ./mic-output && sudo rm -rf ./mic-output
+test -d /var/tmp/temp_repo && sudo rm -rf /var/tmp/temp_repo
+test -e mic1.log && sudo rm mic1.log
+echo "finish cleaning..."
+]]></teardown>
+</testcase>
diff --git a/cases/create/mixed_cases/mic_cr_raw_active_partition.case b/cases/create/mixed_cases/mic_cr_raw_active_partition.case
new file mode 100755 (executable)
index 0000000..554e46e
--- /dev/null
@@ -0,0 +1,37 @@
+<testcase>
+  <summary>This case is used to test if mic can work well with '--active' configed to partition in ks config file, the command is as bellow:
+            mic cr raw ./ks_files/ivi_with_active_partition.ks</summary>
+  <tracking>
+    <ticket>639</ticket>
+  </tracking>
+  <fixtures>
+    <copy src="ks_files/ivi_with_active_partition.ks" />
+  </fixtures>
+  <steps><![CDATA[
+losetup_path=$(sudo which losetup)
+sudo $losetup_path -a
+sudo $losetup_path -a | wc -l | xargs test 0 -eq
+sudo mic -d -v cr raw ivi_with_active_partition.ks --logfile=log.file
+test -e ./log.file
+grep "Finished" log.file
+raw_name=$(ls mic-output/ivi_with_active_partition-*-sdb.raw)
+test -f $raw_name
+kpartx_path=$(sudo which kpartx)
+sudo $kpartx_path -av $raw_name
+sleep 2
+blkid_path=$(sudo which blkid)
+blkid_output=$(sudo $blkid_path -L boot | sed 's/.*loop\([0-9]*\)p\([0-9]\)/\2/')
+parted_path=$(sudo which parted)
+parted_boot_output=$(sudo $parted_path  $raw_name print| grep 'boot' | awk '{print $1}')
+test  $blkid_output -eq $parted_boot_output
+sudo $kpartx_path -d $raw_name
+sudo $losetup_path -a
+sudo $losetup_path -a | wc -l | xargs test 0 -eq
+]]></steps>
+  <teardown><![CDATA[
+echo "clean space...."
+test -f log.file && sudo rm log.file
+test -d mic-output && sudo rm -rf ./mic-output
+echo 'clean space finished...'
+]]></teardown>
+</testcase>
diff --git a/cases/create/mixed_cases/mic_cr_raw_broken_bootstrap.case b/cases/create/mixed_cases/mic_cr_raw_broken_bootstrap.case
new file mode 100755 (executable)
index 0000000..d2ca819
--- /dev/null
@@ -0,0 +1,21 @@
+<testcase>
+  <summary>Testing broken mic-bootstrap</summary>
+  <fixtures>
+    <copy src="ks_files/ivi_broken_content_bootstrap.ks" />
+  </fixtures>
+  <steps><![CDATA[
+losetup_path=$(sudo which losetup)
+sudo $losetup_path -a
+sudo $losetup_path -a | wc -l | xargs test 0 -eq
+(! sudo mic -d -v cr raw ivi_broken_content_bootstrap.ks --logfile=mic.log)
+grep -i 'Failed to download/install bootstrap package or the package is in bad format' mic.log
+sudo $losetup_path -a
+sudo $losetup_path -a | wc -l | xargs test 0 -eq
+]]></steps>
+  <teardown><![CDATA[
+echo "cleaning..."
+test -e mic.log && sudo rm mic.log
+test -e mic-output && sudo rm -rf mic-output
+echo 'finish cleaning'
+]]></teardown>
+</testcase>
diff --git a/cases/create/mixed_cases/mic_cr_raw_installerfw_extlinux.case b/cases/create/mixed_cases/mic_cr_raw_installerfw_extlinux.case
new file mode 100755 (executable)
index 0000000..01ee888
--- /dev/null
@@ -0,0 +1,46 @@
+<testcase>
+  <summary>This case is used to test if 'installerfw' command in ks</summary>
+  <fixtures>
+    <copy src="ks_files/ivi_with_installerfw.ks" />
+    <copy src="ks_files/ivi_syslinux_problem.ks" />
+  </fixtures>
+  <steps><![CDATA[
+platform=$(uname -m)
+distro=$(python -c "import platform;print platform.linux_distribution()[0].lower().rstrip()")
+if [ "$platform" == "x86_64" ] || [ "$distro" == "centos" ]
+then
+    losetup_path=$(sudo which losetup)
+    sudo $losetup_path -a
+    sudo $losetup_path -a | wc -l | xargs test 0 -eq
+    sudo mic -d -v cr raw ivi_with_installerfw.ks --logfile=mic1.log
+    grep 'Finished' mic1.log
+    test -f ./mic-output/ivi_with_installerfw-*.raw
+    sudo $losetup_path -a
+    sudo $losetup_path -a | wc -l | xargs test 0 -eq
+else
+    losetup_path=$(sudo which losetup)
+    sudo $losetup_path -a
+    sudo $losetup_path -a | wc -l | xargs test 0 -eq
+    ! (sudo mic cr raw ivi_syslinux_problem.ks -d -v --logfile=log.file)
+    sudo test -e ./log.file
+    grep "Unable to install syslinux bootloader" log.file
+    sed -i '/password/ a installerfw_plugins "bootloader"' ivi_syslinux_problem.ks
+    sudo $losetup_path -a
+    sudo $losetup_path -a | wc -l | xargs test 0 -eq
+    sudo mic -d -v cr raw ivi_syslinux_problem.ks --logfile=new_log.file
+    sudo test -e ./new_log.file
+    grep "Finished" new_log.file
+    test -f ./mic-output/ivi_syslinux_problem-*.raw
+    sudo $losetup_path -a
+    sudo $losetup_path -a | wc -l | xargs test 0 -eq
+
+fi
+]]></steps>
+  <teardown><![CDATA[
+echo "clean space...."
+test -f log.file && sudo rm log.file
+test -f new_log.file && sudo rm new_log.file
+test -d mic-output && sudo rm -rf ./mic-output
+echo 'clean space finished...'
+]]></teardown>
+</testcase>
diff --git a/cases/create/mixed_cases/mic_cr_raw_invliad_mic-bootstrap.case b/cases/create/mixed_cases/mic_cr_raw_invliad_mic-bootstrap.case
new file mode 100755 (executable)
index 0000000..4da5cf8
--- /dev/null
@@ -0,0 +1,21 @@
+<testcase>
+  <summary>Testing invalid mic-bootstrap</summary>
+  <fixtures>
+    <copy src="ks_files/ivi_invalid_content_mic-bootstrap.ks" />
+  </fixtures>
+  <steps><![CDATA[
+losetup_path=$(sudo which losetup)
+sudo $losetup_path -a
+sudo $losetup_path -a | wc -l | xargs test 0 -eq
+(! sudo mic -d -v cr raw ivi_invalid_content_mic-bootstrap.ks --logfile=mic.log)
+grep -i 'Failed to download/install bootstrap package or the package is in bad format' mic.log
+sudo $losetup_path -a
+sudo $losetup_path -a | wc -l | xargs test 0 -eq
+]]></steps>
+  <teardown><![CDATA[
+echo "cleaning..."
+test -e mic.log && sudo rm mic.log
+test -e mic-output && sudo rm -rf mic-output
+echo 'finish cleaning'
+]]></teardown>
+</testcase>
diff --git a/cases/create/mixed_cases/mic_cr_raw_ivi_partition_size_compute_ia32.case b/cases/create/mixed_cases/mic_cr_raw_ivi_partition_size_compute_ia32.case
new file mode 100755 (executable)
index 0000000..3a46797
--- /dev/null
@@ -0,0 +1,45 @@
+<testcase>
+  <summary></summary>
+  <tracking>
+    <ticket>624</ticket>
+  </tracking>
+  <fixtures>
+    <copy src="ks_files/ivi_624.ks" />
+  </fixtures>
+  <steps><![CDATA[
+losetup_path=$(sudo which losetup)
+sudo $losetup_path -a
+sudo $losetup_path -a | wc -l | xargs test 0 -eq
+distro=`python -c "import platform;a=platform.linux_distribution();print a[0]"`
+sudo mic -d -v cr raw ivi_624.ks --logfile=./log/handset.log 
+test -f ./log/handset.log
+grep 'Finished' ./log/handset.log
+test -e ./mic-output/ivi_624*.raw
+sudo $losetup_path -a
+sudo $losetup_path -a | wc -l | xargs test 0 -eq
+if [ "$distro" == "CentOS" ]
+then
+    parted ./mic-output/ivi*.raw print | grep -o "Disk.*" >> tmp1.log
+    VAL1=$(awk '{print $NF}' tmp1.log | grep -o [0-9]*)
+    parted ./mic-output/ivi*.raw print >> tmp2.log
+    sed -i '/^$/d' tmp2.log
+    tail -1 tmp2.log >> tmp3.log
+    VAL2=$(awk '{print $3}' tmp3.log | grep -o [0-9]*)
+    test "$VAL1" -eq "$VAL2"
+else
+    fdisk_path=$(sudo which fdisk)
+    VAL1=`sudo $fdisk_path -l ./mic-output/ivi*.raw  | sed '/^$/d' |  sed -n '$p' | awk '{print $3}'`
+    sudo $fdisk_path -l ./mic-output/ivi*.raw | sed -n '/.*sectors$/p' >> tmp2.file
+    VAL2=`awk '{print $(NF-1)}' tmp2.file`
+    let VAL3=$VAL2-1
+    test "$VAL1" -eq "$VAL3"
+fi
+]]></steps>
+  <teardown><![CDATA[
+echo "cleaning..."
+test -e ./mic-output && sudo rm -rf ./mic-output
+test -e ./log/handset.log && sudo rm ./log/handset.log
+test -e tmp1.file && sudo rm tmp1.file
+test -e tmp2.file && sudo rm tmp2.file
+]]></teardown>
+</testcase>
diff --git a/cases/create/mixed_cases/mic_cr_raw_locale.case b/cases/create/mixed_cases/mic_cr_raw_locale.case
new file mode 100755 (executable)
index 0000000..bbdf600
--- /dev/null
@@ -0,0 +1,61 @@
+<testcase>
+  <summary>
+    test if '/etc/locale.conf' exists
+  </summary>
+  <fixtures>
+    <copy src="ks_files/ivi.ks" />
+  </fixtures>
+  <tracking>
+    <ticket>1745</ticket>
+  </tracking>
+  <steps><![CDATA[
+losetup_path=$(sudo which losetup)
+sudo $losetup_path -a
+sudo $losetup_path -a | wc -l | xargs test 0 -eq
+sudo mic -d -v cr raw ivi.ks --logfile=log.file
+grep "Finished" log.file
+sudo $losetup_path -a
+sudo $losetup_path -a | wc -l | xargs test 0 -eq
+raw_image=$(ls mic-output/ivi-*-sdb.raw)
+sudo mkdir -p mic-output/ivi_dir/boot
+kpartx_path=$(sudo which kpartx)
+for i in {1..5}
+do
+    kpartx_output=$(sudo $kpartx_path -av $raw_image)
+    if [ -n "$kpartx_output" ]; then
+        first_part=$(echo "$kpartx_output" | awk '{print $3}' | sed -n '1p')
+        second_part=$(echo "$kpartx_output" | awk '{print $3}' | sed -n '2p')
+        ls /dev/mapper/
+        if [ -n "$first_part" ] && [ -e "/dev/mapper/$first_part" ];then
+            sudo mount /dev/mapper/$first_part  mic-output/ivi_dir/boot/ -t ext4
+            sudo mount /dev/mapper/$second_part  mic-output/ivi_dir/ -t ext4
+            sudo chroot mic-output/ivi_dir/ test -f /etc/locale.conf
+            sudo chroot mic-output/ivi_dir/ cat  /etc/locale.conf | grep 'en_US.UTF-8'
+            exit 0
+        fi
+    fi
+    sleep 3
+done
+echo "can not get kpartx output: $kpartx_path -av $raw_image"
+exit 1
+]]></steps>
+  <teardown><![CDATA[
+echo "cleaning..."
+sudo test -f log.file && sudo rm log.file
+raw_image=$(ls mic-output/ivi-*-sdb.raw)
+if [ -f $raw_image ]; then
+    for i in {1..5}; do
+      test -d mic-output/ivi_dir && sudo umount -l mic-output/ivi_dir
+      test -d mic-output/ivi_dir/boot && sudo umount -l mic-output/ivi_dir/boot
+      kpartx_path=$(sudo which kpartx)
+      sudo $kpartx_path -d $raw_image
+      if sudo losetup -a | grep "ivi"; then
+          sleep 2
+      else
+          test -d mic-output && sudo rm -rf ./mic-output
+          break
+      fi
+    done
+fi
+]]></teardown>
+</testcase>
diff --git a/cases/create/mixed_cases/mic_cr_raw_multi_partition_gpt.case b/cases/create/mixed_cases/mic_cr_raw_multi_partition_gpt.case
new file mode 100755 (executable)
index 0000000..1e0f0f7
--- /dev/null
@@ -0,0 +1,28 @@
+<testcase>
+  <summary>This case is used to test if mic can work well with multi partitions for GPT partition table format, which are setted in ks config file, the command is : mic cr raw ./ks_files/ivi_four_partition_gpt.ks</summary>
+  <tracking>
+    <ticket>741</ticket>
+  </tracking>
+  <fixtures>
+    <copy src="ks_files/ivi_four_partition_gpt.ks" />
+  </fixtures>
+  <steps><![CDATA[
+losetup_path=$(sudo which losetup)
+sudo $losetup_path -a
+sudo $losetup_path -a | wc -l | xargs test 0 -eq
+sudo mic -d -v cr raw ivi_four_partition_gpt.ks --logfile=log.file 
+sudo test -e ./log.file
+grep "Finished" log.file
+sudo test -f ./mic-output/ivi_four_partition_gpt-*-sdb.raw
+raw_name=$(ls mic-output/ivi_four_partition_gpt-*-sdb.raw)
+parted_path=$(sudo which parted)
+sudo $parted_path  $raw_name print | grep "Partition Table: gpt"
+sudo $losetup_path -a
+sudo $losetup_path -a | wc -l | xargs test 0 -eq
+]]></steps>
+  <teardown><![CDATA[
+echo "clean space...."
+test -e ./mic-output && sudo rm -rf ./mic-output
+test -e log.file && sudo rm log.file
+]]></teardown>
+</testcase>
diff --git a/cases/create/mixed_cases/mic_cr_raw_multi_partition_mbr.case b/cases/create/mixed_cases/mic_cr_raw_multi_partition_mbr.case
new file mode 100755 (executable)
index 0000000..95368f9
--- /dev/null
@@ -0,0 +1,28 @@
+<testcase>
+  <summary>This case is used to test if mic can work well with multi partitions for 'msdos' partition table format which are setted in ks config file, the command is as bellow: mic cr raw ./ks_files/ivi_four_partition_mbr.ks</summary>
+  <tracking>
+    <ticket>742</ticket>
+  </tracking>
+  <fixtures>
+    <copy src="ks_files/ivi_four_partition_mbr.ks" />
+  </fixtures>
+  <steps><![CDATA[
+losetup_path=$(sudo which losetup)
+sudo $losetup_path -a
+sudo $losetup_path -a | wc -l | xargs test 0 -eq
+sudo mic -d -v cr raw ivi_four_partition_mbr.ks --logfile=log.file
+test -e ./log.file
+grep "Finished" log.file
+test -f ./mic-output/ivi_four_partition_mbr-*-sdb.raw
+raw_name=$(ls ./mic-output/ivi_four_partition_mbr-*-sdb.raw)
+parted_path=$(sudo which parted)
+sudo $parted_path  $raw_name print | grep msdos
+sudo $losetup_path -a
+sudo $losetup_path -a | wc -l | xargs test 0 -eq
+]]></steps>
+  <teardown><![CDATA[
+echo "clean space...."
+test -e ./mic-output && sudo rm -rf ./mic-output
+test -e log.file && sudo rm log.file
+]]></teardown>
+</testcase>
diff --git a/cases/create/mixed_cases/mic_cr_raw_no_mountpoint.case b/cases/create/mixed_cases/mic_cr_raw_no_mountpoint.case
new file mode 100755 (executable)
index 0000000..40a96d6
--- /dev/null
@@ -0,0 +1,22 @@
+<testcase>
+  <summary>Test the condition that the ks file has no mountpoint.</summary>
+  <fixtures>
+    <copy src="ks_files/ivi_no_mountpoint.ks" />
+  </fixtures>
+  <steps><![CDATA[
+losetup_path=$(sudo which losetup)
+sudo $losetup_path -a
+sudo $losetup_path -a | wc -l | xargs test 0 -eq
+sudo mic -d -v cr raw ivi_no_mountpoint.ks --logfile=./log/ivi.log
+test -f ./log/ivi.log
+grep 'Finished' ./log/ivi.log
+test -f ./mic-output/ivi*.raw
+sudo $losetup_path -a
+sudo $losetup_path -a | wc -l | xargs test 0 -eq
+]]></steps>
+  <teardown><![CDATA[
+echo "cleaning..."
+sudo test -e ./mic-output && sudo rm -rf ./mic-output
+sudo test -e ./log/ivi.log && sudo rm ./log/ivi.log
+]]></teardown>
+</testcase>
diff --git a/cases/create/mixed_cases/mic_cr_raw_no_partition.case b/cases/create/mixed_cases/mic_cr_raw_no_partition.case
new file mode 100755 (executable)
index 0000000..40e747d
--- /dev/null
@@ -0,0 +1,23 @@
+<testcase>
+  <summary>This case is used to test if mic can work well with no partitions in ks config file,
+  the command is as bellow: mic cr raw ./ks_files/ivi_no_partition.ks</summary>
+  <fixtures>
+    <copy src="ks_files/ivi_no_partition.ks" />
+  </fixtures>
+  <steps><![CDATA[
+losetup_path=$(sudo which losetup)
+sudo $losetup_path -a
+sudo $losetup_path -a | wc -l | xargs test 0 -eq
+sudo mic -d -v cr raw ivi_no_partition.ks --logfile=log.file
+test -e ./log.file
+grep "Finished" log.file
+sudo test -f ./mic-output/ivi_no_partition-*-sda.raw
+sudo $losetup_path -a
+sudo $losetup_path -a | wc -l | xargs test 0 -eq
+]]></steps>
+  <teardown><![CDATA[
+echo "clean space...."
+test -d mic-output && sudo rm -rf ./mic-output
+test -f log.file && sudo rm log.file
+]]></teardown>
+</testcase>
diff --git a/cases/create/mixed_cases/mic_cr_raw_unicode.case b/cases/create/mixed_cases/mic_cr_raw_unicode.case
new file mode 100755 (executable)
index 0000000..53a2224
--- /dev/null
@@ -0,0 +1,23 @@
+<testcase>
+  <summary>create raw image when LANG is zh_CN.UTF-8</summary>
+  <fixtures>
+    <copy src="ks_files/ivi.ks" />
+  </fixtures>
+  <steps><![CDATA[
+losetup_path=$(sudo which losetup)
+sudo $losetup_path -a
+sudo $losetup_path -a | wc -l | xargs test 0 -eq
+LANG=zh_CN.UTF-8
+sudo mic -d -v cr raw ivi.ks --logfile=mic1.log 
+grep 'Finished' mic1.log
+test -f ./mic-output/ivi*.raw
+sudo $losetup_path -a
+sudo $losetup_path -a | wc -l | xargs test 0 -eq
+]]></steps>
+  <teardown><![CDATA[
+echo "cleaning..."
+test -d ./mic-output && sudo rm -rf ./mic-output/
+test -f mic1.log && sudo rm mic1.log
+echo 'finish cleaning...'
+]]></teardown>
+</testcase>
diff --git a/cases/create/mixed_cases/mic_cr_raw_without_conf_bootstrap_ia32.case b/cases/create/mixed_cases/mic_cr_raw_without_conf_bootstrap_ia32.case
new file mode 100755 (executable)
index 0000000..9ff748e
--- /dev/null
@@ -0,0 +1,24 @@
+<testcase>
+  <summary>Without /etc/mic/mic.conf, raw image cannot be created in bootstrap mode</summary>
+  <fixtures>
+    <copy src="ks_files/ivi.ks" />
+  </fixtures>
+  <steps><![CDATA[
+test -e /etc/mic/mic.conf
+sudo mv /etc/mic/mic.conf /etc/mic/mic.conf.bak
+losetup_path=$(sudo which losetup)
+sudo $losetup_path -a
+sudo $losetup_path -a | wc -l | xargs test 0 -eq
+! (sudo mic -d -v cr loop ivi.ks --logfile=ivi.log --runtime=bootstrap) 2>&1 | tee mic.log
+grep -i "Failed to download/install bootstrap package" mic.log
+sudo $losetup_path -a
+sudo $losetup_path -a | wc -l | xargs test 0 -eq
+]]></steps>
+  <teardown><![CDATA[
+echo "cleaning..."
+test -e ./mic-output && sudo rm -rf ./mic-output
+test -e ivi.log && sudo rm ivi.log
+test -e mic.log && sudo rm mic.log
+test -e /etc/mic/mic.conf.bak && sudo mv /etc/mic/mic.conf.bak /etc/mic/mic.conf
+]]></teardown>
+</testcase>
diff --git a/cases/create/opt_cases/mic_cr_raw_compress-image-bz2_ia32.case b/cases/create/opt_cases/mic_cr_raw_compress-image-bz2_ia32.case
new file mode 100755 (executable)
index 0000000..2c512b5
--- /dev/null
@@ -0,0 +1,43 @@
+<testcase>
+  <summary>create raw image with ia32 arch and compress-image option with bz2</summary>
+  <fixtures>
+    <copy src="ks_files/ivi.ks" />
+    <copy src="scripts/compute_volume.sh" />
+  </fixtures>
+  <steps><![CDATA[
+losetup_path=$(sudo which losetup)
+sudo $losetup_path -a
+sudo $losetup_path -a | wc -l | xargs test 0 -eq
+enforce_path=$(sudo which setenforce || true)
+if [ ! -z $enforce_path ];then
+    sudo $enforce_path 0 || true
+fi
+sudo mic -d -v cr raw ivi.ks -o out1 --logfile=mic1.log
+grep 'Finished' mic1.log
+sudo $losetup_path -a
+sudo $losetup_path -a | wc -l | xargs test 0 -eq
+sudo mic -d -v cr raw ivi.ks --compress-image=bz2 -o out2  --logfile=mic2.log
+grep 'Finished' mic2.log
+test -f ./out2/ivi*.raw.bz2
+sudo $losetup_path -a
+sudo $losetup_path -a | wc -l | xargs test 0 -eq
+source compute_volume.sh
+cd out1
+name1=`ls ivi*.raw`
+p1=`compute_volume $name1`
+cd ../out2
+name2=`ls ivi*.raw.bz2`
+p2=`compute_volume $name2`
+result=`awk -v before_volume=$p1 -v cpmpress_volume=$p2 'BEGIN {print(before_volume>cpmpress_volume)?"yes":"no"}'`
+test $result = 'yes'
+sudo bunzip2 $name2
+raw_name=`ls ivi*.raw`
+test -f $raw_name
+]]></steps>
+  <teardown><![CDATA[
+echo "cleaning..."
+sudo rm -rf ./out1/ ./out2/
+sudo rm mic1.log mic2.log
+echo "finish cleaning..."
+]]></teardown>
+</testcase>
diff --git a/cases/create/opt_cases/mic_cr_raw_compress-image-gz_ia32.case b/cases/create/opt_cases/mic_cr_raw_compress-image-gz_ia32.case
new file mode 100755 (executable)
index 0000000..f8eb73f
--- /dev/null
@@ -0,0 +1,39 @@
+<testcase>
+  <summary>create raw image with ia32 arch and compress-image option with gz</summary>
+  <fixtures>
+    <copy src="ks_files/ivi.ks" />
+    <copy src="scripts/compute_volume.sh" />
+  </fixtures>
+  <steps><![CDATA[
+losetup_path=$(sudo which losetup)
+sudo $losetup_path -a
+sudo $losetup_path -a | wc -l | xargs test 0 -eq
+sudo mic -d -v cr raw ivi.ks -o out1 --logfile=mic1.log
+grep 'Finished' mic1.log
+test -f ./out1/ivi*.raw
+sudo $losetup_path -a
+sudo $losetup_path -a | wc -l | xargs test 0 -eq
+sudo mic -d -v cr raw ivi.ks --compress-image=gz -o out2 --logfile=mic2.log
+grep 'Finished' mic2.log
+test -f ./out2/ivi*.raw.gz
+sudo $losetup_path -a
+sudo $losetup_path -a | wc -l | xargs test 0 -eq
+source compute_volume.sh
+cd out1
+name1=`ls ivi*.raw`
+p1=`compute_volume $name1`
+cd ../out2
+name2=`ls ivi*.raw.gz`
+p2=`compute_volume $name2`
+result=`awk -v before_volume=$p1 -v cpmpress_volume=$p2 'BEGIN {print(before_volume>cpmpress_volume)?"yes":"no"}'`
+test $result = 'yes'
+sudo gunzip $name2
+raw_name=`ls ivi*.raw`
+test -f $name
+]]></steps>
+  <teardown><![CDATA[
+echo "cleaning..."
+sudo rm -rf ./out1/ ./out2/
+sudo rm mic1.log mic2.log
+]]></teardown>
+</testcase>
diff --git a/cases/create/opt_cases/mic_cr_raw_compress-image-invalid_ia32.case b/cases/create/opt_cases/mic_cr_raw_compress-image-invalid_ia32.case
new file mode 100755 (executable)
index 0000000..352809d
--- /dev/null
@@ -0,0 +1,21 @@
+<testcase>
+  <summary>create raw image with ia32 arch and compress-image option with invalid option, like zip</summary>
+  <fixtures>
+    <copy src="ks_files/ivi.ks" />
+  </fixtures>
+  <steps><![CDATA[
+losetup_path=$(sudo which losetup)
+sudo $losetup_path -a
+sudo $losetup_path -a | wc -l | xargs test 0 -eq
+! (sudo mic -d -v cr raw ivi.ks --compress-image=zip 2>&1 | tee mic2.log )
+grep  "compress-image: invalid choice: 'zip'" mic2.log
+sudo $losetup_path -a
+sudo $losetup_path -a | wc -l | xargs test 0 -eq
+]]></steps>
+  <teardown><![CDATA[
+echo "cleaning..."
+sudo rm -f mic2.log
+sudo rm -rf ./mic-output
+echo "finish cleaning..."
+]]></teardown>
+</testcase>
diff --git a/cases/create/opt_cases/mic_cr_raw_fstab-entry-name.case b/cases/create/opt_cases/mic_cr_raw_fstab-entry-name.case
new file mode 100755 (executable)
index 0000000..a754aef
--- /dev/null
@@ -0,0 +1,59 @@
+<testcase>
+  <summary>This test case is used to test the option "--fstab-entry=name",</summary>
+  <fixtures>
+    <copy src="ks_files/ivi.ks" />
+  </fixtures>
+  <steps><![CDATA[
+losetup_path=$(sudo which losetup)
+sudo $losetup_path -a
+sudo $losetup_path -a | wc -l | xargs test 0 -eq
+sudo mic -d -v cr raw  ivi.ks --fstab-entry=name --logfile=log.file
+grep "Finished" log.file
+ls mic-output/ | grep 'ivi-.*-sdb.raw'
+sudo $losetup_path -a
+sudo $losetup_path -a | wc -l | xargs test 0 -eq
+raw_image=$(ls mic-output/ivi-*-sdb.raw)
+sudo mkdir -p mic-output/ivi_dir/boot
+kpartx_path=$(sudo which kpartx)
+for i in {1..5}
+do
+    kpartx_output=$(sudo $kpartx_path -av $raw_image)
+    if [ -n "$kpartx_output" ]; then
+        first_part=$(echo "$kpartx_output" | awk '{print $3}' | sed -n '1p')
+        second_part=$(echo "$kpartx_output" | awk '{print $3}' | sed -n '2p')
+        ls /dev/mapper/
+        if [ -n "$first_part" ] && [ -e "/dev/mapper/$first_part" ];then
+            sudo mount /dev/mapper/$first_part  mic-output/ivi_dir/boot/ -t ext4
+            sudo mount /dev/mapper/$second_part  mic-output/ivi_dir/ -t ext4
+            sudo chroot mic-output/ivi_dir/ cat /etc/fstab | grep /dev/sdb
+            (! sudo chroot mic-output/ivi_dir/ cat /etc/fstab | grep -i 'uuid')
+            exit 0
+       fi
+   fi
+   sleep 3
+done
+echo "can not get kpartx output: $kpartx_path -av $raw_image"
+exit 1
+]]></steps>
+  <teardown><![CDATA[
+echo "cleaning..."
+test -f log.file && sudo rm log.file
+raw_image=$(ls mic-output/ivi-*-sdb.raw)
+losetup_path=$(sudo which losetup)
+if [ -f $raw_image ];then
+    for i in {1..5}
+    do
+    test -d mic-output/ivi_dir && sudo umount -l mic-output/ivi_dir
+    test -d mic-output/ivi_dir/boot && sudo umount -l mic-output/ivi_dir/boot
+    kpartx_path=$(sudo which kpartx)
+    sudo $kpartx_path -d $raw_image
+    if sudo $losetup_path -a | grep "ivi"; then
+        sleep 2
+    else
+        test -d mic-output && sudo rm -rf ./mic-output
+        break
+    fi
+    done
+fi
+]]></teardown>
+</testcase>
diff --git a/cases/create/opt_cases/mic_cr_raw_fstab-entry-uuid.case b/cases/create/opt_cases/mic_cr_raw_fstab-entry-uuid.case
new file mode 100755 (executable)
index 0000000..544c3da
--- /dev/null
@@ -0,0 +1,60 @@
+<testcase>
+  <summary>This test case is used to test the option "--fstab-entry=uuid",</summary>
+  <fixtures>
+    <copy src="ks_files/ivi.ks" />
+  </fixtures>
+  <steps><![CDATA[
+losetup_path=$(sudo which losetup)
+sudo $losetup_path -a
+sudo $losetup_path -a | wc -l | xargs test 0 -eq
+sudo mic -d -v cr raw ivi.ks --fstab-entry=uuid --logfile=log.file
+grep "Finished" log.file
+ls mic-output/ | grep 'ivi-.*-sdb.raw'
+sudo $losetup_path -a
+sudo $losetup_path -a | wc -l | xargs test 0 -eq
+raw_image=$(ls mic-output/ivi-*-sdb.raw)
+sudo mkdir -p mic-output/ivi_dir/boot
+kpartx_path=$(sudo which kpartx)
+for i in {1..5}
+do
+    kpartx_output=$(sudo $kpartx_path -av $raw_image)
+    if [ -n "$kpartx_output" ]; then
+        first_part=$(echo "$kpartx_output" | awk '{print $3}' | sed -n '1p')
+        second_part=$(echo "$kpartx_output"| awk '{print $3}' | sed -n '2p')
+        ls /dev/mapper/
+        if [ -n "$kpartx_output" ] && [ -e "/dev/mapper/$first_part" ];then
+            sudo mount /dev/mapper/$first_part  mic-output/ivi_dir/boot/ -t ext4
+            sudo mount /dev/mapper/$second_part  mic-output/ivi_dir/ -t ext4
+            (! sudo chroot mic-output/ivi_dir/ cat /etc/fstab | grep /dev/sdb)
+            sudo chroot mic-output/ivi_dir/ cat /etc/fstab | grep -i 'uuid'
+            exit 0
+        fi
+     fi
+     sleep 3
+done
+echo "can not get kpartx output: $kpartx_path -av $raw_image"
+exit 1
+]]></steps>
+  <teardown><![CDATA[
+echo "cleaning..."
+test -f log.file && sudo rm log.file
+raw_image=$(ls mic-output/ivi-*-sdb.raw)
+losetup_path=$(sudo which losetup)
+if [ -f $raw_image ];then
+    for i in {1..5}
+    do
+    test -d mic-output/ivi_dir && sudo umount -l mic-output/ivi_dir
+    test -d mic-output/ivi_dir/boot && sudo umount -l mic-output/ivi_dir/boot
+    kpartx_path=$(sudo which kpartx)
+    sudo $kpartx_path -d $raw_image
+    if sudo $losetup_path -a | grep 'ivi'; then
+        sleep 2
+    else
+        test -d mic-output && sudo rm -rf ./mic-output
+        break
+    fi
+    done
+fi
+echo 'finish cleaning'
+]]></teardown>
+</testcase>
diff --git a/cases/create/opt_cases/mic_cr_raw_generate-bmap_ia32.case b/cases/create/opt_cases/mic_cr_raw_generate-bmap_ia32.case
new file mode 100755 (executable)
index 0000000..f36c721
--- /dev/null
@@ -0,0 +1,23 @@
+<testcase>
+  <summary>create loop image with ia32 arch and shrink option</summary>
+  <fixtures>
+    <copy src="ks_files/ivi.ks" />
+  </fixtures>
+  <steps><![CDATA[
+losetup_path=$(sudo which losetup)
+sudo $losetup_path -a
+sudo $losetup_path -a | wc -l | xargs test 0 -eq
+sudo mic -d -v cr raw ivi.ks --generate-bmap --logfile=mic1.log
+grep 'Finished' mic1.log
+test -f ./mic-output/ivi*.raw
+sudo $losetup_path -a
+sudo $losetup_path -a | wc -l | xargs test 0 -eq
+test -f ./mic-output/ivi*.bmap
+]]></steps>
+  <teardown><![CDATA[
+echo "cleaning..."
+sudo rm -rf ./mic-output/
+sudo rm mic1.log
+echo "finish cleaning..."
+]]></teardown>
+</testcase>