configurationengine/source/plugins/symbian/integration-test/unittest_generate.py
changeset 3 e7e0ae78773e
parent 0 2e8eeb919028
child 5 d2c80f5cab53
--- a/configurationengine/source/plugins/symbian/integration-test/unittest_generate.py	Fri Mar 12 08:30:17 2010 +0200
+++ b/configurationengine/source/plugins/symbian/integration-test/unittest_generate.py	Tue Aug 10 14:29:28 2010 +0300
@@ -16,7 +16,7 @@
 #
 
 import sys, os, shutil, unittest
-import __init__
+
 from testautomation.base_testcase import BaseTestCase
 from testautomation import zip_dir
 
@@ -25,7 +25,7 @@
 if sys.platform == "win32":
     CONE_SCRIPT = "cone.cmd"
 else:
-    CONE_SCRIPT = "cone.sh"
+    CONE_SCRIPT = "cone"
 
 def get_cmd(action='generate'):
     """Return the command used to run the ConE sub-action"""
@@ -71,7 +71,21 @@
     def test_generate_all_impls_on_last_layer_on_file_storage(self):
         project_dir = os.path.join(ROOT_PATH, "testdata/generate/project")
         self.assert_exists_and_contains_something(project_dir)
-        self._run_test_generate_all_impls_on_last_layer('temp/gen_ll1', project_dir)
+        self._run_test_generate_all_impls_on_last_layer(
+            workdir = 'temp/gen_ll1',
+            project = project_dir,
+            expected = os.path.join(ROOT_PATH, 'testdata/generate/expected_last_layer'),
+            args = '--layer -1',
+            linux_ignores = ['anim1.mbm', 'anim2.mif', '20000000.txt', '10207114',  'themepackage.mbm', 'themepackage.mif', '12340001', '12340002'])
+    
+    def test_generate_all_impls_target_rofs2_file_storage(self):
+        project_dir = os.path.join(ROOT_PATH, "testdata/generate/project")
+        self.assert_exists_and_contains_something(project_dir)
+        self._run_test_generate_all_impls_on_last_layer(
+            workdir = 'temp/gen_ll_rofs2',
+            project = project_dir,
+            expected = os.path.join(ROOT_PATH, 'testdata/generate/expected_rofs2'),
+            args = '--all-layers --impl-tag target:rofs2')
     
     def test_generate_all_impls_on_last_layer_on_zip_storage(self):
         project_dir = os.path.join(ROOT_PATH, "testdata/generate/project")
@@ -82,9 +96,14 @@
         zip_dir.zip_dir(project_dir, project_zip, [zip_dir.SVN_IGNORE_PATTERN])
         self.assert_exists_and_contains_something(project_zip)
         
-        self._run_test_generate_all_impls_on_last_layer('temp/gen_ll2', project_zip)
+        self._run_test_generate_all_impls_on_last_layer(
+            workdir = 'temp/gen_ll2',
+            project = project_zip,
+            expected = os.path.join(ROOT_PATH, 'testdata/generate/expected_last_layer'),
+            args = '--layer -1',
+            linux_ignores = ['anim1.mbm', 'anim2.mif', '20000000.txt', '10207114', 'themepackage.mbm', 'themepackage.mif', '12340001', '12340002' ])
     
-    def _run_test_generate_all_impls_on_last_layer(self, workdir, project):
+    def _run_test_generate_all_impls_on_last_layer(self, workdir, project, expected, args='', linux_ignores=[]):
         # Create a temp workdir and go there to run the test
         orig_workdir = os.getcwd()
         workdir = self._prepare_workdir(workdir)
@@ -92,62 +111,57 @@
         
         try:
             # Run the generation command
-            cmd = '%s -p "%s" --output output --layer -1 --add-setting-file imaker_variantdir.cfg' % (get_cmd(), project)
+            cmd = '%s -p "%s" --output output --add-setting-file imaker_variantdir.cfg %s' % (get_cmd(), project, args)
             self.run_command(cmd)
             
-            # Check that all expected output files are generated
-            def check(path):
-                self.assert_exists_and_contains_something("output/" + path)
-            
-            try:
-                check("content/animations/anim1.mbm")
-                check("content/animations/anim2.mif")
-            except AssertionError:
-                if ' ' in ROOT_PATH:
-                    self.fail("Known bug (#177)")
-                else:
-                    raise
-            
-            check("content/data/sounds/test.mp3")
-            check("content/data/sequence_setting_test.txt")
-            check("content/private/10202BE9/10000000.txt")
-            check("content/private/10202BE9/12341001.txt")
-            check("content/private/10202BE9/12341002.txt")
-            check("content/private/10202BE9/20000000.txt")
-            check("content/sound_folder/test2.mp3")
-            check("hcr_test.h")
-            check("content/private/10207114/import/12340001/themepackage.mbm")
-            check("content/private/10207114/import/12340001/themepackage.mif")
-            check("content/private/10207114/import/12340001/themepackage.skn")
+            self.assert_dir_contents_equal('output', expected, ['.svn'] + linux_ignores)
+        finally:
+            os.chdir(orig_workdir)
+
+class TestDeltaCenrepGeneration(BaseTestCase):
+    
+    def test_generate_deltacenreps(self):
+        self._run_test_generation(
+            workdir      = 'temp/deltacenrep/deltacenrep',
+            expected_dir = 'testdata/deltacenrep/deltacenrep_expected',
+            tag_args     = '--impl-tag target:rofs3 --impl-tag crml:deltacenrep')
+    
+    def test_generate_normal_cenreps_from_deltacenrep_project(self):
+        self._run_test_generation(
+            workdir      = 'temp/deltacenrep/normalcenrep',
+            expected_dir = 'testdata/deltacenrep/normalcenrep_expected',
+            tag_args     = '--impl-tag target:rofs3')
+    
+    def _run_test_generation(self, workdir, expected_dir, tag_args):
+        PROJECT_DIR = os.path.join(ROOT_PATH, 'testdata/deltacenrep/project')
+        EXPECTED_DIR = os.path.join(ROOT_PATH, expected_dir)
+        
+        # Create a temp workdir and go there to run the test
+        orig_workdir = os.getcwd()
+        workdir = os.path.join(ROOT_PATH, workdir)
+        self.recreate_dir(workdir)
+        os.chdir(workdir)
+        
+        try:
+            # Run the generation command
+            cmd = '%(cmd)s -p "%(project)s" --output output --layer -1 '\
+                  '--add-setting-file imaker_variantdir.cfg %(args)s'\
+                  % {'cmd'      : get_cmd(),
+                     'project'  : PROJECT_DIR,
+                     'args'     : tag_args}
+            self.run_command(cmd)
+            OUTPUT_DIR = os.path.abspath('output')
             
-            # Check that files that should not have been generated are not
-            def check_not_gen(path):
-                self.assertFalse(os.path.exists("output/" + path),
-                                 "'%s' was generated when it should not have been!" % path)
-            check_not_gen("content/private/10202BE9/ABCD0000.txt")
-            check_not_gen("content/private/10202BE9/12341000.txt")
+            # Assert that the CenRep files are equal
+            self.assert_dir_contents_equal(OUTPUT_DIR, EXPECTED_DIR, ignore=['.svn', 'include'])
             
-            # Check that the data has been generated correctly
-            self.assert_file_contains(
-                "output/content/private/10202BE9/12341002.txt",
-                "0x1 int 42 0 cap_rd=alwayspass cap_wr=WriteDeviceData",
-                encoding='utf-16')
-            self.assert_file_contains(
-                "output/content/private/10202BE9/10000000.txt",
-                r'0x1 string "Z:\\data\\sounds\\test.mp3" 0 cap_rd=alwayspass cap_wr=WriteDeviceData',
-                encoding='utf-16')
-            self.assert_file_contains(
-                "output/content/private/10202BE9/12341001.txt",
-                u'0x1 string "default string カタカナ <&> カタカナ" 0 cap_rd=alwayspass cap_wr=WriteDeviceData',
-                encoding='utf-16')
-            self.assert_file_contains(
-                "output/content/private/10202BE9/20000000.txt",
-                ['0x11 string "305397761" 0',
-                 '0x12 string "305397761" 0',
-                 '0x13 string "305397761" 0',
-                 '0x21 string "305397762" 0',
-                 '0x22 string "305397762" 0'],
-                encoding='utf-16')
+            # If generating delta CenReps, check also the iby file
+            OUTPUT_IBY = os.path.join(OUTPUT_DIR, 'include/deltacenreps.iby')
+            EXPECTED_IBY = os.path.join(EXPECTED_DIR, 'include/deltacenreps.iby')
+            if os.path.exists(EXPECTED_IBY):
+                self.assert_file_contents_equal(OUTPUT_IBY, EXPECTED_IBY,
+                    ignore_patterns = [r'(\w:)?[\\/].*output[\\/]deltacenreps[\\/]'],
+                    ignore_endline_style = True)
         finally:
             os.chdir(orig_workdir)