summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorZhou Shuangquan <shuangquan.zhou@intel.com>2011-08-10 10:20:36 +0800
committerZhou Shuangquan <shuangquan.zhou@intel.com>2011-08-10 10:20:36 +0800
commit98657e38015bb1c3b3e04ba7a1e8c1bc72906c46 (patch)
treeeb983173750ffad3598144d7685585e5ebd8455a /tests
parentc9a40ffb278a34263b841f079e1e08f02214e0f8 (diff)
downloadmic-98657e38015bb1c3b3e04ba7a1e8c1bc72906c46.tar.gz
mic-98657e38015bb1c3b3e04ba7a1e8c1bc72906c46.tar.bz2
mic-98657e38015bb1c3b3e04ba7a1e8c1bc72906c46.zip
Initial checkin of micng
Note: create fs/loop/raw/livecd/liveusb chroot fs/loop/raw/livecd/liveusb Signed-off-by: Zhou Shuangquan <shuangquan.zhou@intel.com>
Diffstat (limited to 'tests')
-rwxr-xr-xtests/addcase.sh22
-rw-r--r--tests/mic-test.py35
-rw-r--r--tests/mic_cases/base/test.ks66
-rw-r--r--tests/mic_cases/test-bootstrap/expect1
-rw-r--r--tests/mic_cases/test-bootstrap/ks.p0
-rw-r--r--tests/mic_cases/test-bootstrap/options1
-rw-r--r--tests/mic_cases/test-creatprc/expect1
-rw-r--r--tests/mic_cases/test-creatprc/ks.p41
-rw-r--r--tests/mic_cases/test-creatprc/options1
-rw-r--r--tests/mic_cases/test-genimg/ks.p376
-rw-r--r--tests/mic_cases/test-genimg/options1
-rw-r--r--tests/mic_cases/test-imageformat/expect1
-rw-r--r--tests/mic_cases/test-imageformat/ks.p108
-rw-r--r--tests/mic_cases/test-imageformat/options1
-rw-r--r--tests/mic_cases/test-invalidrepostr/expect1
-rw-r--r--tests/mic_cases/test-invalidrepostr/ks.p86
-rw-r--r--tests/mic_cases/test-invalidrepostr/options1
-rw-r--r--tests/mic_cases/test-misspkgs/expect1
-rw-r--r--tests/mic_cases/test-misspkgs/ks.p41
-rw-r--r--tests/mic_cases/test-misspkgs/options1
-rw-r--r--tests/mic_cases/test-norepo/expect1
-rw-r--r--tests/mic_cases/test-norepo/ks.p85
-rw-r--r--tests/mic_cases/test-norepo/options1
-rw-r--r--tests/mic_cases/test-root/expect1
-rw-r--r--tests/mic_cases/test-root/ks.p0
-rw-r--r--tests/mic_cases/test-root/options1
-rw-r--r--tests/mic_cases/test-runmode/expect1
-rw-r--r--tests/mic_cases/test-runmode/ks.p0
-rw-r--r--tests/mic_cases/test-runmode/options1
-rw-r--r--tests/testbase.py61
30 files changed, 938 insertions, 0 deletions
diff --git a/tests/addcase.sh b/tests/addcase.sh
new file mode 100755
index 0000000..2ea1f22
--- /dev/null
+++ b/tests/addcase.sh
@@ -0,0 +1,22 @@
+#!/bin/sh
+
+if [ $# -ne 2 ]; then
+ echo "Usage addcase.sh <case-name> <case-ksfile>"
+ exit 1
+fi
+
+CaseName=$1
+CaseKs=$2
+
+diff -upN ./mic_cases/base/test.ks ${CaseKs} > ks.p
+
+cd ./mic_cases
+mkdir test-${CaseName}
+cd test-${CaseName}
+
+mv ../../ks.p .
+vi options
+vi expect
+
+echo 'Ks diff:'
+cat ks.p
diff --git a/tests/mic-test.py b/tests/mic-test.py
new file mode 100644
index 0000000..4dbba3d
--- /dev/null
+++ b/tests/mic-test.py
@@ -0,0 +1,35 @@
+#!/usr/bin/python
+import unittest
+import os, sys, glob, tempfile, shutil
+from testbase import *
+
+class MICTest(unittest.TestCase):
+ cases_dir = "mic_cases"
+ if os.path.isdir(cases_dir):
+ for case in glob.glob(os.path.join(cases_dir,'test-*')):
+ case = os.path.basename(case)[5:]
+ method = """
+def test_%s(self):
+ self._testTemplate("%s")
+""" % (case, case)
+ exec method in locals()
+
+ def setUp(self):
+ self.work_env = tempfile.mkdtemp()
+
+ def tearDown(self):
+ shutil.rmtree(self.work_env, ignore_errors = True)
+
+ def _testTemplate(self, case):
+ """test function"""
+ PrepEnv(self.cases_dir, case, self.work_env)
+ RunandCheck(self, self.work_env)
+
+def MICtestsuite():
+ suite = unittest.TestLoader().loadTestsFromModule(sys.modules[__name__])
+ alltests = unittest.TestSuite(suite)
+ return alltests
+
+if __name__ == '__main__':
+ suite = MICtestsuite()
+ unittest.TextTestRunner(verbosity=2).run(suite)
diff --git a/tests/mic_cases/base/test.ks b/tests/mic_cases/base/test.ks
new file mode 100644
index 0000000..fc43108
--- /dev/null
+++ b/tests/mic_cases/base/test.ks
@@ -0,0 +1,66 @@
+#
+# Do not Edit! Generated by:
+# kickstarter.py
+#
+
+lang en_US.UTF-8
+keyboard us
+timezone --utc America/New_York
+auth --useshadow --enablemd5
+part / --size 3000 --ondisk sda --fstype=ext3
+rootpw meego
+xconfig --startxonboot
+bootloader --timeout=0 --append="quiet"
+desktop --autologinuser=meego
+user --name meego --groups audio,video --password meego
+
+repo --name=oss --baseurl=http://linux-ftp.jf.intel.com/pub/mirrors/MeeGo-other/trunk-daily/builds/trunk/1.1.90.3.20110214.2/oss/repos/ia32/packages/ --save --debuginfo --source --gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-meego
+
+%packages
+@MeeGo Core
+@MeeGo Netbook Desktop
+@X for Netbooks
+@MeeGo Compliance
+@MeeGo X Window System
+@Virtual Machine Support
+@Games
+@Printing
+@Base Double Byte IME Support
+@MeeGo Base Development
+
+kernel
+chromium
+%end
+
+%post
+
+# save a little bit of space at least...
+rm -f /boot/initrd*
+
+# make sure there aren't core files lying around
+rm -f /core*
+
+
+
+# Prelink can reduce boot time
+if [ -x /usr/sbin/prelink ]; then
+ /usr/sbin/prelink -aRqm
+fi
+
+
+# work around for poor key import UI in PackageKit
+rm -f /var/lib/rpm/__db*
+rpm --rebuilddb
+
+if [ -f /etc/pki/rpm-gpg/RPM-GPG-KEY-meego ]; then
+ rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-meego
+fi
+
+
+%end
+
+%post --nochroot
+if [ -n "$IMG_NAME" ]; then
+ echo "BUILD: $IMG_NAME" >> $INSTALL_ROOT/etc/meego-release
+fi
+%end
diff --git a/tests/mic_cases/test-bootstrap/expect b/tests/mic_cases/test-bootstrap/expect
new file mode 100644
index 0000000..c785ffa
--- /dev/null
+++ b/tests/mic_cases/test-bootstrap/expect
@@ -0,0 +1 @@
+Please use -b | --build-bootstrap with -B | --bootstrap together
diff --git a/tests/mic_cases/test-bootstrap/ks.p b/tests/mic_cases/test-bootstrap/ks.p
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/mic_cases/test-bootstrap/ks.p
diff --git a/tests/mic_cases/test-bootstrap/options b/tests/mic_cases/test-bootstrap/options
new file mode 100644
index 0000000..013c204
--- /dev/null
+++ b/tests/mic_cases/test-bootstrap/options
@@ -0,0 +1 @@
+sudo mic-image-creator -f livecd -b
diff --git a/tests/mic_cases/test-creatprc/expect b/tests/mic_cases/test-creatprc/expect
new file mode 100644
index 0000000..4033a56
--- /dev/null
+++ b/tests/mic_cases/test-creatprc/expect
@@ -0,0 +1 @@
+Unable to set unencrypted password due to lack of /usr/sbin/chpasswd
diff --git a/tests/mic_cases/test-creatprc/ks.p b/tests/mic_cases/test-creatprc/ks.p
new file mode 100644
index 0000000..a7b200d
--- /dev/null
+++ b/tests/mic_cases/test-creatprc/ks.p
@@ -0,0 +1,41 @@
+--- ./mic_cases/base/test.ks 2011-02-25 09:21:41.778621925 +0800
++++ /home/zhou/Code/min_nb.ks 2011-02-23 12:19:12.453405953 +0800
+@@ -1,4 +1,4 @@
+-#
++#
+ # Do not Edit! Generated by:
+ # kickstarter.py
+ #
+@@ -15,25 +15,17 @@ desktop --autologinuser=meego
+ user --name meego --groups audio,video --password meego
+
+ repo --name=oss --baseurl=http://linux-ftp.jf.intel.com/pub/mirrors/MeeGo-other/trunk-daily/builds/trunk/1.1.90.3.20110214.2/oss/repos/ia32/packages/ --save --debuginfo --source --gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-meego
++repo --name=oss-source --baseurl=http://linux-ftp.jf.intel.com/pub/mirrors/MeeGo-other/trunk-daily/builds/trunk/1.1.90.3.20110214.2/oss/repos/source/ --source
+
+-%packages
+-@MeeGo Core
+-@MeeGo Netbook Desktop
+-@X for Netbooks
+-@MeeGo Compliance
+-@MeeGo X Window System
+-@Virtual Machine Support
+-@Games
+-@Printing
+-@Base Double Byte IME Support
+-@MeeGo Base Development
+-
+-kernel
+-chromium
++%packages --ignoremissing
++libacl
++alsa-lib
++libattr
++basesystem
++bash
+ %end
+
+ %post
+-
+ # save a little bit of space at least...
+ rm -f /boot/initrd*
+
diff --git a/tests/mic_cases/test-creatprc/options b/tests/mic_cases/test-creatprc/options
new file mode 100644
index 0000000..9620766
--- /dev/null
+++ b/tests/mic_cases/test-creatprc/options
@@ -0,0 +1 @@
+sudo mic-image-creator -f livecd
diff --git a/tests/mic_cases/test-genimg/ks.p b/tests/mic_cases/test-genimg/ks.p
new file mode 100644
index 0000000..a5d57ea
--- /dev/null
+++ b/tests/mic_cases/test-genimg/ks.p
@@ -0,0 +1,376 @@
+--- ./mic_cases/base/test.ks 2011-02-25 09:21:41.778621925 +0800
++++ /home/zhou/Code/minimal.ks 2011-02-25 15:22:26.878620886 +0800
+@@ -1,66 +1,322 @@
+-#
+-# Do not Edit! Generated by:
+-# kickstarter.py
+-#
++# kickstart file for MeeGo minimal compliance image
++# Usage: $ sudo mic-image-creator --run-mode=0 --cache=mycachedir --format=fs --config=<meego-minimal-compliance-xxxx.ks> --package=tar.bz2 --include-source
+
+ lang en_US.UTF-8
+ keyboard us
+-timezone --utc America/New_York
++timezone --utc America/Los_Angeles
+ auth --useshadow --enablemd5
+-part / --size 3000 --ondisk sda --fstype=ext3
+-rootpw meego
+-xconfig --startxonboot
++part / --size 1600 --ondisk sda --fstype=ext3
++rootpw meego
+ bootloader --timeout=0 --append="quiet"
+-desktop --autologinuser=meego
+-user --name meego --groups audio,video --password meego
++user --name meego --groups audio,video --password meego
+
++repo --name=non-oss --baseurl=http://linux-ftp.jf.intel.com/pub/mirrors/MeeGo-other/trunk-daily/builds/trunk/1.1.90.3.20110214.2/non-oss/repos/ia32/packages/ --save --debuginfo --source --gpgkey=file:///eetc/pki/rpm-gpg/RPM-GPG-KEY-meego
+ repo --name=oss --baseurl=http://linux-ftp.jf.intel.com/pub/mirrors/MeeGo-other/trunk-daily/builds/trunk/1.1.90.3.20110214.2/oss/repos/ia32/packages/ --save --debuginfo --source --gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-meego
+
+-%packages
+-@MeeGo Core
+-@MeeGo Netbook Desktop
+-@X for Netbooks
+-@MeeGo Compliance
+-@MeeGo X Window System
+-@Virtual Machine Support
+-@Games
+-@Printing
+-@Base Double Byte IME Support
+-@MeeGo Base Development
+-
+-kernel
+-chromium
++%packages --ignoremissing
++libacl
++alsa-lib
++libattr
++basesystem
++bash
++bluez
++bluez-libs
++buteo-mtp
++buteo-syncfw
++buteo-syncml
++buteo-sync-plugins
++bzip2-libs
++cairo
++chkconfig
++connman
++ConsoleKit
++ConsoleKit-libs
++contextkit
++coreutils
++cryptsetup-luks
++curl
++libcurl
++cyrus-sasl-lib
++db4
++db4-utils
++dbus
++dbus-libs
++dbus-x11
++dbus-glib
++desktop-file-utils
++device-mapper-libs
++dsme
++libiphb
++e2fsprogs
++e2fsprogs-libs
++libcom_err
++libss
++eggdbus
++elfutils-libelf
++exempi
++expat
++farsight2
++file-libs
++filesystem
++flac
++fontconfig
++freetype
++gamin
++libgcc
++libstdc++
++GConf-dbus
++gdbm
++giflib
++glib2
++glibc
++glibc-common
++gmime
++gnupg2
++gnutls
++grep
++gssdp
++gst-plugins-base
++gst-plugins-good
++gstreamer
++gtk2
++gupnp
++gupnp-igd
++hwdata
++libicu
++jasper
++jasper-libs
++kcalcore
++kernel>=2.6.35
++keyutils-libs
++krb5-libs
++lcms
++lcms-libs
++libaccounts-glib
++libaccounts-qt
++libarchive
++libatasmart
++libcap
++libcreds2
++libdaemon
++libdres
++ohm-plugin-resolver
++libdrm
++libdsme
++libexif
++libffi
++libfontenc
++libgcrypt
++libgdbus
++libgee
++libgnome-keyring
++libgpg-error
++libgsf
++libical
++libICE
++libidn
++libiodata
++libjpeg
++libmng
++libnice
++libnl
++libogg
++libpng
++libprolog
++libqmlog
++libqttracker
++libresource
++libresource-client
++satsolver-tools
++libsignon
++libsignon-passwordplugin
++libsignon-saslplugin
++libSM
++libsndfile
++libsoup
++libtasn1
++libtelepathy
++libthai
++libtheora
++libtiff
++libtool-ltdl
++libtrace
++libusb
++libuser
++libvisual
++libvorbis
++libX11
++libXau
++libXaw
++libxcb
++libXcomposite
++libXcursor
++libXdamage
++libXext
++libXfixes
++libXfont
++libXft
++libXi
++libXinerama
++libxkbfile
++libxml2
++libXmu
++libXpm
++libXrandr
++libXrender
++libXt
++libXtst
++libXv
++libXxf86vm
++libzypp
++/usr/lib/libGL.so.1
++/usr/lib/libEGL.so.1
++mesa-libGLUT
++mesa-libOSMesa
++mingetty
++ncurses
++ncurses-base
++ncurses-libs
++nspr
++nss
++nss-softokn-freebl
++nss-sysinit
++o3read
++obexd
++ofono
++ohm
++ohm-config
++ohm-plugin-core
++ohm-plugins-misc
++openjpeg-libs
++openobex
++openssl
++orc
++PackageKit
++PackageKit-glib
++PackageKit-gtk-module
++PackageKit-qt
++PackageKit-zypp
++pam
++pango
++passwd
++pciutils
++pcre
++libphonon4
++pixman
++pm-utils
++polkit
++poppler
++poppler-utils
++popt
++pulseaudio
++python
++python-libs
++qjson
++libqtcore4
++libqtdbus4
++libqtdeclarative4
++libqtdeclarative4-folderlistmodel
++libqtdeclarative4-gestures
++libqtdeclarative4-particles
++libqtdesigner4
++libqtgui4
++libqtnetwork4
++libqtopengl4
++libqtscript4
++libqtsql4
++libqtsql4-sqlite
++libqtsvg4
++libqttest4
++libqtxml4
++libqtxmlpatterns4
++qtcontacts-tracker
++libdeclarative-contacts
++libdeclarative-multimedia
++libdeclarative-publishsubscribe
++libdeclarative-sensors
++libdeclarative-serviceframework
++libqtcontacts1
++libqtlocation1
++libqtmessaging1
++libqtmultimediakit1
++libqtpublishsubscribe1
++libqtsensors1
++libqtserviceframework1
++libqtsysteminfo1
++libqtversit1
++qt-mobility
++servicefw
++libqtwebkit4
++libqtwebkit-qmlwebkitplugin
++readline
++rpm
++rpm-libs
++rtkit
++sed
++sensorfw
++setup
++sg3_utils-libs
++shadow-utils
++shared-mime-info
++sofia-sip
++sofia-sip-glib
++speex
++sqlite
++swi-prolog
++swi-prolog-library
++swi-prolog-library-core
++sysvinit
++sysvinit-tools
++taglib
++telepathy-farsight
++telepathy-gabble
++telepathy-glib
++telepathy-mission-control
++telepathy-qt4
++telepathy-qt4-farsight
++telepathy-ring
++telepathy-sofiasip
++telepathy-stream-engine
++timed
++tinycdb
++totem-pl-parser
++tracker
++tzdata
++libgudev1
++libudev
++udev
++udisks
++upower
++usermode
++libblkid
++libuuid
++util-linux-ng
++wpa_supplicant
++xcb-util
++xorg-x11-font-utils
++xorg-x11-server
++xorg-x11-server-common
++xorg-x11-utils
++xorg-x11-utils-xdpyinfo
++xorg-x11-utils-xdriinfo
++xorg-x11-utils-xev
++xorg-x11-utils-xfd
++xorg-x11-utils-xfontsel
++xorg-x11-utils-xlsatoms
++xorg-x11-utils-xlsclients
++xorg-x11-utils-xlsfonts
++xorg-x11-utils-xprop
++xorg-x11-utils-xrandr
++xorg-x11-utils-xvinfo
++xorg-x11-utils-xwininfo
++xorg-x11-xauth
++xorg-x11-xkb-utils
++xz-libs
++zlib
+ %end
+
+ %post
+-
+-# save a little bit of space at least...
+-rm -f /boot/initrd*
+-
+ # make sure there aren't core files lying around
+ rm -f /core*
+-
+-
+-
+-# Prelink can reduce boot time
+-if [ -x /usr/sbin/prelink ]; then
+- /usr/sbin/prelink -aRqm
+-fi
+-
+-
+-# work around for poor key import UI in PackageKit
+-rm -f /var/lib/rpm/__db*
+ rpm --rebuilddb
+-
+-if [ -f /etc/pki/rpm-gpg/RPM-GPG-KEY-meego ]; then
+- rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-meego
+-fi
+-
+-
+-%end
+-
+-%post --nochroot
+-if [ -n "$IMG_NAME" ]; then
+- echo "BUILD: $IMG_NAME" >> $INSTALL_ROOT/etc/meego-release
+-fi
+ %end
diff --git a/tests/mic_cases/test-genimg/options b/tests/mic_cases/test-genimg/options
new file mode 100644
index 0000000..fe7c479
--- /dev/null
+++ b/tests/mic_cases/test-genimg/options
@@ -0,0 +1 @@
+sudo mic-image-creator -f fs
diff --git a/tests/mic_cases/test-imageformat/expect b/tests/mic_cases/test-imageformat/expect
new file mode 100644
index 0000000..c07440b
--- /dev/null
+++ b/tests/mic_cases/test-imageformat/expect
@@ -0,0 +1 @@
+Image format 'tar' isn't supported
diff --git a/tests/mic_cases/test-imageformat/ks.p b/tests/mic_cases/test-imageformat/ks.p
new file mode 100644
index 0000000..5b68493
--- /dev/null
+++ b/tests/mic_cases/test-imageformat/ks.p
@@ -0,0 +1,108 @@
+--- ./mic_cases/base/test.ks 2011-02-25 09:21:41.778621925 +0800
++++ /home/zhou/Code/handset.ks 2011-02-22 18:05:32.693146002 +0800
+@@ -1,62 +1,80 @@
+-#
++#
+ # Do not Edit! Generated by:
+ # kickstarter.py
+ #
+
+ lang en_US.UTF-8
+ keyboard us
+-timezone --utc America/New_York
++timezone --utc America/Los_Angeles
+ auth --useshadow --enablemd5
+-part / --size 3000 --ondisk sda --fstype=ext3
++part / --size 1700 --ondisk sda --fstype=ext3
+ rootpw meego
+ xconfig --startxonboot
+-bootloader --timeout=0 --append="quiet"
+-desktop --autologinuser=meego
++bootloader --timeout=2 --append="ro pci=noearly console=tty1 console=ttyS0 console=ttyMFD2 earlyprintk=mrst loglevel=8 s0ix_latency=160"
++desktop --autologinuser=meego --defaultdesktop=DUI --session="/usr/bin/mcompositor"
+ user --name meego --groups audio,video --password meego
+
+-repo --name=oss --baseurl=http://linux-ftp.jf.intel.com/pub/mirrors/MeeGo-other/trunk-daily/builds/trunk/1.1.90.3.20110214.2/oss/repos/ia32/packages/ --save --debuginfo --source --gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-meego
++repo --name=oss --baseurl=http://linux-ftp.jf.intel.com/pub/mirrors/MeeGo-other/trunk-daily/builds/trunk/1.1.90.3.20110214.2/oss/repos/ia32/packages/ --save --debuginfo --source --gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-meego
++repo --name=non-oss --baseurl=http://linux-ftp.jf.intel.com/pub/mirrors/MeeGo-other/trunk-daily/builds/trunk/1.1.90.3.20110214.2/non-oss/repos/ia32/packages/ --save --debuginfo --source --gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-meego
++repo --name=oss-source --baseurl=http://linux-ftp.jf.intel.com/pub/mirrors/MeeGo-other/trunk-daily/builds/trunk/1.1.90.3.20110214.2/oss/repos/source/ --source
++repo --name=non-oss-source --baseurl=http://linux-ftp.jf.intel.com/pub/mirrors/MeeGo-other/trunk-daily/builds/trunk/1.1.90.3.20110214.2/non-oss/repos/source/ --source
++
++%packages
+
+-%packages
+ @MeeGo Core
+-@MeeGo Netbook Desktop
+-@X for Netbooks
++@Minimal MeeGo X Window System
++@X for Handsets
+ @MeeGo Compliance
+-@MeeGo X Window System
+-@Virtual Machine Support
+-@Games
+-@Printing
+-@Base Double Byte IME Support
++@MeeGo Handset Desktop
++@MeeGo Handset Applications
++@Moorestown Support
+ @MeeGo Base Development
+
+-kernel
+-chromium
++kernel-adaptation-medfield
++#pulseaudio-modules-mfld
++
+ %end
+
+ %post
+
+-# save a little bit of space at least...
+-rm -f /boot/initrd*
++#Create Initrd if it does not exist and create symlinks for bzImage and initrd for kboot autoboot
++echo "ro pci=noearly console=tty1 console=ttyS0 console=ttyMFD2 earlyprintk=mrst loglevel=8 s0ix_latency=160" > /boot/kboot.cmdline
++
++echo "Checking for kernel......."
++Kernel_Name=`ls /boot | grep vmlinuz`
++if [ -f /boot/$Kernel_Name ]; then
++ Kernel_Ver=`echo $Kernel_Name | sed s/vmlinuz-//`
++ if [ -f /boot/initrd* ]; then
++ echo "Initrd exists" > /dev/null
++ else
++ /usr/libexec/mkmrstinitrd /boot/initrd-$Kernel_Ver.img $Kernel_Ver
++ fi
++ #Create Symlinks
++ cd /boot
++ ln -s $Kernel_Name bzImage
++ ln -s initrd-$Kernel_Ver.img initrd
++ ln -s kboot.cmdline cmdline
++else
++ echo "No Kernels were found"
++fi
+
+ # make sure there aren't core files lying around
+ rm -f /core*
+
+-
+-
+ # Prelink can reduce boot time
+ if [ -x /usr/sbin/prelink ]; then
+ /usr/sbin/prelink -aRqm
+ fi
+
++# open serial line console for embedded system
++echo "s0:235:respawn:/sbin/agetty -L 115200 ttyS0 vt100" >> /etc/inittab
++echo "s1:235:respawn:/sbin/agetty -L 115200 ttyMFD2 vt100" >> /etc/inittab
++echo "ttyMFD2" >> /etc/securetty
+
+ # work around for poor key import UI in PackageKit
+ rm -f /var/lib/rpm/__db*
+ rpm --rebuilddb
+
+-if [ -f /etc/pki/rpm-gpg/RPM-GPG-KEY-meego ]; then
+- rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-meego
+-fi
+-
+-
+ %end
+
+ %post --nochroot
diff --git a/tests/mic_cases/test-imageformat/options b/tests/mic_cases/test-imageformat/options
new file mode 100644
index 0000000..a1c0b2b
--- /dev/null
+++ b/tests/mic_cases/test-imageformat/options
@@ -0,0 +1 @@
+sudo mic-image-creator -f tar
diff --git a/tests/mic_cases/test-invalidrepostr/expect b/tests/mic_cases/test-invalidrepostr/expect
new file mode 100644
index 0000000..3ee4fbf
--- /dev/null
+++ b/tests/mic_cases/test-invalidrepostr/expect
@@ -0,0 +1 @@
+unable to load kickstart file
diff --git a/tests/mic_cases/test-invalidrepostr/ks.p b/tests/mic_cases/test-invalidrepostr/ks.p
new file mode 100644
index 0000000..38c6578
--- /dev/null
+++ b/tests/mic_cases/test-invalidrepostr/ks.p
@@ -0,0 +1,86 @@
+--- ./mic_cases/base/test.ks 2011-02-25 09:21:41.778621925 +0800
++++ ../tools/invalidrepo.ks 2011-02-21 17:04:40.663145997 +0800
+@@ -1,4 +1,4 @@
+-#
++#
+ # Do not Edit! Generated by:
+ # kickstarter.py
+ #
+@@ -7,47 +7,45 @@ lang en_US.UTF-8
+ keyboard us
+ timezone --utc America/New_York
+ auth --useshadow --enablemd5
+-part / --size 3000 --ondisk sda --fstype=ext3
++part / --size 2200 --ondisk sda --fstype=ext3
+ rootpw meego
+ xconfig --startxonboot
+ bootloader --timeout=0 --append="quiet"
+-desktop --autologinuser=meego
++desktop --autologinuser=meego --defaultdesktop=X-IVI --session=/usr/bin/startivi
+ user --name meego --groups audio,video --password meego
+
+-repo --name=oss --baseurl=http://linux-ftp.jf.intel.com/pub/mirrors/MeeGo-other/trunk-daily/builds/trunk/1.1.90.3.20110214.2/oss/repos/ia32/packages/ --save --debuginfo --source --gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-meego
+-
+-%packages
++repo --save=0 --debuginfo --source --name=core --baseurl=http://xxx.com --gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-meego
++%packages
+ @MeeGo Core
+-@MeeGo Netbook Desktop
+-@X for Netbooks
+ @MeeGo Compliance
++@X for IVI
++@IVI Desktop
+ @MeeGo X Window System
+-@Virtual Machine Support
+-@Games
+-@Printing
+-@Base Double Byte IME Support
++@MeeGo IVI Applications
+ @MeeGo Base Development
++@Development Tools
++
++kernel-adaptation-intel-automotive
++
++# forced for compliance...
++mesa-libEGL
+
+-kernel
+-chromium
+ %end
+
+ %post
+
++
+ # save a little bit of space at least...
+ rm -f /boot/initrd*
+
+ # make sure there aren't core files lying around
+ rm -f /core*
+
+-
+-
+ # Prelink can reduce boot time
+ if [ -x /usr/sbin/prelink ]; then
+ /usr/sbin/prelink -aRqm
+ fi
+
+-
+ # work around for poor key import UI in PackageKit
+ rm -f /var/lib/rpm/__db*
+ rpm --rebuilddb
+@@ -56,7 +54,6 @@ if [ -f /etc/pki/rpm-gpg/RPM-GPG-KEY-mee
+ rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-meego
+ fi
+
+-
+ %end
+
+ %post --nochroot
+@@ -64,3 +61,7 @@ if [ -n "$IMG_NAME" ]; then
+ echo "BUILD: $IMG_NAME" >> $INSTALL_ROOT/etc/meego-release
+ fi
+ %end
++
++
++
++
diff --git a/tests/mic_cases/test-invalidrepostr/options b/tests/mic_cases/test-invalidrepostr/options
new file mode 100644
index 0000000..9620766
--- /dev/null
+++ b/tests/mic_cases/test-invalidrepostr/options
@@ -0,0 +1 @@
+sudo mic-image-creator -f livecd
diff --git a/tests/mic_cases/test-misspkgs/expect b/tests/mic_cases/test-misspkgs/expect
new file mode 100644
index 0000000..b0b7d7f
--- /dev/null
+++ b/tests/mic_cases/test-misspkgs/expect
@@ -0,0 +1 @@
+Failed to find package 'zhou'
diff --git a/tests/mic_cases/test-misspkgs/ks.p b/tests/mic_cases/test-misspkgs/ks.p
new file mode 100644
index 0000000..9c75428
--- /dev/null
+++ b/tests/mic_cases/test-misspkgs/ks.p
@@ -0,0 +1,41 @@
+--- ./mic_cases/base/test.ks 2011-02-25 09:21:41.778621925 +0800
++++ losepkg.ks 2011-02-25 15:10:02.358622001 +0800
+@@ -1,4 +1,4 @@
+-#
++#
+ # Do not Edit! Generated by:
+ # kickstarter.py
+ #
+@@ -15,25 +15,18 @@ desktop --autologinuser=meego
+ user --name meego --groups audio,video --password meego
+
+ repo --name=oss --baseurl=http://linux-ftp.jf.intel.com/pub/mirrors/MeeGo-other/trunk-daily/builds/trunk/1.1.90.3.20110214.2/oss/repos/ia32/packages/ --save --debuginfo --source --gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-meego
++repo --name=oss-source --baseurl=http://linux-ftp.jf.intel.com/pub/mirrors/MeeGo-other/trunk-daily/builds/trunk/1.1.90.3.20110214.2/oss/repos/source/ --source
+
+ %packages
+-@MeeGo Core
+-@MeeGo Netbook Desktop
+-@X for Netbooks
+-@MeeGo Compliance
+-@MeeGo X Window System
+-@Virtual Machine Support
+-@Games
+-@Printing
+-@Base Double Byte IME Support
+-@MeeGo Base Development
+-
+-kernel
+-chromium
++libacl
++alsa-lib
++libattr
++basesystem
++bash
++zhou
+ %end
+
+ %post
+-
+ # save a little bit of space at least...
+ rm -f /boot/initrd*
+
diff --git a/tests/mic_cases/test-misspkgs/options b/tests/mic_cases/test-misspkgs/options
new file mode 100644
index 0000000..9620766
--- /dev/null
+++ b/tests/mic_cases/test-misspkgs/options
@@ -0,0 +1 @@
+sudo mic-image-creator -f livecd
diff --git a/tests/mic_cases/test-norepo/expect b/tests/mic_cases/test-norepo/expect
new file mode 100644
index 0000000..636d818
--- /dev/null
+++ b/tests/mic_cases/test-norepo/expect
@@ -0,0 +1 @@
+No repositories found
diff --git a/tests/mic_cases/test-norepo/ks.p b/tests/mic_cases/test-norepo/ks.p
new file mode 100644
index 0000000..9eff66a
--- /dev/null
+++ b/tests/mic_cases/test-norepo/ks.p
@@ -0,0 +1,85 @@
+--- ./mic_cases/base/test.ks 2011-02-25 09:21:41.778621925 +0800
++++ ../tools/norepo.ks 2011-02-21 16:29:29.933146021 +0800
+@@ -1,4 +1,4 @@
+-#
++#
+ # Do not Edit! Generated by:
+ # kickstarter.py
+ #
+@@ -7,47 +7,44 @@ lang en_US.UTF-8
+ keyboard us
+ timezone --utc America/New_York
+ auth --useshadow --enablemd5
+-part / --size 3000 --ondisk sda --fstype=ext3
++part / --size 2200 --ondisk sda --fstype=ext3
+ rootpw meego
+ xconfig --startxonboot
+ bootloader --timeout=0 --append="quiet"
+-desktop --autologinuser=meego
++desktop --autologinuser=meego --defaultdesktop=X-IVI --session=/usr/bin/startivi
+ user --name meego --groups audio,video --password meego
+
+-repo --name=oss --baseurl=http://linux-ftp.jf.intel.com/pub/mirrors/MeeGo-other/trunk-daily/builds/trunk/1.1.90.3.20110214.2/oss/repos/ia32/packages/ --save --debuginfo --source --gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-meego
+-
+-%packages
++%packages
+ @MeeGo Core
+-@MeeGo Netbook Desktop
+-@X for Netbooks
+ @MeeGo Compliance
++@X for IVI
++@IVI Desktop
+ @MeeGo X Window System
+-@Virtual Machine Support
+-@Games
+-@Printing
+-@Base Double Byte IME Support
++@MeeGo IVI Applications
+ @MeeGo Base Development
++@Development Tools
++
++kernel-adaptation-intel-automotive
++
++# forced for compliance...
++mesa-libEGL
+
+-kernel
+-chromium
+ %end
+
+ %post
+
++
+ # save a little bit of space at least...
+ rm -f /boot/initrd*
+
+ # make sure there aren't core files lying around
+ rm -f /core*
+
+-
+-
+ # Prelink can reduce boot time
+ if [ -x /usr/sbin/prelink ]; then
+ /usr/sbin/prelink -aRqm
+ fi
+
+-
+ # work around for poor key import UI in PackageKit
+ rm -f /var/lib/rpm/__db*
+ rpm --rebuilddb
+@@ -56,7 +53,6 @@ if [ -f /etc/pki/rpm-gpg/RPM-GPG-KEY-mee
+ rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-meego
+ fi
+
+-
+ %end
+
+ %post --nochroot
+@@ -64,3 +60,7 @@ if [ -n "$IMG_NAME" ]; then
+ echo "BUILD: $IMG_NAME" >> $INSTALL_ROOT/etc/meego-release
+ fi
+ %end
++
++
++
++
diff --git a/tests/mic_cases/test-norepo/options b/tests/mic_cases/test-norepo/options
new file mode 100644
index 0000000..9620766
--- /dev/null
+++ b/tests/mic_cases/test-norepo/options
@@ -0,0 +1 @@
+sudo mic-image-creator -f livecd
diff --git a/tests/mic_cases/test-root/expect b/tests/mic_cases/test-root/expect
new file mode 100644
index 0000000..b21a32e
--- /dev/null
+++ b/tests/mic_cases/test-root/expect
@@ -0,0 +1 @@
+You must run mic-image-creator as root
diff --git a/tests/mic_cases/test-root/ks.p b/tests/mic_cases/test-root/ks.p
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/mic_cases/test-root/ks.p
diff --git a/tests/mic_cases/test-root/options b/tests/mic_cases/test-root/options
new file mode 100644
index 0000000..b2de23a
--- /dev/null
+++ b/tests/mic_cases/test-root/options
@@ -0,0 +1 @@
+mic-image-creator -f livecd
diff --git a/tests/mic_cases/test-runmode/expect b/tests/mic_cases/test-runmode/expect
new file mode 100644
index 0000000..78355bb
--- /dev/null
+++ b/tests/mic_cases/test-runmode/expect
@@ -0,0 +1 @@
+invalid run mode
diff --git a/tests/mic_cases/test-runmode/ks.p b/tests/mic_cases/test-runmode/ks.p
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/mic_cases/test-runmode/ks.p
diff --git a/tests/mic_cases/test-runmode/options b/tests/mic_cases/test-runmode/options
new file mode 100644
index 0000000..ef8fa9d
--- /dev/null
+++ b/tests/mic_cases/test-runmode/options
@@ -0,0 +1 @@
+sudo mic-image-creator -f livecd --run-mode=2
diff --git a/tests/testbase.py b/tests/testbase.py
new file mode 100644
index 0000000..098a02c
--- /dev/null
+++ b/tests/testbase.py
@@ -0,0 +1,61 @@
+#!/usr/bin/python
+import os
+import subprocess, re, shutil, glob
+import gettext
+
+_ = gettext.lgettext
+COLOR_BLACK = "\033[00m"
+COLOR_RED = "\033[1;31m"
+
+def PrepEnv(cases_dir, case, work_env):
+ """prepare working env"""
+ for one in glob.glob(os.path.join(cases_dir, 'base', '*')):
+ shutil.copy(one, work_env)
+ for other in glob.glob(os.path.join(cases_dir, 'test-'+case, '*')):
+ shutil.copy(other, work_env)
+
+def ImgCheck(work_env):
+ """check image generate"""
+ genImage = False
+ for file in os.listdir(work_env):
+ m = re.match('^meego-.*', file)
+ if m:
+ genImage = True
+ break
+ return genImage
+
+def RunandCheck(object, work_env):
+ """run mic-image-creator command and check something"""
+ ret = False
+
+ cwd = os.getcwd()
+ os.chdir(work_env)
+ os.system("patch -s < ks.p")
+ #set value of "expect"
+ expect = None
+ if "expect" in os.listdir(work_env):
+ exp_f = open('expect', 'r')
+ exp = exp_f.read()
+ if len(exp) > 0:
+ expect = exp.strip()
+ #set cmdline
+ opt_f = open('options','r')
+ args = opt_f.read().strip()+' -c test.ks'
+
+ dev_null = os.open('/dev/null',os.O_WRONLY)
+ proc = subprocess.Popen(args,stdout = dev_null,stderr=subprocess.PIPE,shell=True)
+ os.close(dev_null)
+ errorinfo = proc.communicate()[1]
+ #check
+ if expect:
+ if errorinfo.find(expect) != -1:#FIXME
+ ret =True
+ else:
+ proc.wait()
+ ret = ImgCheck(work_env)
+ os.chdir(cwd)
+
+ try:
+ object.assertTrue(ret)
+ except object.failureException:
+ raise object.failureException(_("%s%s%s") %(COLOR_RED,errorinfo,COLOR_BLACK))