diff options
Diffstat (limited to 'test')
68 files changed, 15220 insertions, 0 deletions
diff --git a/test/functional-tests/ACTCampaignEngine.py b/test/functional-tests/ACTCampaignEngine.py new file mode 100755 index 0000000..6d39436 --- /dev/null +++ b/test/functional-tests/ACTCampaignEngine.py @@ -0,0 +1,67 @@ +#!/usr/bin/python2 +# -*-coding:utf-8 -* + +# Copyright (c) 2011-2015, Intel Corporation +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, +# are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation and/or +# other materials provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its contributors +# may be used to endorse or promote products derived from this software without +# specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +""" +Create a test suite for all tests about SET/GET commands + +Uses PfwSetTsetSuite to create a single instance of the HAL +for all the SET/GEt commands. + +These commands are tested using the methods of the classes +"BooleanTestCase", etc... +""" + +import sys +import unittest +from Util import PfwUnitTestLib + +class Logger(object): + + def __init__(self, filename="Default.log"): + self.terminal = sys.stdout + self.log = open(filename, "a") + + def write(self, message): + self.terminal.write(message) + self.log.write(message) + +def testsRunner(testDirectory): + + tests = unittest.defaultTestLoader.discover(testDirectory, pattern='t*.py') + runner = unittest.TextTestRunner(verbosity=2) + + return runner.run(tests).wasSuccessful() + +def main(): + sys.exit(not testsRunner('PfwTestCase')) + +if __name__ == "__main__": + main() diff --git a/test/functional-tests/PfwTestCase/Domains/__init__.py b/test/functional-tests/PfwTestCase/Domains/__init__.py new file mode 100644 index 0000000..e49f417 --- /dev/null +++ b/test/functional-tests/PfwTestCase/Domains/__init__.py @@ -0,0 +1,10 @@ +""" +Domains Package : All testcases about DOMAINS functions in PFW : + - domains configuration selections and restore + - domains creation and deletion + - domain rename + - rules management + - elements management + - elements sequences in domains + - domains split +"""
\ No newline at end of file diff --git a/test/functional-tests/PfwTestCase/Domains/tDomain_Configuration.py b/test/functional-tests/PfwTestCase/Domains/tDomain_Configuration.py new file mode 100644 index 0000000..e5fcfed --- /dev/null +++ b/test/functional-tests/PfwTestCase/Domains/tDomain_Configuration.py @@ -0,0 +1,505 @@ +# -*-coding:utf-8 -* + +# Copyright (c) 2011-2015, Intel Corporation +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, +# are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation and/or +# other materials provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its contributors +# may be used to endorse or promote products derived from this software without +# specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +""" +Creation, renaming and deletion configuration testcases + +List of tested functions : +-------------------------- + - [listConfigurations] function + - [createConfiguration] function + - [deleteConfiguration] function + - [renameConfiguration] function + +Test cases : +------------ + - Testing configuration creation error + - Testing configuration renaming error + - Testing configuration deletion error + - Testing nominal case +""" +import os +from Util.PfwUnitTestLib import PfwTestCase +from Util import ACTLogging +log=ACTLogging.Logger() + + +# Test of Domains - Rename +class TestCases(PfwTestCase): + def setUp(self): + self.pfw.sendCmd("setTuningMode", "on") + self.domain_name = "domain_test" + self.conf_test = "conf_white" + self.conf_test_renamed = "conf_black" + self.new_conf_number = 5 + + def tearDown(self): + self.pfw.sendCmd("setTuningMode", "off") + + def test_Conf_Creation_Error(self): + """ + Testing configuration creation error + ------------------------------------ + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - Create an already existent configuration + - Create a configuration with no name specified + - Create a configuration on a wrong domain name + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [createConfiguration] function + - [createDomain] function + - [listConfigurations] function + - [deleteConfiguration] function + - [deleteDomain] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - no configuration created + - existent configurations not affected by error + """ + log.D(self.test_Conf_Creation_Error.__doc__) + # New domain creation for testing purpose + log.I("New domain creation for testing purpose : %s" % (self.domain_name)) + log.I("command [createDomain]") + out, err = self.pfw.sendCmd("createDomain",self.domain_name, "") + assert out == "Done", out + assert err == None, "ERROR : command [createDomain] - Error while creating domain %s" % (self.domain_name) + log.I("command [createDomain] correctly executed") + log.I("Domain %s created" % (self.domain_name)) + + # New configurations creation for testing purpose + for iteration in range (self.new_conf_number): + new_conf_name = "".join([self.conf_test, "_", str(iteration)]) + log.I("New configuration %s creation for domain %s" % (new_conf_name,self.domain_name)) + log.I("command [createConfiguration]") + out, err = self.pfw.sendCmd("createConfiguration",self.domain_name,new_conf_name) + assert out == "Done", out + assert err == None, "ERROR : command [createConfiguration] - Error while creating configuration %s" % (new_conf_name) + log.I("command [createConfiguration] correctly executed") + log.I("Configuration %s created for domain %s" % (new_conf_name,self.domain_name)) + + # Domain configurations listing backup + log.I("Configurations listing for domain %s" % (self.domain_name)) + log.I("command [listConfigurations]") + out, err = self.pfw.sendCmd("listConfigurations",self.domain_name, "") + assert err == None, "ERROR : command [listConfigurations] - Error while listing configurations for domain %s" % (self.domain_name) + log.I("command [listConfigurations] correctly executed") + # Saving configurations names + f_configurations_backup = open("f_configurations_backup", "w") + f_configurations_backup.write(out) + f_configurations_backup.close() + + # New configurations creation error + log.I("Creating an already existent configurations names") + for iteration in range (self.new_conf_number): + new_conf_name = "".join([self.conf_test, "_", str(iteration)]) + log.I("Trying to create already existent %s configuration for domain %s" % (new_conf_name,self.domain_name)) + log.I("command [createConfiguration]") + out, err = self.pfw.sendCmd("createConfiguration",self.domain_name,new_conf_name) + assert out != "Done", "ERROR : command [createConfiguration] - Error not detected while creating already existent configuration %s" % (new_conf_name) + assert err == None, "ERROR : command [createConfiguration] - Error while creating configuration %s" % (new_conf_name) + log.I("command [createConfiguration] correctly executed") + log.I("error correctly detected, no configuration created") + log.I("Creating a configuration without specifying a name") + out, err = self.pfw.sendCmd("createConfiguration",self.domain_name) + assert out != "Done", "ERROR : command [createConfiguration] - Error not detected while creating a configuration without specifying a name" + assert err == None, "ERROR : command [createConfiguration] - Error while creating configuration" + log.I("error correctly detected") + log.I("Creating a configuration on a wrong domain name") + new_conf_name = "new_conf" + out, err = self.pfw.sendCmd("createConfiguration","wrong_domain_name",new_conf_name) + assert out != "Done", "ERROR : command [createConfiguration] - Error not detected while creating a configuration on a wrong domain name" + assert err == None, "ERROR : command [createConfiguration] - Error while creating configuration" + log.I("error correctly detected") + + # New domain configurations listing + log.I("Configurations listing for domain %s" % (self.domain_name)) + log.I("command [listConfigurations]" ) + out, err = self.pfw.sendCmd("listConfigurations",self.domain_name, "") + assert err == None, "ERROR : command [listConfigurations] - Error while listing configurations for domain %s" % (self.domain_name) + log.I("command [listConfigurations] correctly executed") + # Saving configurations names + f_configurations = open("f_configurations", "w") + f_configurations.write(out) + f_configurations.close() + + # Checking configurations names integrity + log.I("Configurations listing conformity check") + f_configurations = open("f_configurations", "r") + f_configurations_backup = open("f_configurations_backup", "r") + for iteration in range(self.new_conf_number): + listed_conf_backup = f_configurations_backup.readline().strip('\n') + listed_conf = f_configurations.readline().strip('\n') + assert listed_conf==listed_conf_backup, "ERROR : Error while listing configuration %s (found %s)" % (listed_conf_backup, listed_conf) + log.I("No change detected, listed configurations names conform to expected values") + + # New domain deletion + log.I("End of test, new domain deletion") + log.I("command [deleteDomain]") + out, err = self.pfw.sendCmd("deleteDomain",self.domain_name, "") + assert out == "Done", "ERROR : %s" % (out) + assert err == None, "ERROR : command [deleteDomain] - Error while deleting domain %s" % (self.domain_name) + log.I("command [deleteDomain] correctly executed") + + # Closing and deleting temp files + f_configurations_backup.close() + os.remove("f_configurations_backup") + f_configurations.close() + os.remove("f_configurations") + + def test_Conf_Renaming_Error(self): + """ + Testing configuration renaming error + ------------------------------------ + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - Rename a configuration with an already used name + - Rename a configuration with no name specified + - Rename a configuration on a wrong domain name + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [renameConfiguration] function + - [createDomain] function + - [listConfigurations] function + - [createConfiguration] function + - [deleteConfiguration] function + - [deleteDomain] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - error detected + - no configuration created + - existent configurations not affected by error + """ + log.D(self.test_Conf_Renaming_Error.__doc__) + # New domain creation for testing purpose + log.I("New domain creation for testing purpose : %s" % (self.domain_name)) + log.I("command [createDomain]") + out, err = self.pfw.sendCmd("createDomain",self.domain_name, "") + assert out == "Done", out + assert err == None, "ERROR : command [createDomain] - Error while creating domain %s" % (self.domain_name) + log.I("command [createDomain] correctly executed") + log.I("Domain %s created" % (self.domain_name)) + + # New configurations creation for testing purpose + for iteration in range (self.new_conf_number): + new_conf_name = "".join([self.conf_test, "_", str(iteration)]) + log.I("New configuration %s creation for domain %s" % (new_conf_name,self.domain_name)) + log.I("command [createConfiguration]") + out, err = self.pfw.sendCmd("createConfiguration",self.domain_name,new_conf_name) + assert out == "Done", out + assert err == None, "ERROR : command [createConfiguration] - Error while creating configuration %s" % (new_conf_name) + log.I("command [createConfiguration] correctly executed") + log.I("Configuration %s created for domain %s" % (new_conf_name,self.domain_name)) + + # Domain configurations listing backup + log.I("Configurations listing for domain %s" % (self.domain_name)) + log.I("command [listConfigurations]") + out, err = self.pfw.sendCmd("listConfigurations",self.domain_name, "") + assert err == None, "ERROR : command [listConfigurations] - Error while listing configurations for domain %s" % (self.domain_name) + log.I("command [listConfigurations] correctly executed") + # Saving configurations names + f_configurations_backup = open("f_configurations_backup", "w") + f_configurations_backup.write(out) + f_configurations_backup.close() + + # New configurations renaming error + log.I("renaming a configuration with an already used name") + for iteration in range (self.new_conf_number-1): + conf_name = "".join([self.conf_test, "_", str(iteration)]) + new_conf_name = "".join([self.conf_test, "_", str(iteration+1)]) + log.I("Trying to rename %s on domain %s with an already used name : %s" % (conf_name,self.domain_name,new_conf_name)) + log.I("command [renameConfiguration]" ) + out, err = self.pfw.sendCmd("renameConfiguration",self.domain_name,conf_name,new_conf_name) + assert out != "Done", "ERROR : command [renameConfiguration] - Error not detected while renaming configuration %s with an already used name" % (new_conf_name) + assert err == None, "ERROR : command [renameConfiguration] - Error while renaming configuration %s" % (new_conf_name) + log.I("command [renameConfiguration] correctly executed") + log.I("error correctly detected, no configuration renamed") + log.I("renaming a configuration without specifying a new name") + out, err = self.pfw.sendCmd("renameConfiguration",self.domain_name,new_conf_name) + assert out != "Done", "ERROR : command [renameConfiguration] - Error not detected while renaming a configuration without specifying a new name" + assert err == None, "ERROR : command [renameConfiguration] - Error while renaming configuration" + log.I("error correctly detected, no configuration renamed") + log.I("renaming a configuration on a wrong domain name") + new_conf_name = "new_conf" + out, err = self.pfw.sendCmd("renameConfiguration","wrong_domain_name",new_conf_name,"Configuration") + assert out != "Done", "ERROR : command [renameConfiguration] - Error not detected while renaming a configuration on a wrong domain name" + assert err == None, "ERROR : command [renameConfiguration] - Error while renaming configuration" + log.I("error correctly detected, no configuration renamed") + + # New domain configurations listing + log.I("Configurations listing for domain %s" % (self.domain_name)) + log.I("command [listConfigurations]") + out, err = self.pfw.sendCmd("listConfigurations",self.domain_name, "") + assert err == None, "ERROR : command [listConfigurations] - Error while listing configurations for domain %s" % (self.domain_name) + log.I("command [listConfigurations] correctly executed") + # Saving configurations names + f_configurations = open("f_configurations", "w") + f_configurations.write(out) + f_configurations.close() + + # Checking configurations names integrity + log.I("Configurations listing conformity check") + f_configurations = open("f_configurations", "r") + f_configurations_backup = open("f_configurations_backup", "r") + for iteration in range(self.new_conf_number): + listed_conf_backup = f_configurations_backup.readline().strip('\n') + listed_conf = f_configurations.readline().strip('\n') + assert listed_conf==listed_conf_backup, "ERROR : Error while listing configuration %s (found %s)" % (listed_conf_backup, listed_conf) + log.I("No change detected, listed configurations names conform to expected values") + + # Testing domain deletion + log.I("End of test, new domain deletion") + log.I("command [deleteDomain]") + out, err = self.pfw.sendCmd("deleteDomain",self.domain_name, "") + assert out == "Done", "ERROR : %s" % (out) + assert err == None, "ERROR : command [deleteDomain] - Error while deleting domain %s" % (self.domain_name) + log.I("command [deleteDomain] correctly executed") + + # Closing and deleting temp files + f_configurations_backup.close() + os.remove("f_configurations_backup") + f_configurations.close() + os.remove("f_configurations") + + def test_Conf_Deletion_Error(self): + """ + Testing configuration deletion error + ------------------------------------ + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - Delete a configuration with a non existent name + - Delete a configuration with no name specified + - Delete a configuration on a wrong domain name + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [deleteConfiguration] function + - [createDomain] function + - [listConfigurations] function + - [createConfiguration] function + - [deleteDomain] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - error detected + - no configuration created + - existent configurations not affected by error + """ + print self.test_Conf_Renaming_Error.__doc__ + # New domain creation for testing purpose + log.I("New domain creation for testing purpose : %s" % (self.domain_name)) + log.I("command [createDomain]") + out, err = self.pfw.sendCmd("createDomain",self.domain_name, "") + assert out == "Done", out + assert err == None, "ERROR : command [createDomain] - Error while creating domain %s" % (self.domain_name) + log.I("command [createDomain] correctly executed") + log.I("Domain %s created" % (self.domain_name)) + + # New configurations creation for testing purpose + for iteration in range (self.new_conf_number): + new_conf_name = "".join([self.conf_test, "_", str(iteration)]) + log.I("New configuration %s creation for domain %s" % (new_conf_name,self.domain_name)) + log.I("command [createConfiguration]") + out, err = self.pfw.sendCmd("createConfiguration",self.domain_name,new_conf_name) + assert out == "Done", out + assert err == None, "ERROR : command [createConfiguration] - Error while creating configuration %s" % (new_conf_name) + log.I("command [createConfiguration] correctly executed") + log.I("Configuration %s created for domain %s" % (new_conf_name,self.domain_name)) + + # Domain configurations listing backup + log.I("Configurations listing for domain %s" % (self.domain_name)) + log.I("command [listConfigurations]") + out, err = self.pfw.sendCmd("listConfigurations",self.domain_name, "") + assert err == None, "ERROR : command [listConfigurations] - Error while listing configurations for domain %s" % (self.domain_name) + log.I("command [listConfigurations] correctly executed") + # Saving configurations names + f_configurations_backup = open("f_configurations_backup", "w") + f_configurations_backup.write(out) + f_configurations_backup.close() + + # Configurations deletion errors + log.I("Trying various deletions error test cases") + log.I("Trying to delete a wrong configuration name on domain %s" % (self.domain_name)) + log.I("command [deleteConfiguration]") + out, err = self.pfw.sendCmd("deleteConfiguration",self.domain_name,"wrong_configuration_name") + assert out != "Done", "ERROR : command [deleteConfiguration] - Error not detected while deleting non existent configuration name" + assert err == None, "ERROR : command [deleteConfiguration] - Error while deleting configuration" + log.I("command [deleteConfiguration] correctly executed") + log.I("error correctly detected, no configuration deleted") + log.I("deleting a configuration with no name specified") + out, err = self.pfw.sendCmd("deleteConfiguration",self.domain_name) + assert out != "Done", "ERROR : command [deleteConfiguration] - Error not detected while deleting a configuration without specifying a name" + assert err == None, "ERROR : command [deleteConfiguration] - Error while deleting configuration" + log.I("error correctly detected, no configuration deleted") + log.I("deleting a configuration on a wrong domain name") + out, err = self.pfw.sendCmd("deleteConfiguration","wrong_domain_name",new_conf_name) + assert out != "Done", "ERROR : command [deleteConfiguration] - Error not detected while deleting a configuration on a wrong domain name" + assert err == None, "ERROR : command [deleteConfiguration] - Error while deleting configuration" + log.I("error correctly detected, no configuration deleted") + + # New domain configurations listing + log.I("Configurations listing for domain %s" % (self.domain_name)) + log.I("command [listConfigurations]") + out, err = self.pfw.sendCmd("listConfigurations",self.domain_name, "") + assert err == None, "ERROR : command [listConfigurations] - Error while listing configurations for domain %s" % (self.domain_name) + log.I("command [listConfigurations] correctly executed") + # Saving configurations names + f_configurations = open("f_configurations", "w") + f_configurations.write(out) + f_configurations.close() + + # Checking configurations names integrity + log.I("Configurations listing conformity check") + f_configurations = open("f_configurations", "r") + f_configurations_backup = open("f_configurations_backup", "r") + for iteration in range(self.new_conf_number): + listed_conf_backup = f_configurations_backup.readline().strip('\n') + listed_conf = f_configurations.readline().strip('\n') + assert listed_conf==listed_conf_backup, "ERROR : Error while listing configuration %s (found %s)" % (listed_conf_backup, listed_conf) + log.I("No change detected, listed configurations names conform to expected values") + + # Testing domain deletion + log.I("End of test, new domain deletion") + log.I("command [deleteDomain]") + out, err = self.pfw.sendCmd("deleteDomain",self.domain_name, "") + assert out == "Done", "ERROR : %s" % (out) + assert err == None, "ERROR : command [deleteDomain] - Error while deleting domain %s" % (self.domain_name) + log.I("command [deleteDomain] correctly executed") + + # Closing and deleting temp files + f_configurations_backup.close() + os.remove("f_configurations_backup") + f_configurations.close() + os.remove("f_configurations") + + def test_Nominal_Case(self): + """ + Testing nominal cases + --------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - Create new configurations + - List domain configurations + - Rename configurations + - Delete configurations + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [listConfigurations] function + - [createConfiguration] function + - [renameConfiguration] function + - [deleteConfiguration] function + - [createDomain] function + - [deleteDomain] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - all operations succeed + """ + log.D(self.test_Nominal_Case.__doc__) + # New domain creation + log.I("New domain creation for testing purpose : %s" % (self.domain_name)) + log.I("command [createDomain]") + out, err = self.pfw.sendCmd("createDomain",self.domain_name, "") + assert out == "Done", out + assert err == None, "ERROR : command [createDomain] - Error while creating domain %s" % (self.domain_name) + log.I("command [createDomain] correctly executed") + log.I("Domain %s created" % (self.domain_name)) + + # New configurations creation + for iteration in range (self.new_conf_number): + new_conf_name = "".join([self.conf_test, "_", str(iteration)]) + log.I("New configuration %s creation for domain %s" % (new_conf_name,self.domain_name)) + log.I("command [createConfiguration]" ) + out, err = self.pfw.sendCmd("createConfiguration",self.domain_name,new_conf_name) + assert out == "Done", out + assert err == None, "ERROR : command [createConfiguration] - Error while creating configuration %s" % (new_conf_name) + log.I("command [createConfiguration] correctly executed") + log.I("Configuration %s created for domain %s" % (new_conf_name,self.domain_name)) + + # Listing domain configurations + log.I("Configurations listing for domain %s" % (self.domain_name)) + log.I("command [listConfigurations]") + out, err = self.pfw.sendCmd("listConfigurations",self.domain_name, "") + assert err == None, "ERROR : command [listConfigurations] - Error while listing configurations for domain %s" % (self.domain_name) + log.I("command [listConfigurations] correctly executed") + # Saving configurations names + f_configurations = open("f_configurations", "w") + f_configurations.write(out) + f_configurations.close() + # Checking configurations names integrity + log.I("Configurations listing conformity check") + f_configurations = open("f_configurations", "r") + for iteration in range(self.new_conf_number): + new_conf_name = "".join([self.conf_test, "_", str(iteration)]) + listed_conf = f_configurations.readline().strip('\n') + assert listed_conf==new_conf_name, "ERROR : Error while listing configuration %s (found %s)" % (listed_conf, new_conf_name) + log.I("Listed configurations names conform to expected values") + + # Configuration renaming + log.I("Configurations renaming") + for iteration in range (self.new_conf_number): + conf_name = "".join([self.conf_test, "_", str(iteration)]) + new_conf_name = "".join([self.conf_test_renamed, "_", str(iteration)]) + log.I("Configuration %s renamed to %s in domain %s" % (conf_name,new_conf_name,self.domain_name)) + log.I("command [renameConfiguration]") + out, err = self.pfw.sendCmd("renameConfiguration",self.domain_name,conf_name,new_conf_name) + assert out == "Done", out + assert err == None, "ERROR : command [renameConfiguration] - Error while renaming configuration %s to %s" % (conf_name,new_conf_name) + log.I("command [renameConfiguration] correctly executed") + log.I("Configuration %s renamed to %s for domain %s" % (conf_name,new_conf_name,self.domain_name)) + # Listing domain configurations + log.I("Configurations listing to check configurations renaming") + log.I("command [listConfigurations]") + out, err = self.pfw.sendCmd("listConfigurations",self.domain_name, "") + assert err == None, "ERROR : command [listConfigurations] - Error while listing configurations for domain %s" % (self.domain_name) + log.I("command [listConfigurations] correctly executed") + # Saving configurations names + f_configurations_renamed = open("f_configurations_renamed", "w") + f_configurations_renamed.write(out) + f_configurations_renamed.close() + # Checking configurations names integrity + log.I("Configurations listing conformity check") + f_configurations_renamed = open("f_configurations_renamed", "r") + for iteration in range(self.new_conf_number): + new_conf_name = "".join([self.conf_test_renamed, "_", str(iteration)]) + listed_conf = f_configurations_renamed.readline().strip('\n') + assert listed_conf==new_conf_name, "ERROR : Error while renaming configuration %s (found %s)" % (new_conf_name,listed_conf) + log.I("Listed configurations names conform to expected values, renaming successfull") + + # New domain deletion + log.I("End of test, new domain deletion") + log.I("command [deleteDomain]") + out, err = self.pfw.sendCmd("deleteDomain",self.domain_name, "") + assert out == "Done", "ERROR : %s" % (out) + assert err == None, "ERROR : command [deleteDomain] - Error while deleting domain %s" % (self.domain_name) + log.I("command [deleteDomain] correctly executed") + + # Closing and deleting temp file + f_configurations.close() + os.remove("f_configurations") + f_configurations_renamed.close() + os.remove("f_configurations_renamed") diff --git a/test/functional-tests/PfwTestCase/Domains/tDomain_Configuration_Backup.py b/test/functional-tests/PfwTestCase/Domains/tDomain_Configuration_Backup.py new file mode 100644 index 0000000..51d3d2b --- /dev/null +++ b/test/functional-tests/PfwTestCase/Domains/tDomain_Configuration_Backup.py @@ -0,0 +1,239 @@ +# -*-coding:utf-8 -* + +# Copyright (c) 2011-2015, Intel Corporation +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, +# are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation and/or +# other materials provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its contributors +# may be used to endorse or promote products derived from this software without +# specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +""" +Save and restore configuration testcases + +List of tested functions : +-------------------------- + - [saveConfiguration] function + - [restoreConfiguration] function + +Test cases : +------------ + - Testing nominal case + - Testing saveConfiguration errors + - Testing restoreConfiguration errors +""" + +from Util.PfwUnitTestLib import PfwTestCase +from Util import ACTLogging +log=ACTLogging.Logger() + +# Test of Domains - save/restore configuration +class TestCases(PfwTestCase): + def setUp(self): + self.pfw.sendCmd("setTuningMode", "on") + self.domain_name = "Domain_0" + self.conf_1 = "Conf_0" + self.conf_2 = "Conf_1" + self.param_name = "/Test/Test/TEST_DIR/INT8" + + def tearDown(self): + self.pfw.sendCmd("setTuningMode", "off") + + def test_Nominal_Case(self): + """ + Testing nominal case + -------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - save a configuration + - restore a configuration + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [saveConfiguration] function + - [restoreConfiguration] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - all operations succeed + """ + log.D(self.test_Nominal_Case.__doc__) + + # Saving original parameter value + log.I("restoring configuration %s from domain %s" % (self.conf_1, self.domain_name)) + out, err = self.pfw.sendCmd("restoreConfiguration", self.domain_name, self.conf_1) + assert err == None, "Error when restoring configuration %s from domain %s : %s" % (self.conf_1, self.domain_name, err) + assert out == "Done", out + out, err = self.pfw.sendCmd("getParameter", self.param_name) + assert err == None, "Error when getting parameter %s : %s" % (self.param_name, err) + Param_saved_1 = int(out) + log.I("saved parameter %s value on %s from domain %s = %s" % (self.param_name, self.conf_1, self.domain_name, Param_saved_1)) + + # Modifying parameter value + log.I("modifying parameter %s value on configuration %s from domain %s" % (self.param_name, self.conf_1, self.domain_name)) + out, err = self.pfw.sendCmd("setParameter", self.param_name, str(Param_saved_1+1)) + assert err == None, "Error when setting parameter %s : %s" % (self.param_name, err) + log.I("new parameter %s value = %s in place of %s" % (self.param_name, str(Param_saved_1+1), Param_saved_1)) + + # Saving new parameter value + log.I("saving configuration %s from domain %s" % (self.conf_1, self.domain_name)) + out, err = self.pfw.sendCmd("saveConfiguration", self.domain_name, self.conf_1) + assert err == None, "Error when saving configuration %s from domain %s : %s" % (self.conf_1, self.domain_name, err) + assert out == "Done", out + out, err = self.pfw.sendCmd("getParameter", self.param_name) + assert err == None, "Error when getting parameter %s : %s" % (self.param_name, err) + Param_saved_1 = int(out) + log.I("new saved parameter %s value on %s from domain %s = %s" % (self.param_name, self.conf_1, self.domain_name, Param_saved_1)) + + # Modifying and restoring parameter value + log.I("modifying parameter %s value on configuration %s from domain %s" % (self.param_name, self.conf_1, self.domain_name)) + out, err = self.pfw.sendCmd("setParameter", self.param_name, str(Param_saved_1+1)) + assert err == None, "Error when setting parameter %s : %s" % (self.param_name, err) + out, err = self.pfw.sendCmd("getParameter", self.param_name) + assert err == None, "Error when getting parameter %s : %s" % (self.param_name, err) + Param_saved_2 = int(out) + log.I("new parameter %s value on %s = %s in place of %s" % (self.param_name, self.conf_1, str(Param_saved_2), Param_saved_1)) + log.I("restoring configuration %s from domain %s" % (self.conf_1, self.domain_name)) + out, err = self.pfw.sendCmd("restoreConfiguration", self.domain_name, self.conf_1) + assert err == None, "Error when restoring configuration %s from domain %s : %s" % (self.conf_1, self.domain_name, err) + assert out == "Done", out + out, err = self.pfw.sendCmd("getParameter", self.param_name) + assert err == None, "Error when getting parameter %s : %s" % (self.param_name, err) + Param_saved_2 = int(out) + assert Param_saved_2 == Param_saved_1, "Error when restoring configuration %s from domain %s" % (self.conf_1, self.domain_name) + log.I("saving and restoring configuration works fine") + + def test_Save_Config_Error(self): + """ + Testing saveConfiguration error + ------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - save a configuration with a missing argument + - save a configuration with a wrong domain name + - save a configuration with a wrong configuration name + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [saveConfiguration] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - errors correctly detected + """ + log.D(self.test_Save_Config_Error.__doc__) + # Saving original parameter value and setting a new value to parameter for testing purpose + log.I("restoring configuration %s from domain %s" % (self.conf_1, self.domain_name)) + out, err = self.pfw.sendCmd("restoreConfiguration", self.domain_name, self.conf_1) + assert err == None, "Error when restoring configuration %s from domain %s : %s" % (self.conf_1, self.domain_name, err) + assert out == "Done", out + out, err = self.pfw.sendCmd("getParameter", self.param_name) + assert err == None, "Error when getting parameter %s : %s" % (self.param_name, err) + Param_saved_1 = int(out) + log.I("saved parameter %s value on %s from domain %s = %s" % (self.param_name, self.conf_1, self.domain_name, Param_saved_1)) + log.I("modifying parameter %s value on configuration %s from domain %s" % (self.param_name, self.conf_1, self.domain_name)) + out, err = self.pfw.sendCmd("setParameter", self.param_name, str(Param_saved_1+1)) + assert err == None, "Error when setting parameter %s : %s" % (self.param_name, err) + log.I("new parameter %s value = %s in place of %s" % (self.param_name, str(Param_saved_1+1), Param_saved_1)) + + # Configuration saving errors + log.I("saving configuration error test cases :") + log.I("saving configuration with a missing argument") + out, err = self.pfw.sendCmd("saveConfiguration", self.domain_name) + assert err == None, "ERROR : Error when saving configuration with a missing argument" + assert out != "Done", "ERROR : Error not detected when saving configuration with a missing argument" + log.I("saving configuration with a wrong domain name") + out, err = self.pfw.sendCmd("saveConfiguration", "Wrong_Domain_Name", self.conf_1) + assert err == None, "ERROR : Error when saving configuration with a wrong domain name" + assert out != "Done", "ERROR : Error not detected when saving configuration with a wrong domain name" + log.I("saving configuration with a wrong configuration name") + out, err = self.pfw.sendCmd("saveConfiguration", self.domain_name, "Wrong_Configuration_Name") + assert err == None, "ERROR : Error when saving configuration with a wrong configuration name" + assert out != "Done", "ERROR : Error not detected when saving configuration with a wrong configuration name" + log.I("saving configuration error test cases : errors correctly detected") + + # Checking that no error has affected original configuration save + log.I("restoring configuration %s from domain %s" % (self.conf_1, self.domain_name)) + out, err = self.pfw.sendCmd("restoreConfiguration", self.domain_name, self.conf_1) + assert err == None, "error when restoring configuration %s from domain %s : %s" % (self.conf_1, self.domain_name, err) + assert out == "Done", out + out, err = self.pfw.sendCmd("getParameter", self.param_name) + assert err == None, "error when getting parameter %s : %s" % (self.param_name, err) + Param_saved_2 = int(out) + assert Param_saved_2 == Param_saved_1, "error when restoring configuration %s from domain %s, parameter %s affected by configuration saving error" % (self.conf_1, self.domain_name, Param_saved_1) + log.I("Test passed : saving errors correctly detected, no impact on previously saved configuration") + + def test_Restore_Config_Error(self): + """ + Testing restoreConfiguration error + ---------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - restore a configuration with a missing argument + - restore a configuration with a wrong domain name + - restore a configuration with a wrong configuration name + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [restoreConfiguration] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - errors correctly detected + - configuration's parameters not affected by errors + """ + + log.D(self.test_Restore_Config_Error.__doc__) + # Saving original parameter value and setting a new value to parameter for testing purpose + log.I("restore configuration %s from domain %s" % (self.conf_1, self.domain_name)) + out, err = self.pfw.sendCmd("restoreConfiguration", self.domain_name, self.conf_1) + assert err == None, "Error when restoring configuration %s from domain %s : %s" % (self.conf_1, self.domain_name, err) + assert out == "Done", out + out, err = self.pfw.sendCmd("getParameter", self.param_name) + assert err == None, "Error when getting parameter %s : %s" % (self.param_name, err) + Param_saved_1 = int(out) + log.I("saved parameter %s value on %s from domain %s = %s" % (self.param_name, self.conf_1, self.domain_name, Param_saved_1)) + log.I("modifying parameter %s value on configuration %s from domain %s" % (self.param_name, self.conf_1, self.domain_name)) + out, err = self.pfw.sendCmd("setParameter", self.param_name, str(Param_saved_1+1)) + assert err == None, "Error when setting parameter %s : %s" % (self.param_name, err) + log.I("new parameter %s value = %s in place of %s" % (self.param_name, str(Param_saved_1+1), Param_saved_1)) + out, err = self.pfw.sendCmd("getParameter", self.param_name) + assert err == None, "Error when getting parameter %s : %s" % (self.param_name, err) + Param_saved_2 = int(out) + + # Configuration restore errors + log.I("restoring configuration error test cases :") + log.I("restoring configuration with a missing argument") + out, err = self.pfw.sendCmd("restoreConfiguration", self.domain_name) + assert err == None, "ERROR : Error when restoring configuration with a missing argument" + assert out != "Done", "ERROR : Error not detected when restoring configuration with a missing argument" + log.I("restoring configuration with a wrong domain name") + out, err = self.pfw.sendCmd("restoreConfiguration", "Wrong_Domain_Name", self.conf_1) + assert err == None, "ERROR : Error when restoring configuration with a wrong domain name" + assert out != "Done", "ERROR : Error not detected when restoring configuration with a wrong domain name" + log.I("restoring configuration with a wrong configuration name") + out, err = self.pfw.sendCmd("restoreConfiguration", self.domain_name, "Wrong_Configuration_Name") + assert err == None, "ERROR : Error when restoring configuration with a wrong configuration name" + assert out != "Done", "ERROR : Error not detected when restoring configuration with a wrong configuration name" + log.I("restoring configuration error test cases : errors correctly detected") + + # Checking that no error has affected configuration's parameter value + out, err = self.pfw.sendCmd("getParameter", self.param_name) + assert err == None, "error when getting parameter %s : %s" % (self.param_name, err) + Param_saved_1 = int(out) + assert Param_saved_2 == Param_saved_1, "error when restoring configuration %s from domain %s, parameter %s affected by configuration restoration error" % (self.conf_1, self.domain_name, Param_saved_1) + log.I("Test passed : restoring errors correctly detected, no impact on previously modified configuration's parameter") diff --git a/test/functional-tests/PfwTestCase/Domains/tDomain_Configuration_Selection.py b/test/functional-tests/PfwTestCase/Domains/tDomain_Configuration_Selection.py new file mode 100644 index 0000000..f67ab5f --- /dev/null +++ b/test/functional-tests/PfwTestCase/Domains/tDomain_Configuration_Selection.py @@ -0,0 +1,185 @@ +# -*-coding:utf-8 -* + +# Copyright (c) 2011-2015, Intel Corporation +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, +# are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation and/or +# other materials provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its contributors +# may be used to endorse or promote products derived from this software without +# specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +""" +Effect of criteria changes on configuration testcases + +List of tested functions : +-------------------------- + - [applyConfigurations] function + - [setCriterionState] function + +Test cases : +------------ + - test_Combinatorial_Criteria +""" +import os +from Util.PfwUnitTestLib import PfwTestCase +from Util import ACTLogging +log=ACTLogging.Logger() + +class TestCases(PfwTestCase): + + def setUp(self): + self.pfw.sendCmd("setTuningMode", "on") + self.reference_xml = "$PFW_TEST_TOOLS/xml/XML_Test/Reference_Criteria.xml" + self.temp_domain="f_Domains_Backup" + self.temp_status="f_Config_Status" + # Expected results are defined by Reference_Criteria.xml configuration settings + self.expected_result = [["Conf_1_1", "<none>", "Conf_3_0"] , + ["Conf_1_1", "Conf_2_1", "Conf_3_1"] , + ["Conf_1_1", "Conf_2_1", "Conf_3_0"] , + ["Conf_1_1", "Conf_2_0", "Conf_3_0"] , + ["Conf_1_0", "Conf_2_0", "Conf_3_0"] , + ["Conf_1_1", "Conf_2_0", "Conf_3_0"] , + ["Conf_1_1", "Conf_2_0", "Conf_3_1"]] + self.criterion_setup = [["0x2", "1"] , + ["0x2", "0"] , + ["0x1", "0"] , + ["0x1", "1"] , + ["0x3", "4"] , + ["0x0", "1"]] + # names used in this test refer to names used in Reference_Criteria.xml + self.new_domain_name = "Domain" + self.crit_change_iteration = 6 + + def tearDown(self): + self.pfw.sendCmd("setTuningMode", "off") + + def test_Combinatorial_Criteria(self): + """ + Testing combinatorial criteria + ------------------------------ + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + Checking that PFW behaviour is in line with expectations when setting criteria states. + - Test of all combinatorial of criteria and possible errors + - nominal case in configuration selection + - conflict in configuration selection + - no configuration selected + - error in criterion setting + - test of compound rules : All / Any + - test of matches cases : Is / IsNot / Include / Exclude + - test of criteria types : Inclusive / Exclusive + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [applyConfigurations] function + - [setCriterionState] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - Configurations setting conform to expected behavior + """ + log.D(self.test_Combinatorial_Criteria.__doc__) + + # Import a reference XML file + log.I("Import Domains with settings from %s"%(self.reference_xml)) + out, err = self.pfw.sendCmd("importDomainsWithSettingsXML",self.reference_xml, "") + assert err == None, log.E("Command [importDomainsWithSettingsXML %s] : %s"%(self.reference_xml,err)) + assert out == "Done", log.F("When using function importDomainsWithSettingsXML %s]"%(self.reference_xml)) + + # Check number of domain + log.I("Current domains listing") + log.I("Command [listDomains]") + out, err = self.pfw.sendCmd("listDomains","","") + assert err == None, log.E("Command [listDomains] : %s"%(err)) + log.I("Command [listDomains] : correctly executed") + + # Domains listing backup + f_Domains_Backup = open(self.temp_domain, "w") + f_Domains_Backup.write(out) + f_Domains_Backup.close() + f_Domains_Backup = open(self.temp_domain, "r") + domains_nbr = 0 + line=f_Domains_Backup.readline() + while line!="": + line=f_Domains_Backup.readline() + domains_nbr+=1 + f_Domains_Backup.close() + + # Applying default configurations + out, err = self.pfw.sendCmd("setTuningMode", "off") + assert err == None, log.E("Command [setTuningMode]") + out, err = self.hal.sendCmd("applyConfigurations") + assert err == None, log.E("Command HAL [applyConfigurations]") + + # Saving default status + out, err = self.pfw.sendCmd("status") + f_Config_Status = open(self.temp_status, "w") + f_Config_Status.write(out) + f_Config_Status.close() + + # Test cases iterations + for iteration in range (self.crit_change_iteration+1): + + # Criteria settings + # No criteria are set at the first iteration for testing default configurations + if iteration != 0: + log.I("Setting criterion %s to %s" % ("Crit_0", str(self.criterion_setup[iteration-1][0]))) + state = str(self.criterion_setup[iteration-1][0]) + out, err = self.hal.sendCmd("setCriterionState", "Crit_0", state) + assert err == None, log.E("Command HAL [setCriterionState]") + log.I("Setting criterion %s to %s" % ("Crit_1", str(self.criterion_setup[iteration-1][1]))) + state = str(self.criterion_setup[iteration-1][1]) + out, err = self.hal.sendCmd("setCriterionState", "Crit_1", state) + assert err == None, log.E("Command HAL [setCriterionState]") + log.I("Applaying new configurations") + out, err = self.hal.sendCmd("applyConfigurations") + assert err == None, log.E("Command HAL [applyConfigurations]") + out, err = self.pfw.sendCmd("status") + assert err == None, log.E("Command [status]") + os.remove(self.temp_status) + f_Config_Status = open(self.temp_status, "w") + f_Config_Status.write(out) + f_Config_Status.close() + else : + log.I("Default Configurations - no criteria are set :") + out, err = self.pfw.sendCmd("status") + os.remove(self.temp_status) + f_Config_Status = open(self.temp_status, "w") + f_Config_Status.write(out) + f_Config_Status.close() + + # Configurations checking + for domain in range (domains_nbr): + domain_name = "".join([self.new_domain_name, "_", str(domain+1)]) + config = str(self.expected_result[iteration][domain]) + log.I("Checking that domain %s is set to configuration : %s" % (domain_name,config)) + for line in open(self.temp_status, "r"): + if domain_name in line: + line = line.replace(domain_name,'') + line = line.replace(":","") + line = line.replace(' ','') + line = line.replace("\n","") + assert line == config, log.F("Domain %s - Expected configuration : %s, found : %s" % (domain_name,config,line)) + log.I("Domain %s - configuration correctly set to %s" % (domain_name,line)) + + # Temporary files deletion + os.remove(self.temp_domain) + os.remove(self.temp_status) diff --git a/test/functional-tests/PfwTestCase/Domains/tDomain_Elements.py b/test/functional-tests/PfwTestCase/Domains/tDomain_Elements.py new file mode 100644 index 0000000..8651968 --- /dev/null +++ b/test/functional-tests/PfwTestCase/Domains/tDomain_Elements.py @@ -0,0 +1,311 @@ +# -*-coding:utf-8 -* + +# Copyright (c) 2011-2015, Intel Corporation +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, +# are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation and/or +# other materials provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its contributors +# may be used to endorse or promote products derived from this software without +# specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +""" +Adding and Removing elements from domain testcases + +List of tested functions : +-------------------------- + - [listDomainElements] function + - [addElement] function + - [removeElement] function + +Test cases : +------------ + - Testing nominal case + - Testing addElement errors + - Testing removeElement errors +""" +import os +from Util.PfwUnitTestLib import PfwTestCase +from Util import ACTLogging +log=ACTLogging.Logger() + +class TestCases(PfwTestCase): + def setUp(self): + self.pfw.sendCmd("setTuningMode", "on") + self.domain_name = "Domain_0" + self.elem_0_path = "/Test/Test/TEST_DIR" + self.elem_1_path = "/Test/Test/TEST_DOMAIN_0" + self.elem_2_path = "/Test/Test/TEST_DOMAIN_1" + + def tearDown(self): + self.pfw.sendCmd("setTuningMode", "off") + + def test_Nominal_Case(self): + """ + Testing nominal case + -------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - list and backup initial domain elements + - add a domain element + - remove a domain element + - list and check domains elements + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [listDomainElements] function + - [addElement] function + - [removeElement] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - all operations succeed + """ + log.D(self.test_Nominal_Case.__doc__) + + # List and backup initial domain elements + log.I("Listing initial domain %s elements" % (self.domain_name)) + out, err = self.pfw.sendCmd("listDomainElements",str(self.domain_name)) + assert err == None, "ERROR : command [listDomainElements] - Error while listing domain elements" + f_DomainElements_Backup = open("f_DomainElements_Backup", "w") + f_DomainElements_Backup.write(out) + f_DomainElements_Backup.close() + log.I("command [listDomainElements] correctly executed") + f_DomainElements_Backup = open("f_DomainElements_Backup", "r") + element_nbr_init = 0 + line=f_DomainElements_Backup.readline() + while line!="": + line=f_DomainElements_Backup.readline() + element_nbr_init+=1 + f_DomainElements_Backup.close() + log.I("Actual domain %s elements number is %s" % (self.domain_name,element_nbr_init)) + + # Adding a new domain element + log.I("Adding a new domain element to domain %s" % (self.domain_name)) + out, err = self.pfw.sendCmd("addElement", str(self.domain_name), str(self.elem_1_path)) + assert err == None, "ERROR : command [addElement] - Error while adding new domain element %s" % (self.elem_1_path) + assert out == "Done", "ERROR : command [addElement] - Error while adding new domain element %s" % (self.elem_1_path) + log.I("Adding a new domain element to domain %s" % (self.domain_name)) + out, err = self.pfw.sendCmd("addElement", str(self.domain_name), str(self.elem_2_path)) + assert err == None, "ERROR : command [addElement] - Error while adding new domain element %s" % (self.elem_2_path) + assert out == "Done", "ERROR : command [addElement] - Error while adding new domain element %s" % (self.elem_2_path) + log.I("New domain elements %s and %s added to domain %s" % (self.elem_1_path, self.elem_2_path, self.domain_name)) + + # Removing a domain element + log.I("Removing domain element %s from domain %s" % (self.elem_1_path,self.domain_name)) + out, err = self.pfw.sendCmd("removeElement", str(self.domain_name), str(self.elem_1_path)) + assert err == None, "ERROR : command [removeElement] - Error while removing domain element %s" % (self.elem_1_path) + assert out == "Done", "ERROR : command [removeElement] - Error while removing domain element %s" % (self.elem_1_path) + + # Checking final domain elements + log.I("Listing final domain %s elements" % (self.domain_name)) + out, err = self.pfw.sendCmd("listDomainElements",str(self.domain_name)) + assert err == None, "ERROR : command [listDomainElements] - Error while listing domain elements" + f_DomainElements = open("f_DomainElements", "w") + f_DomainElements.write(out) + f_DomainElements.close() + log.I("command [listDomainElements] correctly executed") + f_DomainElements = open("f_DomainElements", "r") + element_nbr = 0 + line=f_DomainElements.readline() + while line!="": + line=f_DomainElements.readline() + element_nbr+=1 + f_DomainElements.close() + log.I("Actual domain %s elements number is %s" % (self.domain_name,element_nbr)) + log.I("Checking domain %s elements names conformity" % (self.domain_name)) + f_DomainElements = open("f_DomainElements", "r") + f_DomainElements_Backup = open("f_DomainElements_Backup", "r") + for line in range(element_nbr): + # initial domain elements shall not have been impacted by current test + if (line < element_nbr_init): + element_name = f_DomainElements.readline().strip('\n') + element_name_backup = f_DomainElements_Backup.readline().strip('\n') + assert element_name==element_name_backup, "ERROR : Error while modifying domain elements on domain %s" % (self.domain_name) + # last listed element shall be equal to the only one element added previously + else: + element_name = f_DomainElements.readline().strip('\n') + assert element_name==str(self.elem_2_path), "ERROR : Error while modifying domain elements on domain %s" % (self.domain_name) + log.I("Actual domain %s elements names conform to expected values" % (self.domain_name)) + # Temporary files deletion + f_DomainElements.close() + f_DomainElements_Backup.close() + os.remove("f_DomainElements_Backup") + os.remove("f_DomainElements") + # Removing created domain element + out, err = self.pfw.sendCmd("removeElement", str(self.domain_name), str(self.elem_2_path)) + assert err == None, "ERROR : command [removeElement] - Error while removing domain element %s" % (self.elem_2_path) + assert out == "Done", "ERROR : command [removeElement] - Error while removing domain element %s" % (self.elem_2_path) + + def test_addElement_Error(self): + """ + Testing addElement error + ------------------------ + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - add an already existing domain element + - add a non defined domain element + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [addElement] function + - [listDomainElements] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - Errors correctly detected + - No side effect + """ + log.D(self.test_addElement_Error.__doc__) + + # List and backup initial domain elements + log.I("Listing initial domain %s elements" % (self.domain_name)) + out, err = self.pfw.sendCmd("listDomainElements",str(self.domain_name)) + assert err == None, "ERROR : command [listDomainElements] - Error while listing domain elements" + f_DomainElements_Backup = open("f_DomainElements_Backup", "w") + f_DomainElements_Backup.write(out) + f_DomainElements_Backup.close() + log.I("command [listDomainElements] correctly executed") + f_DomainElements_Backup = open("f_DomainElements_Backup", "r") + element_nbr_init = 0 + line=f_DomainElements_Backup.readline() + while line!="": + line=f_DomainElements_Backup.readline() + element_nbr_init+=1 + f_DomainElements_Backup.close() + log.I("Actual domain %s elements number is %s" % (self.domain_name,element_nbr_init)) + + # Adding a new domain element errors + log.I("Adding an already existing domain element to domain %s" % (self.domain_name)) + out, err = self.pfw.sendCmd("addElement", str(self.domain_name), str(self.elem_0_path)) + assert err == None, "ERROR : command [addElement] - Error while adding new domain element %s" % (self.elem_0_path) + assert out != "Done", "ERROR : command [addElement] - Error not detected while adding an already existing domain element to domain %s" % (self.domain_name) + log.I("Adding a non defined domain element to domain %s" % (self.domain_name)) + out, err = self.pfw.sendCmd("addElement", str(self.domain_name), "Non_Defined_Element") + assert err == None, "ERROR : command [addElement] - Error while adding new domain element %s" % (self.elem_2_path) + assert out != "Done", "ERROR : command [addElement] - Error not detected while adding a non defined domain element to domain %s" % (self.domain_name) + log.I("Error when adding elements correctly detected") + + # Checking final domain elements + log.I("Listing final domain %s elements" % (self.domain_name)) + out, err = self.pfw.sendCmd("listDomainElements",str(self.domain_name)) + assert err == None, "ERROR : command [listDomainElements] - Error while listing domain elements" + f_DomainElements = open("f_DomainElements", "w") + f_DomainElements.write(out) + f_DomainElements.close() + log.I("command [listDomainElements] correctly executed") + f_DomainElements = open("f_DomainElements", "r") + element_nbr = 0 + line=f_DomainElements.readline() + while line!="": + line=f_DomainElements.readline() + element_nbr+=1 + f_DomainElements.close() + log.I("Actual domain %s elements number is %s" % (self.domain_name,element_nbr)) + log.I("Checking domain %s elements names conformity" % (self.domain_name)) + f_DomainElements = open("f_DomainElements", "r") + f_DomainElements_Backup = open("f_DomainElements_Backup", "r") + for line in range(element_nbr): + # initial domain elements shall not have been impacted by current test + element_name = f_DomainElements.readline().strip('\n') + element_name_backup = f_DomainElements_Backup.readline().strip('\n') + assert element_name==element_name_backup, "ERROR : domain %s elements affected by addElement errors" % (self.domain_name) + log.I("Actual domain %s elements names conform to expected values" % (self.domain_name)) + # Temporary files deletion + f_DomainElements.close() + f_DomainElements_Backup.close() + os.remove("f_DomainElements_Backup") + os.remove("f_DomainElements") + + def test_removeElement_Error(self): + """ + Testing removeElement error + --------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - remove a non defined domain element + - remove a domain element on a wrong domain name + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [removeElement] function + - [listDomainElements] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - Errors correctly detected + - No side effect + """ + log.D(self.test_removeElement_Error.__doc__) + + # List and backup initial domain elements + log.I("Listing initial domain %s elements" % (self.domain_name)) + out, err = self.pfw.sendCmd("listDomainElements",str(self.domain_name)) + assert err == None, "ERROR : command [listDomainElements] - Error while listing domain elements" + f_DomainElements_Backup = open("f_DomainElements_Backup", "w") + f_DomainElements_Backup.write(out) + f_DomainElements_Backup.close() + log.I("command [listDomainElements] correctly executed") + f_DomainElements_Backup = open("f_DomainElements_Backup", "r") + element_nbr_init = 0 + line=f_DomainElements_Backup.readline() + while line!="": + line=f_DomainElements_Backup.readline() + element_nbr_init+=1 + f_DomainElements_Backup.close() + log.I("Actual domain %s elements number is %s" % (self.domain_name,element_nbr_init)) + + # Error when removing domain elements + log.I("Removing a domain element from a non defined domain") + out, err = self.pfw.sendCmd("removeElement", "Wrong_Domain_Name", str(self.elem_0_path)) + assert err == None, "ERROR : command [removeElement] - Error when removing domain element %s" % (self.elem_0_path) + assert out != "Done", "ERROR : command [removeElement] - Error not detected when removing domain element %s from an undefined domain"% (self.elem_0_path) + log.I("Removing a non existent domain element from domain %s" % (self.domain_name)) + out, err = self.pfw.sendCmd("removeElement", str(self.domain_name), "Wrong_Element_Name") + assert err == None, "ERROR : command [removeElement] - Error when removing domain element %s" % (self.elem_0_path) + assert out != "Done", "ERROR : command [removeElement] - Error not detected when removing a non existent domain element from domain %s" % (self.domain_name) + log.I("Error when removing elements correctly detected") + + # Checking final domain elements + log.I("Listing final domain %s elements" % (self.domain_name)) + out, err = self.pfw.sendCmd("listDomainElements",str(self.domain_name)) + assert err == None, "ERROR : command [listDomainElements] - Error while listing domain elements" + f_DomainElements = open("f_DomainElements", "w") + f_DomainElements.write(out) + f_DomainElements.close() + log.I("command [listDomainElements] correctly executed") + f_DomainElements = open("f_DomainElements", "r") + element_nbr = 0 + line=f_DomainElements.readline() + while line!="": + line=f_DomainElements.readline() + element_nbr+=1 + f_DomainElements.close() + log.I("Actual domain %s elements number is %s" % (self.domain_name,element_nbr)) + log.I("Checking domain %s elements names conformity" % (self.domain_name)) + f_DomainElements = open("f_DomainElements", "r") + f_DomainElements_Backup = open("f_DomainElements_Backup", "r") + for line in range(element_nbr): + # initial domain elements shall not have been impacted by current test + element_name = f_DomainElements.readline().strip('\n') + element_name_backup = f_DomainElements_Backup.readline().strip('\n') + assert element_name==element_name_backup, "ERROR : domain %s elements affected by addElement errors" % (self.domain_name) + log.I("Actual domain %s elements names conform to expected values" % (self.domain_name)) + # Temporary files deletion + f_DomainElements.close() + f_DomainElements_Backup.close() + os.remove("f_DomainElements_Backup") + os.remove("f_DomainElements") diff --git a/test/functional-tests/PfwTestCase/Domains/tDomain_Elements_Sequences.py b/test/functional-tests/PfwTestCase/Domains/tDomain_Elements_Sequences.py new file mode 100644 index 0000000..1544cae --- /dev/null +++ b/test/functional-tests/PfwTestCase/Domains/tDomain_Elements_Sequences.py @@ -0,0 +1,294 @@ +# -*-coding:utf-8 -* + +# Copyright (c) 2011-2015, Intel Corporation +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, +# are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation and/or +# other materials provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its contributors +# may be used to endorse or promote products derived from this software without +# specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +""" +Element Sequence testcases + +List of tested functions : +-------------------------- + - [setElementSequence] function + - [getElementSequence] function + +Test cases : +------------ + - Testing setElementSequence errors + - Testing getElementSequence errors + - Testing nominal case +""" +import os +from Util.PfwUnitTestLib import PfwTestCase +from Util import ACTLogging +log=ACTLogging.Logger() + +class TestCases(PfwTestCase): + def setUp(self): + self.pfw.sendCmd("setTuningMode", "on") + self.domain_name = "Domain_0" + self.elem_0_path = "/Test/Test/TEST_DIR" + self.elem_1_path = "/Test/Test/TEST_DOMAIN_0" + self.elem_2_path = "/Test/Test/TEST_DOMAIN_1" + self.configuration = "Conf_0" + + def tearDown(self): + self.pfw.sendCmd("setTuningMode", "off") + + def test_Nominal_Case(self): + """ + Testing nominal case + -------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - set a new sequences order for a selected configuration + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setElementSequence] function + - [getElementSequence] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - all operations succeed + - new sequences order conform to expected order + """ + log.D(self.test_Nominal_Case.__doc__) + + # Adding new domain elements + log.I("Working on domain %s" % (self.domain_name)) + log.I("Adding a new domain element to domain %s" % (self.domain_name)) + out, err = self.pfw.sendCmd("addElement", str(self.domain_name), str(self.elem_1_path)) + assert err == None, "ERROR : command [addElement] - Error while adding new domain element %s" % (self.elem_1_path) + assert out == "Done", "ERROR : command [addElement] - Error while adding new domain element %s" % (self.elem_1_path) + log.I("Adding a new domain element to domain %s" % (self.domain_name)) + out, err = self.pfw.sendCmd("addElement", str(self.domain_name), str(self.elem_2_path)) + assert err == None, "ERROR : command [addElement] - Error while adding new domain element %s" % (self.elem_2_path) + assert out == "Done", "ERROR : command [addElement] - Error while adding new domain element %s" % (self.elem_2_path) + log.I("New domain elements %s and %s added to domain %s" % (self.elem_1_path, self.elem_2_path, self.domain_name)) + + # Getting elements sequence from selected configuration + log.I("Getting elements sequence from configuration %s" % (self.configuration)) + out, err = self.pfw.sendCmd("getElementSequence", self.domain_name, self.configuration) + assert err == None, "ERROR : command [getElementSequence] - Error while listing elements sequence for configuration %s" % (self.configuration) + log.I("Listing elements sequence for configuration %s correctly executed :\n%s" % (self.configuration, out)) + + # Setting new elements sequence order for selected configuration + log.I("Setting new elements sequence order for configuration %s" % (self.configuration)) + out, err = self.pfw.sendCmd("setElementSequence", self.domain_name, self.configuration, self.elem_2_path, self.elem_0_path, self.elem_1_path) + assert err == None, "ERROR : command [setElementSequence] - Error while setting new elements sequence for configuration %s" % (self.configuration) + assert out == "Done", "ERROR : command [setElementSequence] - Error while setting new elements sequence for configuration %s" % (self.configuration) + log.I("Setting new elements sequence for configuration %s correctly executed") + out, err = self.pfw.sendCmd("getElementSequence", self.domain_name, self.configuration) + assert err == None, "ERROR : command [getElementSequence] - Error while listing elements sequence for configuration %s" % (self.configuration) + log.I("New elements sequence for configuration %s :\n%s" % (self.configuration, out)) + + # Checking new elements sequence order conformity for selected configuration + log.I("Checking new elements sequence order for configuration") + f_ConfigElementsOrder = open("f_ConfigElementsOrder", "w") + f_ConfigElementsOrder.write(out) + f_ConfigElementsOrder.close() + f_ConfigElementsOrder = open("f_ConfigElementsOrder", "r") + element_name = f_ConfigElementsOrder.readline().strip('\n') + assert element_name==self.elem_2_path, "ERROR : Error while modifying configuration %s elements order on domain %s" % (self.configuration) + element_name = f_ConfigElementsOrder.readline().strip('\n') + assert element_name==self.elem_0_path, "ERROR : Error while modifying configuration %s elements order on domain %s" % (self.configuration) + element_name = f_ConfigElementsOrder.readline().strip('\n') + assert element_name==self.elem_1_path, "ERROR : Error while modifying configuration %s elements order on domain %s" % (self.configuration) + log.I("New elements sequence order conform to expected order for configuration %s" % (self.configuration)) + # Closing and removing temp file + f_ConfigElementsOrder.close() + os.remove("f_ConfigElementsOrder") + # Removing created domain element + out, err = self.pfw.sendCmd("removeElement", str(self.domain_name), str(self.elem_1_path)) + assert err == None, "ERROR : command [removeElement] - Error while removing domain element %s" % (self.elem_1_path) + assert out == "Done", "ERROR : command [removeElement] - Error while removing domain element %s" % (self.elem_1_path) + out, err = self.pfw.sendCmd("removeElement", str(self.domain_name), str(self.elem_2_path)) + assert err == None, "ERROR : command [removeElement] - Error while removing domain element %s" % (self.elem_2_path) + assert out == "Done", "ERROR : command [removeElement] - Error while removing domain element %s" % (self.elem_2_path) + + def test_setElementSequence_errors(self): + """ + Testing setElementSequence_errors + --------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - Setting an element not belonging to configuration + - Setting undefined element in sequence order + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setElementSequence] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - all errors correctly detected + - no impact on initial sequences order + """ + log.D(self.test_setElementSequence_errors.__doc__) + + # Adding a new domain element + log.I("Working on domain %s" % (self.domain_name)) + log.I("Adding a new domain element to domain %s" % (self.domain_name)) + out, err = self.pfw.sendCmd("addElement", str(self.domain_name), str(self.elem_1_path)) + assert err == None, "ERROR : command [addElement] - Error while adding new domain element %s" % (self.elem_1_path) + assert out == "Done", "ERROR : command [addElement] - Error while adding new domain element %s" % (self.elem_1_path) + log.I("New domain element %s added to domain %s" % (self.elem_1_path, self.domain_name)) + + # Getting elements sequence from selected configuration + log.I("Getting elements sequence from configuration %s" % (self.configuration)) + out, err = self.pfw.sendCmd("getElementSequence", self.domain_name, self.configuration) + assert err == None, "ERROR : command [getElementSequence] - Error while listing elements sequence for configuration %s" % (self.configuration) + log.I("Listing elements sequence for configuration %s correctly executed :\n%s" % (self.configuration, out)) + + # Elements sequence backup + f_ConfigElementsOrder_Backup = open("f_ConfigElementsOrder_Backup", "w") + f_ConfigElementsOrder_Backup.write(out) + f_ConfigElementsOrder_Backup.close() + + # Setting an element not belonging to configuration in sequence order + log.I("Setting an element not belonging to configuration %s in sequence order" % (self.configuration)) + out, err = self.pfw.sendCmd("setElementSequence", self.domain_name, self.configuration, self.elem_2_path, self.elem_0_path, self.elem_1_path) + assert err == None, "ERROR : command [setElementSequence] - Error while setting elements sequence for configuration %s" % (self.configuration) + assert out != "Done", "ERROR : command [setElementSequence] - Error not detected when setting an element not belonging to configuration" + + # Setting undefined element in sequence order for selected configuration + log.I("Setting undefined element in sequence order for configuration %s" % (self.configuration)) + out, err = self.pfw.sendCmd("setElementSequence", self.domain_name, self.configuration, "Wrong_Element_Name", self.elem_0_path, self.elem_1_path) + assert err == None, "ERROR : command [setElementSequence] - Error while setting elements sequence for configuration %s" % (self.configuration) + assert out != "Done", "ERROR : command [getElementSequence] - Error not detected when setting an undefined element to configuration" + + # Getting elements sequence from selected configuration for checking purpose + out, err = self.pfw.sendCmd("getElementSequence", self.domain_name, self.configuration) + assert err == None, "ERROR : command [getElementSequence] - Error while listing elements sequence for configuration %s" % (self.configuration) + # Elements sequence backup + f_ConfigElementsOrder = open("f_ConfigElementsOrder", "w") + f_ConfigElementsOrder.write(out) + f_ConfigElementsOrder.close() + + # Checking new elements sequence order conformity for selected configuration + log.I("Checking new elements sequence order for configuration") + f_ConfigElementsOrder = open("f_ConfigElementsOrder", "r") + f_ConfigElementsOrder_Backup = open("f_ConfigElementsOrder_Backup", "r") + new_element_name = f_ConfigElementsOrder.readline().strip('\n') + element_name = f_ConfigElementsOrder_Backup.readline().strip('\n') + assert element_name==new_element_name, "ERROR : setElementSequence errors have affected elements order on domain %s" % (self.configuration) + new_element_name = f_ConfigElementsOrder.readline().strip('\n') + element_name = f_ConfigElementsOrder_Backup.readline().strip('\n') + assert element_name==new_element_name, "ERROR : setElementSequence errors have affected elements order on domain %s" % (self.configuration) + log.I("Elements sequence order not affected by setElementSequence errors") + + # Closing and removing temp file + f_ConfigElementsOrder.close() + f_ConfigElementsOrder_Backup.close() + os.remove("f_ConfigElementsOrder") + os.remove("f_ConfigElementsOrder_Backup") + # Removing created domain element + out, err = self.pfw.sendCmd("removeElement", str(self.domain_name), str(self.elem_1_path)) + assert err == None, "ERROR : command [removeElement] - Error while removing domain element %s" % (self.elem_1_path) + assert out == "Done", "ERROR : command [removeElement] - Error while removing domain element %s" % (self.elem_1_path) + + def test_getElementSequence_errors(self): + """ + Testing getElementSequence_errors + --------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - Getting an element sequence on a wrong domain name + - Getting an element sequence on a wrong configuration name + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [getElementSequence] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - all errors correctly detected + - no impact on initial sequences order + """ + log.D(self.test_getElementSequence_errors.__doc__) + + # Adding new domain elements + log.I("Adding a new domain element to domain %s" % (self.domain_name)) + out, err = self.pfw.sendCmd("addElement", str(self.domain_name), str(self.elem_1_path)) + assert err == None, "ERROR : command [addElement] - Error while adding new domain element %s" % (self.elem_1_path) + assert out == "Done", "ERROR : command [addElement] - Error while adding new domain element %s" % (self.elem_1_path) + log.I("Adding a new domain element to domain %s" % (self.domain_name)) + out, err = self.pfw.sendCmd("addElement", str(self.domain_name), str(self.elem_2_path)) + assert err == None, "ERROR : command [addElement] - Error while adding new domain element %s" % (self.elem_2_path) + assert out == "Done", "ERROR : command [addElement] - Error while adding new domain element %s" % (self.elem_2_path) + log.I("New domain elements %s and %s added to domain %s" % (self.elem_1_path, self.elem_2_path, self.domain_name)) + + # Getting elements sequence from selected configuration + log.I("Getting elements sequence from configuration %s" % (self.configuration)) + out, err = self.pfw.sendCmd("getElementSequence", self.domain_name, self.configuration) + assert err == None, "ERROR : command [getElementSequence] - Error while listing elements sequence for configuration %s" % (self.configuration) + log.I("Listing elements sequence for configuration %s correctly executed :\n%s" % (self.configuration, out)) + + # Elements sequence backup + f_ConfigElementsOrder_Backup = open("f_ConfigElementsOrder_Backup", "w") + f_ConfigElementsOrder_Backup.write(out) + f_ConfigElementsOrder_Backup.close() + + # Getting an element sequence on a wrong domain name + log.I("Getting an element sequence on a wrong domain name") + out, err = self.pfw.sendCmd("getElementSequence", "Wrong_Domain_Name", self.configuration) + assert err == None, "ERROR : command [getElementSequence] - Error when getting elements sequence for configuration %s" % (self.configuration) + assert out != "Done", "ERROR : command [getElementSequence] - Error not detected when getting elements sequence for a wrong domain name" + + # Getting an element sequence on a wrong configuration name + log.I("Getting an element sequence on a wrong configuration name") + out, err = self.pfw.sendCmd("getElementSequence", self.domain_name, "Wrong_Configuration_Name") + assert err == None, "ERROR : command [getElementSequence] - Error when getting elements sequence on a wrong configuration name" + assert out != "Done", "ERROR : command [getElementSequence] - Error not detected when getting elements sequence on a wrong configuration name" + + # Getting elements sequence from selected configuration for checking purpose + out, err = self.pfw.sendCmd("getElementSequence", self.domain_name, self.configuration) + assert err == None, "ERROR : command [getElementSequence] - Error while listing elements sequence for configuration %s" % (self.configuration) + # Elements sequence backup + f_ConfigElementsOrder = open("f_ConfigElementsOrder", "w") + f_ConfigElementsOrder.write(out) + f_ConfigElementsOrder.close() + + # Checking new elements sequence order conformity for selected configuration + log.I("Checking new elements sequence order for configuration") + f_ConfigElementsOrder = open("f_ConfigElementsOrder", "r") + f_ConfigElementsOrder_Backup = open("f_ConfigElementsOrder_Backup", "r") + new_element_name = f_ConfigElementsOrder.readline().strip('\n') + element_name = f_ConfigElementsOrder_Backup.readline().strip('\n') + assert element_name==new_element_name, "ERROR : getElementSequence errors have affected elements order on domain %s" % (self.configuration) + new_element_name = f_ConfigElementsOrder.readline().strip('\n') + element_name = f_ConfigElementsOrder_Backup.readline().strip('\n') + assert element_name==new_element_name, "ERROR : getElementSequence errors have affected elements order on domain %s" % (self.configuration) + log.I("Elements sequence order not affected by getElementSequence errors") + + # Closing and removing temp file + f_ConfigElementsOrder.close() + f_ConfigElementsOrder_Backup.close() + os.remove("f_ConfigElementsOrder") + os.remove("f_ConfigElementsOrder_Backup") + # Removing created domain element + out, err = self.pfw.sendCmd("removeElement", str(self.domain_name), str(self.elem_1_path)) + assert err == None, "ERROR : command [removeElement] - Error while removing domain element %s" % (self.elem_1_path) + assert out == "Done", "ERROR : command [removeElement] - Error while removing domain element %s" % (self.elem_1_path) + out, err = self.pfw.sendCmd("removeElement", str(self.domain_name), str(self.elem_2_path)) + assert err == None, "ERROR : command [removeElement] - Error while removing domain element %s" % (self.elem_2_path) + assert out == "Done", "ERROR : command [removeElement] - Error while removing domain element %s" % (self.elem_2_path) diff --git a/test/functional-tests/PfwTestCase/Domains/tDomain_Rules.py b/test/functional-tests/PfwTestCase/Domains/tDomain_Rules.py new file mode 100644 index 0000000..0084e22 --- /dev/null +++ b/test/functional-tests/PfwTestCase/Domains/tDomain_Rules.py @@ -0,0 +1,443 @@ +# -*-coding:utf-8 -* + +# Copyright (c) 2011-2015, Intel Corporation +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, +# are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation and/or +# other materials provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its contributors +# may be used to endorse or promote products derived from this software without +# specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +""" +Rules management testcases + +List of tested functions : +-------------------------- + - [setRule] function + - [clearRule] function + - [getRule] function + +Test cases : +------------ + - Testing clearRule errors + - Testing setRule errors + - Testing getRule errors + - Testing nominal case +""" +from Util.PfwUnitTestLib import PfwTestCase +from Util import ACTLogging +log=ACTLogging.Logger() + +# Test of Domains - Rules +class TestCases(PfwTestCase): + def setUp(self): + self.pfw.sendCmd("setTuningMode", "on") + self.domain_name = "domain_test" + self.conf_1 = "conf_1" + self.conf_2 = "conf_2" + self.rule_1 = "Any{Crit_0 Includes State_0x2, Crit_1 IsNot State_1}" + self.rule_2 = "All{Crit_0 Includes State_0x1, Crit_1 Is State_1}" + self.rule_error_1 = "All{Crit_Error Includes State_0x1, Crit_1 Is State_1}" + self.rule_error_2 = "Any{Crit_0 Includes State_0x2, Crit_0 IsNot State_1}" + self.rule_error_3 = "Ay{Crit_0 Includes State_0x2, Crit_1 IsNot State_1}" + self.rule_error_4 = "All{Crit_0 Includes State_0x4, Crit_1 IsNot State_1}" + self.rule_error_5 = "All{Crit_0 Includes State_0x2, Crit_1 IsNot 1}" + self.rule_error_nbr = 5 + + def tearDown(self): + self.pfw.sendCmd("setTuningMode", "off") + + def test_ClearRule_Errors(self): + """ + Testing configuration creation error + ------------------------------------ + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - Clearing rule on a non-existent configuration + - Clearing rule on a non-existent domain + - Clearing rule with wrong parameters order + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [clearRule] function + - [setRule] function + - [getRule] function + - [createDomain] function + - [createConfiguration] function + - [deleteDomain] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - all errors are detected + - no rule is deleted + """ + log.D(self.test_ClearRule_Errors.__doc__) + # New domain creation for testing purpose + log.I("New domain creation for testing purpose : %s" % (self.domain_name)) + log.I("command [createDomain]") + out, err = self.pfw.sendCmd("createDomain",self.domain_name, "") + assert out == "Done", out + assert err == None, "ERROR : command [createDomain] - Error while creating domain %s" % (self.domain_name) + log.I("command [createDomain] correctly executed") + log.I("Domain %s created" % (self.domain_name)) + + # New configurations creation for testing purpose + log.I("New configuration %s creation for domain %s for testing purpose" % (self.conf_1,self.domain_name)) + log.I("command [createConfiguration]") + out, err = self.pfw.sendCmd("createConfiguration",self.domain_name,self.conf_1) + assert out == "Done", out + assert err == None, "ERROR : command [createConfiguration] - Error while creating configuration %s" % (self.conf_1) + log.I("command [createConfiguration] correctly executed") + log.I("Configuration %s created for domain %s" % (self.conf_1,self.domain_name)) + log.I("New configuration %s creation for domain %s for testing purpose" % (self.conf_2,self.domain_name)) + log.I("command [createConfiguration]") + out, err = self.pfw.sendCmd("createConfiguration",self.domain_name,self.conf_2) + assert out == "Done", out + assert err == None, "ERROR : command [createConfiguration] - Error while creating configuration %s" % (self.conf_2) + log.I("command [createConfiguration] correctly executed") + log.I("Configuration %s created for domain %s" % (self.conf_2,self.domain_name)) + + # Applying rules to configurations + log.I("Applying rules to configurations %s and %s from domain %s" % (self.conf_1,self.conf_2,self.domain_name)) + log.I("command [setRule]") + out, err = self.pfw.sendCmd("setRule",self.domain_name,self.conf_1,self.rule_1) + assert err == None, "ERROR : command [setRule] - Error while setting rule for configurations %s" % (self.conf_1) + assert out == "Done", "FAIL : command [setRule] - Error while setting rule for configuration %s" % (self.conf_1) + log.I("command [setRule] correctly executed") + log.I("rule correctly created for configuration %s" % (self.conf_1)) + out, err = self.pfw.sendCmd("setRule",self.domain_name,self.conf_2,self.rule_2) + assert err == None, "ERROR : command [setRule] - Error while setting rule for configurations %s" % (self.conf_2) + assert out == "Done", "FAIL : command [setRule] - Error while setting rule for configuration %s" % (self.conf_2) + log.I("command [setRule] correctly executed") + log.I("rule correctly created for configuration %s" % (self.conf_2)) + + # Clearing rule errors + log.I("Clearing a rule on domain %s to a non-existent configuration" % (self.domain_name)) + log.I("command [clearRule]") + out, err = self.pfw.sendCmd("clearRule",self.domain_name,"Wrong_Config_Name") + assert err == None, "ERROR : command [clearRule] - Error while clearing rule on domain %s to a non-existent configuration" % (self.domain_name) + assert out != "Done", "ERROR : command [clearRule] - Error not detected while clearing rule on domain %s to a non-existent configuration" % (self.domain_name) + log.I("error correctly detected when clearing a rule to a non-existent configuration") + log.I("Clearing a rule on a non-existent domain") + log.I("command [clearRule]") + out, err = self.pfw.sendCmd("clearRule","Wrong_Domain_Name",self.conf_2) + assert err == None, "ERROR : command [clearRule] - Error while clearing rule on a non-existent domain" + assert out != "Done", "ERROR : command [clearRule] - Error not detected while clearing rule on a non-existent domain" + log.I("error correctly detected while clearing rule on a non-existent domain") + log.I("Clearing a rule with wrong parameters order") + log.I("command [clearRule]") + out, err = self.pfw.sendCmd("clearRule",self.conf_1,self.domain_name) + assert err == None, "ERROR : command [clearRule] - Error when clearing a rule with incorrect paramaters order" + assert out != "Done", "ERROR : command [clearRule] - Error not detected when clearing a rule with incorrect paramaters order" + log.I("error correctly detected when clearing a rule with incorrect paramaters order on domain %s and configuration %s" % (self.domain_name,self.conf_1)) + + #Checking that no rule has been cleared + out, err = self.pfw.sendCmd("getRule",self.domain_name,self.conf_1) + assert out == self.rule_1, "FAIL : command [clearRule] - clearRule error has affected configuration %s" % (self.conf_1) + out, err = self.pfw.sendCmd("getRule",self.domain_name,self.conf_2) + assert out == self.rule_2, "FAIL : command [clearRule] - clearRule error has affected configuration %s" % (self.conf_2) + log.I("command [ClearRule] correctly executed, no impact due to clearing errors") + log.I("no rule removed from configurations %s and %s on domain %s" % (self.conf_1,self.conf_2,self.domain_name)) + + # New domain deletion + log.I("Domain %s deletion" % (self.domain_name)) + log.I("command [deleteDomain]") + out, err = self.pfw.sendCmd("deleteDomain",self.domain_name, "") + assert out == "Done", out + assert err == None, "ERROR : command [deleteDomain] - Error while delting domain %s" % (self.domain_name) + log.I("command [deleteDomain] correctly executed") + log.I("Domain %s deleted" % (self.domain_name)) + + def test_SetRule_Errors(self): + """ + Testing setRule errors + ---------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - Setting rule on a non-existent configuration + - Setting rule on a non-existent domain + - Setting various incorrect format rules + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setRule] function + - [getRule] function + - [createDomain] function + - [createConfiguration] function + - [deleteDomain] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - all errors are detected + - no new rule is created + """ + log.D(self.test_SetRule_Errors.__doc__) + # New domain creation for testing purpose + log.I("New domain creation for testing purpose : %s" % (self.domain_name)) + log.I("command [createDomain]") + out, err = self.pfw.sendCmd("createDomain",self.domain_name, "") + assert out == "Done", out + assert err == None, "ERROR : command [createDomain] - Error while creating domain %s" % (self.domain_name) + log.I("command [createDomain] correctly executed") + log.I("Domain %s created" % (self.domain_name)) + + # New configuration creation for testing purpose + log.I("New configuration %s creation for domain %s for testing purpose" % (self.conf_1,self.domain_name)) + log.I("command [createConfiguration]") + out, err = self.pfw.sendCmd("createConfiguration",self.domain_name,self.conf_1) + assert out == "Done", out + assert err == None, "ERROR : command [createConfiguration] - Error while creating configuration %s" % (self.conf_1) + log.I("command [createConfiguration] correctly executed") + log.I("Configuration %s created for domain %s" % (self.conf_1,self.domain_name)) + + # setRule :basic error cases + log.I("Applying a new rule on domain %s to a non-existent configuration" % (self.domain_name)) + log.I("command [setRule]") + out, err = self.pfw.sendCmd("setRule",self.domain_name,"Wrong_Config_Name",self.rule_1) + assert err == None, "ERROR : command [setRule] - Error while setting rule on domain %s to a non-existent configuration" % (self.domain_name) + assert out != "Done", "ERROR : command [setRule] - Error not detected while setting rule on domain %s to a non-existent configuration" % (self.domain_name) + log.I("error correctly detected when creating a rule to a non-existent configuration") + log.I("Applying a new rule on a non-existent domain") + log.I("command [setRule]") + out, err = self.pfw.sendCmd("setRule","Wrong_Domain_Name",self.conf_1,self.rule_1) + assert err == None, "ERROR : command [setRule] - Error while setting rule on a non-existent domain" + assert out != "Done", "ERROR : command [setRule] - Error not detected while setting rule on a non-existent domain" + log.I("error correctly detected while setting rule on a non-existent domain") + log.I("Applying a new rule with incorrect format") + log.I("command [setRule]") + out, err = self.pfw.sendCmd("setRule",self.domain_name,self.conf_1,"Wrong_Rule_Format") + assert err == None, "ERROR : command [setRule] - Error when setting incorrect format rule" + assert out != "Done", "ERROR : command [setRule] - Error not detected when setting incorrect format rule" + log.I("error correctly detected when setting incorrect format rule on domain %s and configuration %s" % (self.domain_name,self.conf_1)) + + # setRule : various rules errors + log.I("Various rules errors setting :") + for index in range (self.rule_error_nbr): + log.I("Rule error number %s" % (str(index))) + rule_name = "".join(["self.rule_error_", "_", str(index)]) + out, err = self.pfw.sendCmd("setRule",self.domain_name,self.conf_1, rule_name) + assert err == None, "ERROR : command [setRule] - Error when setting incorrect format rule %s" % (str(rule_name)) + assert out != "Done", "ERROR : command [setRule] - Error not detected when setting incorrect format rule %s" % (str(rule_name)) + log.I("error correctly detected when setting incorrect format rule on domain %s and configuration %s" % (self.domain_name,self.conf_1)) + + #Checking that no rule has been created + out, err = self.pfw.sendCmd("getRule",self.domain_name,self.conf_1) + assert out == "<none>", "FAIL : command [setRule] - setRule not working for configuration %s" % (self.conf_1) + log.I("command [setRule] correctly executed, no impact due to setting errors") + log.I("no rule added to configurations %s on domain %s" % (self.conf_1,self.domain_name)) + + # New domain deletion + log.I("Domain %s deletion" % (self.domain_name)) + log.I("command [deleteDomain]") + out, err = self.pfw.sendCmd("deleteDomain",self.domain_name, "") + assert out == "Done", out + assert err == None, "ERROR : command [deleteDomain] - Error while delting domain %s" % (self.domain_name) + log.I("command [deleteDomain] correctly executed") + log.I("Domain %s deleted" % (self.domain_name)) + + def test_GetRule_Errors(self): + """ + Testing getRule errors + ---------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - Getting rule on a non-existent configuration + - Getting rule on a non-existent domain + - Getting rule with wrong parameters order + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [getRule] function + - [setRule] function + - [clearRule] function + - [createDomain] function + - [createConfiguration] function + - [deleteDomain] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - all errors are detected + """ + log.D(self.test_GetRule_Errors.__doc__) + # New domain creation for testing purpose + log.I("New domain creation for testing purpose : %s" % (self.domain_name)) + log.I("command [createDomain]") + out, err = self.pfw.sendCmd("createDomain",self.domain_name, "") + assert out == "Done", out + assert err == None, "ERROR : command [createDomain] - Error while creating domain %s" % (self.domain_name) + log.I("command [createDomain] correctly executed") + log.I("Domain %s created" % (self.domain_name)) + + # New configurations creation for testing purpose + log.I("New configuration %s creation for domain %s for testing purpose" % (self.conf_1,self.domain_name)) + log.I("command [createConfiguration]") + out, err = self.pfw.sendCmd("createConfiguration",self.domain_name,self.conf_1) + assert out == "Done", out + assert err == None, "ERROR : command [createConfiguration] - Error while creating configuration %s" % (self.conf_1) + log.I("command [createConfiguration] correctly executed") + log.I("Configuration %s created for domain %s" % (self.conf_1,self.domain_name)) + log.I("New configuration %s creation for domain %s for testing purpose" % (self.conf_2,self.domain_name)) + log.I("command [createConfiguration]") + out, err = self.pfw.sendCmd("createConfiguration",self.domain_name,self.conf_2) + assert out == "Done", out + assert err == None, "ERROR : command [createConfiguration] - Error while creating configuration %s" % (self.conf_2) + log.I("command [createConfiguration] correctly executed") + log.I("Configuration %s created for domain %s" % (self.conf_2,self.domain_name)) + + # Applying rules to configurations + log.I("Applying rules to configurations %s and %s from domain %s" % (self.conf_1,self.conf_2,self.domain_name)) + log.I("command [setRule]") + out, err = self.pfw.sendCmd("setRule",self.domain_name,self.conf_1,self.rule_1) + assert err == None, "ERROR : command [setRule] - Error while setting rule for configurations %s" % (self.conf_1) + assert out == "Done", "FAIL : command [setRule] - Error while setting rule for configuration %s" % (self.conf_1) + log.I("command [setRule] correctly executed") + log.I("rule correctly created for configuration %s" % (self.conf_1)) + out, err = self.pfw.sendCmd("setRule",self.domain_name,self.conf_2,self.rule_2) + assert err == None, "ERROR : command [setRule] - Error while setting rule for configurations %s" % (self.conf_2) + assert out == "Done", "FAIL : command [setRule] - Error while setting rule for configuration %s" % (self.conf_2) + log.I("command [setRule] correctly executed") + log.I("rule correctly created for configuration %s" % (self.conf_2)) + + # Getting rule errors + log.I("Getting a rule on domain %s from a non-existent configuration" % (self.domain_name)) + log.I("command [getRule]") + out, err = self.pfw.sendCmd("getRule",self.domain_name,"Wrong_Config_Name") + assert err == None, "ERROR : command [getRule] - Error when getting rule on domain %s from a non-existent configuration" % (self.domain_name) + assert out != "Done", "ERROR : command [getRule] - Error not detected while getting rule on domain %s from a non-existent configuration" % (self.domain_name) + log.I("error correctly detected when getting a rule from a non-existent configuration") + log.I("getting a rule from a non-existent domain") + log.I("command [getRule]") + out, err = self.pfw.sendCmd("getRule","Wrong_Domain_Name",self.conf_2) + assert err == None, "ERROR : command [getRule] - Error when getting rule from a non-existent domain" + assert out != "Done", "ERROR : command [getRule] - Error not detected while getting rule from a non-existent domain" + log.I("error correctly detected when getting rule from a non-existent domain") + log.I("getting a rule with wrong parameters order") + log.I("command [getRule]") + out, err = self.pfw.sendCmd("getRule",self.conf_1,self.domain_name) + assert err == None, "ERROR : command [getRule] - Error when getting a rule with incorrect paramaters order" + assert out != "Done", "ERROR : command [getRule] - Error not detected when getting a rule with incorrect paramaters order" + log.I("error correctly detected when getting a rule with incorrect paramaters order on domain %s and configuration %s" % (self.domain_name,self.conf_1)) + + # New domain deletion + log.I("Domain %s deletion" % (self.domain_name)) + log.I("command [deleteDomain]") + out, err = self.pfw.sendCmd("deleteDomain",self.domain_name, "") + assert out == "Done", out + assert err == None, "ERROR : command [deleteDomain] - Error while delting domain %s" % (self.domain_name) + log.I("command [deleteDomain] correctly executed") + log.I("Domain %s deleted" % (self.domain_name)) + + def test_Nominal_Case(self): + """ + Testing nominal case + -------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - setting rules for configurations + - getting rules from configurations + - Clear created rules + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [getRule] function + - [setRule] function + - [clearRule] function + - [createDomain] function + - [createConfiguration] function + - [deleteConfiguration] function + - [deleteDomain] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - all operations succeed + """ + log.D(self.test_Nominal_Case.__doc__) + # New domain creation for testing purpose + log.I("New domain creation for testing purpose : %s" % (self.domain_name)) + log.I("command [createDomain]") + out, err = self.pfw.sendCmd("createDomain",self.domain_name, "") + assert out == "Done", out + assert err == None, "ERROR : command [createDomain] - Error while creating domain %s" % (self.domain_name) + log.I("command [createDomain] correctly executed") + log.I("Domain %s created" % (self.domain_name)) + + # New configurations creation for testing purpose + log.I("New configuration %s creation for domain %s for testing purpose" % (self.conf_1,self.domain_name)) + log.I("command [createConfiguration]") + out, err = self.pfw.sendCmd("createConfiguration",self.domain_name,self.conf_1) + assert out == "Done", out + assert err == None, "ERROR : command [createConfiguration] - Error while creating configuration %s" % (self.conf_1) + log.I("command [createConfiguration] correctly executed") + log.I("Configuration %s created for domain %s" % (self.conf_1,self.domain_name)) + log.I("New configuration %s creation for domain %s for testing purpose" % (self.conf_2,self.domain_name)) + log.I("command [createConfiguration]") + out, err = self.pfw.sendCmd("createConfiguration",self.domain_name,self.conf_2) + assert out == "Done", out + assert err == None, "ERROR : command [createConfiguration] - Error while creating configuration %s" % (self.conf_2) + log.I("command [createConfiguration] correctly executed") + log.I("Configuration %s created for domain %s" % (self.conf_2,self.domain_name)) + + # Applying rules to configurations + log.I("Applying rules to configurations %s and %s from domain %s" % (self.conf_1,self.conf_2,self.domain_name)) + log.I("command [setRule]") + out, err = self.pfw.sendCmd("setRule",self.domain_name,self.conf_1,self.rule_1) + assert err == None, "ERROR : command [setRule] - Error while setting rule for configurations %s" % (self.conf_1) + assert out == "Done", "FAIL : command [setRule] - Error while setting rule for configuration %s" % (self.conf_1) + log.I("command [setRule] correctly executed") + log.I("rule correctly created for configuration %s" % (self.conf_1)) + out, err = self.pfw.sendCmd("setRule",self.domain_name,self.conf_2,self.rule_2) + assert err == None, "ERROR : command [setRule] - Error while setting rule for configurations %s" % (self.conf_2) + assert out == "Done", "FAIL : command [setRule] - Error while setting rule for configuration %s" % (self.conf_2) + log.I("command [setRule] correctly executed") + log.I("rule correctly created for configuration %s" % (self.conf_2)) + + # Checking rules recovered + log.I("Recovering rules for configurations %s and %s from domain %s" % (self.conf_1,self.conf_2,self.domain_name)) + log.I("command [getRule]") + out, err = self.pfw.sendCmd("getRule",self.domain_name,self.conf_1) + assert err == None, "ERROR : command [getRule] - Error while setting rule to configurations %s" % (self.conf_1) + assert out == str(self.rule_1), "FAIL : command [getRule] - Error while recovering rule from configuration %s, incorrect value" % (self.conf_1) + log.I("command [getRule] correctly executed") + log.I("rule correctly recovered from configuration %s" % (self.conf_1)) + out, err = self.pfw.sendCmd("getRule",self.domain_name,self.conf_2) + assert err == None, "ERROR : command [getRule] - Error while setting rule to configurations %s" % (self.conf_2) + assert out == str(self.rule_2), "FAIL : command [getRule] - Error while recovering rule from configuration %s, incorrect value" % (self.conf_2) + log.I("command [getRule] correctly executed") + log.I("rule correctly recovered from configuration %s" % (self.conf_2)) + + # Clearing rules + log.I("Clear rules for configurations %s and %s from domain %s" % (self.conf_1,self.conf_2,self.domain_name)) + log.I("command [clearRule]") + out, err = self.pfw.sendCmd("clearRule",self.domain_name,self.conf_1) + assert err == None, "ERROR : command [clearRule] - Error on clearRule for configuration %s" % (self.conf_1) + assert out == "Done", "FAIL : command [clearRule] - Error on clearRule for configuration %s" % (self.conf_1) + out, err = self.pfw.sendCmd("getRule",self.domain_name,self.conf_1) + assert out == "<none>", "ERROR : command [clearRule] - ClearRule not working for configuration %s" % (self.conf_1) + out, err = self.pfw.sendCmd("clearRule",self.domain_name,self.conf_2) + assert err == None, "ERROR : command [clearRule] - Error on clearRule for configuration %s" % (self.conf_2) + assert out == "Done", "FAIL : command [clearRule] - Error on clearRule for configuration %s" % (self.conf_2) + out, err = self.pfw.sendCmd("getRule",self.domain_name,self.conf_2) + assert out == "<none>", "ERROR : command [clearRule] - ClearRule not working for configuration %s" % (self.conf_2) + log.I("command [clearRule] correctly executed") + log.I("ClearRule effective for configurations %s and %s" % (self.conf_1,self.conf_2)) + + # New domain deletion + log.I("Domain %s deletion" % (self.domain_name)) + log.I("command [deleteDomain]") + out, err = self.pfw.sendCmd("deleteDomain",self.domain_name, "") + assert out == "Done", out + assert err == None, "ERROR : command [deleteDomain] - Error while delting domain %s" % (self.domain_name) + log.I("command [deleteDomain] correctly executed") + log.I("Domain %s deleted" % (self.domain_name)) diff --git a/test/functional-tests/PfwTestCase/Domains/tDomain_Split.py b/test/functional-tests/PfwTestCase/Domains/tDomain_Split.py new file mode 100644 index 0000000..9d2990e --- /dev/null +++ b/test/functional-tests/PfwTestCase/Domains/tDomain_Split.py @@ -0,0 +1,247 @@ +# -*-coding:utf-8 -* + +# Copyright (c) 2011-2015, Intel Corporation +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, +# are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation and/or +# other materials provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its contributors +# may be used to endorse or promote products derived from this software without +# specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +""" +Split elements from domains testcases + +List of tested functions : +-------------------------- + - [splitDomain] function + - [listBelongingDomains] function + - [listAssociatedDomains] function + - [listAssociatedElements] function + - [listConflictingElements] function + - [listRogueElements] function +Test cases : +------------ + - Testing nominal case +""" +import os.path +from Util.PfwUnitTestLib import PfwTestCase +from Util import ACTLogging +log=ACTLogging.Logger() + +class TestCases(PfwTestCase): + + def setUp(self): + self.pfw.sendCmd("setTuningMode", "on") + self.reference_xml = "$PFW_TEST_TOOLS/xml/XML_Test/Reference_Split_Domain.xml" + + self.temp_domain="f_Domains_Backup" + self.temp_status="f_Config_Status" + + self.path_main = "/Test/Test/TEST_MAIN/" + self.path_dir_0 = "/Test/Test/TEST_MAIN/TEST_DIR_0" + self.path_dir_1 = "/Test/Test/TEST_MAIN/TEST_DIR_1" + self.path_dir_2 = "/Test/Test/TEST_MAIN/TEST_DIR_2" + self.dir_nbr = 3 + self.element_name = "TEST_DIR" + + self.domain_1 = "Domain_1" + self.domain_2 = "Domain_2" + self.domain_3 = "Domain_3" + + self.temp_file="f_temp_file" + + def tearDown(self): + self.pfw.sendCmd("setTuningMode", "off") + if os.path.exists(self.temp_file): + os.remove(self.temp_file) + def test_Combinatorial_Criteria(self): + """ + Testing combinatorial criteria + ------------------------------ + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - Split a configuration element associated to a domain + - Check that the configuration element children are associated to the domain + - Pass a configuration element to rogue element + - Add a configuration element to another domain and heck that this element is + conflicting while not removed from original domain. + + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [splitDomain] function + - [listBelongingDomains] function + - [listAssociatedDomains] function + - [listAssociatedElements] function + - [listConflictingElements] function + - [listRogueElements] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - Conform to expected behavior + """ + log.D(self.test_Combinatorial_Criteria.__doc__) + + # Import a reference XML file + log.I("Import Domains with settings from %s"%(self.reference_xml)) + out, err = self.pfw.sendCmd("importDomainsWithSettingsXML",self.reference_xml, "") + assert err == None, log.E("Command [importDomainsWithSettingsXML %s] : %s"%(self.reference_xml,err)) + assert out == "Done", log.F("When using function importDomainsWithSettingsXML %s]"%(self.reference_xml)) + + # Checking initial state + # Checking domain integrity + log.I("Checking initial conditions :") + log.I("Checking that %s configurable element is associated to %s :" % (self.path_main,self.domain_1)) + out, err = self.pfw.sendCmd("listAssociatedDomains", self.path_main) + assert err == None, log.E("Command [listAssociatedDomains] : error when listing domain name") + f_temp_file = open(self.temp_file, "w") + f_temp_file.write(out) + f_temp_file.close() + element_name = self.domain_1 + element_found = 0 + for line in open(self.temp_file, "r"): + if element_name in line: + element_found = 1 + assert element_found==1, log.F("configurable element %s not correctly associated to domain %s" % (self.path_main, self.domain_1)) + log.I("configurable element %s correctly associated to domain %s" % (self.path_main, self.domain_1)) + # Deleting temp file + os.remove(self.temp_file) + + # Checking children integrity + log.I("Checking that %s children configurable elements are correctly set for the test" % (self.path_main)) + out, err = self.pfw.sendCmd("listElements", self.path_main) + assert err == None, log.E("Command [listElements] : listing error") + f_temp_file = open(self.temp_file, "w") + f_temp_file.write(out) + f_temp_file.close() + for index in range (self.dir_nbr): + element_name = "".join([self.element_name, "_", str(index)]) + element_found = 0 + for line in open(self.temp_file, "r"): + if element_name in line: + element_found = 1 + assert element_found==1, log.F("Element %s not found in %s" % (element_name, self.path_main)) + log.I("Element %s found in %s" % (element_name, self.path_main)) + # Checking that child element belong to domain + element_path = "".join([self.path_main, element_name]) + out, err = self.pfw.sendCmd("listBelongingDomains", element_path) + assert err == None, log.E("Command [listBelongingDomains] : listing error") + assert out == self.domain_1, log.F("Wrong behavior : %s not belonging to %s " % (element_name, self.domain_1)) + # Checking that child element is not associated to domain, and only belong to it + out, err = self.pfw.sendCmd("listAssociatedDomains", element_path) + assert err == None, log.E("Command [listAssociatedDomains] : listing error") + assert out == '', log.F("Wrong behavior : configurable element %s not associated to %s" % (element_name, self.domain_1)) + log.I("configurable element %s is belonging to %s" % (element_name, self.domain_1)) + log.I("Configurable elements : check OK") + # Deleting temp file + os.remove(self.temp_file) + + # Split domain_0 + log.I("Splitting configurable element %s from %s" % (self.path_main, self.domain_1)) + out, err = self.pfw.sendCmd("splitDomain", self.domain_1, self.path_main) + assert err == None, log.E("Command [splitDomain] : %s" % (err)) + assert out == 'Done', log.F("Wrong behavior : configurable element %s not splitted correctly" % (self.path_main)) + log.I("Splitting done") + + # check that the configurable element splitted is neither associated nor belonging to the domain + log.I("Checking that %s is neither associated nor belonging to %s" % (self.path_main, self.domain_1)) + out, err = self.pfw.sendCmd("listBelongingDomains", self.path_main) + assert err == None, log.E("Command [listBelongingDomains] : listing error") + assert out != self.domain_1, log.F("Wrong behavior : %s still belonging to %s" % (self.path_main, self.domain_1)) + out, err = self.pfw.sendCmd("listAssociatedDomains", self.path_main) + assert err == None, log.E("Command [listAssociatedDomains] : listing error") + assert out == '', log.F("Wrong behavior : configurable element %s still associated to %s" % (self.path_main, self.domain_1)) + log.I("Configurable element %s is no longer associated to %s" % (self.path_main, self.domain_1)) + + # Checking that children configurable elements are now associated to domain + log.I("Checking that %s children configurable elements are now associated to %s" % (self.path_main, self.domain_1)) + out, err = self.pfw.sendCmd("listElements", self.path_main) + assert err == None, log.E("Command [listElements] : listing error") + f_temp_file = open(self.temp_file, "w") + f_temp_file.write(out) + f_temp_file.close() + for index in range (self.dir_nbr): + element_name = "".join([self.element_name, "_", str(index)]) + element_found = 0 + for line in open(self.temp_file, "r"): + if element_name in line: + element_found = 1 + assert element_found==1, log.F("Element %s not found in %s" % (element_name, self.path_main)) + log.I("Element %s found in %s" % (element_name, self.path_main)) + # Checking that child element is associated to domain + element_path = "".join([self.path_main, element_name]) + out, err = self.pfw.sendCmd("listAssociatedDomains", element_path) + assert err == None, log.E("Command [listAssociatedDomains] : listing error") + assert out == self.domain_1, log.F("Wrong behavior : configurable element %s not associated to %s" % (element_name, self.domain_1)) + log.I("configurable element %s is associated to %s" % (element_name, self.domain_1)) + log.I("Configurable elements : check OK") + # Deleting temp file + os.remove(self.temp_file) + + # Removing one element from domain and checking that it becomes a rogue element + log.I("Removing domain element %s from domain %s" % (self.path_dir_0, self.domain_1)) + out, err = self.pfw.sendCmd("removeElement", str(self.domain_1), str(self.path_dir_0)) + assert err == None, log.E("ERROR : command [removeElement] - Error while removing domain element %s" % (self.path_dir_0)) + assert out == "Done", log.F("Domain element %s not correctly removed" % (self.path_dir_0)) + log.I("Domain element %s correctly removed from domain %s" % (self.path_dir_0, self.domain_1)) + log.I("Checking that %s is a rogue element" % (self.path_dir_0)) + out, err = self.pfw.sendCmd("listRogueElements") + assert err == None, log.E("command [listRogueElements] - Error while listing rogue elements") + f_temp_file = open(self.temp_file, "w") + f_temp_file.write(out) + f_temp_file.close() + element_found = 0 + for line in open(self.temp_file, "r"): + if self.path_dir_0 in line: + element_found = 1 + assert element_found==1, log.F("Configurable element %s not found in rogue elements" % (self.path_dir_0)) + log.I("Element %s found in rogue elements" % (self.path_dir_0)) + + # Moving one configuration element to another domain + log.I("Moving configurable element %s from domain %s to domain %s" % (self.path_dir_1, self.domain_1, self.domain_2)) + log.I("Adding %s to domain %s" % (self.path_dir_1, self.domain_2)) + out, err = self.pfw.sendCmd("addElement", self.domain_2, self.path_dir_1) + assert err == None, log.E("ERROR : command [addElement] - Error while adding element %s to domain %s" % (self.path_dir_1, self.domain_2)) + out, err = self.pfw.sendCmd("listConflictingElements") + assert err == None, log.E("command [listConflictingElements] - Error while listing conflicting elements") + f_temp_file = open(self.temp_file, "w") + f_temp_file.write(out) + f_temp_file.close() + element_found = 0 + for line in open(self.temp_file, "r"): + if self.path_dir_1 in line: + element_found = 1 + assert element_found==1, log.F("Configurable element %s not found in conflicting elements" % (self.path_dir_1)) + log.I("Element %s found in conflicting elements" % (self.path_dir_1)) + log.I("Removing %s from domain %s" % (self.path_dir_1, self.domain_1)) + out, err = self.pfw.sendCmd("removeElement", self.domain_1, self.path_dir_1) + assert err == None, log.E("ERROR : command [removeElement] - Error while removing element %s from domain %s" % (self.path_dir_1, self.domain_2)) + out, err = self.pfw.sendCmd("listConflictingElements") + assert err == None, log.E("command [listConflictingElements] - Error while listing conflicting elements") + f_temp_file = open(self.temp_file, "w") + f_temp_file.write(out) + f_temp_file.close() + element_found = 0 + for line in open(self.temp_file, "r"): + if self.path_dir_1 in line: + element_found = 1 + assert element_found!=1, log.F("Configurable element %s still found in conflicting elements" % (self.path_dir_1)) + log.I("Element %s no longer found in conflicting elements" % (self.path_dir_1)) diff --git a/test/functional-tests/PfwTestCase/Domains/tDomain_creation_deletion.py b/test/functional-tests/PfwTestCase/Domains/tDomain_creation_deletion.py new file mode 100644 index 0000000..039830d --- /dev/null +++ b/test/functional-tests/PfwTestCase/Domains/tDomain_creation_deletion.py @@ -0,0 +1,344 @@ +# -*-coding:utf-8 -* + +# Copyright (c) 2011-2015, Intel Corporation +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, +# are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation and/or +# other materials provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its contributors +# may be used to endorse or promote products derived from this software without +# specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +""" +Creation, renaming and deletion configuration testcases + +List of tested functions : +-------------------------- + - [createDomain] function + - [deleteDomain] function + +Test cases : +------------ + - Testing nominal cases + - Testing domain creation error + - Testing domain deletion error +""" +import os +from Util.PfwUnitTestLib import PfwTestCase +from Util import ACTLogging +log=ACTLogging.Logger() + +# Test of Domains - Basic operations (creations/deletions) +class TestCases(PfwTestCase): + def setUp(self): + self.pfw.sendCmd("setTuningMode", "on") + self.new_domains_number = 4 + self.new_domain_name = "Domain" + + def tearDown(self): + self.pfw.sendCmd("setTuningMode", "off") + + def test_Domain_Creation_Error(self): + """ + Testing domain creation error + ----------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - Create an already existent domain + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [createDomain] function + - [listDomains] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - Error detected when creating an already existent domain + - No domains list update + """ + log.D(self.test_Domain_Creation_Error.__doc__) + # New domain creation + log.I("New domain creation") + log.I("command [createDomain]") + domain_name = 'Test_Domain' + out, err = self.pfw.sendCmd("createDomain",domain_name, "") + assert out == "Done", out + assert err == None, "ERROR : command [createDomain] - Error while creating domain %s" % (domain_name) + log.I("command [createDomain] correctly executed") + + # Domains listing using "listDomains" command + log.I("Current domains listing") + log.I("command [listDomains]") + out, err = self.pfw.sendCmd("listDomains","","") + assert err == None, "ERROR : command [listDomains] - Error while listing domains" + log.I("command [listDomains] - correctly executed") + + # Domains listing backup + f_Domains_Backup = open("f_Domains_Backup", "w") + f_Domains_Backup.write(out) + f_Domains_Backup.close() + f_Domains_Backup = open("f_Domains_Backup", "r") + domains_nbr_init = 0 + line=f_Domains_Backup.readline() + while line!="": + line=f_Domains_Backup.readline() + domains_nbr_init+=1 + f_Domains_Backup.close() + log.I("Actual domains number : %s" % domains_nbr_init) + + # Trying to add an existent domain name + log.I("Adding an already existent domain name") + log.I("command [createDomain]") + domain_name = 'Test_Domain' + out, err = self.pfw.sendCmd("createDomain",domain_name, "") + assert out != "Done", "ERROR : command [createDomain] - Error not detected when creating an already existent domain" + assert err == None, err + log.I("command [createDomain] - error correctly detected") + + # Checking domains list integrity + log.I("Checking domains listing integrity after domain creation error") + ## Domains listing using "listDomains" command + out, err = self.pfw.sendCmd("listDomains","","") + assert err == None, "ERROR : command [listDomains] - Error while listing domains" + f_Domains = open("f_Domains", "w") + f_Domains.write(out) + f_Domains.close() + ## Domains listing integrity check + f_Domains = open("f_Domains", "r") + domains_nbr = 0 + line=f_Domains.readline() + while line!="": + line=f_Domains.readline() + domains_nbr+=1 + f_Domains.close() + assert domains_nbr == domains_nbr_init, "ERROR : Domains number error, expected %s, found %s" % (domains_nbr_init,domains_nbr) + log.I("Test OK - Domains number not updated") + f_Domains = open("f_Domains", "r") + f_Domains_Backup = open("f_Domains_Backup", "r") + for line in range(domains_nbr): + domain_backup_name = f_Domains_Backup.readline().strip('\n'), + domain_name = f_Domains.readline().strip('\n'), + assert domain_backup_name==domain_name, "ERROR : Error while reading domain %s" % (domain_backup_name) + log.I("Test OK - Domains listing not affected by domain creation error") + + # Closing and deleting temp files + f_Domains_Backup.close() + f_Domains.close() + os.remove("f_Domains_Backup") + os.remove("f_Domains") + + def test_Domain_Deletion_Error(self): + """ + Testing domain deletion error + ----------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - Delete a non existent domain + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [deleteDomain] function + - [listDomains] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - Error detected when deleting a non-existent domain + - No domains list update + """ + log.D(self.test_Domain_Deletion_Error.__doc__) + # Domains listing using "listDomains" command + log.I("Current domains listing") + log.I("command [listDomains]") + out, err = self.pfw.sendCmd("listDomains","","") + assert err == None, "ERROR : command [listDomains] - Error while listing domains" + log.I("command [listDomains] correctly executed") + + # Domains listing backup + f_Domains_Backup = open("f_Domains_Backup", "w") + f_Domains_Backup.write(out) + f_Domains_Backup.close() + f_Domains_Backup = open("f_Domains_Backup", "r") + domains_nbr_init = 0 + line=f_Domains_Backup.readline() + while line!="": + line=f_Domains_Backup.readline() + domains_nbr_init+=1 + f_Domains_Backup.close() + log.I("Actual domains number : %s" % domains_nbr_init) + + # Trying to delete a non-existent domain name + log.I("Deleting a non-existent domain name") + log.I("command [deleteDomain]") + domain_name = 'Wrong_Domain_Name' + out, err = self.pfw.sendCmd("deleteDomain",domain_name, "") + assert out != "Done", "ERROR : command [deleteDomain] - Error not detected when deleting a non-existent domain" + assert err == None, err + log.I("command [deleteDomain] - error correctly detected") + + # Checking domains list integrity + log.I("Checking domains listing integrity after domain deletion error") + ## Domains listing using "listDomains" command + out, err = self.pfw.sendCmd("listDomains","","") + assert err == None, "ERROR : command [listDomains] - Error while listing domains" + f_Domains = open("f_Domains", "w") + f_Domains.write(out) + f_Domains.close() + ## Domains listing integrity check + f_Domains = open("f_Domains", "r") + domains_nbr = 0 + line=f_Domains.readline() + while line!="": + line=f_Domains.readline() + domains_nbr+=1 + f_Domains.close() + assert domains_nbr == domains_nbr_init, "ERROR : Domains number error, expected %s, found %s" % (domains_nbr_init,domains_nbr) + log.I("Test OK - Domains number not updated") + f_Domains = open("f_Domains", "r") + f_Domains_Backup = open("f_Domains_Backup", "r") + for line in range(domains_nbr): + domain_backup_name = f_Domains_Backup.readline().strip('\n'), + domain_name = f_Domains.readline().strip('\n'), + assert domain_backup_name==domain_name, "Error while reading domain %s" % (domain_backup_name) + log.I("Test OK - Domains listing not affected by domain deletion error") + + # Closing and deleting temp files + f_Domains_Backup.close() + f_Domains.close() + os.remove("f_Domains_Backup") + os.remove("f_Domains") + + def test_Nominal_Case(self): + """ + Testing nominal cases + --------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - Create X new domains + - Delete X domains + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [createDomain] function + - [deleteDomain] function + - [listDomains] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - X new domains created + - X domains deleted + """ + log.D(self.test_Nominal_Case.__doc__) + # Initial domains listing using "listDomains" command + log.I("Initial domains listing") + log.I("command [listDomains]") + out, err = self.pfw.sendCmd("listDomains","","") + assert err == None, "ERROR : command [listDomains] - Error while listing domains" + log.I("command [listDomains] correctly executed") + + # Initial domains number count + f_init_domains = open("f_init_domains", "w") + f_init_domains.write(out) + f_init_domains.close() + init_domains_nbr = 0 + f_init_domains = open("f_init_domains", "r") + line=f_init_domains.readline() + while line!="": + line=f_init_domains.readline() + init_domains_nbr+=1 + f_init_domains.close() + log.I("Initial domains number : %s" % (init_domains_nbr)) + + # New domains creation + log.I("New domains creation") + log.I("PFW command : [createDomain]") + for index in range (self.new_domains_number): + domain_name = "".join([self.new_domain_name, "_", str(index+init_domains_nbr)]) + out, err = self.pfw.sendCmd("createDomain",domain_name, "") + assert out == "Done", "ERROR : %s" % (out) + assert err == None, "ERROR : command [createDomain] - Error while creating domain %s" % (domain_name) + log.I("command [createDomain] correctly executed") + + # New domain creation check + log.I("New domains creation check :") + log.I("command [listDomains]") + out, err = self.pfw.sendCmd("listDomains","","") + assert err == None, "ERROR : command [listDomains] - Error while listing new domains" + log.I("command [listDomains] correctly executed") + + # Working on a temporary files to record domains listing + tempfile = open("tempfile", "w") + tempfile.write(out) + tempfile.close() + + # Checking last added entries in the listing + tempfile = open("tempfile", "r") + domains_nbr = 0 + line=tempfile.readline() + while line!="": + line=tempfile.readline() + domains_nbr+=1 + tempfile.close() + log.I("New domains conformity check") + tempfile = open("tempfile", "r") + for line in range(domains_nbr): + if (line >= (domains_nbr - self.new_domains_number)): + domain_name = "".join([self.new_domain_name,"_",str(line)]), + domain_created = tempfile.readline().strip('\n'), + assert domain_name==domain_created, "ERROR : Error while creating domain %s %s" % (domain_created, domain_name) + else: + domain_created = tempfile.readline() + log.I("New domains conform to expected values") + created_domains_number = domains_nbr - init_domains_nbr + log.I("%s new domains created" % created_domains_number) + tempfile.close() + os.remove("tempfile") + + # New domains deletion + log.I("New domains deletion") + log.I("command [deleteDomain]") + for index in range (self.new_domains_number): + domain_name = "".join([self.new_domain_name, "_", str(index+init_domains_nbr)]) + out, err = self.pfw.sendCmd("deleteDomain",domain_name, "") + assert out == "Done", "ERROR : %s" % (out) + assert err == None, "ERROR : command [deleteDomain] - Error while deleting domain %s" % (domain_name) + log.I("command [deleteDomain] correctly executed") + + # New domains deletion check + f_init_domains = open("f_init_domains", "r") + tempfile = open("tempfile", "w") + log.I("New domains deletion check :") + log.I("command [listDomains]") + out, err = self.pfw.sendCmd("listDomains","","") + assert err == None, "ERROR : command [listDomains] - Error while listing domains" + log.I("command [listDomains] correctly executed") + tempfile.write(out) + tempfile.close() + tempfile = open("tempfile", "r") + line=tempfile.readline() + line_init=f_init_domains.readline() + while line!="": + line=tempfile.readline() + line_init=f_init_domains.readline() + assert line == line_init, "ERROR : Domain deletion error" + if line=="": + assert line_init == "", "ERROR : Wrong domains deletion number" + log.I("Deletion completed - %s domains deleted" % created_domains_number) + + # Temporary files deletion + tempfile.close() + f_init_domains.close() + os.remove("tempfile") + os.remove("f_init_domains") diff --git a/test/functional-tests/PfwTestCase/Domains/tDomain_rename.py b/test/functional-tests/PfwTestCase/Domains/tDomain_rename.py new file mode 100644 index 0000000..81d4539 --- /dev/null +++ b/test/functional-tests/PfwTestCase/Domains/tDomain_rename.py @@ -0,0 +1,337 @@ +# -*-coding:utf-8 -* + +# Copyright (c) 2011-2015, Intel Corporation +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, +# are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation and/or +# other materials provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its contributors +# may be used to endorse or promote products derived from this software without +# specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +""" +Renaming domains testcases + +List of tested functions : +-------------------------- + - [renameDomain] function + +Test cases : +------------ + - Nominal cases + - Renaming errors + - Special cases +""" +import os +from Util.PfwUnitTestLib import PfwTestCase +from Util import ACTLogging +log=ACTLogging.Logger() + +# Test of Domains - Rename +class TestCases(PfwTestCase): + def setUp(self): + self.pfw.sendCmd("setTuningMode", "on") + self.domain_name = "domain_white" + self.new_domain_name = "domain_black" + self.renaming_iterations = 5 + + def tearDown(self): + self.pfw.sendCmd("setTuningMode", "off") + + def test_Nominal_Case(self): + """ + Nominal case + ------------ + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - Renaming a domain + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [renameDomain] function + - [createDomain] function + - [listDomains] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - domains correctly renamed + """ + log.D(self.test_Nominal_Case.__doc__) + # New domain creation + log.I("New domain creation : %s" % (self.domain_name)) + log.I("command [createDomain]" ) + out, err = self.pfw.sendCmd("createDomain",self.domain_name, "") + assert out == "Done", out + assert err == None, "ERROR : command [createDomain] - ERROR while creating domain %s" % (self.domain_name) + log.I("command [createDomain] correctly executed") + log.I("Domain %s created" % (self.domain_name)) + + # Initial domains listing using "listDomains" command + log.I("Creating a domains listing backup") + log.I("command [listDomains]") + out, err = self.pfw.sendCmd("listDomains","","") + assert err == None, "INFO : command [listDomains] - ERROR while listing domains" + log.I("command [listDomains] correctly executed") + # Saving initial domains names + f_init_domains = open("f_init_domains", "w") + f_init_domains.write(out) + f_init_domains.close() + log.I("Domains listing backup created") + + # Checking domains number + f_init_domains = open("f_init_domains", "r") + domains_nbr = 0 + line=f_init_domains.readline() + while line!="": + line=f_init_domains.readline() + domains_nbr+=1 + f_init_domains.close() + os.remove("f_init_domains") + log.I("%s domains names saved" % domains_nbr) + + # Domain renaming iterations + log.I("Checking domain renaming - %s iterations" % self.renaming_iterations) + old_name = self.domain_name + new_name = self.new_domain_name + for iteration in range (self.renaming_iterations): + log.I("Iteration %s" % (iteration)) + log.I("Renaming domain %s to %s" % (old_name,new_name)) + log.I("command [renameDomain]") + out, err = self.pfw.sendCmd("renameDomain",old_name,new_name) + assert out == "Done", out + assert err == None, "ERROR : command [renameDomain] - ERROR while renaming domain %s" % (old_name) + # Domains listing using "listDomains" command + log.I("Creating a domains listing") + log.I("command [listDomains]") + out, err = self.pfw.sendCmd("listDomains","","") + assert err == None, "ERROR : command [listDomains] - ERROR while listing domains" + log.I("command [listDomains] correctly executed") + # Saving domains names + f_domains = open("f_domains", "w") + f_domains.write(out) + f_domains.close() + log.I("Domains listing created") + # Checking renaming + log.I("Checking that renaming is correct in domains listing") + f_domains = open("f_domains", "r") + for line in range(domains_nbr): + if (line >= (domains_nbr - 1)): + domain_renamed = f_domains.readline().strip('\n') + assert domain_renamed==new_name, "ERROR : Error while renaming domain %s" % (old_name) + else: + f_domains.readline() + f_domains.close() + log.I("New domain name %s conform to expected value" % (new_name)) + temp = old_name + old_name = new_name + new_name = temp + os.remove("f_domains") + + def test_Renaming_Error(self): + """ + Renaming errors + --------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - renaming a non existent domain + - renaming a domain with an already existent domain name + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [renameDomain] function + - [createDomain] function + - [renameDomain] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - error detected + - domains names remain unchanged + """ + log.D(self.test_Renaming_Error.__doc__) + # New domains creation + log.I("New domain creation : %s" % (self.domain_name)) + log.I("command [createDomain]") + out, err = self.pfw.sendCmd("createDomain",self.domain_name, "") + assert out == "Done", out + assert err == None, "ERROR : command [createDomain] - Error while creating domain %s" % (self.domain_name) + log.I("command [createDomain] - correctly executed") + log.I("command Domain %s created" % (self.domain_name)) + + # Initial domains listing using "listDomains" command + log.I("Creating a domains listing backup") + log.I("command [listDomains]") + out, err = self.pfw.sendCmd("listDomains","","") + assert err == None, "INFO : command [listDomains] - Error while listing domains" + log.I("command [listDomains] correctly executed") + # Saving initial domains names + f_init_domains = open("f_init_domains", "w") + f_init_domains.write(out) + f_init_domains.close() + log.I("Domains listing backup created") + + # Checking domains number + f_init_domains = open("f_init_domains", "r") + domains_nbr = 0 + line=f_init_domains.readline() + while line!="": + line=f_init_domains.readline() + domains_nbr+=1 + f_init_domains.close() + log.I("%s domains names saved" % domains_nbr) + + # Domain renaming error : renamed domain does not exist + log.I("Renaming a non existent domain") + log.I("Renaming domain FAKE to NEW_NAME") + log.I("command [renameDomain]") + out, err = self.pfw.sendCmd("renameDomain",'FAKE','NEW_NAME') + assert out != "Done", out + assert err == None, "ERROR : command [renameDomain] - Error while renaming domain" + log.I("command [renameDomain] - renaming error correctly detected") + # Domains listing using "listDomains" command + log.I("Creating a domains listing") + log.I("command [listDomains]") + out, err = self.pfw.sendCmd("listDomains","","") + assert err == None, "ERROR : command [listDomains] - Error while listing domains" + log.I("command [listDomains] correctly executed") + # Saving domains names + f_domains = open("f_domains", "w") + f_domains.write(out) + f_domains.close() + log.I("Domains listing created") + # Checking domains names integrity + log.I("Checking domains names integrity") + f_domains = open("f_domains", "r") + f_init_domains = open("f_init_domains", "r") + for line in range(domains_nbr): + domain_name = f_domains.readline().strip('\n') + domain_backup_name = f_init_domains.readline().strip('\n') + assert domain_name==domain_backup_name, "ERROR : Domain name %s affected by the renaming error" % (domain_backup_name) + f_domains.close() + f_init_domains.close() + log.I("Domains names not affected by the renaming error") + os.remove("f_domains") + + # Domain renaming error : renaming a domain with an already existent domain name + log.I("renaming a domain with an already existent domain name") + log.I("Renaming domain %s to %s" % (self.domain_name,self.new_domain_name) ) + log.I("command [renameDomain]") + out, err = self.pfw.sendCmd("renameDomain",self.domain_name,self.new_domain_name) + assert out != "Done", out + assert err == None, "INFO : command [renameDomain] - Error while renaming domain" + log.I("command [renameDomain] - renaming error correctly detected") + # Domains listing using "listDomains" command + log.I("Creating a domains listing") + log.I("command [listDomains]") + out, err = self.pfw.sendCmd("listDomains","","") + assert err == None, "ERROR : command [listDomains] - Error while listing domains" + log.I("command [listDomains] correctly executed") + # Saving domains names + f_domains = open("f_domains", "w") + f_domains.write(out) + f_domains.close() + log.I("Domains listing created") + # Checking domains names integrity + log.I("Checking domains names integrity") + f_domains = open("f_domains", "r") + f_init_domains = open("f_init_domains", "r") + for line in range(domains_nbr): + domain_name = f_domains.readline().strip('\n') + domain_backup_name = f_init_domains.readline().strip('\n') + assert domain_name==domain_backup_name, "ERROR : domain name %s affected by the renaming error" % (domain_backup_name) + f_domains.close() + f_init_domains.close() + log.I("Domains names not affected by the renaming error") + os.remove("f_domains") + os.remove("f_init_domains") + + def test_Special_Cases(self): + """ + Special cases + ------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - renaming a domain with its own name + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [renameDomain] function + - [createDomain] function + - [listDomains] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - no error + - domains names remain unchanged + """ + log.D(self.test_Special_Cases.__doc__) + # New domain creation + # Already created in previous test + + # Initial domains listing using "listDomains" command + log.I("Creating a domains listing backup") + log.I("command [listDomains]") + out, err = self.pfw.sendCmd("listDomains","","") + assert err == None, "ERROR : command [listDomains] - Error while listing domains" + log.I("command [listDomains] correctly executed") + # Saving initial domains names + f_init_domains = open("f_init_domains", "w") + f_init_domains.write(out) + f_init_domains.close() + log.I("Domains listing backup created") + + # Checking domains number + f_init_domains = open("f_init_domains", "r") + domains_nbr = 0 + line=f_init_domains.readline() + while line!="": + line=f_init_domains.readline() + domains_nbr+=1 + f_init_domains.close() + log.I("%s domains names saved" % domains_nbr) + + # Domain renaming error : renaming a domain with its own name + log.I("renaming a domain with its own name") + log.I("Renaming domain %s to %s" % (self.domain_name,self.domain_name)) + log.I("command [renameDomain]") + out, err = self.pfw.sendCmd("renameDomain",self.domain_name,self.domain_name) + assert out == "Done", out + assert err == None, "ERROR : command [renameDomain] - Error while renaming domain" + log.I("command [renameDomain] correctly executed") + # Domains listing using "listDomains" command + log.I("Creating a domains listing") + log.I("command [listDomains]") + out, err = self.pfw.sendCmd("listDomains","","") + assert err == None, "ERROR : command [listDomains] - Error while listing domains" + log.I("command [listDomains] correctly executed") + # Saving domains names + f_domains = open("f_domains", "w") + f_domains.write(out) + f_domains.close() + log.I("Domains listing created") + # Checking domains names integrity + log.I("Checking domains names integrity") + f_domains = open("f_domains", "r") + f_init_domains = open("f_init_domains", "r") + for line in range(domains_nbr): + domain_name = f_domains.readline().strip('\n') + domain_backup_name = f_init_domains.readline().strip('\n') + assert domain_name==domain_backup_name, "ERROR : domain name %s affected by the renaming" % (domain_backup_name) + f_domains.close() + f_init_domains.close() + log.I("Domains names not affected by the renaming") + + os.remove("f_domains") + os.remove("f_init_domains") diff --git a/test/functional-tests/PfwTestCase/Functions/__init__.py b/test/functional-tests/PfwTestCase/Functions/__init__.py new file mode 100644 index 0000000..7b72df8 --- /dev/null +++ b/test/functional-tests/PfwTestCase/Functions/__init__.py @@ -0,0 +1,9 @@ +""" +Functions Package : All testcases about main functions in PFW : + - listing functions + - help function + - status function + - export/import functions + - get/set parameter functions + - synchronization functions +"""
\ No newline at end of file diff --git a/test/functional-tests/PfwTestCase/Functions/tFunction_Export_Import_Domains.py b/test/functional-tests/PfwTestCase/Functions/tFunction_Export_Import_Domains.py new file mode 100644 index 0000000..847ed47 --- /dev/null +++ b/test/functional-tests/PfwTestCase/Functions/tFunction_Export_Import_Domains.py @@ -0,0 +1,1143 @@ +# -*-coding:utf-8 -* + +# Copyright (c) 2011-2015, Intel Corporation +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, +# are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation and/or +# other materials provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its contributors +# may be used to endorse or promote products derived from this software without +# specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +""" +Export and import settings and domains from file testcases + +List of tested functions : +-------------------------- + - [exportDomainsWithSettingsXML] function + - [importDomainsWithSettingsXML] function + - [exportDomainsXML] function + - [importDomainsXML] function + - [importSettings] function + - [exportSettings] function + +Test cases : +------------ + - Testing importDomainsWithSettingsXML nominal case + - Testing exportDomainsWithSettingsXML nominal case + - Testing exportDomainsXML/importDomainsXML nominal case + - Testing importSettings/exportSettings nominal case + - Testing import errors + - Testing export errors +""" +import os, commands +import unittest +from Util.PfwUnitTestLib import PfwTestCase +from Util import ACTLogging +log=ACTLogging.Logger() + +class TestCases(PfwTestCase): + + def setUp(self): + + self.pfw.sendCmd("setTuningMode", "on") + self.param_name_01 = "/Test/Test/TEST_DIR/UINT16" + self.filesystem_01 = "$PFW_FILESYSTEM/UINT16" + self.param_name_02 = "/Test/Test/TEST_DOMAIN_0/Param_00" + self.filesystem_02 = "$PFW_FILESYSTEM/Param_00" + self.param_name_03 = "/Test/Test/TEST_DOMAIN_1/Param_12" + self.filesystem_03 = "$PFW_FILESYSTEM/Param_12" + + pfw_test_tools=os.getenv("PFW_TEST_TOOLS") + self.reference_xml = pfw_test_tools+"/xml/XML_Test/Reference_Compliant.xml" + self.initial_xml = pfw_test_tools+"/xml/TestConfigurableDomains.xml" + self.temp_config="f_Config_Backup" + self.temp_domain="f_Domains_Backup" + self.temp_xml=pfw_test_tools+"/f_temp.xml" + self.temp_binary=pfw_test_tools+"/f_temp.binary" + + self.nb_domains_in_reference_xml=3 + self.nb_conf_per_domains_in_reference_xml=[2,2,2] + + def tearDown(self): + self.pfw.sendCmd("setTuningMode", "off") + if os.path.exists(self.temp_domain): + os.remove(self.temp_domain) + if os.path.exists(self.temp_config): + os.remove(self.temp_config) + if os.path.exists(self.temp_xml): + os.remove(self.temp_xml) + if os.path.exists(self.temp_binary): + os.remove(self.temp_binary) + + def test_01_importDomainsWithSettingsXML_Nominal_Case(self): + """ + Testing importDomainsWithSettingsXML nominal case + ------------------------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - import a reference XML + - check Domains + - check Configuration + - restore Configuration + - check Parameters + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [createConfiguration] function + Used commands : + ~~~~~~~~~~~~~~~ + - [restoreConfiguration] function + - [listDomains] function + - [listConfiguration] function + - [getRules] function + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - all operations succeed + """ + log.D(self.test_01_importDomainsWithSettingsXML_Nominal_Case.__doc__) + + #Import a reference XML file + log.I("Import Domains with settings from %s"%(self.reference_xml)) + out, err = self.pfw.sendCmd("importDomainsWithSettingsXML",self.reference_xml, "") + assert err == None, log.E("Command [importDomainsWithSettingsXML %s] : %s"%(self.reference_xml,err)) + assert out == "Done", log.F("When using function importDomainsWithSettingsXML %s]"%(self.reference_xml)) + + #Check number of domain(3 domains are setup in the reference XML, initially only one domains is declared) + # Domains listing using "listDomains" command + log.I("Current domains listing") + log.I("Command [listDomains]") + out, err = self.pfw.sendCmd("listDomains","","") + assert err == None, log.E("Command [listDomains] : %s"%(err)) + log.I("Command [listDomains] - correctly executed") + # Domains listing backup + f_Domains_Backup = open(self.temp_domain, "w") + f_Domains_Backup.write(out) + f_Domains_Backup.close() + f_Domains_Backup = open(self.temp_domain, "r") + domains_nbr = 0 + line=f_Domains_Backup.readline() + while line!="": + line=f_Domains_Backup.readline() + domains_nbr+=1 + f_Domains_Backup.close() + log.I("Actual domains number : %s" % domains_nbr) + assert domains_nbr==self.nb_domains_in_reference_xml, log.F("Number of listed domains is not compliant with the file %s - expected : %s - found : %s"%(self.reference_xml,self.nb_domains_in_reference_xml, domains_nbr)) + + #Check number of config per domain(2 config per domains are setup in the reference XML) + # Config listing + domain_basename="Domain_" + for index in range(self.nb_domains_in_reference_xml): + domain_name=domain_basename+str(index+1) + log.I("Listing config for domain %s"%(domain_name)) + out, err = self.pfw.sendCmd("listConfigurations",domain_name,"") + assert err == None, log.E("Command [listConfigurations %s] : %s"%(domain_name,err)) + log.I("Command [listConfigurations %s] - correctly executed"%(domain_name)) + f_Config_Backup = open(self.temp_config, "w") + f_Config_Backup.write(out) + f_Config_Backup.close() + f_Config_Backup = open(self.temp_config, "r") + config_nbr = 0 + line=f_Config_Backup.readline() + while line!="": + line=f_Config_Backup.readline() + config_nbr+=1 + f_Config_Backup.close() + assert config_nbr==self.nb_conf_per_domains_in_reference_xml[index], log.F("Number of listed config for %s is not compliant with the file %s - expected : %s - found : %s"%(domain_name, self.reference_xml,self.nb_conf_per_domains_in_reference_xml[index], domains_nbr)) + log.I("Config checking : OK") + + #Check number of config per domain(2 config per domains are setup in the reference XML) + # Config listing + conf_basename="Conf_" + for index_domain in range(3): + for index_conf in range(2): + domain_name=domain_basename+str(index_domain+1) + conf_name=conf_basename+str(index_domain+1)+"_"+str(index_conf) + log.I("Get rule for domain %s - conf %s"%(domain_name,conf_name)) + out, err = self.pfw.sendCmd("getRule",domain_name,conf_name) + assert err == None, log.E("Command [getRules %s %s] : %s"%(domain_name,conf_name,err)) + assert out !="", log.F("No rules loaded for domain %s conf %s"%(domain_name,conf_name)) + log.I("Rules checking : OK") + + #Restore config + conf_basename="Conf_" + for index_domain in range(3): + for index_conf in range(2): + domain_name=domain_basename+str(index_domain+1) + conf_name=conf_basename+str(index_domain+1)+"_"+str(index_conf) + log.I("Restore config %s for domain %s"%(conf_name,domain_name)) + out, err = self.pfw.sendCmd("restoreConfiguration",domain_name,conf_name) + assert err == None, log.E("Command [restoreConfiguration %s %s] : %s"%(domain_name,conf_name,err)) + assert out =="Done", log.F("When restoring configuration %s for domain %s"%(conf_name,domain_name)) + log.I("Restore configurations: OK") + + #set Tuning Mode off to check parameter value + self.pfw.sendCmd("setTuningMode", "off") + + #Check parameter values + #UINT16 + expected_value="0" + hex_value="0x0" + log.I("UINT16 parameter in the conf Conf_1_1= %s"%(expected_value)) + out, err = self.pfw.sendCmd("getParameter", self.param_name_01, "") + assert err == None, log.E("When setting parameter %s : %s" % (self.param_name_01, err)) + assert out == expected_value, log.F("BLACKBOARD : Incorrect value for %s, expected: %s, found: %s" % (self.param_name_01, expected_value, out)) + #Check parameter value on filesystem + assert commands.getoutput("cat %s"%(self.filesystem_01)) == hex_value, log.F("FILESYSTEM : parameter %s update error"%self.param_name_01) + #Param_00 + expected_value="4" + hex_value="0x4" + log.I("Param_00 parameter in the conf Conf_2_1= %s"%(expected_value)) + out, err = self.pfw.sendCmd("getParameter", self.param_name_02, "") + assert err == None, log.E("When setting parameter %s : %s" % (self.param_name_02, err)) + assert out == expected_value, log.F("BLACKBOARD : Incorrect value for %s, expected: %s, found: %s" % (self.param_name_02, expected_value, out)) + #Check parameter value on filesystem + assert commands.getoutput("cat %s"%(self.filesystem_02)) == hex_value, log.F("FILESYSTEM : parameter %s update error"%self.param_name_02) + #Param_12 + expected_value="4" + hex_value="0x4" + log.I("Param_12 parameter in the conf Conf_3_1= %s"%(expected_value)) + out, err = self.pfw.sendCmd("getParameter", self.param_name_03, "") + assert err == None, log.E("When setting parameter %s : %s" % (self.param_name_03, err)) + assert out == expected_value, log.F("BLACKBOARD : Incorrect value for %s, expected: %s, found: %s" % (self.param_name_03, expected_value, out)) + #Check parameter value on filesystem + assert commands.getoutput("cat %s"%(self.filesystem_03)) == hex_value, log.F("FILESYSTEM : parameter %s update error"%self.param_name_03) + log.I("Parameters checking : OK") + + def test_02_exportDomainsWithSettingsXML_Nominal_Case(self): + """ + Testing exportDomainsWithSettingsXML nominal case + ------------------------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - export domains with settings in temp XML + - import a reference XML + - restore Configuration + - import the temp XML + - restore Configuration + - check Domains + - check Configuration + - check Parameters + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [exportDomainsWithSettingsXML] function + - [importDomainsWithSettingsXML] function + Used commands : + ~~~~~~~~~~~~~~~ + - [restoreConfiguration] function + - [listDomains] function + - [listConfiguration] function + - [getRules] function + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - all operations succeed + """ + log.D(self.test_02_exportDomainsWithSettingsXML_Nominal_Case.__doc__) + + ### INIT Domains Settings #### + + #Import a reference XML file + + log.I("Import Domains with initial settings from %s"%(self.reference_xml)) + out, err = self.pfw.sendCmd("importDomainsWithSettingsXML",self.reference_xml, "") + assert err == None, log.E("Command [importDomainsWithSettingsXML %s] : %s"%(self.reference_xml,err)) + assert out == "Done", log.F("When using function importDomainsWithSettingsXML %s]"%(self.reference_xml)) + self.pfw.sendCmd("setTuningMode", "off","") + init_value_01, err = self.pfw.sendCmd("getParameter", self.param_name_01, "") + init_value_02, err = self.pfw.sendCmd("getParameter", self.param_name_02, "") + init_value_03, err = self.pfw.sendCmd("getParameter", self.param_name_03, "") + init_filesystem_01 = commands.getoutput("cat %s"%(self.filesystem_01)) + init_filesystem_02 = commands.getoutput("cat %s"%(self.filesystem_02)) + init_filesystem_03 = commands.getoutput("cat %s"%(self.filesystem_03)) + + ### END OF INIT ### + + #Export in a temp XML file + log.I("Export Domains with initial settings in %s"%(self.temp_xml)) + out, err = self.pfw.sendCmd("exportDomainsWithSettingsXML",self.temp_xml, "") + assert err == None, log.E("Command [exportDomainsWithSettingsXML %s] : %s"%(self.temp_xml,err)) + assert out == "Done", log.F("When using function exportDomainsWithSettingsXML %s]"%(self.temp_xml)) + + #Change the value of checked parameters + self.pfw.sendCmd("setTuningMode", "on","") + out, err = self.pfw.sendCmd("setParameter", self.param_name_01, str(int(init_value_01)+1)) + out, err = self.pfw.sendCmd("setParameter", self.param_name_02, str(int(init_value_02)+1)) + out, err = self.pfw.sendCmd("setParameter", self.param_name_03, str(int(init_value_03)+1)) + #save config + domain_basename="Domain_" + conf_basename="Conf_" + for index_domain in range(3): + for index_conf in range(2): + domain_name=domain_basename+str(index_domain+1) + conf_name=conf_basename+str(index_domain+1)+"_"+str(index_conf) + log.I("Save config %s for domain %s"%(conf_name,domain_name)) + out, err = self.pfw.sendCmd("saveConfiguration",domain_name,conf_name) + assert err == None, log.E("Command [saveConfiguration %s %s] : %s"%(domain_name,conf_name,err)) + assert out =="Done", log.F("When saving configuration %s for domain %s"%(conf_name,domain_name)) + log.I("Save configurations: OK") + self.pfw.sendCmd("setTuningMode", "off","") + + #Check parameter values + #UINT16 + expected_value=str(int(init_value_01)+1) + log.I("UINT16 parameter = %s"%(expected_value)) + out, err = self.pfw.sendCmd("getParameter", self.param_name_01, "") + assert err == None, log.E("When setting parameter %s : %s" % (self.param_name_01, err)) + assert out == expected_value, log.F("BLACKBOARD : Incorrect value for %s, expected: %s, found: %s" % (self.param_name_01, expected_value, out)) + #Check parameter value on filesystem + assert commands.getoutput("cat %s"%(self.filesystem_01)) != init_filesystem_01, log.F("FILESYSTEM : parameter %s update error"%self.param_name_01) + #Param_00 + expected_value=str(int(init_value_02)+1) + log.I("Param_00 parameter= %s"%(expected_value)) + out, err = self.pfw.sendCmd("getParameter", self.param_name_02, "") + assert err == None, log.E("When setting parameter %s : %s" % (self.param_name_02, err)) + assert out == expected_value, log.F("BLACKBOARD : Incorrect value for %s, expected: %s, found: %s" % (self.param_name_02, expected_value, out)) + #Check parameter value on filesystem + assert commands.getoutput("cat %s"%(self.filesystem_02)) != init_filesystem_02, log.F("FILESYSTEM : parameter %s update error"%self.param_name_02) + #Param_12 + expected_value=str(int(init_value_03)+1) + log.I("Param_12 parameter= %s"%(expected_value)) + out, err = self.pfw.sendCmd("getParameter", self.param_name_03, "") + assert err == None, log.E("When setting parameter %s : %s" % (self.param_name_03, err)) + assert out == expected_value, log.F("BLACKBOARD : Incorrect value for %s, expected: %s, found: %s" % (self.param_name_03, expected_value, out)) + #Check parameter value on filesystem + assert commands.getoutput("cat %s"%(self.filesystem_03)) != init_filesystem_03, log.F("FILESYSTEM : parameter %s update error"%self.param_name_03) + + #Import the temp XML file + self.pfw.sendCmd("setTuningMode", "on","") + log.I("Import Domains with settings from %s"%(self.temp_xml)) + out, err = self.pfw.sendCmd("importDomainsWithSettingsXML",self.temp_xml, "") + assert err == None, log.E("Command [importDomainsWithSettingsXML %s] : %s"%(self.temp_xml,err)) + assert out == "Done", log.F("When using function importDomainsWithSettingsXML %s]"%(self.temp_xml)) + self.pfw.sendCmd("setTuningMode", "off","") + + #Check parameter values + #UINT16 + expected_value=init_value_01 + log.I("UINT16 parameter = %s"%(expected_value)) + out, err = self.pfw.sendCmd("getParameter", self.param_name_01, "") + assert err == None, log.E("When setting parameter %s : %s" % (self.param_name_01, err)) + assert out == expected_value, log.F("BLACKBOARD : Incorrect value for %s, expected: %s, found: %s" % (self.param_name_01, expected_value, out)) + #Check parameter value on filesystem + assert commands.getoutput("cat %s"%(self.filesystem_01)) == init_filesystem_01, log.F("FILESYSTEM : parameter %s update error"%self.param_name_01) + #Param_00 + expected_value=init_value_02 + log.I("Param_00 parameter= %s"%(expected_value)) + out, err = self.pfw.sendCmd("getParameter", self.param_name_02, "") + assert err == None, log.E("When setting parameter %s : %s" % (self.param_name_02, err)) + assert out == expected_value, log.F("BLACKBOARD : Incorrect value for %s, expected: %s, found: %s" % (self.param_name_02, expected_value, out)) + #Check parameter value on filesystem + assert commands.getoutput("cat %s"%(self.filesystem_02)) == init_filesystem_02, log.F("FILESYSTEM : parameter %s update error"%self.param_name_02) + #Param_12 + expected_value=init_value_03 + log.I("Param_12 parameter= %s"%(expected_value)) + out, err = self.pfw.sendCmd("getParameter", self.param_name_03, "") + assert err == None, log.E("When setting parameter %s : %s" % (self.param_name_03, err)) + assert out == expected_value, log.F("BLACKBOARD : Incorrect value for %s, expected: %s, found: %s" % (self.param_name_03, expected_value, out)) + #Check parameter value on filesystem + assert commands.getoutput("cat %s"%(self.filesystem_03)) == init_filesystem_03, log.F("FILESYSTEM : parameter %s update error"%self.param_name_03) + + def test_03_exportImportXML_withoutSettings_Nominal_Case(self): + """ + Testing exportDomainsXML/importDomainsXML nominal case + ------------------------------------------------------ + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - export domains in temp XML + - import a reference XML + - restore Configuration + - import the temp XML + - restore Configuration + - check Domains + - check Configuration + - check Parameters + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [exportDomainsXML] function + - [importDomainsWithSettingsXML] function + - [importDomainsXML] function + Used commands : + ~~~~~~~~~~~~~~~ + - [restoreConfiguration] function + - [listDomains] function + - [listConfiguration] function + - [getRules] function + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - all operations succeed + - parameter must not change + """ + log.D(self.test_03_exportImportXML_withoutSettings_Nominal_Case.__doc__) + + ### INIT Domains Settings #### + + #Import a reference XML file + + log.I("Import Domains with initial settings from %s"%(self.reference_xml)) + out, err = self.pfw.sendCmd("importDomainsWithSettingsXML",self.reference_xml, "") + assert err == None, log.E("Command [importDomainsWithSettingsXML %s] : %s"%(self.reference_xml,err)) + assert out == "Done", log.F("When using function importDomainsWithSettingsXML %s]"%(self.reference_xml)) + self.pfw.sendCmd("setTuningMode", "off","") + init_value_01, err = self.pfw.sendCmd("getParameter", self.param_name_01, "") + init_value_02, err = self.pfw.sendCmd("getParameter", self.param_name_02, "") + init_value_03, err = self.pfw.sendCmd("getParameter", self.param_name_03, "") + init_filesystem_01 = commands.getoutput("cat %s"%(self.filesystem_01)) + init_filesystem_02 = commands.getoutput("cat %s"%(self.filesystem_02)) + init_filesystem_03 = commands.getoutput("cat %s"%(self.filesystem_03)) + + ### END OF INIT ### + + #Export domains without settings in a temp XML file + log.I("Export Domains without initial settings in %s"%(self.temp_xml)) + out, err = self.pfw.sendCmd("exportDomainsXML",self.temp_xml, "") + assert err == None, log.E("Command [exportDomainsXML %s] : %s"%(self.temp_xml,err)) + assert out == "Done", log.F("When using function exportDomainsXML %s]"%(self.temp_xml)) + + #Change the value of checked parameters + self.pfw.sendCmd("setTuningMode", "on","") + out, err = self.pfw.sendCmd("setParameter", self.param_name_01, str(int(init_value_01)+1)) + out, err = self.pfw.sendCmd("setParameter", self.param_name_02, str(int(init_value_02)+1)) + out, err = self.pfw.sendCmd("setParameter", self.param_name_03, str(int(init_value_03)+1)) + #save config + domain_basename="Domain_" + conf_basename="Conf_" + for index_domain in range(3): + for index_conf in range(2): + domain_name=domain_basename+str(index_domain+1) + conf_name=conf_basename+str(index_domain+1)+"_"+str(index_conf) + log.I("Save config %s for domain %s"%(conf_name,domain_name)) + out, err = self.pfw.sendCmd("saveConfiguration",domain_name,conf_name) + assert err == None, log.E("Command [saveConfiguration %s %s] : %s"%(domain_name,conf_name,err)) + assert out =="Done", log.F("When saving configuration %s for domain %s"%(conf_name,domain_name)) + log.I("Save configurations: OK") + self.pfw.sendCmd("setTuningMode", "off","") + + #Check parameter values + #UINT16 + expected_value=str(int(init_value_01)+1) + log.I("UINT16 parameter = %s"%(expected_value)) + out, err = self.pfw.sendCmd("getParameter", self.param_name_01, "") + assert err == None, log.E("When setting parameter %s : %s" % (self.param_name_01, err)) + assert out == expected_value, log.F("BLACKBOARD : Incorrect value for %s, expected: %s, found: %s" % (self.param_name_01, expected_value, out)) + #Check parameter value on filesystem + assert commands.getoutput("cat %s"%(self.filesystem_01)) != init_filesystem_01, log.F("FILESYSTEM : parameter %s update error"%self.param_name_01) + #Param_00 + expected_value=str(int(init_value_02)+1) + log.I("Param_00 parameter= %s"%(expected_value)) + out, err = self.pfw.sendCmd("getParameter", self.param_name_02, "") + assert err == None, log.E("When setting parameter %s : %s" % (self.param_name_02, err)) + assert out == expected_value, log.F("BLACKBOARD : Incorrect value for %s, expected: %s, found: %s" % (self.param_name_02, expected_value, out)) + #Check parameter value on filesystem + assert commands.getoutput("cat %s"%(self.filesystem_02)) != init_filesystem_02, log.F("FILESYSTEM : parameter %s update error"%self.param_name_02) + #Param_12 + expected_value=str(int(init_value_03)+1) + log.I("Param_12 parameter= %s"%(expected_value)) + out, err = self.pfw.sendCmd("getParameter", self.param_name_03, "") + assert err == None, log.E("When setting parameter %s : %s" % (self.param_name_03, err)) + assert out == expected_value, log.F("BLACKBOARD : Incorrect value for %s, expected: %s, found: %s" % (self.param_name_03, expected_value, out)) + #Check parameter value on filesystem + assert commands.getoutput("cat %s"%(self.filesystem_03)) != init_filesystem_03, log.F("FILESYSTEM : parameter %s update error"%self.param_name_03) + + #Import the temp XML file without + self.pfw.sendCmd("setTuningMode", "on","") + log.I("Import Domains without settings from %s"%(self.temp_xml)) + out, err = self.pfw.sendCmd("importDomainsXML",self.temp_xml, "") + assert err == None, log.E("Command [importDomainsXML %s] : %s"%(self.temp_xml,err)) + assert out == "Done", log.F("When using function importDomainsXML %s]"%(self.temp_xml)) + self.pfw.sendCmd("setTuningMode", "off","") + + #Check parameter values + #UINT16 + unexpected_value=init_value_01 + log.I("UINT16 parameter = %s"%(unexpected_value)) + out, err = self.pfw.sendCmd("getParameter", self.param_name_01, "") + assert err == None, log.E("When setting parameter %s : %s" % (self.param_name_01, err)) + assert out != unexpected_value, log.F("BLACKBOARD : Unexpected value found for %s: %s" % (self.param_name_01, out)) + #Check parameter value on filesystem + assert commands.getoutput("cat %s"%(self.filesystem_01)) != init_filesystem_01, log.F("FILESYSTEM : parameter %s update error"%self.param_name_01) + #Param_00 + unexpected_value=init_value_02 + log.I("Param_00 parameter= %s"%(unexpected_value)) + out, err = self.pfw.sendCmd("getParameter", self.param_name_02, "") + assert err == None, log.E("When setting parameter %s : %s" % (self.param_name_02, err)) + assert out != unexpected_value, log.F("BLACKBOARD : Unexpected value found for %s: %s" % (self.param_name_02, out)) + #Check parameter value on filesystem + assert commands.getoutput("cat %s"%(self.filesystem_02)) != init_filesystem_02, log.F("FILESYSTEM : parameter %s update error"%self.param_name_02) + #Param_12 + unexpected_value=init_value_03 + log.I("Param_12 parameter= %s"%(unexpected_value)) + out, err = self.pfw.sendCmd("getParameter", self.param_name_03, "") + assert err == None, log.E("When setting parameter %s : %s" % (self.param_name_03, err)) + assert out != unexpected_value, log.F("BLACKBOARD : Unexpected value found for %s: %s"% (self.param_name_03, out)) + #Check parameter value on filesystem + assert commands.getoutput("cat %s"%(self.filesystem_03)) != init_filesystem_03, log.F("FILESYSTEM : parameter %s update error"%self.param_name_03) + + #Import the reference_XML file without settings + self.pfw.sendCmd("setTuningMode", "on","") + log.I("Import Domains without settings from %s"%(self.reference_xml)) + out, err = self.pfw.sendCmd("importDomainsXML",self.reference_xml, "") + assert err == None, log.E("Command [importDomainsXML %s] : %s"%(self.reference_xml,err)) + assert out == "Done", log.F("When using function importDomainsXML %s]"%(self.reference_xml)) + self.pfw.sendCmd("setTuningMode", "off","") + + #Check parameter values + #UINT16 + unexpected_value=init_value_01 + log.I("UINT16 parameter = %s"%(unexpected_value)) + out, err = self.pfw.sendCmd("getParameter", self.param_name_01, "") + assert err == None, log.E("When setting parameter %s : %s" % (self.param_name_01, err)) + assert out != unexpected_value, log.F("BLACKBOARD : Unexpected value found for %s: %s" % (self.param_name_01, out)) + #Check parameter value on filesystem + assert commands.getoutput("cat %s"%(self.filesystem_01)) != init_filesystem_01, log.F("FILESYSTEM : parameter %s update error"%self.param_name_01) + #Param_00 + unexpected_value=init_value_02 + log.I("Param_00 parameter= %s"%(unexpected_value)) + out, err = self.pfw.sendCmd("getParameter", self.param_name_02, "") + assert err == None, log.E("When setting parameter %s : %s" % (self.param_name_02, err)) + assert out != unexpected_value, log.F("BLACKBOARD : Unexpected value found for %s: %s" % (self.param_name_02, out)) + #Check parameter value on filesystem + assert commands.getoutput("cat %s"%(self.filesystem_02)) != init_filesystem_02, log.F("FILESYSTEM : parameter %s update error"%self.param_name_02) + #Param_12 + unexpected_value=init_value_03 + log.I("Param_12 parameter= %s"%(unexpected_value)) + out, err = self.pfw.sendCmd("getParameter", self.param_name_03, "") + assert err == None, log.E("When setting parameter %s : %s" % (self.param_name_03, err)) + assert out != unexpected_value, log.F("BLACKBOARD : Unexpected value found for %s: %s" % (self.param_name_03, out)) + #Check parameter value on filesystem + assert commands.getoutput("cat %s"%(self.filesystem_03)) != init_filesystem_03, log.F("FILESYSTEM : parameter %s update error"%self.param_name_03) + + + + def test_04_exportImportSettings_Binary_Nominal_Case(self): + """ + Testing exportSettings/importSettings nominal case + -------------------------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - export settings in temp binary files + - import a reference XML + - restore Configuration + - import the temp binary files + - restore Configuration + - check Domains + - check Configuration + - check Parameters + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [exportSettings] function + - [importDomainsWithSettingsXML] function + - [importSettings] function + Used commands : + ~~~~~~~~~~~~~~~ + - [restoreConfiguration] function + - [listDomains] function + - [listConfiguration] function + - [getRules] function + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - all operations succeed + """ + log.D(self.test_04_exportImportSettings_Binary_Nominal_Case.__doc__) + ### INIT Domains Settings #### + + #Import a reference XML file + + log.I("Import Domains with initial settings from %s" + %(self.reference_xml)) + out, err = self.pfw.sendCmd("importDomainsWithSettingsXML",self.reference_xml, "") + assert err == None, log.E("Command [importDomainsWithSettingsXML %s] : %s"%(self.reference_xml,err)) + assert out == "Done", log.F("When using function importDomainsWithSettingsXML %s]"%(self.reference_xml)) + self.pfw.sendCmd("setTuningMode", "off","") + init_value_01, err = self.pfw.sendCmd("getParameter", self.param_name_01, "") + init_value_02, err = self.pfw.sendCmd("getParameter", self.param_name_02, "") + init_value_03, err = self.pfw.sendCmd("getParameter", self.param_name_03, "") + init_filesystem_01 = commands.getoutput("cat %s"%(self.filesystem_01)) + init_filesystem_02 = commands.getoutput("cat %s"%(self.filesystem_02)) + init_filesystem_03 = commands.getoutput("cat %s"%(self.filesystem_03)) + + ### END OF INIT ### + + #Export domains without settings in a temp XML file + log.I("Export Domains without initial settings in %s"%(self.temp_xml)) + out, err = self.pfw.sendCmd("exportDomainsXML",self.temp_xml, "") + assert err == None, log.E("Command [exportDomainsXML %s] : %s"%(self.temp_xml,err)) + assert out == "Done", log.F("When using function exportDomainsXML %s]"%(self.temp_xml)) + #Export settings in a binary temp file + log.I("Export settings in the binary files %s"%(self.temp_binary)) + out, err = self.pfw.sendCmd("exportSettings",self.temp_binary, "") + assert err == None, log.E("Command [exportSettings %s] : %s"%(self.temp_binary,err)) + assert out == "Done", log.F("When using function exportSettings %s]"%(self.temp_binary)) + + #Change the value of checked parameters + self.pfw.sendCmd("setTuningMode", "on","") + out, err = self.pfw.sendCmd("setParameter", self.param_name_01, str(int(init_value_01)+1)) + out, err = self.pfw.sendCmd("setParameter", self.param_name_02, str(int(init_value_02)+1)) + out, err = self.pfw.sendCmd("setParameter", self.param_name_03, str(int(init_value_03)+1)) + #save config + domain_basename="Domain_" + conf_basename="Conf_" + for index_domain in range(3): + for index_conf in range(2): + domain_name=domain_basename+str(index_domain+1) + conf_name=conf_basename+str(index_domain+1)+"_"+str(index_conf) + log.I("Save config %s for domain %s"%(conf_name,domain_name)) + out, err = self.pfw.sendCmd("saveConfiguration",domain_name,conf_name) + assert err == None, log.E("Command [saveConfiguration %s %s] : %s"%(domain_name,conf_name,err)) + assert out =="Done", log.F("When saving configuration %s for domain %s"%(conf_name,domain_name)) + log.I("Save configurations: OK") + self.pfw.sendCmd("setTuningMode", "off","") + + #Check parameter values + #UINT16 + expected_value=str(int(init_value_01)+1) + log.I("UINT16 parameter = %s"%(expected_value)) + out, err = self.pfw.sendCmd("getParameter", self.param_name_01, "") + assert err == None, log.E("When setting parameter %s : %s" % (self.param_name_01, err)) + assert out == expected_value, log.F("BLACKBOARD : Incorrect value for %s, expected: %s, found: %s" % (self.param_name_01, expected_value, out)) + #Check parameter value on filesystem + assert commands.getoutput("cat %s"%(self.filesystem_01)) != init_filesystem_01, log.F("FILESYSTEM : parameter %s update error"%self.param_name_01) + #Param_00 + expected_value=str(int(init_value_02)+1) + log.I("Param_00 parameter= %s"%(expected_value)) + out, err = self.pfw.sendCmd("getParameter", self.param_name_02, "") + assert err == None, log.E("When setting parameter %s : %s" % (self.param_name_02, err)) + assert out == expected_value, log.F("BLACKBOARD : Incorrect value for %s, expected: %s, found: %s" % (self.param_name_02, expected_value, out)) + #Check parameter value on filesystem + assert commands.getoutput("cat %s"%(self.filesystem_02)) != init_filesystem_02, log.F("FILESYSTEM : parameter %s update error"%self.param_name_02) + #Param_12 + expected_value=str(int(init_value_03)+1) + log.I("Param_12 parameter= %s"%(expected_value)) + out, err = self.pfw.sendCmd("getParameter", self.param_name_03, "") + assert err == None, log.E("When setting parameter %s : %s" % (self.param_name_03, err)) + assert out == expected_value, log.F("BLACKBOARD : Incorrect value for %s, expected: %s, found: %s" % (self.param_name_03, expected_value, out)) + #Check parameter value on filesystem + assert commands.getoutput("cat %s"%(self.filesystem_03)) != init_filesystem_03, log.F("FILESYSTEM : parameter %s update error"%self.param_name_03) + + #Import the temp XML file without + self.pfw.sendCmd("setTuningMode", "on","") + log.I("Import Domains without settings from %s"%(self.temp_xml)) + out, err = self.pfw.sendCmd("importDomainsXML",self.temp_xml, "") + assert err == None, log.E("Command [importDomainsXML %s] : %s"%(self.temp_xml,err)) + assert out == "Done", log.F("When using function importDomainsXML %s]"%(self.temp_xml)) + self.pfw.sendCmd("setTuningMode", "off","") + + #Check parameter values + #UINT16 + unexpected_value=init_value_01 + log.I("UINT16 parameter = %s"%(unexpected_value)) + out, err = self.pfw.sendCmd("getParameter", self.param_name_01, "") + assert err == None, log.E("When setting parameter %s : %s" % (self.param_name_01, err)) + assert out != unexpected_value, log.F("BLACKBOARD : Unexpected value found for %s: %s" % (self.param_name_01, out)) + #Check parameter value on filesystem + assert commands.getoutput("cat %s"%(self.filesystem_01)) != init_filesystem_01, log.F("FILESYSTEM : parameter %s update error"%self.param_name_01) + #Param_00 + unexpected_value=init_value_02 + log.I("Param_00 parameter= %s"%(unexpected_value)) + out, err = self.pfw.sendCmd("getParameter", self.param_name_02, "") + assert err == None, log.E("When setting parameter %s : %s" % (self.param_name_02, err)) + assert out != unexpected_value, log.F("BLACKBOARD : Unexpected value found for %s: %s" % (self.param_name_02, out)) + #Check parameter value on filesystem + assert commands.getoutput("cat %s"%(self.filesystem_02)) != init_filesystem_02, log.F("FILESYSTEM : parameter %s update error"%self.param_name_02) + #Param_12 + unexpected_value=init_value_03 + log.I("Param_12 parameter= %s"%(unexpected_value)) + out, err = self.pfw.sendCmd("getParameter", self.param_name_03, "") + assert err == None, log.E("When setting parameter %s : %s" % (self.param_name_03, err)) + assert out != unexpected_value, log.F("BLACKBOARD : Unexpected value found for %s: %s"% (self.param_name_03, out)) + #Check parameter value on filesystem + assert commands.getoutput("cat %s"%(self.filesystem_03)) != init_filesystem_03, log.F("FILESYSTEM : parameter %s update error"%self.param_name_03) + + #Import settings from the binary files + self.pfw.sendCmd("setTuningMode", "on","") + log.I("Import settings from %s"%(self.temp_binary)) + out, err = self.pfw.sendCmd("importSettings",self.temp_binary, "") + assert err == None, log.E("Command [importSettings %s] : %s"%(self.temp_binary,err)) + assert out == "Done", log.F("When using function importSettings %s]"%(self.temp_binary)) + self.pfw.sendCmd("setTuningMode", "off","") + + #Check parameter values + #UINT16 + expected_value=init_value_01 + log.I("UINT16 parameter = %s"%(expected_value)) + out, err = self.pfw.sendCmd("getParameter", self.param_name_01, "") + assert err == None, log.E("When setting parameter %s : %s" % (self.param_name_01, err)) + assert out == expected_value, log.F("BLACKBOARD : Incorrect value for %s, expected: %s, found: %s" % (self.param_name_01, expected_value, out)) + #Check parameter value on filesystem + assert commands.getoutput("cat %s"%(self.filesystem_01)) == init_filesystem_01, log.F("FILESYSTEM : parameter %s update error"%self.param_name_01) + #Param_00 + expected_value=init_value_02 + log.I("Param_00 parameter= %s"%(expected_value)) + out, err = self.pfw.sendCmd("getParameter", self.param_name_02, "") + assert err == None, log.E("When setting parameter %s : %s" % (self.param_name_02, err)) + assert out == expected_value, log.F("BLACKBOARD : Incorrect value for %s, expected: %s, found: %s" % (self.param_name_02, expected_value, out)) + #Check parameter value on filesystem + assert commands.getoutput("cat %s"%(self.filesystem_02)) == init_filesystem_02, log.F("FILESYSTEM : parameter %s update error"%self.param_name_02) + #Param_12 + expected_value=init_value_03 + log.I("Param_12 parameter= %s"%(expected_value)) + out, err = self.pfw.sendCmd("getParameter", self.param_name_03, "") + assert err == None, log.E("When setting parameter %s : %s" % (self.param_name_03, err)) + assert out == expected_value, log.F("BLACKBOARD : Incorrect value for %s, expected: %s, found: %s" % (self.param_name_03, expected_value, out)) + #Check parameter value on filesystem + assert commands.getoutput("cat %s"%(self.filesystem_03)) == init_filesystem_03, log.F("FILESYSTEM : parameter %s update error"%self.param_name_03) + + + + @unittest.expectedFailure + def test_05_Import_XML_With_Settings_Error_Case(self): + """ + Testing importDomainsWithSettingsXML error case + ----------------------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - import with settings non-compliant XML + - import with settings a non-existing XML file + - check Domains + - check Configuration + - check Parameters + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [importDomainsWithSettingsXML] function + - [importDomainsXML] function + - [importSettings] function + Used commands : + ~~~~~~~~~~~~~~~ + - [restoreConfiguration] function + - [listDomains] function + - [listConfiguration] function + - [getRules] function + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - all errors are detected, initial domains keep settings + """ + log.D(self.test_05_Import_XML_With_Settings_Error_Case.__doc__) + + ### INIT Domains Settings #### + #Import a reference XML file + + log.I("Import Domains with initial settings from %s"%(self.reference_xml)) + out, err = self.pfw.sendCmd("importDomainsWithSettingsXML",self.reference_xml, "") + assert err == None, log.E("Command [importDomainsWithSettingsXML %s] : %s"%(self.reference_xml,err)) + assert out == "Done", log.F("When using function importDomainsWithSettingsXML %s]"%(self.reference_xml)) + + self.pfw.sendCmd("setTuningMode", "off","") + init_value_01, err = self.pfw.sendCmd("getParameter", self.param_name_01, "") + init_value_02, err = self.pfw.sendCmd("getParameter", self.param_name_02, "") + init_value_03, err = self.pfw.sendCmd("getParameter", self.param_name_03, "") + init_filesystem_01 = commands.getoutput("cat %s"%(self.filesystem_01)) + init_filesystem_02 = commands.getoutput("cat %s"%(self.filesystem_02)) + init_filesystem_03 = commands.getoutput("cat %s"%(self.filesystem_03)) + xml_path="$PFW_TEST_TOOLS/xml/XML_Test/" + ### END OF INIT ### + + self.pfw.sendCmd("setTuningMode", "on","") + #Import domains and settings from xml with outbound parameter value + xml_name="Uncompliant_OutboundParameter.xml" + log.I("Import %s with initial settings"%(xml_name)) + out, err = self.pfw.sendCmd("importDomainsWithSettingsXML",xml_path+xml_name, "") + assert err == None, log.E("Command [importDomainsWithSettingsXML %s] : %s"%(xml_path+xml_name,err)) + assert out != "Done", log.F("Error not detected when imported %s]"%(xml_path+xml_name)) + log.I("Test OK : %s is not imported"%(xml_name)) + #Import domains and settings from xml using undeclared configurable element + xml_name="Uncompliant_UndeclaredConfigurableElement.xml" + log.I("Import %s with initial settings"%(xml_name)) + out, err = self.pfw.sendCmd("importDomainsWithSettingsXML",xml_path+xml_name, "") + assert err == None, log.E("Command [importDomainsWithSettingsXML %s] : %s"%(xml_path+xml_name,err)) + assert out != "Done", log.F("Error not detected when imported %s]"%(xml_path+xml_name)) + log.I("Test OK : %s is not imported"%(xml_name)) + #Import domains and settings from xml using undeclared parameter + xml_name="Uncompliant_UndeclaredParameter.xml" + log.I("Import %s with initial settings"%(xml_name)) + out, err = self.pfw.sendCmd("importDomainsWithSettingsXML",xml_path+xml_name, "") + assert err == None, log.E("Command [importDomainsWithSettingsXML %s] : %s"%(xml_path+xml_name,err)) + assert out != "Done", log.F("Error not detected when imported %s]"%(xml_path+xml_name)) + log.I("Test OK : %s is not imported"%(xml_name)) + #Import domains and settings from xml using wrong order of configurable element + xml_name="Uncompliant_UnorderConfigurableElement.xml" + log.I("Import %s with initial settings"%(xml_name)) + out, err = self.pfw.sendCmd("importDomainsWithSettingsXML",xml_path+xml_name, "") + assert err == None, log.E("Command [importDomainsWithSettingsXML %s] : %s"%(xml_path+xml_name,err)) + assert out != "Done", log.F("Error not detected when imported %s]"%(xml_path+xml_name)) + log.I("Test OK : %s is not imported"%(xml_name)) + #Import domains and settings from unexistent xml + xml_name="Unexistent.xml" + log.I("Import %s with initial settings"%(xml_name)) + out, err = self.pfw.sendCmd("importDomainsWithSettingsXML",xml_path+xml_name, "") + assert err == None, log.E("Command [importDomainsWithSettingsXML %s] : %s"%(xml_path+xml_name,err)) + assert out != "Done", log.F("Error not detected when imported %s]"%(xml_path+xml_name)) + log.I("Test OK : %s is not imported"%(xml_name)) + self.pfw.sendCmd("setTuningMode", "off","") + + #### check domains and settings #### + + #Check number of domain(3 domains are setup in the reference XML, initially only one domains is declared) + # Domains listing using "listDomains" command + log.I("Current domains listing") + log.I("Command [listDomains]") + out, err = self.pfw.sendCmd("listDomains","","") + assert err == None, log.E("Command [listDomains] : %s"%(err)) + log.I("Command [listDomains] - correctly executed") + # Domains listing backup + f_Domains_Backup = open(self.temp_domain, "w") + f_Domains_Backup.write(out) + f_Domains_Backup.close() + f_Domains_Backup = open(self.temp_domain, "r") + domains_nbr = 0 + line=f_Domains_Backup.readline() + while line!="": + line=f_Domains_Backup.readline() + domains_nbr+=1 + f_Domains_Backup.close() + log.I("Actual domains number : %s" % domains_nbr) + assert domains_nbr==self.nb_domains_in_reference_xml, log.F("Number of listed domains is not compliant with the file %s - expected : %s - found : %s"%(self.reference_xml,self.nb_domains_in_reference_xml, domains_nbr)) + #Check number of config per domain(2 config per domains are setup in the reference XML) + # Config listing + domain_basename="Domain_" + for index in range(self.nb_domains_in_reference_xml): + domain_name=domain_basename+str(index+1) + log.I("Listing config for domain %s"%(domain_name)) + out, err = self.pfw.sendCmd("listConfigurations",domain_name,"") + assert err == None, log.E("Command [listConfigurations %s] : %s"%(domain_name,err)) + log.I("Command [listConfigurations %s] - correctly executed"%(domain_name)) + f_Config_Backup = open(self.temp_config, "w") + f_Config_Backup.write(out) + f_Config_Backup.close() + f_Config_Backup = open(self.temp_config, "r") + config_nbr = 0 + line=f_Config_Backup.readline() + while line!="": + line=f_Config_Backup.readline() + config_nbr+=1 + f_Config_Backup.close() + assert config_nbr==self.nb_conf_per_domains_in_reference_xml[index], log.F("Number of listed config for %s is not compliant with the file %s - expected : %s - found : %s"%(domain_name, self.reference_xml,self.nb_conf_per_domains_in_reference_xml[index], domains_nbr)) + log.I("Config checking : OK") + #Check parameter values + #UINT16 + expected_value=init_value_01 + hex_value=init_filesystem_01 + log.I("UINT16 parameter in the conf Conf_1_1= %s"%(expected_value)) + out, err = self.pfw.sendCmd("getParameter", self.param_name_01, "") + assert err == None, log.E("When setting parameter %s : %s" % (self.param_name_01, err)) + assert out == expected_value, log.F("BLACKBOARD : Incorrect value for %s, expected: %s, found: %s" % (self.param_name_01, expected_value, out)) + #Check parameter value on filesystem + assert commands.getoutput("cat %s"%(self.filesystem_01)) == hex_value, log.F("FILESYSTEM : parameter %s update error"%self.param_name_01) + #Param_00 + expected_value=init_value_02 + hex_value=init_filesystem_02 + log.I("Param_00 parameter in the conf Conf_2_1= %s"%(expected_value)) + out, err = self.pfw.sendCmd("getParameter", self.param_name_02, "") + assert err == None, log.E("When setting parameter %s : %s" % (self.param_name_02, err)) + assert out == expected_value, log.F("BLACKBOARD : Incorrect value for %s, expected: %s, found: %s" % (self.param_name_02, expected_value, out)) + #Check parameter value on filesystem + assert commands.getoutput("cat %s"%(self.filesystem_02)) == hex_value, log.F("FILESYSTEM : parameter %s update error"%self.param_name_02) + #Param_12 + expected_value=init_value_03 + hex_value=init_filesystem_03 + log.I("Param_12 parameter in the conf Conf_3_1= %s"%(expected_value)) + out, err = self.pfw.sendCmd("getParameter", self.param_name_03, "") + assert err == None, log.E("When setting parameter %s : %s" % (self.param_name_03, err)) + assert out == expected_value, log.F("BLACKBOARD : Incorrect value for %s, expected: %s, found: %s" % (self.param_name_03, expected_value, out)) + #Check parameter value on filesystem + assert commands.getoutput("cat %s"%(self.filesystem_03)) == hex_value, log.F("FILESYSTEM : parameter %s update error"%self.param_name_03) + log.I("Parameters checking : OK") + + #### END check domains and settings #### + + + @unittest.expectedFailure + def test_06_Import_XML_Without_Settings_Error_Case(self): + """ + Testing import XML without settings error case + ---------------------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - import non-compliant XML + - import a non-existing XML files + - import a reference XML + - check Domains + - check Configuration + - check Parameters + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [importDomainsWithSettingsXML] function + - [importDomainsXML] function + - [importSettings] function + Used commands : + ~~~~~~~~~~~~~~~ + - [restoreConfiguration] function + - [listDomains] function + - [listConfiguration] function + - [getRules] function + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - all errors are detected, initial domains keep settings + """ + log.D(self.test_06_Import_XML_Without_Settings_Error_Case.__doc__) + + ### INIT Domains Settings #### + #Import a reference XML file + + log.I("Import Domains with initial settings from %s"%(self.reference_xml)) + out, err = self.pfw.sendCmd("importDomainsWithSettingsXML",self.reference_xml, "") + assert err == None, log.E("Command [importDomainsWithSettingsXML %s] : %s"%(self.reference_xml,err)) + assert out == "Done", log.F("When using function importDomainsWithSettingsXML %s]"%(self.reference_xml)) + + self.pfw.sendCmd("setTuningMode", "off","") + xml_path="$PFW_TEST_TOOLS/xml/XML_Test/" + ### END OF INIT ### + + self.pfw.sendCmd("setTuningMode", "on","") + #Import domains from xml with outbound parameter value + xml_name="Uncompliant_OutboundParameter.xml" + log.I("Import %s without settings"%(xml_name)) + out, err = self.pfw.sendCmd("importDomainsXML",xml_path+xml_name, "") + assert err == None, log.E("Command [importDomainsXML %s] : %s"%(xml_path+xml_name,err)) + assert out != "Done", log.F("Error not detected when imported %s]"%(xml_path+xml_name)) + log.I("Test OK : %s is not imported"%(xml_name)) + #Import domains from xml using undeclared configurable element + xml_name="Uncompliant_UndeclaredConfigurableElement.xml" + log.I("Import %s without settings"%(xml_name)) + out, err = self.pfw.sendCmd("importDomainsXML",xml_path+xml_name, "") + assert err == None, log.E("Command [importDomainsXML %s] : %s"%(xml_path+xml_name,err)) + assert out != "Done", log.F("Error not detected when imported %s]"%(xml_path+xml_name)) + log.I("Test OK : %s is not imported"%(xml_name)) + #Import domains from xml using undeclared parameter + #xml_name="Uncompliant_UndeclaredParameter.xml" + #log.I("Import %s without settings"%(xml_name)) + #out, err = self.pfw.sendCmd("importDomainsXML",xml_path+xml_name, "") + #assert err == None, log.E("Command [importDomainsXML %s] : %s"%(xml_path+xml_name,err)) + #assert out != "Done", log.F("Error not detected when imported %s]"%(xml_path+xml_name)) + #log.I("Test OK : %s is not imported"%(xml_name)) + #Import domains from xml using wrong order of configurable element + xml_name="Uncompliant_UnorderConfigurableElement.xml" + log.I("Import %s without settings"%(xml_name)) + out, err = self.pfw.sendCmd("importDomainsXML",xml_path+xml_name, "") + assert err == None, log.E("Command [importDomainsXML %s] : %s"%(xml_path+xml_name,err)) + assert out != "Done", log.F("Error not detected when imported %s]"%(xml_path+xml_name)) + log.I("Test OK : %s is not imported"%(xml_name)) + #Import domains from unexistent xml + xml_name="Unexistent.xml" + log.I("Import %s without settings"%(xml_name)) + out, err = self.pfw.sendCmd("importDomainsXML",xml_path+xml_name, "") + assert err == None, log.E("Command [importDomainsXML %s] : %s"%(xml_path+xml_name,err)) + assert out != "Done", log.F("Error not detected when imported %s]"%(xml_path+xml_name)) + log.I("Test OK : %s is not imported"%(xml_name)) + self.pfw.sendCmd("setTuningMode", "off","") + + #### check domains and settings #### + + #Check number of domain(3 domains are setup in the reference XML, initially only one domains is declared) + # Domains listing using "listDomains" command + log.I("Current domains listing") + log.I("Command [listDomains]") + out, err = self.pfw.sendCmd("listDomains","","") + assert err == None, log.E("Command [listDomains] : %s"%(err)) + log.I("Command [listDomains] - correctly executed") + # Domains listing backup + f_Domains_Backup = open(self.temp_domain, "w") + f_Domains_Backup.write(out) + f_Domains_Backup.close() + f_Domains_Backup = open(self.temp_domain, "r") + domains_nbr = 0 + line=f_Domains_Backup.readline() + while line!="": + line=f_Domains_Backup.readline() + domains_nbr+=1 + f_Domains_Backup.close() + log.I("Actual domains number : %s" % domains_nbr) + assert domains_nbr==self.nb_domains_in_reference_xml, log.F("Number of listed domains is not compliant with the file %s - expected : %s - found : %s"%(self.reference_xml,self.nb_domains_in_reference_xml, domains_nbr)) + #Check number of config per domain(2 config per domains are setup in the reference XML) + # Config listing + domain_basename="Domain_" + for index in range(self.nb_domains_in_reference_xml): + domain_name=domain_basename+str(index+1) + log.I("Listing config for domain %s"%(domain_name)) + out, err = self.pfw.sendCmd("listConfigurations",domain_name,"") + assert err == None, log.E("Command [listConfigurations %s] : %s"%(domain_name,err)) + log.I("Command [listConfigurations %s] - correctly executed"%(domain_name)) + f_Config_Backup = open(self.temp_config, "w") + f_Config_Backup.write(out) + f_Config_Backup.close() + f_Config_Backup = open(self.temp_config, "r") + config_nbr = 0 + line=f_Config_Backup.readline() + while line!="": + line=f_Config_Backup.readline() + config_nbr+=1 + f_Config_Backup.close() + assert config_nbr==self.nb_conf_per_domains_in_reference_xml[index], log.F("Number of listed config for %s is not compliant with the file %s - expected : %s - found : %s"%(domain_name, self.reference_xml,self.nb_conf_per_domains_in_reference_xml[index], domains_nbr)) + log.I("Config checking : OK") + + #### END check domains and settings #### + + + @unittest.expectedFailure + def test_07_Import_Settings_From_Binary_Error_Case(self): + """ + Testing importDomainsWithSettingsXML error case + ---------------------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - import settings from a non-compliant binary + - import settings from a non-existing file + - check Domains + - check Configuration + - check Parameters + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [importDomainsWithSettingsXML] function + - [importDomainsXML] function + - [importSettings] function + Used commands : + ~~~~~~~~~~~~~~~ + - [restoreConfiguration] function + - [listDomains] function + - [listConfiguration] function + - [getRules] function + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - all errors are detected, initial domains keep settings + """ + log.D(self.test_07_Import_Settings_From_Binary_Error_Case.__doc__) + + ### INIT Domains Settings #### + #Import the initial XML file + log.I("Import Domains with initial settings from %s"%(self.initial_xml)) + out, err = self.pfw.sendCmd("importDomainsWithSettingsXML",self.initial_xml, "") + assert err == None, log.E("Command [importDomainsWithSettingsXML %s] : %s"%(self.initial_xml,err)) + assert out == "Done", log.F("When using function importDomainsWithSettingsXML %s]"%(self.initial_xml)) + #Export a binary files from the initial setting and config + log.I("Export settings in the binary files %s"%(self.temp_binary)) + out, err = self.pfw.sendCmd("exportSettings",self.temp_binary, "") + assert err == None, log.E("Command [exportSettings %s] : %s"%(self.temp_binary,err)) + assert out == "Done", log.F("When using function exportSettings %s]"%(self.temp_binary)) + #Import the reference XML file with another configuration + log.I("Import Domains with initial settings from %s"%(self.reference_xml)) + out, err = self.pfw.sendCmd("importDomainsWithSettingsXML",self.reference_xml, "") + assert err == None, log.E("Command [importDomainsWithSettingsXML %s] : %s"%(self.reference_xml,err)) + assert out == "Done", log.F("When using function importDomainsWithSettingsXML %s]"%(self.reference_xml)) + + self.pfw.sendCmd("setTuningMode", "off","") + init_value_01, err = self.pfw.sendCmd("getParameter", self.param_name_01, "") + init_value_02, err = self.pfw.sendCmd("getParameter", self.param_name_02, "") + init_value_03, err = self.pfw.sendCmd("getParameter", self.param_name_03, "") + init_filesystem_01 = commands.getoutput("cat %s"%(self.filesystem_01)) + init_filesystem_02 = commands.getoutput("cat %s"%(self.filesystem_02)) + init_filesystem_03 = commands.getoutput("cat %s"%(self.filesystem_03)) + xml_path="$PFW_TEST_TOOLS/xml/XML_Test/" + ### END OF INIT ### + + self.pfw.sendCmd("setTuningMode", "on","") + #Import the temporary binary file, normaly uncompatible with this config + self.pfw.sendCmd("setTuningMode", "on","") + log.I("Import settings from %s"%(self.temp_binary)) + out, err = self.pfw.sendCmd("importSettings",self.temp_binary, "") + assert err == None, log.E("Command [importSettings %s] : %s"%(self.temp_binary,err)) + assert out != "Done", log.F("Error not detected when imported %s]"%(self.temp_binary)) + log.I("Test OK : %s is not imported"%(self.temp_binary)) + #Import setings from a non-existing binary files + name="Unexistent" + log.I("Import settings from %s"%(name)) + out, err = self.pfw.sendCmd("importDomainsWithSettingsXML",xml_path+name, "") + assert err == None, log.E("Command [importDomainsWithSettingsXML %s] : %s"%(xml_path+name,err)) + assert out != "Done", log.F("Error not detected when imported %s]"%(xml_path+name)) + log.I("Test OK : %s is not imported"%(name)) + self.pfw.sendCmd("setTuningMode", "off","") + + #### check domains and settings #### + + #Check number of domain(3 domains are setup in the reference XML, initially only one domains is declared) + # Domains listing using "listDomains" command + log.I("Current domains listing") + log.I("Command [listDomains]") + out, err = self.pfw.sendCmd("listDomains","","") + assert err == None, log.E("Command [listDomains] : %s"%(err)) + log.I("Command [listDomains] - correctly executed") + # Domains listing backup + f_Domains_Backup = open(self.temp_domain, "w") + f_Domains_Backup.write(out) + f_Domains_Backup.close() + f_Domains_Backup = open(self.temp_domain, "r") + domains_nbr = 0 + line=f_Domains_Backup.readline() + while line!="": + line=f_Domains_Backup.readline() + domains_nbr+=1 + f_Domains_Backup.close() + log.I("Actual domains number : %s" % domains_nbr) + assert domains_nbr==self.nb_domains_in_reference_xml, log.F("Number of listed domains is not compliant with the file %s - expected : %s - found : %s"%(self.reference_xml,self.nb_domains_in_reference_xml, domains_nbr)) + #Check number of config per domain(2 config per domains are setup in the reference XML) + # Config listing + domain_basename="Domain_" + for index in range(self.nb_domains_in_reference_xml): + domain_name=domain_basename+str(index+1) + log.I("Listing config for domain %s"%(domain_name)) + out, err = self.pfw.sendCmd("listConfigurations",domain_name,"") + assert err == None, log.E("Command [listConfigurations %s] : %s"%(domain_name,err)) + log.I("Command [listConfigurations %s] - correctly executed"%(domain_name)) + f_Config_Backup = open(self.temp_config, "w") + f_Config_Backup.write(out) + f_Config_Backup.close() + f_Config_Backup = open(self.temp_config, "r") + config_nbr = 0 + line=f_Config_Backup.readline() + while line!="": + line=f_Config_Backup.readline() + config_nbr+=1 + f_Config_Backup.close() + assert config_nbr==self.nb_conf_per_domains_in_reference_xml[index], log.F("Number of listed config for %s is not compliant with the file %s - expected : %s - found : %s"%(domain_name, self.reference_xml,self.nb_conf_per_domains_in_reference_xml[index], domains_nbr)) + log.I("Config checking : OK") + #Check parameter values + #UINT16 + expected_value=init_value_01 + hex_value=init_filesystem_01 + log.I("UINT16 parameter in the conf Conf_1_1= %s"%(expected_value)) + out, err = self.pfw.sendCmd("getParameter", self.param_name_01, "") + assert err == None, log.E("When setting parameter %s : %s" % (self.param_name_01, err)) + assert out == expected_value, log.F("BLACKBOARD : Incorrect value for %s, expected: %s, found: %s" % (self.param_name_01, expected_value, out)) + #Check parameter value on filesystem + assert commands.getoutput("cat %s"%(self.filesystem_01)) == hex_value, log.F("FILESYSTEM : parameter %s update error"%self.param_name_01) + #Param_00 + expected_value=init_value_02 + hex_value=init_filesystem_02 + log.I("Param_00 parameter in the conf Conf_2_1= %s"%(expected_value)) + out, err = self.pfw.sendCmd("getParameter", self.param_name_02, "") + assert err == None, log.E("When setting parameter %s : %s" % (self.param_name_02, err)) + assert out == expected_value, log.F("BLACKBOARD : Incorrect value for %s, expected: %s, found: %s" % (self.param_name_02, expected_value, out)) + #Check parameter value on filesystem + assert commands.getoutput("cat %s"%(self.filesystem_02)) == hex_value, log.F("FILESYSTEM : parameter %s update error"%self.param_name_02) + #Param_12 + expected_value=init_value_03 + hex_value=init_filesystem_03 + log.I("Param_12 parameter in the conf Conf_3_1= %s"%(expected_value)) + out, err = self.pfw.sendCmd("getParameter", self.param_name_03, "") + assert err == None, log.E("When setting parameter %s : %s" % (self.param_name_03, err)) + assert out == expected_value, log.F("BLACKBOARD : Incorrect value for %s, expected: %s, found: %s" % (self.param_name_03, expected_value, out)) + #Check parameter value on filesystem + assert commands.getoutput("cat %s"%(self.filesystem_03)) == hex_value, log.F("FILESYSTEM : parameter %s update error"%self.param_name_03) + log.I("Parameters checking : OK") diff --git a/test/functional-tests/PfwTestCase/Functions/tFunction_Sync.py b/test/functional-tests/PfwTestCase/Functions/tFunction_Sync.py new file mode 100644 index 0000000..1b8013c --- /dev/null +++ b/test/functional-tests/PfwTestCase/Functions/tFunction_Sync.py @@ -0,0 +1,250 @@ +# -*-coding:utf-8 -* + +# Copyright (c) 2011-2015, Intel Corporation +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, +# are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation and/or +# other materials provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its contributors +# may be used to endorse or promote products derived from this software without +# specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +""" +synchronization functions testcases + +List of tested functions : +-------------------------- + - [getAutoSync] function + - [setAutoSync] function + - [sync] function + +Test cases : +------------ + - Testing getAutoSync nominal case + - Testing setAutoSync nominal case + - Testing sync nominal case + - Testing errors +""" +import commands, os +import unittest +from Util.PfwUnitTestLib import PfwTestCase +from Util import ACTLogging +log=ACTLogging.Logger() + +class TestCases(PfwTestCase): + + def setUp(self): + + pfw_filesystem=os.getenv("PFW_FILESYSTEM") + + self.pfw.sendCmd("setTuningMode", "on") + self.param_name_01 = "/Test/Test/TEST_DIR/BOOL" + self.filesystem_01 = pfw_filesystem+"/BOOL" + self.param_name_02 = "/Test/Test/TEST_DIR/INT16" + self.filesystem_02 = pfw_filesystem+"/INT16" + self.param_name_03 = "/Test/Test/TEST_DIR/UINT32" + self.filesystem_03 = pfw_filesystem+"/UINT32" + + def tearDown(self): + self.pfw.sendCmd("setTuningMode", "off") + + def test_01_getAutoSync_Case(self): + """ + Testing getAutoSync nominal case + ---------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - enable autosync + - get autosync state + - disable autosync + - get autosync state + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setAutoSync] function + - [getAutoSync] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - getAutoSync return expected state + """ + log.D(self.test_01_getAutoSync_Case.__doc__) + value = "on" + log.I("Enable autosync") + out,err = self.pfw.sendCmd("setAutoSync", value) + assert err == None, log.E("When enabling autosync : %s" % (err)) + assert out == "Done", log.F("setAutoSync - expected : Done , found : %s" % (out)) + log.I("Check autosync state") + out, err = self.pfw.sendCmd("getAutoSync","") + assert err == None, log.E("When getting autosync state : %s" % (err)) + assert out == value, log.F("setAutoSync - expected : %s , found : %s" % (value,out)) + value = "off" + log.I("Disable autosync") + out,err = self.pfw.sendCmd("setAutoSync", value) + assert err == None, log.E("When enabling autosync : %s" % (err)) + assert out == "Done", log.F("setAutoSync - expected : Done , found : %s" % (out)) + log.I("Check autosync state") + out, err = self.pfw.sendCmd("getAutoSync","") + assert err == None, log.E("When getting autosync state : %s" % (err)) + assert out == value, log.F("setAutoSync - expected : %s , found : %s" % (value,out)) + + def test_02_setAutoSync_Case(self): + """ + Testing getAutoSync nominal case + ------------------------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - enable autosync + - set differents parameters + - check the value on the filesystem + - disable autosync + - set differents parameters + - check the value on the filesystem + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setAutoSync] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getAutoSync] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - When autosync is enabled, the filesystem is automatically + synchronized with the blackboard. + """ + log.D(self.test_02_setAutoSync_Case.__doc__) + #Check the initial parameter value + init_value_01, err = self.pfw.sendCmd("getParameter", self.param_name_01, "") + init_value_02, err = self.pfw.sendCmd("getParameter", self.param_name_02, "") + init_value_03, err = self.pfw.sendCmd("getParameter", self.param_name_03, "") + init_filesystem_01 = commands.getoutput("cat %s"%(self.filesystem_01)) + init_filesystem_02 = commands.getoutput("cat %s"%(self.filesystem_02)) + init_filesystem_03 = commands.getoutput("cat %s"%(self.filesystem_03)) + #Implement a new value + if int(init_value_01)==0 : + new_value_01 = "1" + else : + new_value_01 = "0" + new_value_02 = str(int(init_value_02)+1) + new_value_03 = str(int(init_value_03)+1) + #Enable the autosync + value = "on" + log.I("Enable autosync") + out,err = self.pfw.sendCmd("setAutoSync", value) + assert err == None, log.E("When enabling autosync : %s" % (err)) + assert out == "Done", log.F("setAutoSync - expected : Done , found : %s" % (out)) + #Set the new parameter value + self.pfw.sendCmd("setParameter", self.param_name_01, new_value_01) + self.pfw.sendCmd("setParameter", self.param_name_02, new_value_02) + self.pfw.sendCmd("setParameter", self.param_name_03, new_value_03) + #Check the filesystem values + #BOOL + assert commands.getoutput("cat %s"%(self.filesystem_01)) != init_filesystem_01, log.F("FILESYSTEM : parameter %s update error"%self.param_name_01) + #INT16 + assert commands.getoutput("cat %s"%(self.filesystem_02)) != init_filesystem_02, log.F("FILESYSTEM : parameter %s update error"%self.param_name_02) + #UINT32 + assert commands.getoutput("cat %s"%(self.filesystem_03)) != init_filesystem_03, log.F("FILESYSTEM : parameter %s update error"%self.param_name_03) + log.I("test setAutoSync %s : OK"%(value)) + #Enable the autosync + value = "off" + log.I("Disable autosync") + out,err = self.pfw.sendCmd("setAutoSync", value) + assert err == None, log.E("When enabling autosync : %s" % (err)) + assert out == "Done", log.F("setAutoSync - expected : Done , found : %s" % (out)) + #Set the new parameter value + self.pfw.sendCmd("setParameter", self.param_name_01, init_value_01) + self.pfw.sendCmd("setParameter", self.param_name_02, init_value_02) + self.pfw.sendCmd("setParameter", self.param_name_03, init_value_03) + #Check the filesystem values + #BOOL + assert commands.getoutput("cat %s"%(self.filesystem_01)) != init_filesystem_01, log.F("FILESYSTEM : parameter %s is updated, autosync is still enabled"%self.param_name_01) + #INT16 + assert commands.getoutput("cat %s"%(self.filesystem_02)) != init_filesystem_02, log.F("FILESYSTEM : parameter %s is updated, autosync is still enabled"%self.param_name_02) + #UINT32 + assert commands.getoutput("cat %s"%(self.filesystem_03)) != init_filesystem_03, log.F("FILESYSTEM : parameter %s is updated, autosync is still enabled"%self.param_name_03) + log.I("test setAutoSync %s : OK"%(value)) + + + @unittest.expectedFailure + def test_03_Manual_Sync_Case(self): + """ + Testing getAutoSync nominal case + ------------------------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - disable autosync + - set differents parameters + - check the value on the filesystem + - sync + - check the value on the filesystem + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [sync] function + Used commands : + ~~~~~~~~~~~~~~~ + - [setAutoSync] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - sync should synchronized filessystem with blackboard + """ + log.D(self.test_03_Manual_Sync_Case.__doc__) + #Check the initial parameter value + init_value_01, err = self.pfw.sendCmd("getParameter", self.param_name_01, "") + init_value_02, err = self.pfw.sendCmd("getParameter", self.param_name_02, "") + init_value_03, err = self.pfw.sendCmd("getParameter", self.param_name_03, "") + init_filesystem_01 = commands.getoutput("cat %s"%(self.filesystem_01)) + init_filesystem_02 = commands.getoutput("cat %s"%(self.filesystem_02)) + init_filesystem_03 = commands.getoutput("cat %s"%(self.filesystem_03)) + #Implement a new value + if int(init_value_01)==0 : + new_value_01 = "1" + else : + new_value_01 = "0" + new_value_02 = str(int(init_value_02)+1) + new_value_03 = str(int(init_value_03)+1) + #Enable the autosync + value = "off" + log.I("Disable autosync") + out,err = self.pfw.sendCmd("setAutoSync", value) + assert err == None, log.E("When enabling autosync : %s" % (err)) + assert out == "Done", log.F("setAutoSync - expected : Done , found : %s" % (out)) + #Set the new parameter value + self.pfw.sendCmd("setParameter", self.param_name_01, new_value_01) + self.pfw.sendCmd("setParameter", self.param_name_02, new_value_02) + self.pfw.sendCmd("setParameter", self.param_name_03, new_value_03) + #Check the filesystem values, must not changed + #BOOL + assert commands.getoutput("cat %s"%(self.filesystem_01)) == init_filesystem_01, log.F("FILESYSTEM : parameter %s update error"%self.param_name_01) + #INT16 + assert commands.getoutput("cat %s"%(self.filesystem_02)) == init_filesystem_02, log.F("FILESYSTEM : parameter %s update error"%self.param_name_02) + #UINT32 + assert commands.getoutput("cat %s"%(self.filesystem_03)) == init_filesystem_03, log.F("FILESYSTEM : parameter %s update error"%self.param_name_03) + log.I("test setAutoSync %s : OK"%(value)) + log.I("Sync") + out,err = self.pfw.sendCmd("sync", "") + assert err == None, log.E("When syncing : %s" % (err)) + assert out == "Done", log.F("Sync - expected : Done , found : %s" % (out)) + #Check the filesystem values + #BOOL + assert commands.getoutput("cat %s"%(self.filesystem_01)) != init_filesystem_01, log.F("FILESYSTEM : parameter %s is updated, autosync is still enabled"%self.param_name_01) + #INT16 + assert commands.getoutput("cat %s"%(self.filesystem_02)) != init_filesystem_02, log.F("FILESYSTEM : parameter %s is updated, autosync is still enabled"%self.param_name_02) + #UINT32 + assert commands.getoutput("cat %s"%(self.filesystem_03)) != init_filesystem_03, log.F("FILESYSTEM : parameter %s is updated, autosync is still enabled"%self.param_name_03) + log.I("test setAutoSync %s : OK"%(value)) diff --git a/test/functional-tests/PfwTestCase/Functions/tFunction_getParameter.py b/test/functional-tests/PfwTestCase/Functions/tFunction_getParameter.py new file mode 100644 index 0000000..2e02713 --- /dev/null +++ b/test/functional-tests/PfwTestCase/Functions/tFunction_getParameter.py @@ -0,0 +1,76 @@ +# -*-coding:utf-8 -* + +# Copyright (c) 2011-2015, Intel Corporation +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, +# are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation and/or +# other materials provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its contributors +# may be used to endorse or promote products derived from this software without +# specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +""" +getParameter testcase + +List of tested functions : +-------------------------- + - [getParameter] function + +Test cases : +------------ + This function is intensively tested through all the tests of data types. + We test only function commands errors in that script +""" +from Util.PfwUnitTestLib import PfwTestCase +from Util import ACTLogging +log=ACTLogging.Logger() + +class TestCases(PfwTestCase): + def setUp(self): + self.pfw.sendCmd("setTuningMode", "on") + self.param_name = "/Test/Test/TEST_DIR/INT8" + + + def tearDown(self): + self.pfw.sendCmd("setTuningMode", "off") + + def test_Function_Commands_Errors(self): + """ + Testing importDomainsWithSettingsXML nominal case + ------------------------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - getParameter with a wrong parameter name + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - errors correctly detected + """ + log.D(self.test_Function_Commands_Errors.__doc__) + #Get undefined parameter value + log.I("Get undefined parameter value") + out, err = self.pfw.sendCmd("getParameter", "Undefined_parameter") + print str(out) + assert err == None, "Error when getting parameter : %s" % (err) + assert out != "Done", "Error not detected when getting an undefined parameter" diff --git a/test/functional-tests/PfwTestCase/Functions/tFunction_listingFunctions.py b/test/functional-tests/PfwTestCase/Functions/tFunction_listingFunctions.py new file mode 100644 index 0000000..28de75d --- /dev/null +++ b/test/functional-tests/PfwTestCase/Functions/tFunction_listingFunctions.py @@ -0,0 +1,597 @@ +# -*-coding:utf-8 -* + +# Copyright (c) 2011-2015, Intel Corporation +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, +# are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation and/or +# other materials provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its contributors +# may be used to endorse or promote products derived from this software without +# specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +""" +All listing and dumping function testcases. + +List of tested functions : +-------------------------- + - [dumpDomains] function + - [dumpElement] function + +Test cases : +------------ + - Testing dumpDomains function on nominal case + - Testing dumpElements function on nominal case +""" +import commands, os +import unittest +from Util.PfwUnitTestLib import PfwTestCase +from Util import ACTLogging +log=ACTLogging.Logger() + +class TestCases(PfwTestCase): + + def setUp(self): + + self.pfw.sendCmd("setTuningMode", "on") + + pfw_test_tools=os.getenv("PFW_TEST_TOOLS") + self.reference_dumpDomains_xml = pfw_test_tools+"/xml/XML_Test/Reference_dumpDomains.xml" + self.reference_dumpDomains_file = pfw_test_tools+"/xml/XML_Test/Reference_dumpDomains" + self.reference_dumpElement_file = pfw_test_tools+"/xml/XML_Test/Reference_dumpElement" + self.initial_xml = pfw_test_tools+"/xml/TestConfigurableDomains.xml" + + self.list_domains=[] + self.list_criteria=["Crit_0", "Crit_1"] + self.list_parameters=[] + self.temp_file="tempfile" + + self.domain_name = "Domain_0" + self.config_name = "Conf_0" + + def tearDown(self): + self.pfw.sendCmd("setTuningMode", "off") + if os.path.exists(self.temp_file): + os.remove(self.temp_file) + + def test_01_dumpDomains_Case(self): + """ + Testing dumpDomains function + ---------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - import a reference XML : Reference_DumpDomains.xml + - dumpDomains + - compare out to a reference file : Reference_DumpDomains + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [dumpDomains] function + Used commands : + ~~~~~~~~~~~~~~~ + - [importDomainsWithSettingsXML] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - string stdout due to dumpDomains is the same than string in + the reference file + """ + log.D(self.test_01_dumpDomains_Case.__doc__) + + #Import a reference XML file + log.I("Import Domains with settings from %s"%(self.reference_dumpDomains_xml)) + out, err = self.pfw.sendCmd("importDomainsWithSettingsXML",self.reference_dumpDomains_xml, "") + assert err == None, log.E("Command [importDomainsWithSettingsXML %s] : %s"%(self.reference_dumpDomains_xml,err)) + assert out == "Done", log.F("When using function importDomainsWithSettingsXML %s]"%(self.reference_dumpDomains_xml)) + + log.I("Command [dumpDomains]") + out, err = self.pfw.sendCmd("dumpDomains","","") + assert err == None, log.E("Command [dumpDomains] : %s"%(err)) + assert out == commands.getoutput("cat %s"%(self.reference_dumpDomains_file)), log.F("A diff is found between dumpDomains output and %s"%(self.reference_dumpDomains_file)) + log.I("Command [dumpDomains] - correctly executed") + + def test_02_dumpElements_Case(self): + """ + Testing dumpElements function + ----------------------------- + WARNING: This test is based on the Reference_DumpElements that must + be updated and reviewed when TestSubsystem.xml is modified. + PATH : + - $PFW_TEST_TOOLS/xml/XML_Tests/Reference_DumpElements + - $PFW_TEST_TOOLS/xml/TestSubsystem.xml + + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - dumpElements + - compare out to a reference file : Reference_DumpElements + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [importDomainsWithSettingsXML] function + - [dumpElements] function + Used commands : + ~~~~~~~~~~~~~~~ + - [importDomainsWithSettingsXML] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - string stdout due to dumpElements is the same than string in + the reference file + """ + log.D(self.test_02_dumpElements_Case.__doc__) + + #Import a reference XML file + log.I("Import Domains with settings from %s"%(self.reference_dumpDomains_xml)) + out, err = self.pfw.sendCmd("importDomainsWithSettingsXML",self.reference_dumpDomains_xml, "") + assert err == None, log.E("Command [importDomainsWithSettingsXML %s] : %s"%(self.reference_dumpDomains_xml,err)) + assert out == "Done", log.F("When using function importDomainsWithSettingsXML %s]"%(self.reference_dumpDomains_xml)) + + log.I("Command [dumpElement /Test/]") + out, err = self.pfw.sendCmd("dumpElement","/Test/") + assert err == None, log.E("Command [dumpElement /Test/] : %s"%(err)) + + f = open(self.reference_dumpElement_file, 'r') + ref_dumpElement = f.read() + f.closed + + assert out == ref_dumpElement,log.F("A diff is found between dumpDomains output and %s"%(self.reference_dumpElement_file)) + log.I("Command [dumpElement] - correctly executed") + + def test_03_help_Case(self): + """ + Testing help function + --------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - help + - check results + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [help] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - string stdout due to help is not empty + """ + log.D(self.test_03_help_Case.__doc__) + log.I("Command [help]") + out, err = self.pfw.sendCmd("help","") + assert err == None, log.E("Command [help] : %s"%(err)) + assert out != "" + log.I("Command [help] - correctly executed") + + def test_04_status_Case(self): + """ + Testing status function + ----------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - status + - check results + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [status] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - string stdout due to status is not empty + """ + log.D(self.test_04_status_Case.__doc__) + log.I("Command [status]") + out, err = self.pfw.sendCmd("status","") + assert err == None, log.E("Command [help] : %s"%(err)) + assert out != "" + log.I("Command [status] - correctly executed") + + def test_05_listCriteria_Case(self): + """ + Testing listCriteria function + ----------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - listCriteria + - check results + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [listCriteria] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - string stdout due to listCriteria is not empty + """ + log.D(self.test_05_listCriteria_Case.__doc__) + log.I("Command [listCriteria]") + out, err = self.pfw.sendCmd("listCriteria","") + assert err == None, log.E("Command [listCriteria] : %s"%(err)) + assert out != "" + log.I("Command [listCriteria] - correctly executed") + + def test_06_listDomains_Case(self): + """ + Testing listDomains function + ---------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - listDomains + - check results + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [listDomains] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - string stdout due to listDomains is not empty + """ + log.D(self.test_06_listDomains_Case.__doc__) + log.I("Command [listDomains]") + out, err = self.pfw.sendCmd("listDomains") + assert err == None, log.E("Command [listDomains] : %s"%(err)) + assert out != "" + log.I("Command [listDomains] - correctly executed") + + @unittest.expectedFailure + def test_06_listDomainElements_Case(self): + """ + Testing listDomains function + ---------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - listDomainElements + - check results + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [listDomainElements] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - string stdout due to listDomains is not empty + """ + log.D(self.test_06_listDomainElements_Case.__doc__) + log.I("Command [listDomainElements]") + out, err = self.pfw.sendCmd("listDomainElements",self.domain_name) + assert err == None, log.E("Command [listDomainElements] : %s"%(err)) + assert out != "", log.F("Fail when listDomainElements %s: stdout is empty"%(self.domain_name)) + log.I("Command [listDomainElements] - correctly executed") + + @unittest.expectedFailure + def test_07_listConfigurations_Case(self): + """ + Testing listConfigurations function + ----------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - listConfigurations + - check results + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [listConfigurations] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - string stdout due to listConfigurations is not empty + """ + log.D(self.test_07_listConfigurations_Case.__doc__) + log.I("Command [listConfigurations]") + out, err = self.pfw.sendCmd("listConfigurations",self.domain_name) + assert err == None, log.E("Command [listConfigurations] : %s"%(err)) + assert out != "", log.F("Fail when listConfigurations %s: stdout is empty"%(self.domain_name)) + log.I("Command [listConfigurations] - correctly executed") + + def test_08_listElements_Case(self): + """ + Testing listElements function + ----------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - listElements + - check results + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [listElements] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - string stdout due to listElements is not empty + """ + log.D(self.test_08_listElements_Case.__doc__) + log.I("Command [listElements]") + out, err = self.pfw.sendCmd("listElements") + assert err == None, log.E("Command [listElements] : %s"%(err)) + out, err = self.pfw.sendCmd("listElements","/Test/") + assert err == None, log.E("Command [listElements /Test/] : %s"%(err)) + assert out != "" + log.I("Command [listElements] - correctly executed") + + def test_09_listParameters_Case(self): + """ + Testing listParameters function + ------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - listParameters + - check results + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [listParameters] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - string stdout due to listParameters is not empty + """ + log.D(self.test_09_listParameters_Case.__doc__) + log.I("Command [listParameters]") + out, err = self.pfw.sendCmd("listParameters") + assert err == None, log.E("Command [listParameters] : %s"%(err)) + out, err = self.pfw.sendCmd("listParameters","/Test/") + assert err == None, log.E("Command [listParameters /Test/] : %s"%(err)) + assert out != "" + log.I("Command [listParameters] - correctly executed") + + def test_10_getElementSize_Case(self): + """ + Testing getElementSize function + ------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - listParameters + - getElementSize for all parameters + - check results + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [getElementSize] function + Used commands : + ~~~~~~~~~~~~~~~ + - [listParameters] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - string stdout due to getElementSize is not empty + """ + log.D(self.test_10_getElementSize_Case.__doc__) + log.I("Command [listParameters]") + out, err = self.pfw.sendCmd("listParameters","/Test/") + assert err == None, log.E("Command [listParameters /Test/] : %s"%(err)) + assert out != "" + log.I("Command [listParameters] - correctly executed") + # Write out in temp file + f_temp_file = open(self.temp_file, "w") + f_temp_file.write(out) + f_temp_file.close() + + # Extract parameter from the temp file + f_temp_file = open(self.temp_file, "r") + lines = f_temp_file.readlines() + f_temp_file.close() + + for line in lines : + if not line.find("/") == -1 : + final_position_in_line= line.find("[")-1 + self.list_parameters.append(line[0:final_position_in_line]) + + for parameter in self.list_parameters : + out, err = self.pfw.sendCmd("getElementSize",parameter) + assert err == None, log.E("Command [getElementSize %s] : %s"%(parameter,err)) + assert out != "" + + out, err = self.pfw.sendCmd("getElementSize","/Test/") + assert err == None, log.E("Command [getElementSize /Test/] : %s"%(err)) + assert out != "" + + out, err = self.pfw.sendCmd("getElementSize") + assert err == None, log.E("Command [getElementSize /Test/] : %s"%(err)) + + def test_11_showProperties_Case(self): + """ + Testing showProperties function + ------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - listParameters + - showProperties for all parameters + - check results + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [showProperties] function + Used commands : + ~~~~~~~~~~~~~~~ + - [listParameters] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - string stdout due to getElementSize is not empty + """ + log.D(self.test_11_showProperties_Case.__doc__) + log.I("Command [listParameters]") + out, err = self.pfw.sendCmd("listParameters","/Test/") + assert err == None, log.E("Command [listParameters /Test/] : %s"%(err)) + assert out != "" + log.I("Command [listParameters] - correctly executed") + # Write out in temp file + f_temp_file = open(self.temp_file, "w") + f_temp_file.write(out) + f_temp_file.close() + + # Extract parameter from the temp file + f_temp_file = open(self.temp_file, "r") + lines = f_temp_file.readlines() + f_temp_file.close() + + for line in lines : + if not line.find("/") == -1 : + final_position_in_line= line.find("[")-1 + self.list_parameters.append(line[0:final_position_in_line]) + + for parameter in self.list_parameters : + out, err = self.pfw.sendCmd("showProperties",parameter) + assert err == None, log.E("Command [showProperties %s] : %s"%(parameter,err)) + assert out != "" + + out, err = self.pfw.sendCmd("showProperties","/Test/") + assert err == None, log.E("Command [showProperties /Test/] : %s"%(err)) + assert out != "" + + out, err = self.pfw.sendCmd("showProperties") + assert err == None, log.E("Command [showProperties] : %s"%(err)) + + def test_12_listBelongingDomains_Case(self): + """ + Testing listBelongingDomains function + ------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - listParameters + - listBelongingDomains for all parameters + - check results + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [listBelongingDomains] function + Used commands : + ~~~~~~~~~~~~~~~ + - [listParameters] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - string stdout due to listBelongingDomains is not empty + """ + log.D(self.test_12_listBelongingDomains_Case.__doc__) + log.I("Command [listParameters]") + out, err = self.pfw.sendCmd("listParameters","/Test/") + assert err == None, log.E("Command [listParameters /Test/] : %s"%(err)) + assert out != "" + log.I("Command [listParameters] - correctly executed") + # Write out in temp file + f_temp_file = open(self.temp_file, "w") + f_temp_file.write(out) + f_temp_file.close() + + # Extract parameter from the temp file + f_temp_file = open(self.temp_file, "r") + lines = f_temp_file.readlines() + f_temp_file.close() + + for line in lines : + if not line.find("/") == -1 : + final_position_in_line= line.find("[")-1 + self.list_parameters.append(line[0:final_position_in_line]) + + for parameter in self.list_parameters : + out, err = self.pfw.sendCmd("listBelongingDomains",parameter) + assert err == None, log.E("Command [listBelongingDomains %s] : %s"%(parameter,err)) + + out, err = self.pfw.sendCmd("listBelongingDomains","/Test/") + assert err == None, log.E("Command [listBelongingDomains /Test/] : %s"%(err)) + + out, err = self.pfw.sendCmd("listBelongingDomains") + assert err == None, log.E("Command [listBelongingDomains] : %s"%(err)) + + def test_13_listAssociatedDomains_Case(self): + """ + Testing listAssociatedDomains function + ------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - listParameters + - listAssociatedDomains for all parameters + - check results + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [listAssociatedDomains] function + Used commands : + ~~~~~~~~~~~~~~~ + - [listParameters] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - string stdout due to listBelongingDomains is not empty + """ + log.D(self.test_13_listAssociatedDomains_Case.__doc__) + log.I("Command [listParameters]") + out, err = self.pfw.sendCmd("listParameters","/Test/") + assert err == None, log.E("Command [listParameters /Test/] : %s"%(err)) + log.I("Command [listParameters] - correctly executed") + # Write out in temp file + f_temp_file = open(self.temp_file, "w") + f_temp_file.write(out) + f_temp_file.close() + + # Extract parameter from the temp file + f_temp_file = open(self.temp_file, "r") + lines = f_temp_file.readlines() + f_temp_file.close() + + for line in lines : + if not line.find("/") == -1 : + final_position_in_line= line.find("[")-1 + self.list_parameters.append(line[0:final_position_in_line]) + + for parameter in self.list_parameters : + out, err = self.pfw.sendCmd("listAssociatedDomains",parameter) + assert err == None, log.E("Command [listAssociatedDomains %s] : %s"%(parameter,err)) + + out, err = self.pfw.sendCmd("listAssociatedDomains","/Test/") + assert err == None, log.E("Command [listAssociatedDomains /Test/] : %s"%(err)) + + def test_14_listAssociatedElements_Case(self): + """ + Testing listAssociatedElements function + ------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - listAssociatedElements + - check results + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [listAssociatedElements] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - string stdout due to listAssociatedElements is not empty + """ + log.D(self.test_14_listAssociatedElements_Case.__doc__) + log.I("Command [listAssociatedElements]") + out, err = self.pfw.sendCmd("listAssociatedElements") + assert err == None, log.E("Command [listAssociatedElements] : %s"%(err)) + log.I("Command [listAssociatedElements] - correctly executed") + + def test_15_listConflictingElements_Case(self): + """ + Testing listConflictingElements function + ------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - listConflictingElements + - check results + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [listConflictingElements] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - string stdout due to listConflictingElements is not empty + """ + log.D(self.test_15_listConflictingElements_Case.__doc__) + log.I("Command [listConflictingElements]") + out, err = self.pfw.sendCmd("listConflictingElements") + assert err == None, log.E("Command [listConflictingElements] : %s"%(err)) + log.I("Command [listConflictingElements] - correctly executed") + + def test_16_listRogueElements_Case(self): + """ + Testing listRogueElements function + ------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - listRogueElements + - check results + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [listRogueElements] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - string stdout due to listRogueElements is not empty + """ + log.D(self.test_16_listRogueElements_Case.__doc__) + log.I("Command [listRogueElements]") + out, err = self.pfw.sendCmd("listRogueElements") + assert err == None, log.E("Command [listRogueElements] : %s"%(err)) + log.I("Command [listRogueElements] - correctly executed") diff --git a/test/functional-tests/PfwTestCase/Functions/tFunction_setParameter.py b/test/functional-tests/PfwTestCase/Functions/tFunction_setParameter.py new file mode 100644 index 0000000..b5605dd --- /dev/null +++ b/test/functional-tests/PfwTestCase/Functions/tFunction_setParameter.py @@ -0,0 +1,90 @@ +# -*-coding:utf-8 -* + +# Copyright (c) 2011-2015, Intel Corporation +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, +# are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation and/or +# other materials provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its contributors +# may be used to endorse or promote products derived from this software without +# specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +""" +setParameter testcase + +List of tested functions : +-------------------------- + - [setParameter] function + +Test cases : +------------ + This function is intensively tested through all the tests of data types. + We test only function commands errors in that script +""" +from Util.PfwUnitTestLib import PfwTestCase +from Util import ACTLogging +log=ACTLogging.Logger() + +class TestCases(PfwTestCase): + def setUp(self): + self.pfw.sendCmd("setTuningMode", "on") + self.domain_name = "Domain_0" + self.param_name = "/Test/Test/TEST_DIR/INT8" + + + def tearDown(self): + self.pfw.sendCmd("setTuningMode", "off") + + def test_Function_Commands_Errors(self): + """ + Testing function command errors + ---------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - setParameter with a wrong parameter name + - setParameter with a forbiden character value + - setParameter with a Float into an Integer parameter + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - errors correctly detected + """ + log.D(self.test_Function_Commands_Errors.__doc__) + #Set undefined parameter value + log.I("Set undefined parameter value") + out, err = self.pfw.sendCmd("setParameter", "Undefined_parameter", "0") + assert err == None, "Error when setting parameter : %s" % (err) + assert out != "Done", "Error not detected when setting an undefined parameter" + #Set parameter with a forbiden character value + log.I("Set parameter with a forbiden character value") + out, err = self.pfw.sendCmd("setParameter", self.param_name, "Wrong_Value") + assert err == None, "Error when setting parameter : %s" % (err) + assert out != "Done", "Error not detected when setting a parameter with a forbiden character value" + log.I("Errors correctly detected") + #Set parameter with a Float into an Integer parameter + log.I("Set parameter with a Float into an Integer parameter") + out, err = self.pfw.sendCmd("setParameter", self.param_name, "1.2345") + assert err == None, "Error when setting parameter : %s" % (err) + assert out != "Done", "Error not detected when setting a Float into an Integer parameter" + log.I("Errors correctly detected") diff --git a/test/functional-tests/PfwTestCase/Types/__init__.py b/test/functional-tests/PfwTestCase/Types/__init__.py new file mode 100644 index 0000000..9fbd9f6 --- /dev/null +++ b/test/functional-tests/PfwTestCase/Types/__init__.py @@ -0,0 +1,32 @@ +""" +Types Package : All testcases about differents types used in PFW : + - bit block + - boolean + - enum + - FP16_Q0_15 : 16bits Fixed point - 0 integer bits, 15 fractionnal bits + - FP16_Q15_0 : 16bits Fixed point - 15 integer bits, 0 fractionnal bits + - FP16_Q7_8 : 16bits Fixed point - 7 integer bits, 8 fractionnal bits + - FP32_Q0_31 : 32bits Fixed point - 0 integer bits, 31 fractionnal bits + - FP32_Q15_16 : 32bits Fixed point - 15 integer bits, 16 fractionnal bits + - FP32_Q31_0 : 32bits Fixed point - 31 integer bits, 0 fractionnal bits + - FP32_Q8_20 : 32bits Fixed point - 8 integer bits, 20 fractionnal bits + - FP8_Q0_7 : 8bits Fixed point - 0 integer bits, 7 fractionnal bits + - FP8_Q3_4 : 8bits Fixed point - 3 integer bits, 4 fractionnal bits + - FP8_Q7_0 : 8bits Fixed point - 7 integer bits, 0 fractionnal bits + - INT8 : signed integer 8 bits bounded + - INT8_MAX : signed integer 8 bits full range + - INT16 : signed integer 16 bits bounded + - INT16_MAX : signed integer 16 bits full range + - INT32 : signed integer 32 bits bounded + - INT32_MAX : signed integer 23 bits full range + - UINT8 : unsigned integer 8 bits bounded + - UINT8_MAX : unsigned integer 8 bits full range + - UINT16 : unsigned integer 16 bits bounded + - UINT16_MAX : unsigned integer 16 bits full range + - UINT32 : unsigned integer 32 bits bounded + - UINT32_MAX : unsigned integer 23 bits full range + - string + - raw data + - integer array + - parameter block +""" diff --git a/test/functional-tests/PfwTestCase/Types/tBit_Block.py b/test/functional-tests/PfwTestCase/Types/tBit_Block.py new file mode 100644 index 0000000..6ea87bf --- /dev/null +++ b/test/functional-tests/PfwTestCase/Types/tBit_Block.py @@ -0,0 +1,319 @@ +# -*-coding:utf-8 -* + +# Copyright (c) 2011-2015, Intel Corporation +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, +# are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation and/or +# other materials provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its contributors +# may be used to endorse or promote products derived from this software without +# specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +""" +Bit block parameter type testcases. + +List of tested functions : +-------------------------- + - [setParameter] function + - [getParameter] function + +Initial Settings : +------------------ + Block size = 8bits : + - BIT_0_3, size = 3, pos=0 + - BIT_3_1, size = 1, pos=3 + - BIT_4_1, size = 1, pos=4 + - BIT_6_2, size = 2, pos=6 + - BIT_7_1, size = 1, pos=7 + +Test cases : +------------ + - Testing nominal TestCase : set bit to bit + - Testing error testcase : set block in one shot + - Testing out of bound TestCase + - Testing conflicting TestCase : two bits at the same position + - Testing out of size TestCase : Bit define on a wrong position +""" + +import commands +import unittest +from Util.PfwUnitTestLib import PfwTestCase +from Util import ACTLogging +log=ACTLogging.Logger() + +# Test of type UINT16 - range [0, 1000] +class TestCases(PfwTestCase): + def setUp(self): + self.block_name = "/Test/Test/TEST_TYPES/BLOCK_8BIT" + self.filesystem_name="$PFW_FILESYSTEM/BLOCK_8BIT" + + self.bit_name=[] + + #BIT_0_3, size = 3, pos = 0 + self.bit_name.append("/Test/Test/TEST_TYPES/BLOCK_8BIT/BIT_0_3") + #BIT_3_1, size = 1, pos = 3 + self.bit_name.append("/Test/Test/TEST_TYPES/BLOCK_8BIT/BIT_3_1") + #BIT_4_1, size = 1, pos = 4 + self.bit_name.append("/Test/Test/TEST_TYPES/BLOCK_8BIT/BIT_4_1") + #BIT_6_2, size = 2, pos = 6 + self.bit_name.append("/Test/Test/TEST_TYPES/BLOCK_8BIT/BIT_6_2") + #BIT_7_1, size = 1, pos = 7 + self.bit_name.append("/Test/Test/TEST_TYPES/BLOCK_8BIT/BIT_7_1") + + self.pfw.sendCmd("setTuningMode", "on") + + def tearDown(self): + self.pfw.sendCmd("setTuningMode", "off") + + + def test_Nominal_Case(self): + """ + Testing Bit block parameter in nominal case + ------------------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - set Bit parameter in nominal case : + - BLOCK_BIT = 0b01011101, 0x5D, 93 + - BIT_0_3 = 5 + - BIT_3_1 = 1 + - BIT_4_1 = 1 + - BIT_6_1 = 1 + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - BIT parameters set to nominal value + - FILESYSTEM BLOCK_8BIT set to 0x5D + """ + log.D(self.test_Nominal_Case.__doc__) + + value_bit=["5","1","1","1"] + filesystem_value=["0x5","0xd","0x1d","0x5d"] + + for index_bit in range(4): + log.I("set parameter %s to %s"%(self.bit_name[index_bit],value_bit[index_bit])) + out,err = self.pfw.sendCmd("setParameter",self.bit_name[index_bit],value_bit[index_bit]) + assert err == None, log.E("setParameter %s %s : %s" % (self.bit_name[index_bit],value_bit[index_bit], err)) + assert out == "Done", log.F("setParameter %s %s" %(self.bit_name[index_bit],value_bit[index_bit])) + log.I("Check bit %s value"%(self.bit_name[index_bit])) + out,err = self.pfw.sendCmd("getParameter",self.bit_name[index_bit]) + assert err == None, log.E("getParameter %s : %s" % (self.block_name, err)) + assert out == value_bit[index_bit], log.F("getParameter %s - Expected : %s Found : %s" %(self.bit_name[index_bit],value_bit[index_bit], out)) + log.I("Check filesystem value") + assert commands.getoutput("cat %s"%(self.filesystem_name)) == filesystem_value[index_bit], log.F("FILESYSTEM : parameter update error for %s after setting bit %s "%(self.block_name, self.bit_name[index_bit])) + + + def test_Set_Block_Directly_Case(self): + """ + Testing setting Bit block parameter in one shot + ----------------------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - set Bit block directly without setting bit to bit : + - BLOCK_BIT = 0b01011101, 0x5D, 93 + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - Unable to set directly a block bit + - FILESYSTEM BLOCK_8BIT must not change + """ + log.D(self.test_Set_Block_Directly_Case.__doc__) + + value = "93" + + log.I("Load the initial value of bit parameter") + init_value_bit=[] + for index_bit in range(4): + out,err=self.pfw.sendCmd("getParameter",self.bit_name[index_bit]) + assert err == None, log.E("getParameter %s"%self.bit_name[index_bit]) + init_value_bit.append(out) + + init_filesystem_value=commands.getoutput("cat %s"%(self.filesystem_name)) + + log.I("Try to set parameter %s to %s, failed expected"%(self.block_name,value)) + out,err = self.pfw.sendCmd("setParameter",self.block_name, value) + assert err == None, log.E("setParameter %s %s : %s" % (self.block_name, value, err)) + assert out != "Done", log.F("Error not detected when setting directly the block %s" % (self.block_name)) + log.I("Try to get parameter %s to %s, failed expected"%(self.block_name,value)) + out,err = self.pfw.sendCmd("getParameter",self.block_name, value) + assert err == None, log.E("getParameter %s : %s" % (self.block_name, err)) + assert out != value, log.F("Error not detected when getting directly the block %s" % (self.block_name)) + log.I("Check filesystem value") + assert commands.getoutput("cat %s"%(self.filesystem_name)) == init_filesystem_value, log.F("FILESYSTEM : parameter update error for %s"%(self.block_name)) + + log.I("Check Bit value") + for index_bit in range(4): + out,err=self.pfw.sendCmd("getParameter",self.bit_name[index_bit]) + assert out==init_value_bit[index_bit], log.F("BLACKBOARD: Forbidden change value for bit %s - Expected : %s Found : %s"%(self.bit_name[index_bit],init_value_bit[index_bit],out)) + + def test_Out_Of_Bound_Bit_Value_Case(self): + """ + Testing setting bit in out of bound + ----------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - set bit BIT_3_1 to 2 + - check bit BIT_3_1 value + - check bit BIT_0_3 value + - check bit BIT_4_1 value + - check block bit Filesystem value + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - Error detected when setting BIT_3_1 to out of bound value + - FILESYSTEM BLOCK_8BIT must not change + """ + log.D(self.test_Out_Of_Bound_Bit_Value_Case.__doc__) + + bit_value="3" + + log.I("Load the initial value of bit parameter") + init_value_bit=[] + for index_bit in range(4): + out,err=self.pfw.sendCmd("getParameter",self.bit_name[index_bit]) + assert err == None, log.E("getParameter %s"%self.bit_name[index_bit]) + init_value_bit.append(out) + + init_filesystem_value=commands.getoutput("cat %s"%(self.filesystem_name)) + + log.I("set parameter %s to %s, failed expected"%(self.bit_name[1],bit_value)) + out,err = self.pfw.sendCmd("setParameter",self.bit_name[1],bit_value) + assert err == None, log.E("setParameter %s %s : %s" % (self.bit_name[1],bit_value, err)) + assert out != "Done", log.F("Error not detected when setting the bit %s to out of bound value %s" % (self.bit_name[1],bit_value)) + log.I("Check Bit value") + for index_bit in range(4): + out,err=self.pfw.sendCmd("getParameter",self.bit_name[index_bit]) + assert out==init_value_bit[index_bit], log.F("BLACKBOARD: Forbidden change value for bit %s - Expected : %s Found : %s"%(self.bit_name[index_bit],init_value_bit[index_bit],out)) + log.I("Check filesystem value") + assert commands.getoutput("cat %s"%(self.filesystem_name)) == init_filesystem_value, log.F("FILESYSTEM : parameter update error for %s"%(self.block_name)) + + def test_Undefined_Bit_Case(self): + """ + Testing setting an undefined bit + -------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - set bit BIT_UNDEF to 1 + - check block bit Filesystem value + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - Error detected when setting BIT_UNDEF + - FILESYSTEM BLOCK_8BIT must not change + """ + log.D(self.test_Undefined_Bit_Case.__doc__) + + bit_value="1" + bit_undefined_name="/Test/Test/TEST_TYPES/BLOCK_8BIT/BIT_UNDEF" + + log.I("Load the initial value of bit parameter") + init_value_bit=[] + for index_bit in range(4): + out,err=self.pfw.sendCmd("getParameter",self.bit_name[index_bit]) + assert err == None, log.E("getParameter %s"%self.bit_name[index_bit]) + init_value_bit.append(out) + + init_filesystem_value=commands.getoutput("cat %s"%(self.filesystem_name)) + + log.I("set parameter %s to %s, failed expected"%(bit_undefined_name,bit_value)) + out,err = self.pfw.sendCmd("setParameter",bit_undefined_name,bit_value) + assert err == None, log.E("setParameter %s %s : %s" % (bit_undefined_name,bit_value, err)) + assert out != "Done", log.F("Error not detected when setting the bit %s to out of bound value %s" % (bit_undefined_name,bit_value)) + log.I("Check Bit value") + for index_bit in range(4): + out,err=self.pfw.sendCmd("getParameter",self.bit_name[index_bit]) + assert out==init_value_bit[index_bit], log.F("BLACKBOARD: Forbidden change value for bit %s - Expected : %s Found : %s"%(self.bit_name[index_bit],init_value_bit[index_bit],out)) + log.I("Check filesystem value") + assert commands.getoutput("cat %s"%(self.filesystem_name)) == init_filesystem_value, log.F("FILESYSTEM : parameter update error for %s"%(self.block_name)) + + @unittest.expectedFailure + def test_Position_Conflicting_Case(self): + """ + Testing conflicting position + ---------------------------- + Parameter : + ~~~~~~~~~~~ + BIT_6_2 : Position = 6, size = 2 conflicting with + BIT_7_1 : Position = 7; size = 1 + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - set bit BIT_6_2 to 0 + - set bit BIT_7_1 to 1 + - check bit BIT_6_2 value + - check block bit Filesystem value + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - Unable to define 2 bits at the same position + """ + log.D(self.test_Position_Conflicting_Case.__doc__) + + bit_value_6_2="0" + bit_value_7_1="1" + + log.I("set parameter %s to %s"%(self.bit_name[3],bit_value_6_2)) + out,err = self.pfw.sendCmd("setParameter",self.bit_name[3],bit_value_6_2) + assert err == None, log.E("setParameter %s %s : %s" % (self.bit_name[3],bit_value_6_2, err)) + assert out == "Done", log.F("setParameter %s %s" %(self.bit_name[3],bit_value_6_2)) + + log.I("Load the value of bit parameter") + init_value_bit=[] + for index_bit in range(4): + out,err=self.pfw.sendCmd("getParameter",self.bit_name[index_bit]) + init_value_bit.append(out) + + init_filesystem_value=commands.getoutput("cat %s"%(self.filesystem_name)) + + log.I("set parameter %s to %s, failed expected"%(self.bit_name[4],bit_value_7_1)) + out,err = self.pfw.sendCmd("setParameter",self.bit_name[4],bit_value_7_1) + assert err == None, log.E("setParameter %s %s : %s" % (self.bit_name[4],bit_value_7_1, err)) + assert out != "Done", log.F("Error not detected when setting the conflicting bit %s" % (self.bit_name[4])) + log.I("Check Bit value") + for index_bit in range(4): + out,err=self.pfw.sendCmd("getParameter",self.bit_name[index_bit]) + assert out==init_value_bit[index_bit], log.F("BLACKBOARD: Forbidden change value for bit %s - Expected : %s Found : %s"%(self.bit_name[index_bit],init_value_bit[index_bit],out)) + log.I("Check filesystem value") + assert commands.getoutput("cat %s"%(self.filesystem_name)) == init_filesystem_value, log.F("FILESYSTEM : parameter update error for %s"%(self.block_name)) diff --git a/test/functional-tests/PfwTestCase/Types/tBoolean.py b/test/functional-tests/PfwTestCase/Types/tBoolean.py new file mode 100644 index 0000000..0658964 --- /dev/null +++ b/test/functional-tests/PfwTestCase/Types/tBoolean.py @@ -0,0 +1,161 @@ +# -*-coding:utf-8 -* + +# Copyright (c) 2011-2015, Intel Corporation +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, +# are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation and/or +# other materials provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its contributors +# may be used to endorse or promote products derived from this software without +# specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +""" +Boolean parameter type testcases. + +List of tested functions : +-------------------------- + - [setParameter] function + - [getParameter] function + + +Test cases : +------------ + - Testing minimum + - Testing maximum + - Testing negative value + - Testing overflow +""" + +from Util.PfwUnitTestLib import PfwTestCase +from Util import ACTLogging +log=ACTLogging.Logger() + +# Class containing SET/GET tests on a Boolean parameter +class TestCases(PfwTestCase): + def setUp(self): + self.param_name = "/Test/Test/TEST_DIR/BOOL" + self.pfw.sendCmd("setTuningMode", "on") + + def tearDown(self): + self.pfw.sendCmd("setTuningMode", "off") + + def testBooleanMaximum(self): + """ + Testing maximum value for boolean parameter + ------------------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - Set a boolean parameter to the max value 1 + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - Boolean set to 1 + """ + log.D(self.testBooleanMaximum.__doc__) + value = "1" + out, err = self.pfw.sendCmd("setParameter", self.param_name, value) + assert err == None, log.E("When setting parameter %s : %s" % (self.param_name, err)) + assert out == "Done", log.F("When setting parameter %s : %s" % (self.param_name, out)) + out, err = self.pfw.sendCmd("getParameter", self.param_name, "") + assert out == value, log.F("incorrect value for %s, expected: %s, found: %s" % (self.param_name, value, out)) + + def testBooleanMinimum(self): + """ + Testing minimum value for boolean parameter + ------------------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - Set a boolean parameter to the min value 0 + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - Boolean set to 0 + """ + log.D(self.testBooleanMinimum.__doc__) + value = "0" + out, err = self.pfw.sendCmd("setParameter", self.param_name, value) + assert err == None, log.E("When setting parameter %s : %s" % (self.param_name, err)) + assert out == "Done", log.F("When setting parameter %s : %s" % (self.param_name, out)) + out, err = self.pfw.sendCmd("getParameter", self.param_name, "") + assert err == None, log.E("Error when setting parameter %s : %s" % (self.param_name, err)) + assert out == value, log.F("Incorrect value for %s, expected: %s, found: %s" % (self.param_name, value, out)) + + def testBooleanNegative(self): + """ + Testing negative value for boolean parameter + -------------------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - Set a boolean parameter to -1 + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - Error detected, boolean not updated + """ + print self.testBooleanNegative.__doc__ + value = "-1" + out, err = self.pfw.sendCmd("setParameter", self.param_name, value) + assert err == None, log.E("When setting parameter %s : %s" % (self.param_name, err)) + assert out != "Done", log.F("When setting parameter %s : %s" % (self.param_name, out)) + out, err = self.pfw.sendCmd("getParameter", self.param_name, "") + assert out != value, log.F("incorrect value for %s, expected: %s, found: %s") % (self.param_name, value, out) + + + def testBooleanOverflow(self): + """ + Testing overflowed value for boolean parameter + ---------------------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - Set a boolean parameter to 2 + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - Error detected, boolean not updated + """ + print self.testBooleanOverflow.__doc__ + value = "2" + out, err = self.pfw.sendCmd("setParameter", self.param_name, value) + assert err == None, log.E("When setting parameter %s : %s" % (self.param_name, err)) + assert out != "Done", log.F("When setting parameter %s : %s" % (self.param_name, out)) + out, err = self.pfw.sendCmd("getParameter", self.param_name, "") + assert out != value, log.F("incorrect value for %s, expected: %s, found: %s") % (self.param_name, value, out) diff --git a/test/functional-tests/PfwTestCase/Types/tEnum.py b/test/functional-tests/PfwTestCase/Types/tEnum.py new file mode 100644 index 0000000..6dd41f4 --- /dev/null +++ b/test/functional-tests/PfwTestCase/Types/tEnum.py @@ -0,0 +1,265 @@ +# -*-coding:utf-8 -* + +# Copyright (c) 2011-2015, Intel Corporation +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, +# are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation and/or +# other materials provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its contributors +# may be used to endorse or promote products derived from this software without +# specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +""" +Enum parameter type testcases. + +List of tested functions : +-------------------------- + - [setParameter] function + - [getParameter] function + +Initial Settings : +------------------ + Enum size = 8bits; 5 components : + - max range [-127,128] + +Test cases : +------------ + - Enum parameter nominal value = ENUM_NOMINAL : 5 + - Enum parameter min value = ENUM_MIN : -127 + - Enum parameter max value = ENUM_MAX : 128 + - Enum parameter out of bound value = ENUM_OOB : 255 + - Enum parameter out of size value = ENUM_OOS : 256 + - Enum parameter undefined value = UNDEF +""" +import commands +from Util.PfwUnitTestLib import PfwTestCase +from Util import ACTLogging +log=ACTLogging.Logger() + +# Test of type UINT16 - range [0, 1000] +class TestCases(PfwTestCase): + def setUp(self): + self.param_name = "/Test/Test/TEST_TYPES/ENUM" + self.filesystem_name="$PFW_FILESYSTEM/ENUM" + self.pfw.sendCmd("setTuningMode", "on") + + def tearDown(self): + self.pfw.sendCmd("setTuningMode", "off") + + + def test_Nominal_Case(self): + """ + Testing Enum parameter in nominal case + -------------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - ENUM parameter in nominal case = ENUM_NOMINAL + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - ENUM parameter set to ENUM_NOMINAL + - FILESYSTEM set to 0x5 + """ + log.D(self.test_Nominal_Case.__doc__) + value = "ENUM_NOMINAL" + filesystem_value="0x5" + log.I("Set parameter %s to %s"%(self.param_name,value)) + out,err = self.pfw.sendCmd("setParameter",self.param_name, value) + assert err == None, log.E("setParameter %s %s : %s" % (self.param_name, value, err)) + assert out == "Done", log.F("setParameter %s %s - expected : Done : %s" % (self.param_name, value,out)) + log.I("Check Enum parameter state") + out, err = self.pfw.sendCmd("getParameter",self.param_name) + assert err == None, log.E("getParameter %s : %s" % (self.param_name, err)) + assert out == value, log.F("getParameter %s - expected : %s , found : %s" % (self.param_name,value,out)) + log.I("Check filesystem value") + assert commands.getoutput("cat %s"%(self.filesystem_name)) == filesystem_value, log.F("FILESYSTEM : parameter update error for %s"%(self.param_name)) + + def test_TypeMin(self): + """ + Testing minimal value for Enum parameter + ---------------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - ENUM parameter in min case = ENUM_MIN + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - ENUM parameter set to ENUM_MIN + - FILESYSTEM set to 0x80 + """ + log.D(self.test_TypeMin.__doc__) + value = "ENUM_MIN" + filesystem_value="0x80" + log.I("Set parameter %s to %s"%(self.param_name,value)) + out,err = self.pfw.sendCmd("setParameter",self.param_name, value) + assert err == None, log.E("setParameter %s %s : %s" % (self.param_name, value, err)) + assert out == "Done", log.F("setParameter %s %s - expected : Done : %s" % (self.param_name, value,out)) + log.I("Check Enum parameter state") + out, err = self.pfw.sendCmd("getParameter",self.param_name) + assert err == None, log.E("getParameter %s : %s" % (self.param_name, err)) + assert out == value, log.F("getParameter %s - expected : %s , found : %s" % (self.param_name,value,out)) + log.I("Check filesystem value") + assert commands.getoutput("cat %s"%(self.filesystem_name)) == filesystem_value, log.F("FILESYSTEM : parameter update error for %s"%(self.param_name)) + + def test_TypeMax(self): + """ + Testing maximal value for Enum parameter + ---------------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - ENUM parameter in max case = ENUM_MAX + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - ENUM parameter set to ENUM_MAX + - FILESYSTEM set to 0x7F + """ + log.D(self.test_TypeMax.__doc__) + value = "ENUM_MAX" + filesystem_value="0x7f" + log.I("Set parameter %s to %s"%(self.param_name,value)) + out,err = self.pfw.sendCmd("setParameter",self.param_name, value) + assert err == None, log.E("setParameter %s %s : %s" % (self.param_name, value, err)) + assert out == "Done", log.F("setParameter %s %s - expected : Done : %s" % (self.param_name, value,out)) + log.I("Check Enum parameter state") + out, err = self.pfw.sendCmd("getParameter",self.param_name) + assert err == None, log.E("getParameter %s : %s" % (self.param_name, err)) + assert out == value, log.F("getParameter %s - expected : %s , found : %s" % (self.param_name,value,out)) + log.I("Check filesystem value") + assert commands.getoutput("cat %s"%(self.filesystem_name)) == filesystem_value, log.F("FILESYSTEM : parameter update error for %s"%(self.param_name)) + + def test_TypeUndefined(self): + """ + Testing ENUM parameter in undefined reference case + -------------------------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - ENUM parameter = UNDEF + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - error detected, parameter must not change + - FILESYSTEM must not change + """ + log.D(self.test_TypeUndefined.__doc__) + value = "UNDEF" + log.I("Check parameter %s initial value"%(self.param_name)) + init_parameter_value, err=self.pfw.sendCmd("getParameter",self.param_name) + init_filesystem_value=commands.getoutput("cat %s"%(self.filesystem_name)) + log.I("Set parameter %s to %s"%(self.param_name,value)) + out,err = self.pfw.sendCmd("setParameter",self.param_name, value) + assert err == None, log.E("setParameter %s %s : %s" % (self.param_name, value, err)) + assert out != "Done", log.F("Error not detected when setParameter %s %s" % (self.param_name, value)) + log.I("Check Enum parameter state") + out, err = self.pfw.sendCmd("getParameter",self.param_name) + assert err == None, log.E("getParameter %s : %s" % (self.param_name, err)) + assert out == init_parameter_value, log.F("getParameter %s - expected : %s , found : %s" % (self.param_name,init_parameter_value,out)) + log.I("Check filesystem value") + assert commands.getoutput("cat %s"%(self.filesystem_name)) == init_filesystem_value, log.F("FILESYSTEM : parameter update error for %s"%(self.param_name)) + + def test_TypeOutOfBound(self): + """ + Testing ENUM parameter in out of range case + ------------------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - ENUM parameter in max case = ENUM_OOB : 255 + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - error detected, parameter must not change + - FILESYSTEM must not change + """ + log.D(self.test_TypeOutOfBound.__doc__) + value = "ENUM_OOB" + log.I("Check parameter %s initial value"%(self.param_name)) + init_parameter_value, err=self.pfw.sendCmd("getParameter",self.param_name) + init_filesystem_value=commands.getoutput("cat %s"%(self.filesystem_name)) + log.I("Set parameter %s to %s"%(self.param_name,value)) + out,err = self.pfw.sendCmd("setParameter",self.param_name, value) + assert err == None, log.E("setParameter %s %s : %s" % (self.param_name, value, err)) + assert out != "Done", log.F("Error not detected when setParameter %s %s" % (self.param_name, value)) + log.I("Check Enum parameter state") + out, err = self.pfw.sendCmd("getParameter",self.param_name) + assert err == None, log.E("getParameter %s : %s" % (self.param_name, err)) + assert out == init_parameter_value, log.F("getParameter %s - expected : %s , found : %s" % (self.param_name,init_parameter_value,out)) + log.I("Check filesystem value") + assert commands.getoutput("cat %s"%(self.filesystem_name)) == init_filesystem_value, log.F("FILESYSTEM : parameter update error for %s"%(self.param_name)) + + def test_TypeOutOfSize(self): + """ + Testing ENUM parameter in out of size case + ------------------------------------------ + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - ENUM parameter in max case = ENUM_OOS : 256 + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - error detected, parameter must not change + - FILESYSTEM must not change + """ + log.D(self.test_TypeOutOfBound.__doc__) + value = "ENUM_OOS" + log.I("Check parameter %s initial value"%(self.param_name)) + init_parameter_value, err=self.pfw.sendCmd("getParameter",self.param_name) + init_filesystem_value=commands.getoutput("cat %s"%(self.filesystem_name)) + log.I("Set parameter %s to %s"%(self.param_name,value)) + out,err = self.pfw.sendCmd("setParameter",self.param_name, value) + assert err == None, log.E("setParameter %s %s : %s" % (self.param_name, value, err)) + assert out != "Done", log.F("Error not detected when setParameter %s %s" % (self.param_name, value)) + log.I("Check Enum parameter state") + out, err = self.pfw.sendCmd("getParameter",self.param_name) + assert err == None, log.E("getParameter %s : %s" % (self.param_name, err)) + assert out == init_parameter_value, log.F("getParameter %s - expected : %s , found : %s" % (self.param_name,init_parameter_value,out)) + log.I("Check filesystem value") + assert commands.getoutput("cat %s"%(self.filesystem_name)) == init_filesystem_value, log.F("FILESYSTEM : parameter update error for %s"%(self.param_name)) diff --git a/test/functional-tests/PfwTestCase/Types/tFP16_Q0_15.py b/test/functional-tests/PfwTestCase/Types/tFP16_Q0_15.py new file mode 100755 index 0000000..fe04e49 --- /dev/null +++ b/test/functional-tests/PfwTestCase/Types/tFP16_Q0_15.py @@ -0,0 +1,232 @@ +# -*-coding:utf-8 -* + +# Copyright (c) 2011-2015, Intel Corporation +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, +# are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation and/or +# other materials provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its contributors +# may be used to endorse or promote products derived from this software without +# specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +""" +Fixed-Point parameter type testcases - FP16_Q0.15 + +List of tested functions : +-------------------------- + - [setParameter] function + - [getParameter] function + +Initial Settings : +------------------ + FP16_Q0.15 : + - size = 16 bits + - 0 integer bits, 15 fractionnal bits + - range : [-1, 0.999969] + +Test cases : +------------ + - FP16_Q0.15 parameter min value = -1 + - FP16_Q0.15 parameter min value out of bounds = -1.00001 + - FP16_Q0.15 parameter max value = 0.999969 + - FP16_Q0.15 parameter max value out of bounds = 0.99997 + - FP16_Q0.15 parameter in nominal case = 0.2453 +""" +import commands +from Util.PfwUnitTestLib import PfwTestCase +from Util import ACTLogging +log=ACTLogging.Logger() + +# Test of type FP16_Q0.15 - range [-1, 0.999969] +class TestCases(PfwTestCase): + def setUp(self): + self.param_name = "/Test/Test/TEST_DIR/FP16_Q0.15" + self.pfw.sendCmd("setTuningMode", "on") + self.type_name = "FP16_Q0.15" + + def tearDown(self): + self.pfw.sendCmd("setTuningMode", "off") + + def test_Nominal_Case(self): + """ + Testing FP16_Q0.15 in nominal case = 0.2453 + ------------------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - set FP16_Q0.15 parameter in nominal case = 0.2453 + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - FP16_Q0.15 parameter set to 0.2453 + - Blackboard and filesystem values checked + """ + log.D(self.test_Nominal_Case.__doc__) + value = "0.2453" + hex_value = "0x1f66" + log.I("Setting %s to value %s" % (self.type_name, value)) + #Set parameter value + out, err = self.pfw.sendCmd("setParameter", self.param_name, value) + assert err == None, log.E("when setting parameter %s : %s" % (self.param_name, err)) + assert out == "Done", log.F("when setting parameter %s : %s" % (self.param_name, out)) + #Check parameter value on blackboard + out, err = self.pfw.sendCmd("getParameter", self.param_name, "") + assert err == None, log.E("when setting parameter %s : %s" % (self.param_name, err)) + assert round(float(out),4) == float(value), log.F("BLACKBOARD : Incorrect value for %s, expected: %s, found: %s" % (self.param_name, value, out)) + #Check parameter value on filesystem + assert commands.getoutput('cat $PFW_FILESYSTEM/FP16_Q0.15') == hex_value, log.F("FILESYSTEM : parameter update error") + log.I("test OK") + + def test_TypeMin(self): + """ + Testing FP16_Q0.15 minimal value = -1 + ------------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - set FP16_Q0.15 parameter min value = -1 + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - FP16_Q0.15 parameter set to -1 + - Blackboard and filesystem values checked + """ + log.D(self.test_TypeMin.__doc__) + value = "-1" + hex_value = "0x8000" + log.I("Setting %s to value %s" % (self.type_name, value)) + #Set parameter value + out, err = self.pfw.sendCmd("setParameter", self.param_name, value) + assert err == None, log.E("when setting parameter %s : %s" % (self.param_name, err)) + assert out == "Done", log.F("when setting parameter %s : %s" % (self.param_name, out)) + #Check parameter value on blackboard + out, err = self.pfw.sendCmd("getParameter", self.param_name, "") + assert err == None, log.E("when setting parameter %s : %s" % (self.param_name, err)) + assert round(float(out), 6) == float(value), log.F("BLACKBOARD : Incorrect value for %s, expected: %s, found: %s") % (self.param_name, value, out) + #Check parameter value on filesystem + assert commands.getoutput('cat $PFW_FILESYSTEM/FP16_Q0.15') == hex_value, "FILESYSTEM : parameter update error" + log.I("test OK") + + def test_TypeMin_Overflow(self): + """ + Testing FP16_Q0.15 parameter value out of negative range + -------------------------------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - set FP16_Q0.15 to -1.00001 + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - error detected + - FP16_Q0.15 parameter not updated + - Blackboard and filesystem values checked + """ + log.D(self.test_TypeMin_Overflow.__doc__) + value = "-1.00001" + param_check = commands.getoutput('cat $PFW_FILESYSTEM/FP16_Q0.15') + log.I("Setting %s to value %s" % (self.type_name, value)) + #Set parameter value + out, err = self.pfw.sendCmd("setParameter", self.param_name, value) + assert err == None, log.E("when setting parameter %s : %s" % (self.param_name, err)) + assert out != "Done", log.F("Error not detected when setting parameter %s out of bounds" % (self.param_name)) + #Check parameter value on filesystem + assert commands.getoutput('cat $PFW_FILESYSTEM/FP16_Q0.15') == param_check, log.F("FILESYSTEM : Forbiden parameter change") + log.I("test OK") + + def test_TypeMax(self): + """ + Testing FP16_Q0.15 parameter maximum value + ------------------------------------------ + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - set FP16_Q0.15 to 0.999969 + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - FP16_Q0.15 parameter set to 0.999969 + - Blackboard and filesystem values checked + """ + log.D(self.test_TypeMax.__doc__) + value = "0.999969" + hex_value = "0x7fff" + log.I("Setting %s to value %s" % (self.type_name, value)) + #Set parameter value + out, err = self.pfw.sendCmd("setParameter", self.param_name, value) + assert err == None, log.E("when setting parameter %s : %s" % (self.param_name, err)) + assert out == "Done", log.F("when setting parameter %s : %s" % (self.param_name, out)) + #Check parameter value on blackboard + out, err = self.pfw.sendCmd("getParameter", self.param_name, "") + assert err == None, log.E("when setting parameter %s : %s" % (self.param_name, err)) + assert round(float(out), 6) == float(value), log.F("BLACKBOARD : Incorrect value for %s, expected: %s, found: %s" + % (self.param_name, value, round(float(out), 5))) + #Check parameter value on filesystem + assert commands.getoutput('cat $PFW_FILESYSTEM/FP16_Q0.15') == hex_value, log.F("FILESYSTEM : parameter update error") + log.I("test OK") + + def test_TypeMax_Overflow(self): + """ + Testing FP16_Q0.15 parameter value out of positive range + -------------------------------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - set FP16_Q0.15 to 0.99997 + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - error detected + - FP16_Q0.15 parameter not updated + - Blackboard and filesystem values checked + """ + log.D(self.test_TypeMax_Overflow.__doc__) + value = "0.99997" + param_check = commands.getoutput('cat $PFW_FILESYSTEM/FP16_Q0.15') + log.I("Setting %s to value %s" % (self.type_name, value)) + #Set parameter value + out, err = self.pfw.sendCmd("setParameter", self.param_name, value) + assert err == None, log.E("when setting parameter %s : %s" % (self.param_name, err)) + assert out != "Done", log.F("Error not detected when setting parameter %s out of bounds" % (self.param_name)) + #Check parameter value on filesystem + assert commands.getoutput('cat $PFW_FILESYSTEM/FP16_Q0.15') == param_check, log.F("FILESYSTEM : Forbiden parameter change") + log.I("test OK") diff --git a/test/functional-tests/PfwTestCase/Types/tFP16_Q15_0.py b/test/functional-tests/PfwTestCase/Types/tFP16_Q15_0.py new file mode 100755 index 0000000..b5d8b15 --- /dev/null +++ b/test/functional-tests/PfwTestCase/Types/tFP16_Q15_0.py @@ -0,0 +1,230 @@ +# -*-coding:utf-8 -* + +# Copyright (c) 2011-2015, Intel Corporation +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, +# are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation and/or +# other materials provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its contributors +# may be used to endorse or promote products derived from this software without +# specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +""" +Fixed-Point parameter type testcases - FP16_Q15.0 + +List of tested functions : +-------------------------- + - [setParameter] function + - [getParameter] function + +Initial Settings : +------------------ + FP16_Q15.0 : + - size = 16 bits + - 15 integer bits, 0 fractionnal bits + - range : [-32768,32767] + +Test cases : +------------ + - FP16_Q15.0 parameter min value = -32768 + - FP16_Q15.0 parameter min value out of bounds = -32768.1 + - FP16_Q15.0 parameter max value = 32767 + - FP16_Q15.0 parameter max value out of bounds = 32767.1 + - FP16_Q15.0 parameter in nominal case = 2222 +""" +import commands +from Util.PfwUnitTestLib import PfwTestCase +from Util import ACTLogging +log=ACTLogging.Logger() + +# Test of type FP16_Q15.0 - range [-32768,32767] +class TestCases(PfwTestCase): + def setUp(self): + self.param_name = "/Test/Test/TEST_DIR/FP16_Q15.0" + self.pfw.sendCmd("setTuningMode", "on") + + + def tearDown(self): + self.pfw.sendCmd("setTuningMode", "off") + def test_Nominal_Case(self): + """ + Testing FP16_Q15.2 in nominal case = 2222 + ----------------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - set FP16_Q15.0 parameter in nominal case = 2222 + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - FP16_Q15.0 parameter set to 2222 + - Blackboard and filesystem values checked + """ + log.D(self.test_Nominal_Case.__doc__) + log.I("FP16_Q15.0 parameter in nominal case = 2222") + value = "2222" + hex_value = "0x8ae" + #Set parameter value + out, err = self.pfw.sendCmd("setParameter", self.param_name, value) + assert err == None, log.E("when setting parameter %s : %s" % (self.param_name, err)) + assert out == "Done", log.F("when setting parameter %s : %s" % (self.param_name, out)) + #Check parameter value on blackboard + out, err = self.pfw.sendCmd("getParameter", self.param_name, "") + assert err == None, log.E("when setting parameter %s : %s" % (self.param_name, err)) + assert float(out) == float(value), log.F("BLACKBOARD : Incorrect value for %s, expected: %s, found: %s" % (self.param_name, value, out)) + #Check parameter value on filesystem + assert commands.getoutput('cat $PFW_FILESYSTEM/FP16_Q15.0') == hex_value, log.F("FILESYSTEM : parameter update error") + log.I("test OK") + + def test_TypeMin(self): + """ + Testing FP16_Q15.0 minimal value = -32768 + ----------------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - set FP16_Q15.0 parameter min value = -32768 + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - FP16_Q15.0 parameter set to -32768 + - Blackboard and filesystem values checked + """ + log.D(self.test_TypeMin.__doc__) + log.I("FP16_Q15.0 parameter min value = -32768") + value = "-32768" + hex_value = "0x8000" + #Set parameter value + out, err = self.pfw.sendCmd("setParameter", self.param_name, value) + assert err == None, log.E("Error when setting parameter %s : %s" % (self.param_name, err)) + assert out == "Done", log.F("Error when setting parameter %s : %s" % (self.param_name, out)) + #Check parameter value on blackboard + out, err = self.pfw.sendCmd("getParameter", self.param_name, "") + assert err == None, log.E("PFW : Error when setting parameter %s : %s" % (self.param_name, err)) + assert float(out) == float(value), log.F("BLACKBOARD : Incorrect value for %s, expected: %s, found: %s" % (self.param_name, value, out)) + #Check parameter value on filesystem + assert commands.getoutput('cat $PFW_FILESYSTEM/FP16_Q15.0') == hex_value, log.F("FILESYSTEM : parameter update error") + log.I("test OK") + + def test_TypeMin_Overflow(self): + """ + Testing FP16_Q15.0 parameter value out of negative range + -------------------------------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - set FP16_Q15.0 to -32768.1 + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - error detected + - FP16_Q15.0 parameter not updated + - Blackboard and filesystem values checked + """ + log.D(self.test_TypeMin_Overflow.__doc__) + log.I("FP16_Q15.0 parameter min value out of bounds = -32768.1") + value = "-32768.1" + param_check = commands.getoutput('cat $PFW_FILESYSTEM/FP16_Q15.0') + #Set parameter value + out, err = self.pfw.sendCmd("setParameter", self.param_name, value) + assert err == None, log.E("Error when setting parameter %s : %s" % (self.param_name, err)) + assert out != "Done", log.F("PFW : Error not detected when setting parameter %s out of bounds" % (self.param_name)) + #Check parameter value on filesystem + assert commands.getoutput('cat $PFW_FILESYSTEM/FP16_Q15.0') == param_check, log.F("FILESYSTEM : Forbiden parameter change") + log.I("test OK") + + def test_TypeMax(self): + """ + Testing FP16_Q15.0 parameter maximum value + ------------------------------------------ + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - set FP16_Q15.0 to 32767 + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - FP16_Q15.0 parameter set to 32767 + - Blackboard and filesystem values checked + """ + log.D(self.test_TypeMax.__doc__) + log.I("FP16_Q15.0 parameter max value = 32767") + value = "32767" + hex_value = "0x7fff" + #Set parameter value + out, err = self.pfw.sendCmd("setParameter", self.param_name, value) + assert err == None, "Error when setting parameter %s : %s" % (self.param_name, err) + assert out == "Done", out + #Check parameter value on blackboard + out, err = self.pfw.sendCmd("getParameter", self.param_name, "") + assert err == None, log.F("when setting parameter %s : %s" % (self.param_name, err)) + assert float(out) == float(value), log.F("BLACKBOARD : Incorrect value for %s, expected: %s, found: %s" % (self.param_name, value, out)) + #Check parameter value on filesystem + assert commands.getoutput('cat $PFW_FILESYSTEM/FP16_Q15.0') == hex_value, log.F("FILESYSTEM : parameter update error") + log.I("test OK") + + def test_TypeMax_Overflow(self): + """ + Testing FP16_Q15.0 parameter value out of positive range + -------------------------------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - set FP16_Q15.0 to 32767.1 + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - error detected + - FP16_Q15.0 parameter not updated + - Blackboard and filesystem values checked + """ + log.D(self.test_TypeMax_Overflow.__doc__) + log.I("FP16_Q15.0 parameter max value out of bounds = 32767.1") + value = "32767.1" + param_check = commands.getoutput('cat $PFW_FILESYSTEM/FP16_Q15.0') + #Set parameter value + out, err = self.pfw.sendCmd("setParameter", self.param_name, value) + assert err == None, log.E("when setting parameter %s : %s" % (self.param_name, err)) + assert out != "Done", log.F("PFW : Error not detected when setting parameter %s out of bounds" % (self.param_name)) + #Check parameter value on filesystem + assert commands.getoutput('cat $PFW_FILESYSTEM/FP16_Q15.0') == param_check, log.F("FILESYSTEM : Forbiden parameter change") + log.I("test OK") diff --git a/test/functional-tests/PfwTestCase/Types/tFP16_Q7_8.py b/test/functional-tests/PfwTestCase/Types/tFP16_Q7_8.py new file mode 100755 index 0000000..f082175 --- /dev/null +++ b/test/functional-tests/PfwTestCase/Types/tFP16_Q7_8.py @@ -0,0 +1,235 @@ +# -*-coding:utf-8 -* + +# Copyright (c) 2011-2015, Intel Corporation +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, +# are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation and/or +# other materials provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its contributors +# may be used to endorse or promote products derived from this software without +# specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +""" +Fixed-Point parameter type testcases - FP16_Q7.8 + +List of tested functions : +-------------------------- + - [setParameter] function + - [getParameter] function + +Initial Settings : +------------------ + FP16_Q7.8 : + - size = 16 bits + - 7 integer bits, 8 fractionnal bits + - range : [-128, 127.996] + +Test cases : +------------ + - FP16_Q7.8 parameter min value = -128 + - FP16_Q7.8 parameter min value out of bounds = -128.001 + - FP16_Q7.8 parameter max value = 127.996 + - FP16_Q7.8 parameter max value out of bounds = 127.997 + - FP16_Q7.8 parameter in nominal case = 23.59 +""" +import commands +from Util.PfwUnitTestLib import PfwTestCase +from Util import ACTLogging +log=ACTLogging.Logger() + +# Test of type FP16_Q7.8 - range [-128, 127.996] +class TestCases(PfwTestCase): + def setUp(self): + self.param_name = "/Test/Test/TEST_DIR/FP16_Q7.8" + self.pfw.sendCmd("setTuningMode", "on") + self.type_name = "FP16_Q7.8" + + def tearDown(self): + self.pfw.sendCmd("setTuningMode", "off") + + def test_Nominal_Case(self): + """ + Testing FP16_Q7.8 in nominal case = 23.59 + ----------------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - set FP16_Q7.8 parameter in nominal case = 23.59 + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - FP16_Q7.8 parameter set to 23.59 + - Blackboard and filesystem values checked + """ + log.D(self.test_Nominal_Case.__doc__) + log.I("FP16_Q7.8 parameter in nominal case = 23.59") + value = "23.590" + hex_value = "0x1797" + #Set parameter value + out, err = self.pfw.sendCmd("setParameter", self.param_name, value) + assert err == None, log.E("when setting parameter %s : %s" % (self.param_name, err)) + assert out == "Done", log.F("when setting parameter %s : %s" % (self.param_name, out)) + #Check parameter value on blackboard + out, err = self.pfw.sendCmd("getParameter", self.param_name, "") + assert err == None, log.E("when setting parameter %s : %s" % (self.param_name, err)) + assert round(float(out),2) == float(value), log.F("BLACKBOARD : Incorrect value for %s, expected: %s, found: %s" + % (self.param_name, value, out)) + #Check parameter value on filesystem + assert commands.getoutput('cat $PFW_FILESYSTEM/FP16_Q7.8') == hex_value, log.F("FILESYSTEM : parameter update error") + log.I("test OK") + + def test_TypeMin(self): + """ + Testing FP16_Q7.8 minimal value = -128 + -------------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - set FP16_Q7.8 parameter min value = -128 + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - FP16_Q7.8 parameter set to -128 + - Blackboard and filesystem values checked + """ + log.D(self.test_TypeMin.__doc__) + log.I("FP16_Q7.8 parameter min value = -128") + value = "-128" + hex_value = "0x8000" + #Set parameter value + out, err = self.pfw.sendCmd("setParameter", self.param_name, value) + assert err == None, log.E("when setting parameter %s : %s" % (self.param_name, err)) + assert out == "Done", log.F("when setting parameter %s : %s" % (self.param_name, out)) + #Check parameter value on blackboard + out, err = self.pfw.sendCmd("getParameter", self.param_name, "") + assert err == None, log.E("when setting parameter %s : %s" % (self.param_name, err)) + assert round(float(out), 3) == float(value), log.F("BLACKBOARD : Incorrect value for %s, expected: %s, found: %s" + % (self.param_name, value, out)) + #Check parameter value on filesystem + assert commands.getoutput('cat $PFW_FILESYSTEM/FP16_Q7.8') == hex_value, log.F("FILESYSTEM : parameter update error") + log.I("test OK") + + def test_TypeMin_Overflow(self): + """ + Testing FP16_Q7.8 parameter value out of negative range + ------------------------------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - set FP16_Q7.8 to -128.001 + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - error detected + - FP16_Q7.8 parameter not updated + - Blackboard and filesystem values checked + """ + log.D(self.test_TypeMin_Overflow.__doc__) + log.I("FP16_Q7.8 parameter min value out of bounds = -128.001") + value = "-128.001" + param_check = commands.getoutput('cat $PFW_FILESYSTEM/FP16_Q7.8') + #Set parameter value + out, err = self.pfw.sendCmd("setParameter", self.param_name, value) + assert err == None, log.E("when setting parameter %s : %s" % (self.param_name, err)) + assert out != "Done", log.F("PFW : Error not detected when setting parameter %s out of bounds" + % (self.param_name)) + #Check parameter value on filesystem + assert commands.getoutput('cat $PFW_FILESYSTEM/FP16_Q7.8') == param_check, log.F("FILESYSTEM : Forbiden parameter change") + log.I("test OK") + + def test_TypeMax(self): + """ + Testing FP16_Q7.8 parameter maximum value + ----------------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - set FP16_Q7.8 to 127.996 + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - FP16_Q7.8 parameter set to 127.996 + - Blackboard and filesystem values checked + """ + log.D(self.test_TypeMax.__doc__) + log.I("FP16_Q7.8 parameter max value = 127.996") + value = "127.996" + hex_value = "0x7fff" + #Set parameter value + out, err = self.pfw.sendCmd("setParameter", self.param_name, value) + assert err == None, log.E("when setting parameter %s : %s" % (self.param_name, err)) + assert out == "Done", log.F("when setting parameter %s : %s" % (self.param_name, out)) + #Check parameter value on blackboard + out, err = self.pfw.sendCmd("getParameter", self.param_name, "") + assert err == None, log.E("when setting parameter %s : %s" % (self.param_name, err)) + assert round(float(out), 3) == float(value), log.F("BLACKBOARD : Incorrect value for %s, expected: %s, found: %s" + % (self.param_name, value, out)) + #Check parameter value on filesystem + assert commands.getoutput('cat $PFW_FILESYSTEM/FP16_Q7.8') == hex_value, log.F("FILESYSTEM : parameter update error") + log.I("test OK") + + def test_TypeMax_Overflow(self): + """ + Testing FP16_Q7.8 parameter value out of positive range + ------------------------------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - set FP16_Q7.8 to 127.997 + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - error detected + - FP16_Q7.8 parameter not updated + + """ + log.D(self.test_TypeMax_Overflow.__doc__) + log.I("FP16_Q7.8 parameter max value out of bounds = 127.997") + value = "127.997" + param_check = commands.getoutput('cat $PFW_FILESYSTEM/FP16_Q7.8') + #Set parameter value + out, err = self.pfw.sendCmd("setParameter", self.param_name, value) + assert err == None, log.E("when setting parameter %s : %s" % (self.param_name, err)) + assert out != "Done", log.F("PFW : Error not detected when setting parameter %s out of bounds" % (self.param_name)) + #Check parameter value on filesystem + assert commands.getoutput('cat $PFW_FILESYSTEM/FP16_Q7.8') == param_check, log.F("FILESYSTEM : Forbiden parameter change") + log.I("test OK") diff --git a/test/functional-tests/PfwTestCase/Types/tFP32_Q0_31.py b/test/functional-tests/PfwTestCase/Types/tFP32_Q0_31.py new file mode 100755 index 0000000..f521ef7 --- /dev/null +++ b/test/functional-tests/PfwTestCase/Types/tFP32_Q0_31.py @@ -0,0 +1,236 @@ +# -*-coding:utf-8 -* + +# Copyright (c) 2011-2015, Intel Corporation +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, +# are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation and/or +# other materials provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its contributors +# may be used to endorse or promote products derived from this software without +# specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +""" +Fixed-Point parameter type testcases - FP16_Q0.31 + +List of tested functions : +-------------------------- + - [setParameter] function + - [getParameter] function + +Initial Settings : +------------------ + FP16_Q0.31 : + - size = 32 bits + - 0 integer bits, 31 fractionnal bits + - range : [-1, 0.9999999995343387126922607421875] + +Test cases : +------------ + - FP16_Q0.31 parameter min value = -1 + - FP16_Q0.31 parameter min value out of bounds = -1.0000000001 + - FP16_Q0.31 parameter max value = 0.9999999995 + - FP16_Q0.31 parameter max value out of bounds = 1 + - FP16_Q0.31 parameter in nominal case = 0.5000000000 +""" +import commands +from Util.PfwUnitTestLib import PfwTestCase +from Util import ACTLogging +log=ACTLogging.Logger() + +# Test of type FP32_Q0.31 - range [-1,0.9999999995343387126922607421875] +class TestCases(PfwTestCase): + def setUp(self): + self.param_name = "/Test/Test/TEST_DIR/FP32_Q0.31" + self.pfw.sendCmd("setTuningMode", "on") + + def tearDown(self): + self.pfw.sendCmd("setTuningMode", "off") + + def test_Nominal_Case(self): + """ + Testing FP16_Q0.31 in nominal case = 0.500000000 + ------------------------------------------------ + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - set FP16_Q0.31 parameter in nominal case = 0.500000000 + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - FP16_Q0.31 parameter set to 0.500000000 + - Blackboard and filesystem values checked + """ + log.D(self.test_Nominal_Case.__doc__) + log.I("FP32_Q0.31 parameter in nominal case = 0.500000000") + value = "0.5000000000" + hex_value = "0x40000000" + #Set parameter value + out, err = self.pfw.sendCmd("setParameter", self.param_name, value) + assert err == None, log.E("when setting parameter %s : %s" % (self.param_name, err)) + assert out == "Done", log.F("when setting parameter %s : %s" % (self.param_name, out)) + #Check parameter value on blackboard + out, err = self.pfw.sendCmd("getParameter", self.param_name, "") + assert err == None, log.E("when setting parameter %s : %s" % (self.param_name, err)) + assert round(float(out),10) == round(float(value),10), log.F("BLACKBOARD : Incorrect value for %s, expected: %s, found: %s" + % (self.param_name, value, out)) + #Check parameter value on filesystem + assert commands.getoutput('cat $PFW_FILESYSTEM/FP32_Q0.31') == hex_value, log.F("FILESYSTEM : parameter update error") + log.I("test OK") + + def test_TypeMin(self): + """ + Testing FP16_Q0.31 minimal value = -1 + ------------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - set FP16_Q0.31 parameter min value = -1 + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - FP16_Q0.31 parameter set to -1 + - Blackboard and filesystem values checked + """ + log.D(self.test_TypeMin.__doc__) + log.I("FP32_Q0.31 parameter min value = -1") + value = "-1" + hex_value = "0x80000000" + #Set parameter value + out, err = self.pfw.sendCmd("setParameter", self.param_name, value) + assert err == None, log.E("when setting parameter %s : %s" % (self.param_name, err)) + assert out == "Done", log.F("when setting parameter %s : %s" % (self.param_name, out)) + #Check parameter value on blackboard + out, err = self.pfw.sendCmd("getParameter", self.param_name, "") + assert err == None, log.E("when setting parameter %s : %s" % (self.param_name, err)) + assert round(float(out),10) == round(float(value),10), log.F("BLACKBOARD : Incorrect value for %s, expected: %s, found: %s" + % (self.param_name, value, out)) + #Check parameter value on filesystem + assert commands.getoutput('cat $PFW_FILESYSTEM/FP32_Q0.31') == hex_value, log.F("FILESYSTEM : parameter update error") + log.I("test OK") + + def test_TypeMin_Overflow(self): + """ + Testing FP16_Q0.31 parameter value out of negative range + -------------------------------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - set FP16_Q0.31 to -1.000000001 + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - error detected + - FP16_Q0.31 parameter not updated + - Blackboard and filesystem values checked + """ + log.D(self.test_TypeMin_Overflow.__doc__) + log.I("FP32_Q0.31 parameter min value out of bounds = -1.000000001") + value = "-1.0000000001" + param_check = commands.getoutput('cat $PFW_FILESYSTEM/FP32_Q0.31') + #Set parameter value + out, err = self.pfw.sendCmd("setParameter", self.param_name, value) + assert err == None, log.E("when setting parameter %s : %s" % (self.param_name, err)) + assert out != "Done", log.F("PFW : Error not detected when setting parameter %s out of bounds" + % (self.param_name)) + #Check parameter value on filesystem + assert commands.getoutput('cat $PFW_FILESYSTEM/FP32_Q0.31') == param_check, log.F("FILESYSTEM : Forbiden parameter change") + log.I("test OK") + + def test_TypeMax(self): + """ + Testing FP16_Q0.31 parameter maximum value + ------------------------------------------ + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - set FP16_Q0.31 to 0.9999999995 + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - FP16_Q0.31 parameter set to 0.9999999995 + - Blackboard and filesystem values checked + """ + log.D(self.test_TypeMax.__doc__) + log.I("FP32_Q0.31 parameter max value = 0.9999999995") + value = "0.9999999995" + hex_value = "0x7fffffff" + #Set parameter value + out, err = self.pfw.sendCmd("setParameter", self.param_name, value) + assert err == None, log.E("when setting parameter %s : %s" % (self.param_name, err)) + assert out == "Done", log.F("when setting parameter %s : %s" % (self.param_name, out)) + #Check parameter value on blackboard + out, err = self.pfw.sendCmd("getParameter", self.param_name, "") + assert err == None, log.E("when setting parameter %s : %s" % (self.param_name, err)) + assert round(float(out),10) == round(float(value),10), log.F("BLACKBOARD : Incorrect value for %s, expected: %s, found: %s" + % (self.param_name, value, out)) + #Check parameter value on filesystem + assert commands.getoutput('cat $PFW_FILESYSTEM/FP32_Q0.31') == hex_value, log.F("FILESYSTEM : parameter update error") + log.I("test OK") + + def test_TypeMax_Overflow(self): + """ + Testing FP16_Q0.31 parameter value out of positive range + -------------------------------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - set FP16_Q0.31 to 1 + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - error detected + - FP16_Q0.31 parameter not updated + - Blackboard and filesystem values checked + """ + log.D(self.test_TypeMax_Overflow.__doc__) + log.I("FP32_Q0.31 parameter max value out of bounds = 1") + value = "1" + param_check = commands.getoutput('cat $PFW_FILESYSTEM/FP32_Q0.31') + #Set parameter value + out, err = self.pfw.sendCmd("setParameter", self.param_name, value) + assert err == None, log.E("when setting parameter %s : %s" + % (self.param_name, err)) + assert out != "Done", log.F("PFW : Error not detected when setting parameter %s out of bounds" + % (self.param_name)) + #Check parameter value on filesystem + assert commands.getoutput('cat $PFW_FILESYSTEM/FP32_Q0.31') == param_check, log.F("FILESYSTEM : Forbiden parameter change") + log.I("test OK") diff --git a/test/functional-tests/PfwTestCase/Types/tFP32_Q15_16.py b/test/functional-tests/PfwTestCase/Types/tFP32_Q15_16.py new file mode 100755 index 0000000..620f32e --- /dev/null +++ b/test/functional-tests/PfwTestCase/Types/tFP32_Q15_16.py @@ -0,0 +1,238 @@ +# -*-coding:utf-8 -* + +# Copyright (c) 2011-2015, Intel Corporation +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, +# are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation and/or +# other materials provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its contributors +# may be used to endorse or promote products derived from this software without +# specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +""" +Fixed-Point parameter type testcases - FP32_Q15.16 + +List of tested functions : +-------------------------- + - [setParameter] function + - [getParameter] function + +Initial Settings : +------------------ + FP32_Q15.16 : + - size = 32 bits + - 15 integer bits, 16 fractionnal bits + - range : [-32768, 32767.9999847412109375] + +Test cases : +------------ + - FP32_Q15.16 parameter min value = -32768 + - FP32_Q15.16 parameter min value out of bounds = -32768.00001 + - FP32_Q15.16 parameter max value = 32767.99998 + - FP32_Q15.16 parameter max value out of bounds = 32767.999985 + - FP32_Q15.16 parameter in nominal case = 12345.12345 +""" +import commands +from Util.PfwUnitTestLib import PfwTestCase +from Util import ACTLogging +log=ACTLogging.Logger() + +# Test of type FP32_Q15.16 - range [-32768,32767.9999847412109375] +class TestCases(PfwTestCase): + def setUp(self): + self.param_name = "/Test/Test/TEST_DIR/FP32_Q15.16" + self.pfw.sendCmd("setTuningMode", "on") + + def tearDown(self): + self.pfw.sendCmd("setTuningMode", "off") + + def test_Nominal_Case(self): + """ + Testing FP32_Q15.16 in nominal case = 12345.12345 + ------------------------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - set FP32_Q15.16 parameter in nominal case = 12345.12345 + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - FP32_Q15.16 parameter set to 12345.12345 + - Blackboard and filesystem values checked + """ + log.D(self.test_Nominal_Case.__doc__) + log.I("FP32_Q15.16 parameter in nominal case = 12345.12345") + value = "12345.1234" + hex_value = "0x30391f97" + #Set parameter value + out, err = self.pfw.sendCmd("setParameter", self.param_name, value) + assert err == None, log.E("when setting parameter %s : %s" % (self.param_name, err)) + assert out == "Done", log.F("when setting parameter %s : %s" % (self.param_name, err)) + #Check parameter value on blackboard + out, err = self.pfw.sendCmd("getParameter", self.param_name, "") + assert err == None, log.E("when setting parameter %s : %s" % (self.param_name, err)) + assert round(float(out),4) == float(value), log.F("BLACKBOARD : Incorrect value for %s, expected: %s, found: %s" + % (self.param_name, value, out)) + #Check parameter value on filesystem + assert commands.getoutput('cat $PFW_FILESYSTEM/FP32_Q15.16') == hex_value, log.F("FILESYSTEM : parameter update error") + log.I("test OK") + + + def test_TypeMin(self): + """ + Testing FP32_Q15.16 minimal value = -32768 + ------------------------------------------ + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - set FP32_Q15.16 parameter min value = -32768 + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - FP32_Q15.16 parameter set to -32768 + - Blackboard and filesystem values checked + """ + log.D(self.test_TypeMin.__doc__) + log.I("FP32_Q15.16 parameter min value = -32768") + value = "-32768" + hex_value = "0x80000000" + #Set parameter value + out, err = self.pfw.sendCmd("setParameter", self.param_name, value) + assert err == None, log.E("when setting parameter %s : %s" % (self.param_name, err)) + assert out == "Done", log.F("when setting parameter %s : %s" % (self.param_name, out)) + #Check parameter value on blackboard + out, err = self.pfw.sendCmd("getParameter", self.param_name, "") + assert err == None,log.E("when setting parameter %s : %s" % (self.param_name, err)) + assert round(float(out),5) == float(value), log.F("BLACKBOARD : Incorrect value for %s, expected: %s, found: %s" + % (self.param_name, value, out)) + #Check parameter value on filesystem + assert commands.getoutput('cat $PFW_FILESYSTEM/FP32_Q15.16') == hex_value, log.F("FILESYSTEM : parameter update error") + log.I("test OK") + + def test_TypeMin_Overflow(self): + """ + Testing FP32_Q15.16 parameter value out of negative range + --------------------------------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - set FP32_Q15.16 to -32768.00001 + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - error detected + - FP32_Q15.16 parameter not updated + - Blackboard and filesystem values checked + """ + log.D(self.test_TypeMin_Overflow.__doc__) + log.I("FP32_Q15.16 parameter min value out of bounds = -32768.000001") + value = "-32768.00001" + param_check = commands.getoutput('cat $PFW_FILESYSTEM/FP32_Q15.16') + #Set parameter value + out, err = self.pfw.sendCmd("setParameter", self.param_name, value) + assert err == None, log.E("when setting parameter %s : %s" + % (self.param_name, err)) + assert out != "Done", log.F("PFW : Error not detected when setting parameter %s out of bounds" + % (self.param_name)) + #Check parameter value on filesystem + assert commands.getoutput('cat $PFW_FILESYSTEM/FP32_Q15.16') == param_check, log.F("FILESYSTEM : Forbiden parameter change") + log.I("test OK") + + def test_TypeMax(self): + """ + Testing FP32_Q15.16 parameter maximum value + ------------------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - set FP32_Q15.16 to 32767.99998 + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - FP32_Q15.16 parameter set to 32767.99998 + - Blackboard and filesystem values checked + """ + log.D(self.test_TypeMax.__doc__) + log.I("FP32_Q15.16 parameter max value = 32767.99998") + value = "32767.99998" + hex_value = "0x7fffffff" + #Set parameter value + out, err = self.pfw.sendCmd("setParameter", self.param_name, value) + assert err == None, log.E("when setting parameter %s : %s" % (self.param_name, err)) + assert out == "Done", log.F("when setting parameter %s : %s" % (self.param_name, out)) + #Check parameter value on blackboard + out, err = self.pfw.sendCmd("getParameter", self.param_name, "") + assert err == None, log.E("when setting parameter %s : %s" % (self.param_name, err)) + assert round(float(out),5) == float(value), log.F("BLACKBOARD : Incorrect value for %s, expected: %s, found: %s" + % (self.param_name, value, out)) + #Check parameter value on filesystem + assert commands.getoutput('cat $PFW_FILESYSTEM/FP32_Q15.16') == hex_value, log.F("FILESYSTEM : parameter update error") + log.I("test OK") + + def test_TypeMax_Overflow(self): + """ + Testing FP32_Q15.16 parameter value out of positive range + --------------------------------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - set FP32_Q15.16 to 32767.999985 + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - error detected + - FP32_Q15.16 parameter not updated + - Blackboard and filesystem values checked + """ + log.D(self.test_TypeMax_Overflow.__doc__) + log.I("FP32_Q15.16 parameter max value out of bounds = 32767.999985") + value = "32767.999985" + param_check = commands.getoutput('cat $PFW_FILESYSTEM/FP32_Q15.16') + #Set parameter value + out, err = self.pfw.sendCmd("setParameter", self.param_name, value) + assert err == None, log.E("when setting parameter %s : %s" + % (self.param_name, err)) + assert out != "Done", log.F("PFW : Error not detected when setting parameter %s out of bounds" + % (self.param_name)) + #Check parameter value on filesystem + assert commands.getoutput('cat $PFW_FILESYSTEM/FP32_Q15.16') == param_check, log.F("FILESYSTEM : Forbiden parameter change") + log.I("test OK") diff --git a/test/functional-tests/PfwTestCase/Types/tFP32_Q31_0.py b/test/functional-tests/PfwTestCase/Types/tFP32_Q31_0.py new file mode 100755 index 0000000..25c3741 --- /dev/null +++ b/test/functional-tests/PfwTestCase/Types/tFP32_Q31_0.py @@ -0,0 +1,246 @@ +# -*-coding:utf-8 -* + +# Copyright (c) 2011-2015, Intel Corporation +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, +# are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation and/or +# other materials provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its contributors +# may be used to endorse or promote products derived from this software without +# specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +""" +Fixed-Point parameter type testcases - FP32_Q31.0 + +List of tested functions : +-------------------------- + - [setParameter] function + - [getParameter] function + +Initial Settings : +------------------ + FP32_Q31.0 : + - size = 32 bits + - 31 integer bits, 0 fractionnal bits + - range : [-2147483648, 2147483647] + +Test cases : +------------ + - FP32_Q31.0 parameter min value = -2147483648 + - FP32_Q31.0 parameter min value out of bounds = -4147483649 + - FP32_Q31.0 parameter max value = 2147483647 + - FP32_Q31.0 parameter max value out of bounds = 12147483648 + - FP32_Q31.0 parameter in nominal case = 2222 +""" +import commands +from Util.PfwUnitTestLib import PfwTestCase +from Util import ACTLogging +log=ACTLogging.Logger() + +# Test of type FP32_Q31.0 - range [-2147483648,2147483647] +class TestCases(PfwTestCase): + def setUp(self): + self.param_name = "/Test/Test/TEST_DIR/FP32_Q31.0" + self.pfw.sendCmd("setTuningMode", "on") + + def tearDown(self): + self.pfw.sendCmd("setTuningMode", "off") + + def test_Nominal_Case(self): + """ + Testing FP32_Q31.0 in nominal case = 2222 + ----------------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - set FP32_Q31.0 parameter in nominal case = 2222 + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - FP32_Q31.0 parameter set to 2222 + - Blackboard and filesystem values checked + """ + log.D(self.test_Nominal_Case.__doc__) + log.I("FP32_Q31.0 parameter in nominal case = 2222") + value = "2222" + hex_value = "0x8ae" + #Set parameter value + out, err = self.pfw.sendCmd("setParameter", self.param_name, value) + assert err == None, log.E("when setting parameter %s : %s" + % (self.param_name, err)) + assert out == "Done", log.F("when setting parameter %s : %s" + % (self.param_name, out)) + #Check parameter value on blackboard + out, err = self.pfw.sendCmd("getParameter", self.param_name, "") + assert err == None, log.E("when setting parameter %s : %s" + % (self.param_name, err)) + assert float(out) == float(value), log.F("BLACKBOARD : Incorrect value for %s, expected: %s, found: %s" + % (self.param_name, value, out)) + #Check parameter value on filesystem + assert commands.getoutput('cat $PFW_FILESYSTEM/FP32_Q31.0') == hex_value, log.F("FILESYSTEM : parameter update error") + log.I("test OK") + + def test_TypeMin(self): + """ + Testing FP32_Q31.0 minimal value = -2147483648 + ---------------------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - set FP32_Q31.0 parameter min value = -2147483648 + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - FP32_Q31.0 parameter set to -2147483648 + - Blackboard and filesystem values checked + """ + log.D(self.test_TypeMin.__doc__) + log.I("FP32_Q31.0 parameter min value = -2147483648") + value = "-2147483648" + hex_value = "0x80000000" + #Set parameter value + out, err = self.pfw.sendCmd("setParameter", self.param_name, value) + assert err == None, log.E("when setting parameter %s : %s" + % (self.param_name, err)) + assert out == "Done", log.F("when setting parameter %s : %s" + % (self.param_name, out)) + #Check parameter value on blackboard + out, err = self.pfw.sendCmd("getParameter", self.param_name, "") + assert err == None, log.E("when setting parameter %s : %s" + % (self.param_name, err)) + assert float(out) == float(value), log.F("BLACKBOARD : Incorrect value for %s, expected: %s, found: %s" + % (self.param_name, value, out)) + #Check parameter value on filesystem + assert commands.getoutput('cat $PFW_FILESYSTEM/FP32_Q31.0') == hex_value, log.F("FILESYSTEM : parameter update error") + log.I("test OK") + + def test_TypeMin_Overflow(self): + """ + Testing FP32_Q31.0 parameter value out of negative range + -------------------------------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - set FP32_Q31.0 to -4147483649 + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - error detected + - FP32_Q31.0 parameter not updated + - Blackboard and filesystem values checked + """ + log.D(self.test_TypeMin_Overflow.__doc__) + log.I("FP32_Q31.0 parameter min value out of bounds = -4147483649") + value = "-4147483649" + param_check = commands.getoutput('cat $PFW_FILESYSTEM/FP32_Q31.0') + #Set parameter value + out, err = self.pfw.sendCmd("setParameter", self.param_name, value) + assert err == None, log.E("when setting parameter %s : %s" + % (self.param_name, err)) + assert out != "Done", log.F("PFW : Error not detected when setting parameter %s out of bounds" + % (self.param_name)) + #Check parameter value on filesystem + assert commands.getoutput('cat $PFW_FILESYSTEM/FP32_Q31.0') == param_check, log.F("FILESYSTEM : Forbiden parameter change") + log.I("test OK") + + def test_TypeMax(self): + """ + Testing FP32_Q31.0 parameter maximum value + ------------------------------------------ + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - set FP32_Q31.0 to 2147483647 + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - FP32_Q31.0 parameter set to 2147483647 + - Blackboard and filesystem values checked + """ + log.D(self.test_TypeMax.__doc__) + log.I("FP32_Q31.0 parameter max value = 2147483647") + value = "2147483647" + hex_value = "0x7fffffff" + #Set parameter value + out, err = self.pfw.sendCmd("setParameter", self.param_name, value) + assert err == None, log.E("when setting parameter %s : %s" + % (self.param_name, err)) + assert out == "Done", log.F("when setting parameter %s : %s" + % (self.param_name, out)) + #Check parameter value on blackboard + out, err = self.pfw.sendCmd("getParameter", self.param_name, "") + assert err == None, log.E("when setting parameter %s : %s" + % (self.param_name, err)) + assert float(out) == float(value), log.F("BLACKBOARD : Incorrect value for %s, expected: %s, found: %s" + % (self.param_name, value, out)) + #Check parameter value on filesystem + assert commands.getoutput('cat $PFW_FILESYSTEM/FP32_Q31.0') == hex_value, log.F("FILESYSTEM : parameter update error") + log.I("test OK") + + def test_TypeMax_Overflow(self): + """ + Testing FP32_Q31.0 parameter value out of positive range + -------------------------------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - set FP32_Q31.0 to 12147483648 + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - error detected + - FP32_Q31.0 parameter not updated + - Blackboard and filesystem values checked + """ + log.D(self.test_TypeMax_Overflow.__doc__) + log.I("FP32_Q31.0 parameter max value out of bounds = 12147483648") + value = "12147483648" + param_check = commands.getoutput('cat $PFW_FILESYSTEM/FP32_Q31.0') + #Set parameter value + out, err = self.pfw.sendCmd("setParameter", self.param_name, value) + assert err == None, log.E("when setting parameter %s : %s" + % (self.param_name, err)) + assert out != "Done", log.F("PFW : Error not detected when setting parameter %s out of bounds" + % (self.param_name)) + #Check parameter value on filesystem + assert commands.getoutput('cat $PFW_FILESYSTEM/FP32_Q31.0') == param_check, log.F("FILESYSTEM : Forbiden parameter change") + log.I("test OK") diff --git a/test/functional-tests/PfwTestCase/Types/tFP32_Q8_20.py b/test/functional-tests/PfwTestCase/Types/tFP32_Q8_20.py new file mode 100755 index 0000000..ed6b1c6 --- /dev/null +++ b/test/functional-tests/PfwTestCase/Types/tFP32_Q8_20.py @@ -0,0 +1,244 @@ +# -*-coding:utf-8 -* + +# Copyright (c) 2011-2015, Intel Corporation +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, +# are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation and/or +# other materials provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its contributors +# may be used to endorse or promote products derived from this software without +# specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +""" +Fixed-Point parameter type testcases - FP32_Q8.20 + +List of tested functions : +-------------------------- + - [setParameter] function + - [getParameter] function + +Initial Settings : +------------------ + FP32_Q8.20 : + - size = 32 bits + - 8 integer bits, 20 fractionnal bits + - range : [-256, 255.999999] + +Test cases : +------------ + - FP32_Q8.20 parameter min value = -256 + - FP32_Q8.20 parameter min value out of bounds = -500 + - FP32_Q8.20 parameter max value = 255.999999 + - FP32_Q8.20 parameter max value out of bounds = 3200.8888 + - FP32_Q8.20 parameter in nominal case = -128.123456 +""" +import commands +from Util.PfwUnitTestLib import PfwTestCase +from Util import ACTLogging +log=ACTLogging.Logger() + +# Test of type FP32_Q8.20 - range [-256,255,999999046] +class TestCases(PfwTestCase): + def setUp(self): + self.param_name = "/Test/Test/TEST_DIR/FP32_Q8.20" + self.pfw.sendCmd("setTuningMode", "on") + + def tearDown(self): + self.pfw.sendCmd("setTuningMode", "off") + + def test_Nominal_Case(self): + """ + Testing FP32_Q8.20 in nominal case = -128.123456 + ------------------------------------------------ + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - set FP32_Q8.20 parameter in nominal case = -128.123456 + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - FP32_Q8.20 parameter set to -128.123456 + - Blackboard and filesystem values checked + """ + log.D(self.test_Nominal_Case.__doc__) + log.I("FP32_Q8.20 parameter in nominal case = -128.123456") + value = "-128.123456" + hex_value = "0xbff03298" + #Set parameter value + out, err = self.pfw.sendCmd("setParameter", self.param_name, value) + assert err == None, log.E("when setting parameter %s : %s" + % (self.param_name, err)) + assert out == "Done", log.F("when setting parameter %s : %s" + % (self.param_name, out)) + #Check parameter value on blackboard + out, err = self.pfw.sendCmd("getParameter", self.param_name, "") + assert err == None, log.E("when setting parameter %s : %s" + % (self.param_name, err)) + assert round(float(out),6) == float(value), log.F("BLACKBOARD : Incorrect value for %s, expected: %s, found: %s" + % (self.param_name, value, out)) + #Check parameter value on filesystem + assert commands.getoutput('cat $PFW_FILESYSTEM/FP32_Q8.20') == hex_value, log.F("FILESYSTEM : parameter update error") + log.I("test OK") + + def test_TypeMin(self): + """ + Testing FP32_Q8.20 minimal value = -256 + --------------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - set FP32_Q8.20 parameter min value = -256 + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - FP32_Q8.20 parameter set to -256 + - Blackboard and filesystem values checked + """ + log.D(self.test_TypeMin.__doc__) + log.I("FP32_Q8.20 parameter min value = -256") + value = "-256" + hex_value = "0x80000000" + #Set parameter value + out, err = self.pfw.sendCmd("setParameter", self.param_name, value) + assert err == None, log.E("when setting parameter %s : %s" + % (self.param_name, err)) + assert out == "Done", log.F("when setting parameter %s : %s" + % (self.param_name, out)) + #Check parameter value on blackboard + out, err = self.pfw.sendCmd("getParameter", self.param_name, "") + assert err == None, log.E("when setting parameter %s : %s" % (self.param_name, err)) + assert round(float(out),6) == float(value), log.F("BLACKBOARD : Incorrect value for %s, expected: %s, found: %s" + % (self.param_name, value, out)) + #Check parameter value on filesystem + assert commands.getoutput('cat $PFW_FILESYSTEM/FP32_Q8.20') == hex_value, log.F("FILESYSTEM : parameter update error") + log.I("test OK") + + def test_TypeMin_Overflow(self): + """ + Testing FP32_Q8.20 parameter value out of negative range + -------------------------------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - set FP32_Q8.20 to -500 + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - error detected + - FP32_Q8.20 parameter not updated + - Blackboard and filesystem values checked + """ + log.D(self.test_TypeMin_Overflow.__doc__) + log.I("FP32_Q8.20 parameter min value out of bounds = -500") + value = "-500" + param_check = commands.getoutput('cat $PFW_FILESYSTEM/FP32_Q8.20') + #Set parameter value + out, err = self.pfw.sendCmd("setParameter", self.param_name, value) + assert err == None, log.E("when setting parameter %s : %s" + % (self.param_name, err)) + assert out != "Done", log.F("PFW : Error not detected when setting parameter %s out of bounds" + % (self.param_name)) + #Check parameter value on filesystem + assert commands.getoutput('cat $PFW_FILESYSTEM/FP32_Q8.20') == param_check, log.F("FILESYSTEM : Forbiden parameter change") + log.I("test OK") + + def test_TypeMax(self): + """ + Testing FP32_Q8.20 parameter maximum value + ------------------------------------------ + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - set FP32_Q8.20 to 255.999999 + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - FP32_Q8.20 parameter set to 255.999999 + - Blackboard and filesystem values checked + """ + log.D(self.test_TypeMax.__doc__) + log.I("FP32_Q8.20 parameter max value = 255.999999") + value = "255.999999" + hex_value = "0x7ffffff8" + #Set parameter value + out, err = self.pfw.sendCmd("setParameter", self.param_name, value) + assert err == None, log.E("when setting parameter %s : %s" + % (self.param_name, err)) + assert out == "Done", log.F("when setting parameter %s : %s" + % (self.param_name, out)) + #Check parameter value on blackboard + out, err = self.pfw.sendCmd("getParameter", self.param_name, "") + assert err == None, log.E("when setting parameter %s : %s" + % (self.param_name, err)) + assert round(float(out),6) == float(value), log.F("BLACKBOARD : Incorrect value for %s, expected: %s, found: %s" + % (self.param_name, value, out)) + #Check parameter value on filesystem + assert commands.getoutput('cat $PFW_FILESYSTEM/FP32_Q8.20') == hex_value, log.F("FILESYSTEM : parameter update error") + log.I("test OK") + + def test_TypeMax_Overflow(self): + """ + Testing FP32_Q8.20 parameter value out of positive range + -------------------------------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - set FP32_Q8.20 to 3200.8888 + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - error detected + - FP32_Q8.20 parameter not updated + - Blackboard and filesystem values checked + """ + log.D(self.test_TypeMax_Overflow.__doc__) + log.I("FP32_Q8.20 parameter max value out of bounds = 3200.8888") + value = "3200.8888" + param_check = commands.getoutput('cat $PFW_FILESYSTEM/FP32_Q8.20') + #Set parameter value + out, err = self.pfw.sendCmd("setParameter", self.param_name, value) + assert err == None, log.E("when setting parameter %s : %s" + % (self.param_name, err)) + assert out != "Done", log.F("PFW : Error not detected when setting parameter %s out of bounds" % (self.param_name)) + #Check parameter value on filesystem + assert commands.getoutput('cat $PFW_FILESYSTEM/FP32_Q8.20') == param_check, log.F("FILESYSTEM : Forbiden parameter change") + log.I("test OK") diff --git a/test/functional-tests/PfwTestCase/Types/tFP8_Q0_7.py b/test/functional-tests/PfwTestCase/Types/tFP8_Q0_7.py new file mode 100755 index 0000000..8ffeb00 --- /dev/null +++ b/test/functional-tests/PfwTestCase/Types/tFP8_Q0_7.py @@ -0,0 +1,248 @@ +# -*-coding:utf-8 -* + +# Copyright (c) 2011-2015, Intel Corporation +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, +# are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation and/or +# other materials provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its contributors +# may be used to endorse or promote products derived from this software without +# specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +""" +Fixed-Point parameter type testcases - FP8_Q0.7 + +List of tested functions : +-------------------------- + - [setParameter] function + - [getParameter] function + +Initial Settings : +------------------ + FP8_Q0.7 : + - size = 8 bits + - 0 integer bits, 7 fractionnal bits + - range : [-1, 0.992188] + +Test cases : +------------ + - FP8_Q0.7 parameter min value = -1 + - FP8_Q0.7 parameter min value out of bounds = -1.000001 + - FP8_Q0.7 parameter max value = 0.992188 + - FP8_Q0.7 parameter max value out of bounds = 0.992189 + - FP8_Q0.7 parameter in nominal case = 0.50 +""" +import commands +import unittest +from Util.PfwUnitTestLib import PfwTestCase +from Util import ACTLogging +log=ACTLogging.Logger() + +# Test of type FP8_Q0.7 - range [-1, 0.992188] +class TestCases(PfwTestCase): + def setUp(self): + self.param_name = "/Test/Test/TEST_DIR/FP8_Q0.7" + self.pfw.sendCmd("setTuningMode", "on") + self.type_name = "FP8_Q0.7" + + def tearDown(self): + self.pfw.sendCmd("setTuningMode", "off") + + def test_Nominal_Case(self): + """ + Testing FP8_Q0.7 in nominal case = 0.50 + --------------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - set FP8_Q0.7 parameter in nominal case = 0.50 + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - FP8_Q0.7 parameter set to 0.50 + - Blackboard and filesystem values checked + """ + log.D(self.test_Nominal_Case.__doc__) + value = "0.50" + hex_value = "0x40" + log.I("Setting %s to value %s" % (self.type_name, value)) + #Set parameter value + out, err = self.pfw.sendCmd("setParameter", self.param_name, value) + assert err == None, log.E("when setting parameter %s : %s" + % (self.param_name, err)) + assert out == "Done", log.F("when setting parameter %s : %s" + % (self.param_name, out)) + #Check parameter value on blackboard + out, err = self.pfw.sendCmd("getParameter", self.param_name, "") + assert err == None, log.E("when setting parameter %s : %s" + % (self.param_name, err)) + assert round(float(out), 2) == float(value), log.F("BLACKBOARD - Incorrect value for %s, expected: %s, found: %s" + % (self.param_name, value, out)) + #Check parameter value on filesystem + assert commands.getoutput('cat $PFW_FILESYSTEM/FP8_Q0.7') == hex_value, log.F("FILESYSTEM - parameter update error") + log.I("test OK") + + def test_TypeMin(self): + """ + Testing FP8_Q0.7 minimal value = -1 + ----------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - set FP8_Q0.7 parameter min value = -1 + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - FP8_Q0.7 parameter set to -1 + - Blackboard and filesystem values checked + """ + log.D(self.test_TypeMin.__doc__) + value = "-1" + hex_value = "0x80" + log.I("Setting %s to value %s" % (self.type_name, value)) + #Set parameter value + out, err = self.pfw.sendCmd("setParameter", self.param_name, value) + assert err == None, log.E("when setting parameter %s : %s" + % (self.param_name, err)) + assert out == "Done", log.F("when setting parameter %s : %s" + % (self.param_name, out)) + #Check parameter value on blackboard + out, err = self.pfw.sendCmd("getParameter", self.param_name, "") + assert err == None, log.E("when setting parameter %s : %s" + % (self.param_name, err)) + assert round(float(out), 6) == float(value), log.F("BLACKBOARD - Incorrect value for %s, expected: %s, found: %s" + % (self.param_name, value, out)) + #Check parameter value on filesystem + assert commands.getoutput('cat $PFW_FILESYSTEM/FP8_Q0.7') == hex_value, log.F("FILESYSTEM - parameter update error") + log.I("test OK") + + def test_TypeMin_Overflow(self): + """ + Testing FP8_Q0.7 parameter value out of negative range + ------------------------------------------------------ + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - set FP8_Q0.7 to -1.00001 + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - error detected + - FP8_Q0.7 parameter not updated + - Blackboard and filesystem values checked + """ + log.D(self.test_TypeMin_Overflow.__doc__) + value = "-1.000001" + param_check = commands.getoutput('cat $PFW_FILESYSTEM/FP8_Q0.7') + log.I("Setting %s to value %s" % (self.type_name, value)) + #Set parameter value + out, err = self.pfw.sendCmd("setParameter", self.param_name, value) + assert err == None, log.E("when setting parameter %s : %s" + % (self.param_name, err)) + assert out != "Done", log.F("Error not detected when setting parameter %s out of bounds" + % (self.param_name)) + #Check parameter value on filesystem + assert commands.getoutput('cat $PFW_FILESYSTEM/FP8_Q0.7') == param_check, log.F("FILESYSTEM - Forbiden parameter change") + log.I("test OK") + + @unittest.expectedFailure + def test_TypeMax(self): + """ + Testing FP8_Q0.7 parameter maximum value + ---------------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - set FP8_Q0.7 to 0.992188 + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - FP8_Q0.7 parameter set to 0.992188 + - Blackboard and filesystem values checked + """ + log.D(self.test_TypeMax.__doc__) + value = "0.992188" + hex_value = "0x7f" + log.I("Setting %s to value %s" % (self.type_name, value)) + #Set parameter value + out, err = self.pfw.sendCmd("setParameter", self.param_name, value) + assert err == None, log.E("when setting parameter %s : %s" + % (self.param_name, err)) + assert out == "Done", log.F("when setting parameter %s : %s" + % (self.param_name, out)) + #Check parameter value on blackboard + out, err = self.pfw.sendCmd("getParameter", self.param_name, "") + assert err == None, log.E("when setting parameter %s : %s" + % (self.param_name, err)) + assert round(float(out), 6) == float(value), "ERROR : BLACKBOARD - Incorrect value for %s, expected: %s, found: %s" % (self.param_name, value, out) + #Check parameter value on filesystem + assert commands.getoutput('cat $PFW_FILESYSTEM/FP8_Q0.7') == hex_value, "ERROR : FILESYSTEM - parameter update error" + log.I("test OK") + + def test_TypeMax_Overflow(self): + """ + Testing FP8_Q0.7 parameter value out of positive range + ------------------------------------------------------ + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - set FP8_Q0.7 to 0.992189 + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - error detected + - FP8_Q0.7 parameter not updated + - Blackboard and filesystem values checked + """ + log.D(self.test_TypeMax_Overflow.__doc__) + value = "0.992189" + param_check = commands.getoutput('cat $PFW_FILESYSTEM/FP8_Q0.7') + log.I("Setting %s to value %s" % (self.type_name, value)) + #Set parameter value + out, err = self.pfw.sendCmd("setParameter", self.param_name, value) + assert err == None, log.E("when setting parameter %s : %s" + % (self.param_name, err)) + assert out != "Done", log.F("Error not detected when setting parameter %s out of bounds" + % (self.param_name)) + #Check parameter value on filesystem + assert commands.getoutput('cat $PFW_FILESYSTEM/FP8_Q0.7') == param_check, log.F("FILESYSTEM - Forbiden parameter change") + log.I("test OK") diff --git a/test/functional-tests/PfwTestCase/Types/tFP8_Q3_4.py b/test/functional-tests/PfwTestCase/Types/tFP8_Q3_4.py new file mode 100755 index 0000000..e1fc30f --- /dev/null +++ b/test/functional-tests/PfwTestCase/Types/tFP8_Q3_4.py @@ -0,0 +1,247 @@ +# -*-coding:utf-8 -* + +# Copyright (c) 2011-2015, Intel Corporation +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, +# are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation and/or +# other materials provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its contributors +# may be used to endorse or promote products derived from this software without +# specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +""" +Fixed-Point parameter type testcases - FP8_Q0.7 + +List of tested functions : +-------------------------- + - [setParameter] function + - [getParameter] function + +Initial Settings : +------------------ + FP8_Q0.7 : + - size = 8 bits + - 3 integer bits, 4 fractionnal bits + - range : [-8, 7.9375] + +Test cases : +------------ + - FP8_Q0.7 parameter min value = -8 + - FP8_Q0.7 parameter min value out of bounds = -8.0001 + - FP8_Q0.7 parameter max value = 7.9375 + - FP8_Q0.7 parameter max value out of bounds = 7.9376 + - FP8_Q0.7 parameter in nominal case = 4.3 +""" +import commands +from Util.PfwUnitTestLib import PfwTestCase +from Util import ACTLogging +log=ACTLogging.Logger() + +# Test of type FP8_Q3.4 - range [-8, 7.9375] +class TestCases(PfwTestCase): + def setUp(self): + self.param_name = "/Test/Test/TEST_DIR/FP8_Q3.4" + self.pfw.sendCmd("setTuningMode", "on") + self.type_name = "FP8_Q3.4" + + def tearDown(self): + self.pfw.sendCmd("setTuningMode", "off") + + def test_Nominal_Case(self): + """ + Testing FP8_Q3.4 in nominal case = 4.3 + -------------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - set FP8_Q3.4 parameter in nominal case = 4.3 + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - FP8_Q3.4 parameter set to 4.3 + - Blackboard and filesystem values checked + """ + log.D(self.test_Nominal_Case.__doc__) + value = "4.3" + hex_value = "0x45" + log.I("Setting %s to value %s" % (self.type_name, value)) + #Set parameter value + out, err = self.pfw.sendCmd("setParameter", self.param_name, value) + assert err == None, log.E("when setting parameter %s : %s" + % (self.param_name, err)) + assert out == "Done", log.F("when setting parameter %s : %s" + % (self.param_name, out)) + #Check parameter value on blackboard + out, err = self.pfw.sendCmd("getParameter", self.param_name, "") + assert err == None, log.E("when setting parameter %s : %s" + % (self.param_name, err)) + assert round(float(out), 1) == float(value), log.F("BLACKBOARD : Incorrect value for %s, expected: %s, found: %s" + % (self.param_name, value, out)) + #Check parameter value on filesystem + assert commands.getoutput('cat $PFW_FILESYSTEM/FP8_Q3.4') == hex_value, log.F("FILESYSTEM : parameter update error") + log.I("test OK") + + def test_TypeMin(self): + """ + Testing FP8_Q3.4 minimal value = -8 + ----------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - set FP8_Q3.4 parameter min value = -8 + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - FP8_Q3.4 parameter set to -8 + - Blackboard and filesystem values checked + """ + log.D(self.test_TypeMin.__doc__) + value = "-8" + hex_value = "0x80" + log.I("Setting %s to value %s" % (self.type_name, value)) + #Set parameter value + out, err = self.pfw.sendCmd("setParameter", self.param_name, value) + assert err == None, log.E("when setting parameter %s : %s" + % (self.param_name, err)) + assert out == "Done", log.F("when setting parameter %s : %s" + % (self.param_name, out)) + #Check parameter value on blackboard + out, err = self.pfw.sendCmd("getParameter", self.param_name, "") + assert err == None, log.E("when setting parameter %s : %s" + % (self.param_name, err)) + assert round(float(out), 4) == float(value), log.F("BLACKBOARD : Incorrect value for %s, expected: %s, found: %s" + % (self.param_name, value, out)) + #Check parameter value on filesystem + assert commands.getoutput('cat $PFW_FILESYSTEM/FP8_Q3.4') == hex_value, "FILESYSTEM : parameter update error" + log.I("test OK") + + def test_TypeMin_Overflow(self): + """ + Testing FP8_Q3.4 parameter value out of negative range + ------------------------------------------------------ + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - set FP8_Q3.4 to -8.0001 + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - error detected + - FP8_Q3.4 parameter not updated + - Blackboard and filesystem values checked + """ + log.D(self.test_TypeMin_Overflow.__doc__) + value = "-8.0001" + log.I("Setting %s to value %s" % (self.type_name, value)) + param_check = commands.getoutput('cat $PFW_FILESYSTEM/FP8_Q3.4') + #Set parameter value + out, err = self.pfw.sendCmd("setParameter", self.param_name, value) + assert err == None, log.E("when setting parameter %s : %s" + % (self.param_name, err)) + assert out != "Done", log.F("PFW : Error not detected when setting parameter %s out of bounds" + % (self.param_name)) + #Check parameter value on filesystem + assert commands.getoutput('cat $PFW_FILESYSTEM/FP8_Q3.4') == param_check, log.F("FILESYSTEM : Forbiden parameter change") + log.I("test OK") + + def test_TypeMax(self): + """ + Testing FP8_Q3.4 parameter maximum value + ---------------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - set FP8_Q3.4 to 7.9375 + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - FP8_Q3.4 parameter set to 7.9375 + - Blackboard and filesystem values checked + """ + log.D(self.test_TypeMax.__doc__) + value = "7.9375" + hex_value = "0x7f" + log.I("Setting %s to value %s" % (self.type_name, value)) + #Set parameter value + out, err = self.pfw.sendCmd("setParameter", self.param_name, value) + assert err == None, log.E("when setting parameter %s : %s" + % (self.param_name, err)) + assert out == "Done", log.F("when setting parameter %s : %s" + % (self.param_name, out)) + #Check parameter value on blackboard + out, err = self.pfw.sendCmd("getParameter", self.param_name, "") + assert err == None, log.E("when setting parameter %s : %s" + % (self.param_name, err)) + assert round(float(out), 4) == float(value), log.F("BLACKBOARD : Incorrect value for %s, expected: %s, found: %s" + % (self.param_name, value, out)) + #Check parameter value on filesystem + assert commands.getoutput('cat $PFW_FILESYSTEM/FP8_Q3.4') == hex_value, log.F("FILESYSTEM : parameter update error") + log.I("test OK") + + def test_TypeMax_Overflow(self): + """ + Testing FP8_Q3.4 parameter value out of positive range + ------------------------------------------------------ + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - set FP8_Q3.4 to 7.9376 + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - error detected + - FP8_Q3.4 parameter not updated + - Blackboard and filesystem values checked + """ + log.D(self.test_TypeMax_Overflow.__doc__) + value = "7.9376" + param_check = commands.getoutput('cat $PFW_FILESYSTEM/FP8_Q3.4') + log.I("Setting %s to value %s" % (self.type_name, value)) + #Set parameter value + out, err = self.pfw.sendCmd("setParameter", self.param_name, value) + assert err == None, log.E("when setting parameter %s : %s" + % (self.param_name, err)) + assert out != "Done", log.F("PFW : Error not detected when setting parameter %s out of bounds" + % (self.param_name)) + #Check parameter value on filesystem + assert commands.getoutput('cat $PFW_FILESYSTEM/FP8_Q3.4') == param_check, log.F("FILESYSTEM : Forbiden parameter change") + log.I("test OK") diff --git a/test/functional-tests/PfwTestCase/Types/tFP8_Q7_0.py b/test/functional-tests/PfwTestCase/Types/tFP8_Q7_0.py new file mode 100755 index 0000000..ea83d5f --- /dev/null +++ b/test/functional-tests/PfwTestCase/Types/tFP8_Q7_0.py @@ -0,0 +1,247 @@ +# -*-coding:utf-8 -* + +# Copyright (c) 2011-2015, Intel Corporation +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, +# are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation and/or +# other materials provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its contributors +# may be used to endorse or promote products derived from this software without +# specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +""" +Fixed-Point parameter type testcases - FP8_Q7.0 + +List of tested functions : +-------------------------- + - [setParameter] function + - [getParameter] function + +Initial Settings : +------------------ + FP8_Q7.0 : + - size = 8 bits + - 7 integer bits, 0 fractionnal bits + - range : [-128, 127] + +Test cases : +------------ + - FP8_Q7.0 parameter min value = -128 + - FP8_Q7.0 parameter min value out of bounds = -128.1 + - FP8_Q7.0 parameter max value = 127 + - FP8_Q7.0 parameter max value out of bounds = 127.1 + - FP8_Q7.0 parameter in nominal case = 64 +""" +import commands +from Util.PfwUnitTestLib import PfwTestCase +from Util import ACTLogging +log=ACTLogging.Logger() + +# Test of type FP8_Q7.0 - range [-128,127] +class TestCases(PfwTestCase): + def setUp(self): + self.param_name = "/Test/Test/TEST_DIR/FP8_Q7.0" + self.pfw.sendCmd("setTuningMode", "on") + self.type_name = "FP8_Q7.0" + + def tearDown(self): + self.pfw.sendCmd("setTuningMode", "off") + + def test_Nominal_Case(self): + """ + Testing FP8_Q7.0 in nominal case = 64 + ------------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - set FP8_Q7.0 parameter in nominal case = 64 + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - FP8_Q7.0 parameter set to 64 + - Blackboard and filesystem values checked + """ + log.D(self.test_Nominal_Case.__doc__) + value = "64" + hex_value = "0x40" + log.I("Setting %s to value %s" % (self.type_name, value)) + #Set parameter value + out, err = self.pfw.sendCmd("setParameter", self.param_name, value) + assert err == None, log.E("when setting parameter %s : %s" + % (self.param_name, err)) + assert out == "Done", log.F("when setting parameter %s : %s" + % (self.param_name, out)) + #Check parameter value on blackboard + out, err = self.pfw.sendCmd("getParameter", self.param_name, "") + assert err == None, log.E("when setting parameter %s : %s" + % (self.param_name, err)) + assert float(out) == float(value), log.F("BLACKBOARD : Incorrect value for %s, expected: %s, found: %s" + % (self.param_name, value, out)) + #Check parameter value on filesystem + assert commands.getoutput('cat $PFW_FILESYSTEM/FP8_Q7.0') == hex_value, log.F("FILESYSTEM : parameter update error") + log.I("test OK") + + def test_TypeMin(self): + """ + Testing FP8_Q7.0 minimal value = -128 + ------------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - set FP8_Q7.0 parameter min value = -128 + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - FP8_Q7.0 parameter set to -128 + - Blackboard and filesystem values checked + """ + log.D(self.test_TypeMin.__doc__) + value = "-128" + hex_value = "0x80" + log.I("Setting %s to value %s" % (self.type_name, value)) + #Set parameter value + out, err = self.pfw.sendCmd("setParameter", self.param_name, value) + assert err == None, log.E("when setting parameter %s : %s" + % (self.param_name, err)) + assert out == "Done", log.F("when setting parameter %s : %s" + % (self.param_name, out)) + #Check parameter value on blackboard + out, err = self.pfw.sendCmd("getParameter", self.param_name, "") + assert err == None, log.E("when setting parameter %s : %s" + % (self.param_name, err)) + assert float(out) == float(value), log.F("BLACKBOARD : Incorrect value for %s, expected: %s, found: %s" + % (self.param_name, value, out)) + #Check parameter value on filesystem + assert commands.getoutput('cat $PFW_FILESYSTEM/FP8_Q7.0') == hex_value, log.F("FILESYSTEM : parameter update error") + log.I("test OK") + + def test_TypeMin_Overflow(self): + """ + Testing FP8_Q7.0 parameter value out of negative range + ------------------------------------------------------ + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - set FP8_Q7.0 to -128.1 + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - error detected + - FP8_Q7.0 parameter not updated + - Blackboard and filesystem values checked + """ + log.D(self.test_TypeMin_Overflow.__doc__) + value = "-128.1" + param_check = commands.getoutput('cat $PFW_FILESYSTEM/FP8_Q7.0') + log.I("Setting %s to value %s" % (self.type_name, value)) + #Set parameter value + out, err = self.pfw.sendCmd("setParameter", self.param_name, value) + assert err == None, log.E("when setting parameter %s : %s" + % (self.param_name, err)) + assert out != "Done", log.F("PFW : Error not detected when setting parameter %s out of bounds" + % (self.param_name)) + #Check parameter value on filesystem + assert commands.getoutput('cat $PFW_FILESYSTEM/FP8_Q7.0') == param_check, log.F("FILESYSTEM : Forbiden parameter change") + log.I("test OK") + + def test_TypeMax(self): + """ + Testing FP8_Q7.0 parameter maximum value + ---------------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - set FP8_Q7.0 to 127 + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - FP8_Q7.0 parameter set to 127 + - Blackboard and filesystem values checked + """ + log.D(self.test_TypeMax.__doc__) + value = "127" + hex_value = "0x7f" + log.I("Setting %s to value %s" % (self.type_name, value)) + #Set parameter value + out, err = self.pfw.sendCmd("setParameter", self.param_name, value) + assert err == None, log.E("when setting parameter %s : %s" + % (self.param_name, err)) + assert out == "Done", log.F("when setting parameter %s : %s" + % (self.param_name, out)) + #Check parameter value on blackboard + out, err = self.pfw.sendCmd("getParameter", self.param_name, "") + assert err == None, log.E("when setting parameter %s : %s" + % (self.param_name, err)) + assert float(out) == float(value), log.F("BLACKBOARD : Incorrect value for %s, expected: %s, found: %s" + % (self.param_name, value, out)) + #Check parameter value on filesystem + assert commands.getoutput('cat $PFW_FILESYSTEM/FP8_Q7.0') == hex_value, log.F("FILESYSTEM : parameter update error") + log.I("test OK") + + def test_TypeMax_Overflow(self): + """ + Testing FP8_Q7.0 parameter value out of positive range + ------------------------------------------------------ + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - set FP8_Q7.0 to 127.1 + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - error detected + - FP8_Q7.0 parameter not updated + - Blackboard and filesystem values checked + """ + log.D(self.test_TypeMax_Overflow.__doc__) + value = "127.1" + param_check = commands.getoutput('cat $PFW_FILESYSTEM/FP8_Q7.0') + log.I("Setting %s to value %s" % (self.type_name, value)) + #Set parameter value + out, err = self.pfw.sendCmd("setParameter", self.param_name, value) + assert err == None, log.E("when setting parameter %s : %s" + % (self.param_name, err)) + assert out != "Done", log.F("PFW : Error not detected when setting parameter %s out of bounds" + % (self.param_name)) + #Check parameter value on filesystem + assert commands.getoutput('cat $PFW_FILESYSTEM/FP8_Q7.0') == param_check, log.F("FILESYSTEM : Forbiden parameter change") + log.I("test OK") diff --git a/test/functional-tests/PfwTestCase/Types/tINT16.py b/test/functional-tests/PfwTestCase/Types/tINT16.py new file mode 100644 index 0000000..f3ce617 --- /dev/null +++ b/test/functional-tests/PfwTestCase/Types/tINT16.py @@ -0,0 +1,245 @@ +# -*-coding:utf-8 -* + +# Copyright (c) 2011-2015, Intel Corporation +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, +# are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation and/or +# other materials provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its contributors +# may be used to endorse or promote products derived from this software without +# specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +""" +Integer parameter type testcases - INT16 + +List of tested functions : +-------------------------- + - [setParameter] function + - [getParameter] function + +Initial Settings : +------------------ + INT16 : + - size = 16 + - range : [-1000, 1000] + +Test cases : +------------ + - INT16 parameter min value = -1000 + - INT16 parameter min value out of bounds = -1001 + - INT16 parameter max value = 1000 + - INT16 parameter max value out of bounds = 1001 + - INT16 parameter in nominal case = 50 +""" +import commands +from Util.PfwUnitTestLib import PfwTestCase +from Util import ACTLogging +log=ACTLogging.Logger() + +# Test of type INT16 - range [-1000, 1000] +class TestCases(PfwTestCase): + def setUp(self): + self.param_name = "/Test/Test/TEST_DIR/INT16" + self.pfw.sendCmd("setTuningMode", "on") + + def tearDown(self): + self.pfw.sendCmd("setTuningMode", "off") + + def test_Nominal_Case(self): + """ + Testing INT16 in nominal case = 50 + ---------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - set INT16 parameter in nominal case = 50 + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - INT16 parameter set to 50 + - Blackboard and filesystem values checked + """ + log.D(self.test_Nominal_Case.__doc__) + log.I("INT16 parameter in nominal case = 50") + value = "50" + hex_value = "0x32" + #Set parameter value + out, err = self.pfw.sendCmd("setParameter", self.param_name, value) + assert err == None, log.E("when setting parameter %s : %s" + % (self.param_name, err)) + assert out == "Done", log.F("when setting parameter %s : %s" + % (self.param_name, out)) + #Check parameter value on blackboard + out, err = self.pfw.sendCmd("getParameter", self.param_name, "") + assert err == None, log.E("when setting parameter %s : %s" + % (self.param_name, err)) + assert out == value, log.F("BLACKBOARD : Incorrect value for %s, expected: %s, found: %s" + % (self.param_name, value, out)) + #Check parameter value on filesystem + assert commands.getoutput('cat $PFW_FILESYSTEM/INT16') == hex_value, log.F("FILESYSTEM : parameter update error") + log.I("test OK") + + def test_TypeMin(self): + """ + Testing INT16 minimal value = -1000 + ----------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - set INT16 parameter min value = -1000 + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - INT16 parameter set to -1000 + - Blackboard and filesystem values checked + """ + log.D(self.test_TypeMin.__doc__) + log.I("INT16 parameter min value = -1000") + value = "-1000" + hex_value = "0xfc18" + #Set parameter value + out, err = self.pfw.sendCmd("setParameter", self.param_name, value) + assert err == None, log.E("when setting parameter %s : %s" + % (self.param_name, err)) + assert out == "Done", log.F("when setting parameter %s : %s" + % (self.param_name, out)) + #Check parameter value on blackboard + out, err = self.pfw.sendCmd("getParameter", self.param_name, "") + assert err == None, log.E("when setting parameter %s : %s" + % (self.param_name, err)) + assert out == value, log.F("BLACKBOARD : Incorrect value for %s, expected: %s, found: %s" + % (self.param_name, value, out)) + #Check parameter value on filesystem + assert commands.getoutput('cat $PFW_FILESYSTEM/INT16') == hex_value, log.F("FILESYSTEM : parameter update error") + log.I("test OK") + + def test_TypeMin_Overflow(self): + """ + Testing INT16 parameter value out of negative range + --------------------------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - set INT16 to -1001 + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - error detected + - INT16 parameter not updated + - Blackboard and filesystem values checked + """ + log.D(self.test_TypeMin_Overflow.__doc__) + log.I("INT16 parameter min value out of bounds = -1001") + value = "-1001" + param_check = commands.getoutput('cat $PFW_FILESYSTEM/INT16') + #Set parameter value + out, err = self.pfw.sendCmd("setParameter", self.param_name, value) + assert err == None, log.E("when setting parameter %s : %s" + % (self.param_name, err)) + assert out != "Done", log.F("PFW : Error not detected when setting parameter %s out of bounds" + % (self.param_name)) + #Check parameter value on filesystem + assert commands.getoutput('cat $PFW_FILESYSTEM/INT16') == param_check, log.F("FILESYSTEM : Forbiden parameter change") + log.I("test OK") + + def test_TypeMax(self): + """ + Testing INT16 parameter maximum value + ------------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - set INT16 to 1000 + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - INT16 parameter set to 1000 + - Blackboard and filesystem values checked + """ + log.D(self.test_TypeMax.__doc__) + log.I("INT16 parameter max value = 1000") + value = "1000" + hex_value = "0x3e8" + #Set parameter value + out, err = self.pfw.sendCmd("setParameter", self.param_name, value) + assert err == None, log.E("when setting parameter %s : %s" + % (self.param_name, err)) + assert out == "Done", log.F("when setting parameter %s : %s" + % (self.param_name, out)) + #Check parameter value on blackboard + out, err = self.pfw.sendCmd("getParameter", self.param_name, "") + assert err == None, log.E("when setting parameter %s : %s" + % (self.param_name, err)) + assert out == value, log.F("BLACKBOARD : Incorrect value for %s, expected: %s, found: %s" + % (self.param_name, value, out)) + #Check parameter value on filesystem + assert commands.getoutput('cat $PFW_FILESYSTEM/INT16') == hex_value, log.F("FILESYSTEM : parameter update error") + log.I("test OK") + + def test_TypeMax_Overflow(self): + """ + Testing INT16 parameter value out of positive range + --------------------------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - set INT16 to 1001 + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - error detected + - INT16 parameter not updated + - Blackboard and filesystem values checked + """ + log.D(self.test_TypeMax_Overflow.__doc__) + log.I("INT16 parameter max value out of bounds = 1001") + value = "1001" + param_check = commands.getoutput('cat $PFW_FILESYSTEM/INT16') + #Set parameter value + out, err = self.pfw.sendCmd("setParameter", self.param_name, value) + assert err == None, log.E("when setting parameter %s : %s" + % (self.param_name, err)) + assert out != "Done", log.F("PFW : Error not detected when setting parameter %s out of bounds" + % (self.param_name)) + #Check parameter value on filesystem + assert commands.getoutput('cat $PFW_FILESYSTEM/INT16') == param_check, log.F("FILESYSTEM : Forbiden parameter change") + log.I("test OK") diff --git a/test/functional-tests/PfwTestCase/Types/tINT16_ARRAY.py b/test/functional-tests/PfwTestCase/Types/tINT16_ARRAY.py new file mode 100644 index 0000000..81fdf35 --- /dev/null +++ b/test/functional-tests/PfwTestCase/Types/tINT16_ARRAY.py @@ -0,0 +1,323 @@ +# -*-coding:utf-8 -* + +# Copyright (c) 2011-2015, Intel Corporation +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, +# are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation and/or +# other materials provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its contributors +# may be used to endorse or promote products derived from this software without +# specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +""" +Array parameter type testcases : INT16 Array + +List of tested functions : +-------------------------- + - [setParameter] function + - [getParameter] function + +Initial Settings : +------------------ + UINT16 Array = 16bits signed int array : + - Array size : 5 + - values range : [-50, 50] + +Test cases : +------------ + - Testing nominal case + - Testing minimum + - Testing minimum overflow + - Testing maximum + - Testing maximum overflow + - Testing array index out of bounds +""" +import commands +from Util.PfwUnitTestLib import PfwTestCase +from Util import ACTLogging +log=ACTLogging.Logger() + + +from ctypes import c_uint16 + + +class TestCases(PfwTestCase): + + def setUp(self): + self.param_name = "/Test/Test/TEST_DIR/INT16_ARRAY" + self.param_short_name = "$PFW_FILESYSTEM/INT16_ARRAY" + print '\r' + self.pfw.sendCmd("setTuningMode", "on") + print '\r' + self.array_size = 5 + self.array_min = -50 + self.array_max = 50 + + def tearDown(self): + self.pfw.sendCmd("setTuningMode", "off") + + def test_Nominal_Case(self): + """ + Testing INT16_ARRAY Nominal Case + -------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - Set every INT16_ARRAY elements to autorized values + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - INT16_ARRAY array elements correctly recorded + - Blackboard and filesystem values checked + """ + log.D(self.test_Nominal_Case.__doc__) + + for index in range (self.array_size): + indexed_array_value = index + self.array_min + if indexed_array_value>self.array_max: + indexed_array_value=self.array_max + hex_indexed_array_value = hex(c_uint16(indexed_array_value).value) + #Check parameter value setting + indexed_array_value_path = "".join([self.param_name, "/", str(index)]) + out, err = self.pfw.sendCmd("setParameter", str(indexed_array_value_path), str(indexed_array_value)) + assert err == None, log.E("when setting parameter %s[%s]: %s" + % (self.param_name, str(index), err)) + assert out == "Done", log.F("when setting parameter %s[%s]: %s" + % (self.param_name, str(index), out)) + #Check parameter value on blackboard + out, err = self.pfw.sendCmd("getParameter", str(indexed_array_value_path), "") + assert err == None, log.E("when setting parameter %s[%s] : %s" + % (self.param_name, str(index), err)) + assert out == str(indexed_array_value), log.F("BLACKBOARD : Incorrect value for %s[%s], expected: %s, found: %s" + % (self.param_name, str(index), str(indexed_array_value), out)) + #Check parameter value on filesystem + files_system_check = "awk -v ligne="+str(index)+" 'NR == ligne+1 { print $0}' "+self.param_short_name + indexed_files_system_array_value = commands.getoutput(files_system_check) + assert indexed_files_system_array_value == hex_indexed_array_value, log.F("FILESSYSTEM : %s[%s] update error" + % (self.param_name, str(index))) + + def test_Min_Value(self): + """ + Testing INT16_ARRAY minimum value + --------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - Set every INT16_ARRAY elements to minimum values : 0 + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - INT16_ARRAY array elements correctly recorded + - Blackboard and filesystem values checked + """ + log.D(self.test_Min_Value.__doc__) + index = 0 + indexed_array_value = self.array_min + indexed_array_value_path = "".join([self.param_name, "/", str(index)]) + hex_indexed_array_value = hex(c_uint16(indexed_array_value).value) + #Check parameter value setting + out, err = self.pfw.sendCmd("setParameter", str(indexed_array_value_path), str(indexed_array_value)) + assert err == None, log.E("when setting parameter %s[%s]: %s" + % (self.param_name, str(index), err)) + assert out == "Done", log.E("when setting parameter %s[%s]: %s" + % (self.param_name, str(index), out)) + #Check parameter value on blackboard + out, err = self.pfw.sendCmd("getParameter", str(indexed_array_value_path), "") + assert err == None, log.E("when setting parameter %s[%s] : %s" + % (self.param_name, str(index), err)) + assert out == str(indexed_array_value), log.F("BLACKBOARD : Incorrect value for %s[%s], expected: %s, found: %s" + % (self.param_name, str(index), str(indexed_array_value), out)) + #Check parameter value on filesystem + files_system_check = "awk -v ligne="+str(index)+" 'NR == ligne+1 { print $0}' "+self.param_short_name + indexed_files_system_array_value = commands.getoutput(files_system_check) + assert indexed_files_system_array_value == hex_indexed_array_value, log.F("FILESSYSTEM : %s[%s] update error" + % (self.param_name, str(index))) + + def test_Min_Value_Overflow(self): + """ + Testing INT16_ARRAY parameter values out of negative range + ---------------------------------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - Set every INT16_ARRAY elements to -1 + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - INT16_ARRAY array elements not recorded + - Error correctly detected + """ + log.D(self.test_Min_Value_Overflow.__doc__) + index = 0 + indexed_array_value = self.array_min + indexed_array_value_path = "".join([self.param_name, "/", str(index)]) + #Check initial parameter value setting + out, err = self.pfw.sendCmd("setParameter", str(indexed_array_value_path), str(indexed_array_value)) + assert err == None, log.E("when setting parameter %s[%s]: %s" + % (self.param_name, str(index), err)) + assert out == "Done", log.F("when setting parameter %s[%s]: %s" + % (self.param_name, str(index), out)) + files_system_check = "awk -v ligne="+str(index)+" 'NR == ligne+1 { print $0}' "+self.param_short_name + param_check = commands.getoutput(files_system_check) + #Check final parameter value setting + indexed_array_value = indexed_array_value - 1 + out, err = self.pfw.sendCmd("setParameter", str(indexed_array_value_path), str(indexed_array_value)) + assert err == None, log.E("when setting parameter %s[%s]: %s" + % (self.param_name, str(index), err)) + assert out != "Done", log.F("Error not detected when setting parameter %s[%s] out of bounds" + % (self.param_name, str(index))) + #Check parameter value on filesystem + indexed_files_system_array_value = commands.getoutput(files_system_check) + assert indexed_files_system_array_value == param_check, log.F("FILESSYSTEM : %s[%s] forbiden update" + % (self.param_name, str(index))) + + def test_Max_Value(self): + """ + Testing INT16_ARRAY maximum value + --------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - Set every INT16_ARRAY elements to maximum values : 15 + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - INT16_ARRAY array elements correctly recorded + - Blackboard and filesystem values checked + """ + log.D(self.test_Max_Value.__doc__) + index = 0 + indexed_array_value = self.array_max + indexed_array_value_path = "".join([self.param_name, "/", str(index)]) + hex_indexed_array_value = hex(c_uint16(indexed_array_value).value) + #Check parameter value setting + out, err = self.pfw.sendCmd("setParameter", str(indexed_array_value_path), str(indexed_array_value)) + assert err == None, log.E("when setting parameter %s[%s]: %s" + % (self.param_name, str(index), err)) + assert out == "Done", log.F("when setting parameter %s[%s]: %s" + % (self.param_name, str(index), out)) + #Check parameter value on blackboard + out, err = self.pfw.sendCmd("getParameter", str(indexed_array_value_path), "") + assert err == None, log.E("when setting parameter %s[%s] : %s" + % (self.param_name, str(index), err)) + assert out == str(indexed_array_value), log.F("BLACKBOARD : Incorrect value for %s[%s], expected: %s, found: %s" + % (self.param_name, str(index), str(indexed_array_value), out)) + #Check parameter value on filesystem + files_system_check = "awk -v ligne="+str(index)+" 'NR == ligne+1 { print $0}' "+self.param_short_name + indexed_files_system_array_value = commands.getoutput(files_system_check) + assert indexed_files_system_array_value == hex_indexed_array_value, log.F("FILESSYSTEM : %s[%s] update error" + % (self.param_name, str(index))) + + def test_Max_Value_Overflow(self): + """ + Testing INT16_ARRAY parameter values out of positive range + ---------------------------------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - Set every INT16_ARRAY elements to 16 + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - INT16_ARRAY array elements not recorded + - Error correctly detected + """ + log.D(self.test_Max_Value_Overflow.__doc__) + index = 0 + indexed_array_value = self.array_max + indexed_array_value_path = "".join([self.param_name, "/", str(index)]) + #Check initial parameter value setting + out, err = self.pfw.sendCmd("setParameter", str(indexed_array_value_path), str(indexed_array_value)) + assert err == None, log.E("when setting parameter %s[%s]: %s" + % (self.param_name, str(index), err)) + assert out == "Done", log.F("when setting parameter %s[%s]: %s" + % (self.param_name, str(index), out)) + files_system_check = "awk -v ligne="+str(index)+" 'NR == ligne+1 { print $0}' "+self.param_short_name + param_check = commands.getoutput(files_system_check) + #Check final parameter value setting + indexed_array_value = indexed_array_value + 1 + out, err = self.pfw.sendCmd("setParameter", str(indexed_array_value_path), str(indexed_array_value)) + assert err == None, log.E("when setting parameter %s[%s]: %s" + % (self.param_name, str(index), err)) + assert out != "Done", log.F("Error not detected when setting parameter %s[%s] out of bounds" + % (self.param_name, str(index))) + #Check parameter value on filesystem + indexed_files_system_array_value = commands.getoutput(files_system_check) + assert indexed_files_system_array_value == param_check, log.F("FILESSYSTEM : %s[%s] forbiden update" + % (self.param_name, str(index))) + + def test_Array_Index_Overflow(self): + """ + Testing Array index out of bounds + --------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - Set an out of bounds array indexed element + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - INT16_ARRAY array elements not recorded + - Error correctly detected + """ + log.D(self.test_Array_Index_Overflow.__doc__) + index_values = (self.array_size-1, self.array_size+1, -1) + for index in index_values: + print index + indexed_array_value = self.array_max + indexed_array_value_path = "".join([self.param_name, "/", str(index)]) + #Check parameter value setting + out, err = self.pfw.sendCmd("setParameter", str(indexed_array_value_path), str(indexed_array_value)) + if index in [0, self.array_size-1]: + assert err == None, log.E("when setting parameter %s[%s]: %s" + % (self.param_name, str(index), err)) + assert out == "Done", log.F("when setting parameter %s[%s]: %s" + % (self.param_name, str(index), out)) + else: + assert err == None, log.E("when setting parameter %s[%s]: %s" + % (self.param_name, str(index), err)) + assert out != "Done", log.F("Error not detected when setting array %s index out of bounds" + % (self.param_name)) diff --git a/test/functional-tests/PfwTestCase/Types/tINT16_Max.py b/test/functional-tests/PfwTestCase/Types/tINT16_Max.py new file mode 100644 index 0000000..e0854ed --- /dev/null +++ b/test/functional-tests/PfwTestCase/Types/tINT16_Max.py @@ -0,0 +1,245 @@ +# -*-coding:utf-8 -* + +# Copyright (c) 2011-2015, Intel Corporation +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, +# are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation and/or +# other materials provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its contributors +# may be used to endorse or promote products derived from this software without +# specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +""" +Integer parameter type testcases - INT16_Max + +List of tested functions : +-------------------------- + - [setParameter] function + - [getParameter] function + +Initial Settings : +------------------ + INT16_Max : + - size = 16 + - range : [-32768, 32767] + +Test cases : +------------ + - INT16_Max parameter min value = -32768 + - INT16_Max parameter min value out of bounds = -32769 + - INT16_Max parameter max value = 32767 + - INT16_Max parameter max value out of bounds = 32768 + - INT16_Max parameter in nominal case = 50 +""" +import commands +from Util.PfwUnitTestLib import PfwTestCase +from Util import ACTLogging +log=ACTLogging.Logger() + +# Test of type INT16_Max - range [-32768, 32767] +class TestCases(PfwTestCase): + def setUp(self): + self.param_name = "/Test/Test/TEST_DIR/INT16_Max" + self.pfw.sendCmd("setTuningMode", "on") + + def tearDown(self): + self.pfw.sendCmd("setTuningMode", "off") + + def test_Nominal_Case(self): + """ + Testing INT16_Max in nominal case = 50 + -------------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - set INT16_Max parameter in nominal case = 50 + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - INT16_Max parameter set to 50 + - Blackboard and filesystem values checked + """ + log.D(self.test_Nominal_Case.__doc__) + log.I("INT16_Max parameter in nominal case = 50") + value = "50" + hex_value = "0x32" + #Set parameter value + out, err = self.pfw.sendCmd("setParameter", self.param_name, value) + assert err == None, log.E("when setting parameter %s : %s" + % (self.param_name, err)) + assert out == "Done", log.F("when setting parameter %s : %s" + % (self.param_name, out)) + #Check parameter value on blackboard + out, err = self.pfw.sendCmd("getParameter", self.param_name, "") + assert err == None, log.E("when setting parameter %s : %s" + % (self.param_name, err)) + assert out == value, log.F("BLACKBOARD : Incorrect value for %s, expected: %s, found: %s" + % (self.param_name, value, out)) + #Check parameter value on filesystem + assert commands.getoutput('cat $PFW_FILESYSTEM/INT16_Max') == hex_value, log.F("FILESYSTEM : parameter update error") + log.I("test OK") + + def test_TypeMin(self): + """ + Testing INT16_Max minimal value = -32768 + ---------------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - set INT16_Max parameter min value = -32768 + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - INT16_Max parameter set to -32768 + - Blackboard and filesystem values checked + """ + log.D(self.test_TypeMin.__doc__) + log.I("INT16_Max parameter min value = -32768") + value = "-32768" + hex_value = "0x8000" + #Set parameter value + out, err = self.pfw.sendCmd("setParameter", self.param_name, value) + assert err == None, log.E("when setting parameter %s : %s" + % (self.param_name, err)) + assert out == "Done", log.F("when setting parameter %s : %s" + % (self.param_name, out)) + #Check parameter value on blackboard + out, err = self.pfw.sendCmd("getParameter", self.param_name, "") + assert err == None, log.E("when setting parameter %s : %s" + % (self.param_name, err)) + assert out == value, log.F("BLACKBOARD : Incorrect value for %s, expected: %s, found: %s" + % (self.param_name, value, out)) + #Check parameter value on filesystem + assert commands.getoutput('cat $PFW_FILESYSTEM/INT16_Max') == hex_value, log.F("FILESYSTEM : parameter update error") + log.I("test OK") + + def test_TypeMin_Overflow(self): + """ + Testing INT16_Max parameter value out of negative range + ------------------------------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - set INT16_Max to -32769 + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - error detected + - INT16_Max parameter not updated + - Blackboard and filesystem values checked + """ + log.D(self.test_TypeMin_Overflow.__doc__) + log.I("INT16_Max parameter min value out of bounds = -32769") + value = "-32769" + param_check = commands.getoutput('cat $PFW_FILESYSTEM/INT16_Max') + #Set parameter value + out, err = self.pfw.sendCmd("setParameter", self.param_name, value) + assert err == None, log.E("when setting parameter %s : %s" + % (self.param_name, err)) + assert out != "Done", log.F("PFW : Error not detected when setting parameter %s out of bounds" + % (self.param_name)) + #Check parameter value on filesystem + assert commands.getoutput('cat $PFW_FILESYSTEM/INT16_Max') == param_check, log.F("FILESYSTEM : Forbiden parameter change") + log.I("test OK") + + def test_TypeMax(self): + """ + Testing INT16_Max parameter maximum value + ----------------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - set INT16_Max to 32767 + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - INT16_Max parameter set to 32767 + - Blackboard and filesystem values checked + """ + log.D(self.test_TypeMax.__doc__) + log.I("INT16_Max parameter max value = 32767") + value = "32767" + hex_value = "0x7fff" + #Set parameter value + out, err = self.pfw.sendCmd("setParameter", self.param_name, value) + assert err == None, log.E("when setting parameter %s : %s" + % (self.param_name, err)) + assert out == "Done", log.F("when setting parameter %s : %s" + % (self.param_name, out)) + #Check parameter value on blackboard + out, err = self.pfw.sendCmd("getParameter", self.param_name, "") + assert err == None, log.E("when setting parameter %s : %s" + % (self.param_name, err)) + assert out == value, log.F("BLACKBOARD : Incorrect value for %s, expected: %s, found: %s" + % (self.param_name, value, out)) + #Check parameter value on filesystem + assert commands.getoutput('cat $PFW_FILESYSTEM/INT16_Max') == hex_value, log.F("FILESYSTEM : parameter update error") + log.I("test OK") + + def test_TypeMax_Overflow(self): + """ + Testing INT16_Max parameter value out of positive range + ------------------------------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - set INT16_Max to 32768 + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - error detected + - INT16_Max parameter not updated + - Blackboard and filesystem values checked + """ + log.D(self.test_TypeMax_Overflow.__doc__) + log.I("INT16_Max parameter max value out of bounds = 32768") + value = "32768" + param_check = commands.getoutput('cat $PFW_FILESYSTEM/INT16_Max') + #Set parameter value + out, err = self.pfw.sendCmd("setParameter", self.param_name, value) + assert err == None, log.E("when setting parameter %s : %s" + % (self.param_name, err)) + assert out != "Done", log.F("PFW : Error not detected when setting parameter %s out of bounds" + % (self.param_name)) + #Check parameter value on filesystem + assert commands.getoutput('cat $PFW_FILESYSTEM/INT16_Max') == param_check, log.F("FILESYSTEM : Forbiden parameter change") + log.I("test OK") diff --git a/test/functional-tests/PfwTestCase/Types/tINT32.py b/test/functional-tests/PfwTestCase/Types/tINT32.py new file mode 100644 index 0000000..45f837e --- /dev/null +++ b/test/functional-tests/PfwTestCase/Types/tINT32.py @@ -0,0 +1,229 @@ +# -*-coding:utf-8 -* + +# Copyright (c) 2011-2015, Intel Corporation +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, +# are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation and/or +# other materials provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its contributors +# may be used to endorse or promote products derived from this software without +# specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +""" +Integer parameter type testcases - INT32 + +List of tested functions : +-------------------------- + - [setParameter] function + - [getParameter] function + +Initial Settings : +------------------ + INT32 : + - size = 32 + - range : [-1000, 1000] + +Test cases : +------------ + - INT32 parameter min value = -1000 + - INT32 parameter min value out of bounds = -1001 + - INT32 parameter max value = 1000 + - INT32 parameter max value out of bounds = 1001 + - INT32 parameter in nominal case = 50 +""" +import commands +from Util.PfwUnitTestLib import PfwTestCase +from Util import ACTLogging +log=ACTLogging.Logger() + +# Test of type INT32 - range [-1000, 1000] +class TestCases(PfwTestCase): + def setUp(self): + self.param_name = "/Test/Test/TEST_DIR/INT32" + self.pfw.sendCmd("setTuningMode", "on") + + def tearDown(self): + self.pfw.sendCmd("setTuningMode", "off") + + def test_Nominal_Case(self): + """ + Testing INT32 in nominal case = 50 + ---------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - set INT32 parameter in nominal case = 50 + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - INT32 parameter set to 50 + - Blackboard and filesystem values checked + """ + print self.test_Nominal_Case.__doc__ + print "INFO : INT32 parameter in nominal case = 50" + value = "50" + hex_value = "0x32" + #Set parameter value + out, err = self.pfw.sendCmd("setParameter", self.param_name, value) + assert err == None, "Error when setting parameter %s : %s" % (self.param_name, err) + assert out == "Done", out + #Check parameter value on blackboard + out, err = self.pfw.sendCmd("getParameter", self.param_name, "") + assert err == None, "Error when setting parameter %s : %s" % (self.param_name, err) + assert out == value, "BLACKBOARD : Incorrect value for %s, expected: %s, found: %s" % (self.param_name, value, out) + #Check parameter value on filesystem + assert commands.getoutput('cat $PFW_FILESYSTEM/INT32') == hex_value, "FILESYSTEM : parameter update error" + print "INFO : test OK" + + def test_TypeMin(self): + """ + Testing INT32 minimal value = -1000 + ----------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - set INT32 parameter min value = -1000 + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - INT32 parameter set to -1000 + - Blackboard and filesystem values checked + """ + print self.test_TypeMin.__doc__ + print "INFO : INT32 parameter min value = -1000" + value = "-1000" + hex_value = "0xfffffc18" + #Set parameter value + out, err = self.pfw.sendCmd("setParameter", self.param_name, value) + assert err == None, "Error when setting parameter %s : %s" % (self.param_name, err) + assert out == "Done", out + #Check parameter value on blackboard + out, err = self.pfw.sendCmd("getParameter", self.param_name, "") + assert err == None, "PFW : Error when setting parameter %s : %s" % (self.param_name, err) + assert out == value, "BLACKBOARD : Incorrect value for %s, expected: %s, found: %s" % (self.param_name, value, out) + #Check parameter value on filesystem + assert commands.getoutput('cat $PFW_FILESYSTEM/INT32') == hex_value, "FILESYSTEM : parameter update error" + print "INFO : test OK" + + def test_TypeMin_Overflow(self): + """ + Testing INT32 parameter value out of negative range + --------------------------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - set INT32 to -1001 + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - error detected + - INT32 parameter not updated + - Blackboard and filesystem values checked + """ + print self.test_TypeMin_Overflow.__doc__ + print "INFO : INT32 parameter min value out of bounds = -1001" + value = "-1001" + param_check = commands.getoutput('cat $PFW_FILESYSTEM/INT32') + #Set parameter value + out, err = self.pfw.sendCmd("setParameter", self.param_name, value) + assert err == None, "Error when setting parameter %s : %s" % (self.param_name, err) + assert out != "Done", "PFW : Error not detected when setting parameter %s out of bounds" % (self.param_name) + #Check parameter value on filesystem + assert commands.getoutput('cat $PFW_FILESYSTEM/INT32') == param_check, "FILESYSTEM : Forbiden parameter change" + print "INFO : test OK" + + def test_TypeMax(self): + """ + Testing INT32 parameter maximum value + ------------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - set INT32 to 1000 + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - INT32 parameter set to 1000 + - Blackboard and filesystem values checked + """ + print self.test_TypeMax.__doc__ + print "INFO : INT32 parameter max value = 1000" + value = "1000" + hex_value = "0x3e8" + #Set parameter value + out, err = self.pfw.sendCmd("setParameter", self.param_name, value) + assert err == None, "Error when setting parameter %s : %s" % (self.param_name, err) + assert out == "Done", out + #Check parameter value on blackboard + out, err = self.pfw.sendCmd("getParameter", self.param_name, "") + assert err == None, "Error when setting parameter %s : %s" % (self.param_name, err) + assert out == value, "BLACKBOARD : Incorrect value for %s, expected: %s, found: %s" % (self.param_name, value, out) + #Check parameter value on filesystem + assert commands.getoutput('cat $PFW_FILESYSTEM/INT32') == hex_value, "FILESYSTEM : parameter update error" + print "INFO : test OK" + + def test_TypeMax_Overflow(self): + """ + Testing INT32 parameter value out of positive range + --------------------------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - set INT32 to 1001 + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - error detected + - INT32 parameter not updated + - Blackboard and filesystem values checked + """ + print self.test_TypeMax_Overflow.__doc__ + print "INFO : INT32 parameter max value out of bounds = 1001" + value = "1001" + param_check = commands.getoutput('cat $PFW_FILESYSTEM/INT32') + #Set parameter value + out, err = self.pfw.sendCmd("setParameter", self.param_name, value) + assert err == None, "Error when setting parameter %s : %s" % (self.param_name, err) + assert out != "Done", "PFW : Error not detected when setting parameter %s out of bounds" % (self.param_name) + #Check parameter value on filesystem + assert commands.getoutput('cat $PFW_FILESYSTEM/INT32') == param_check, "FILESYSTEM : Forbiden parameter change" + print "INFO : test OK" diff --git a/test/functional-tests/PfwTestCase/Types/tINT32_Max.py b/test/functional-tests/PfwTestCase/Types/tINT32_Max.py new file mode 100644 index 0000000..91444d9 --- /dev/null +++ b/test/functional-tests/PfwTestCase/Types/tINT32_Max.py @@ -0,0 +1,244 @@ +# -*-coding:utf-8 -* + +# Copyright (c) 2011-2015, Intel Corporation +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, +# are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation and/or +# other materials provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its contributors +# may be used to endorse or promote products derived from this software without +# specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +""" +Integer parameter type testcases - INT32_Max + +List of tested functions : +-------------------------- + - [setParameter] function + - [getParameter] function + +Initial Settings : +------------------ + INT32_Max : + - size = 16 + - range : [-2147483648, 2147483647] + +Test cases : +------------ + - INT32_Max parameter min value = -2147483648 + - INT32_Max parameter min value out of bounds = -2147483649 + - INT32_Max parameter max value = 2147483647 + - INT32_Max parameter max value out of bounds = 2147483648 + - INT32_Max parameter in nominal case = 50 +""" +import commands +from Util.PfwUnitTestLib import PfwTestCase +from Util import ACTLogging +log=ACTLogging.Logger() + +# Test of type INT32_Max - range [-2147483648, 2147483647] +class TestCases(PfwTestCase): + def setUp(self): + self.param_name = "/Test/Test/TEST_DIR/INT32_Max" + self.pfw.sendCmd("setTuningMode", "on") + + def tearDown(self): + self.pfw.sendCmd("setTuningMode", "off") + + def test_Nominal_Case(self): + """ + Testing INT32_Max in nominal case = 50 + -------------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - set INT32_Max parameter in nominal case = 50 + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - INT32_Max parameter set to 50 + - Blackboard and filesystem values checked + """ + log.D(self.test_Nominal_Case.__doc__) + log.I("INT32_Max parameter in nominal case = 50") + value = "50" + hex_value = "0x32" + #Set parameter value + out, err = self.pfw.sendCmd("setParameter", self.param_name, value) + assert err == None, log.E("when setting parameter %s : %s" + % (self.param_name, err)) + assert out == "Done", log.F("when setting parameter %s : %s" + % (self.param_name, out)) + #Check parameter value on blackboard + out, err = self.pfw.sendCmd("getParameter", self.param_name, "") + assert err == None, log.E("when setting parameter %s : %s" + % (self.param_name, err)) + assert out == value, log.F("BLACKBOARD : Incorrect value for %s, expected: %s, found: %s" + % (self.param_name, value, out)) + #Check parameter value on filesystem + assert commands.getoutput('cat $PFW_FILESYSTEM/INT32_Max') == hex_value, log.F("FILESYSTEM : parameter update error") + log.I("test OK") + + def test_TypeMin(self): + """ + Testing INT32_Max minimal value = -2147483648 + --------------------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - set INT32_Max parameter min value = -2147483648 + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - INT32_Max parameter set to -2147483648 + - Blackboard and filesystem values checked + """ + log.D(self.test_TypeMin.__doc__) + log.I("INT32_Max parameter min value = -2147483648") + value = "-2147483648" + hex_value = "0x80000000" + #Set parameter value + out, err = self.pfw.sendCmd("setParameter", self.param_name, value) + assert err == None, log.E("when setting parameter %s : %s" + % (self.param_name, err)) + assert out == "Done", log.F("when setting parameter %s : %s" + % (self.param_name, out)) + #Check parameter value on blackboard + out, err = self.pfw.sendCmd("getParameter", self.param_name, "") + assert err == None, log.E("when setting parameter %s : %s" + % (self.param_name, err)) + assert out == value, log.F("BLACKBOARD : Incorrect value for %s, expected: %s, found: %s" + % (self.param_name, value, out)) + #Check parameter value on filesystem + assert commands.getoutput('cat $PFW_FILESYSTEM/INT32_Max') == hex_value, log.F("FILESYSTEM : parameter update error") + log.I("test OK") + + def test_TypeMin_Overflow(self): + """ + Testing INT32_Max parameter value out of negative range + ------------------------------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - set INT32_Max to -2147483649 + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - error detected + - INT32_Max parameter not updated + - Blackboard and filesystem values checked + """ + log.D(self.test_TypeMin_Overflow.__doc__) + log.I("INT32_Max parameter min value out of bounds = -2147483649") + value = "-2147483649" + param_check = commands.getoutput('cat $PFW_FILESYSTEM/INT32_Max') + #Set parameter value + out, err = self.pfw.sendCmd("setParameter", self.param_name, value) + assert err == None, log.E("when setting parameter %s : %s" + % (self.param_name, err)) + assert out != "Done", log.F("PFW : Error not detected when setting parameter %s out of bounds" + % (self.param_name)) + #Check parameter value on filesystem + assert commands.getoutput('cat $PFW_FILESYSTEM/INT32_Max') == param_check, log.F("FILESYSTEM : Forbiden parameter change") + log.I("test OK") + + def test_TypeMax(self): + """ + Testing INT32_Max parameter maximum value + ----------------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - set INT32_Max to 2147483647 + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - INT32_Max parameter set to 1000 + - Blackboard and filesystem values checked + """ + log.D(self.test_TypeMax.__doc__) + log.I("INT32_Max parameter max value = 2147483647") + value = "2147483647" + hex_value = "0x7fffffff" + #Set parameter value + out, err = self.pfw.sendCmd("setParameter", self.param_name, value) + assert err == None, log.E("when setting parameter %s : %s" + % (self.param_name, err)) + assert out == "Done", log.F("when setting parameter %s : %s" + % (self.param_name, out)) + #Check parameter value on blackboard + out, err = self.pfw.sendCmd("getParameter", self.param_name, "") + assert err == None, log.E("when setting parameter %s : %s" + % (self.param_name, err)) + assert out == value, log.F("BLACKBOARD : Incorrect value for %s, expected: %s, found: %s" + % (self.param_name, value, out)) + #Check parameter value on filesystem + assert commands.getoutput('cat $PFW_FILESYSTEM/INT32_Max') == hex_value, log.F("FILESYSTEM : parameter update error") + log.I("test OK") + + def test_TypeMax_Overflow(self): + """ + Testing INT32_Max parameter value out of positive range + ------------------------------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - set INT32_Max to 2147483648 + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - error detected + - INT32_Max parameter not updated + + """ + log.D(self.test_TypeMax_Overflow.__doc__) + log.I("INT32_Max parameter max value out of bounds = 2147483648") + value = "2147483648" + param_check = commands.getoutput('cat $PFW_FILESYSTEM/INT32_Max') + #Set parameter value + out, err = self.pfw.sendCmd("setParameter", self.param_name, value) + assert err == None, log.E("when setting parameter %s : %s" + % (self.param_name, err)) + assert out != "Done", log.F("PFW : Error not detected when setting parameter %s out of bounds" + % (self.param_name)) + #Check parameter value on filesystem + assert commands.getoutput('cat $PFW_FILESYSTEM/INT32_Max') == param_check, log.F("FILESYSTEM : Forbiden parameter change") + log.I("test OK") diff --git a/test/functional-tests/PfwTestCase/Types/tINT8.py b/test/functional-tests/PfwTestCase/Types/tINT8.py new file mode 100644 index 0000000..eeb594f --- /dev/null +++ b/test/functional-tests/PfwTestCase/Types/tINT8.py @@ -0,0 +1,245 @@ +# -*-coding:utf-8 -* + +# Copyright (c) 2011-2015, Intel Corporation +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, +# are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation and/or +# other materials provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its contributors +# may be used to endorse or promote products derived from this software without +# specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +""" +Integer parameter type testcases - INT8 + +List of tested functions : +-------------------------- + - [setParameter] function + - [getParameter] function + +Initial Settings : +------------------ + INT8 : + - size = 8 + - range : [-100, 100] + +Test cases : +------------ + - INT8 parameter min value = -100 + - INT8 parameter min value out of bounds = -101 + - INT8 parameter max value = 100 + - INT8 parameter max value out of bounds = 101 + - INT8 parameter in nominal case = 50 +""" +import commands +from Util.PfwUnitTestLib import PfwTestCase +from Util import ACTLogging +log=ACTLogging.Logger() + +# Test of type INT8 - range [-100, 100] +class TestCases(PfwTestCase): + def setUp(self): + self.param_name = "/Test/Test/TEST_DIR/INT8" + self.pfw.sendCmd("setTuningMode", "on") + + def tearDown(self): + self.pfw.sendCmd("setTuningMode", "off") + + def test_Nominal_Case(self): + """ + Testing INT8 in nominal case = 50 + --------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - set INT8 parameter in nominal case = 50 + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - INT8 parameter set to 50 + - Blackboard and filesystem values checked + """ + log.D(self.test_Nominal_Case.__doc__) + log.I("INT8 parameter in nominal case = 50") + value = "50" + hex_value = "0x32" + #Set parameter value + out, err = self.pfw.sendCmd("setParameter", self.param_name, value) + assert err == None, log.E("when setting parameter %s : %s" + % (self.param_name, err)) + assert out == "Done", log.F("when setting parameter %s : %s" + % (self.param_name, out)) + #Check parameter value on blackboard + out, err = self.pfw.sendCmd("getParameter", self.param_name, "") + assert err == None, log.E("when setting parameter %s : %s" + % (self.param_name, err)) + assert out == value, log.F("BLACKBOARD : Incorrect value for %s, expected: %s, found: %s" + % (self.param_name, value, out)) + #Check parameter value on filesystem + assert commands.getoutput('cat $PFW_FILESYSTEM/INT8') == hex_value, log.F("FILESYSTEM : parameter update error") + log.I("test OK") + + def test_TypeMin(self): + """ + Testing INT8 minimal value = -100 + --------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - set INT8 parameter min value = -100 + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - INT8 parameter set to -100 + - Blackboard and filesystem values checked + """ + log.D(self.test_TypeMin.__doc__) + log.I("INT8 parameter min value = -100") + value = "-100" + hex_value = "0x9c" + #Set parameter value + out, err = self.pfw.sendCmd("setParameter", self.param_name, value) + assert err == None, log.E("when setting parameter %s : %s" + % (self.param_name, err)) + assert out == "Done", log.F("when setting parameter %s : %s" + % (self.param_name, out)) + #Check parameter value on blackboard + out, err = self.pfw.sendCmd("getParameter", self.param_name, "") + assert err == None, log.E("when setting parameter %s : %s" + % (self.param_name, err)) + assert out == value, log.F("BLACKBOARD : Incorrect value for %s, expected: %s, found: %s" + % (self.param_name, value, out)) + #Check parameter value on filesystem + assert commands.getoutput('cat $PFW_FILESYSTEM/INT8') == hex_value, log.F("FILESYSTEM : parameter update error") + log.I("test OK") + + def test_TypeMin_Overflow(self): + """ + Testing INT8 parameter value out of negative range + -------------------------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - set INT8 to -101 + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - error detected + - INT8 parameter not updated + - Blackboard and filesystem values checked + """ + log.D(self.test_TypeMin_Overflow.__doc__) + log.I("INT8 parameter min value out of bounds = -101") + value = "-101" + param_check = commands.getoutput('cat $PFW_FILESYSTEM/INT8') + #Set parameter value + out, err = self.pfw.sendCmd("setParameter", self.param_name, value) + assert err == None, log.E("when setting parameter %s : %s" + % (self.param_name, err)) + assert out != "Done", log.F("PFW : Error not detected when setting parameter %s out of bounds" + % (self.param_name)) + #Check parameter value on filesystem + assert commands.getoutput('cat $PFW_FILESYSTEM/INT8') == param_check, log.F("FILESYSTEM : Forbiden parameter change") + log.I("test OK") + + def test_TypeMax(self): + """ + Testing INT8 parameter maximum value + ------------------------------------ + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - set INT8 to 100 + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - INT8 parameter set to 100 + - Blackboard and filesystem values checked + """ + log.D(self.test_TypeMax.__doc__) + log.I("INT8 parameter max value = 100") + value = "100" + hex_value = "0x64" + #Set parameter value + out, err = self.pfw.sendCmd("setParameter", self.param_name, value) + assert err == None, log.E("when setting parameter %s : %s" + % (self.param_name, err)) + assert out == "Done", log.F("when setting parameter %s : %s" + % (self.param_name, out)) + #Check parameter value on blackboard + out, err = self.pfw.sendCmd("getParameter", self.param_name, "") + assert err == None, log.E("when setting parameter %s : %s" + % (self.param_name, err)) + assert out == value, log.F("BLACKBOARD : Incorrect value for %s, expected: %s, found: %s" + % (self.param_name, value, out)) + #Check parameter value on filesystem + assert commands.getoutput('cat $PFW_FILESYSTEM/INT8') == hex_value, log.F("FILESYSTEM : parameter update error") + log.I("test OK") + + def test_TypeMax_Overflow(self): + """ + Testing INT8 parameter value out of positive range + -------------------------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - set INT8 to 101 + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - error detected + - INT8 parameter not updated + - Blackboard and filesystem values checked + """ + log.D(self.test_TypeMax_Overflow.__doc__) + log.I("INT8 parameter max value out of bounds = 101") + value = "101" + param_check = commands.getoutput('cat $PFW_FILESYSTEM/INT8') + #Set parameter value + out, err = self.pfw.sendCmd("setParameter", self.param_name, value) + assert err == None, log.E("when setting parameter %s : %s" + % (self.param_name, err)) + assert out != "Done", log.F("PFW : Error not detected when setting parameter %s out of bounds" + % (self.param_name)) + #Check parameter value on filesystem + assert commands.getoutput('cat $PFW_FILESYSTEM/INT8') == param_check, log.F("FILESYSTEM : Forbiden parameter change") + log.I("test OK") diff --git a/test/functional-tests/PfwTestCase/Types/tINT8_Max.py b/test/functional-tests/PfwTestCase/Types/tINT8_Max.py new file mode 100644 index 0000000..b3792e0 --- /dev/null +++ b/test/functional-tests/PfwTestCase/Types/tINT8_Max.py @@ -0,0 +1,229 @@ +# -*-coding:utf-8 -* + +# Copyright (c) 2011-2015, Intel Corporation +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, +# are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation and/or +# other materials provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its contributors +# may be used to endorse or promote products derived from this software without +# specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +""" +Integer parameter type testcases - INT8_Max + +List of tested functions : +-------------------------- + - [setParameter] function + - [getParameter] function + +Initial Settings : +------------------ + INT8_Max : + - size = 8 + - range : [-128, 127] + +Test cases : +------------ + - INT8_Max parameter min value = -128 + - INT8_Max parameter min value out of bounds = -129 + - INT8_Max parameter max value = 127 + - INT8_Max parameter max value out of bounds = 128 + - INT8_Max parameter in nominal case = 50 +""" +import commands +from Util.PfwUnitTestLib import PfwTestCase +from Util import ACTLogging +log=ACTLogging.Logger() + +# Test of type INT8_Max - range [-128, 127] +class TestCases(PfwTestCase): + def setUp(self): + self.param_name = "/Test/Test/TEST_DIR/INT8_Max" + self.pfw.sendCmd("setTuningMode", "on") + + def tearDown(self): + self.pfw.sendCmd("setTuningMode", "off") + + def test_Nominal_Case(self): + """ + Testing INT8_Max in nominal case = 50 + ------------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - set INT8_Max parameter in nominal case = 50 + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - INT8_Max parameter set to 50 + - Blackboard and filesystem values checked + """ + print self.test_Nominal_Case.__doc__ + print "INFO : INT8_Max parameter in nominal case = 50" + value = "50" + hex_value = "0x32" + #Set parameter value + out, err = self.pfw.sendCmd("setParameter", self.param_name, value) + assert err == None, "Error when setting parameter %s : %s" % (self.param_name, err) + assert out == "Done", out + #Check parameter value on blackboard + out, err = self.pfw.sendCmd("getParameter", self.param_name, "") + assert err == None, "Error when setting parameter %s : %s" % (self.param_name, err) + assert out == value, "BLACKBOARD : Incorrect value for %s, expected: %s, found: %s" % (self.param_name, value, out) + #Check parameter value on filesystem + assert commands.getoutput('cat $PFW_FILESYSTEM/INT8_Max') == hex_value, "FILESYSTEM : parameter update error" + print "INFO : test OK" + + def test_TypeMin(self): + """ + Testing INT8_Max minimal value = -128 + ------------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - set INT8_Max parameter min value = -128 + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - INT8_Max parameter set to -128 + - Blackboard and filesystem values checked + """ + print self.test_TypeMin.__doc__ + print "INFO : INT8_Max parameter min value = -128" + value = "-128" + hex_value = "0x80" + #Set parameter value + out, err = self.pfw.sendCmd("setParameter", self.param_name, value) + assert err == None, "Error when setting parameter %s : %s" % (self.param_name, err) + assert out == "Done", out + #Check parameter value on blackboard + out, err = self.pfw.sendCmd("getParameter", self.param_name, "") + assert err == None, "PFW : Error when setting parameter %s : %s" % (self.param_name, err) + assert out == value, "BLACKBOARD : Incorrect value for %s, expected: %s, found: %s" % (self.param_name, value, out) + #Check parameter value on filesystem + assert commands.getoutput('cat $PFW_FILESYSTEM/INT8_Max') == hex_value, "FILESYSTEM : parameter update error" + print "INFO : test OK" + + def test_TypeMin_Overflow(self): + """ + Testing INT8_Max parameter value out of negative range + ------------------------------------------------------ + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - set INT8_Max to -129 + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - error detected + - INT8_Max parameter not updated + - Blackboard and filesystem values checked + """ + print self.test_TypeMin_Overflow.__doc__ + print "INFO : INT8_Max parameter min value out of bounds = -129" + value = "-129" + param_check = commands.getoutput('cat $PFW_FILESYSTEM/INT8_Max') + #Set parameter value + out, err = self.pfw.sendCmd("setParameter", self.param_name, value) + assert err == None, "Error when setting parameter %s : %s" % (self.param_name, err) + assert out != "Done", "PFW : Error not detected when setting parameter %s out of bounds" % (self.param_name) + #Check parameter value on filesystem + assert commands.getoutput('cat $PFW_FILESYSTEM/INT8_Max') == param_check, "FILESYSTEM : Forbiden parameter change" + print "INFO : test OK" + + def test_TypeMax(self): + """ + Testing INT8_Max parameter maximum value + ---------------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - set INT8_Max to 127 + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - INT8_Max parameter set to 127 + - Blackboard and filesystem values checked + """ + print self.test_TypeMax.__doc__ + print "INFO : INT8_Max parameter max value = 127" + value = "127" + hex_value = "0x7f" + #Set parameter value + out, err = self.pfw.sendCmd("setParameter", self.param_name, value) + assert err == None, "Error when setting parameter %s : %s" % (self.param_name, err) + assert out == "Done", out + #Check parameter value on blackboard + out, err = self.pfw.sendCmd("getParameter", self.param_name, "") + assert err == None, "Error when setting parameter %s : %s" % (self.param_name, err) + assert out == value, "BLACKBOARD : Incorrect value for %s, expected: %s, found: %s" % (self.param_name, value, out) + #Check parameter value on filesystem + assert commands.getoutput('cat $PFW_FILESYSTEM/INT8_Max') == hex_value, "FILESYSTEM : parameter update error" + print "INFO : test OK" + + def test_TypeMax_Overflow(self): + """ + Testing INT8_Max parameter value out of positive range + ------------------------------------------------------ + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - set INT8_Max to 128 + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - error detected + - INT8_Max parameter not updated + - Blackboard and filesystem values checked + """ + print self.test_TypeMax_Overflow.__doc__ + print "INFO : INT8_Max parameter max value out of bounds = 128" + value = "128" + param_check = commands.getoutput('cat $PFW_FILESYSTEM/INT8_Max') + #Set parameter value + out, err = self.pfw.sendCmd("setParameter", self.param_name, value) + assert err == None, "Error when setting parameter %s : %s" % (self.param_name, err) + assert out != "Done", "PFW : Error not detected when setting parameter %s out of bounds" % (self.param_name) + #Check parameter value on filesystem + assert commands.getoutput('cat $PFW_FILESYSTEM/INT8_Max') == param_check, "FILESYSTEM : Forbiden parameter change" + print "INFO : test OK" diff --git a/test/functional-tests/PfwTestCase/Types/tParameter_Block.py b/test/functional-tests/PfwTestCase/Types/tParameter_Block.py new file mode 100644 index 0000000..bc763bd --- /dev/null +++ b/test/functional-tests/PfwTestCase/Types/tParameter_Block.py @@ -0,0 +1,290 @@ +# -*-coding:utf-8 -* + +# Copyright (c) 2011-2015, Intel Corporation +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, +# are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation and/or +# other materials provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its contributors +# may be used to endorse or promote products derived from this software without +# specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +""" +Parameter block type testcases. + +List of tested functions : +-------------------------- + - [setParameter] function + - [getParameter] function + +Initial Settings : +------------------ + Block component - 3 UINT: + - UINT8, size = 8 bits, range : [0, 100] + - UINT16, size = 16 bits, range : [0, 1000] + - UINT16, size = 32 bits, range : [0, 1000] + +Test cases : +------------ + - Testing nominal situation + - Testing one-shot setting (setting directly a value for the block) + - Testing error : Out of range TestCase + - Testing error : Try to set an undefined param +""" +import commands +from Util.PfwUnitTestLib import PfwTestCase +from Util import ACTLogging +log=ACTLogging.Logger() + +# Test of type UINT16 - range [0, 1000] +class TestCases(PfwTestCase): + def setUp(self): + self.block_name = "/Test/Test/TEST_TYPES/BLOCK_PARAMETER" + + self.param_name = [] + self.filesystem_name = [] + + #UINT8_0, size = 8 + self.param_name.append(self.block_name+"/UINT8") + self.filesystem_name.append("$PFW_FILESYSTEM/BLOCK_UINT8") + #UINT16_1, size = 16 + self.param_name.append(self.block_name+"/UINT16") + self.filesystem_name.append("$PFW_FILESYSTEM/BLOCK_UINT16") + #UINT32_2, size = 32 + self.param_name.append(self.block_name+"/UINT32") + self.filesystem_name.append("$PFW_FILESYSTEM/BLOCK_UINT32") + + self.pfw.sendCmd("setTuningMode", "on") + + def tearDown(self): + self.pfw.sendCmd("setTuningMode", "off") + + + def test_Nominal_Case(self): + """ + Testing BLOCK_PARAMETER in nominal case + --------------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - set UINT parameters in nominal case : + - UINT8 = 5 + - UINT16 = 5 + - UINT32 = 5 + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - Parameters set to nominal value + - FILESYSTEM parameters set to nominal value + """ + log.D(self.test_Nominal_Case.__doc__) + + value_param = ["5", "5", "5"] + filesystem_value = ["0x5", "0x5", "0x5"] + + for index_param in range(len(self.param_name)) : + log.I("set parameter %s to %s" + %(self.param_name[index_param],value_param[index_param])) + out,err = self.pfw.sendCmd("setParameter",self.param_name[index_param],value_param[index_param]) + assert err == None, log.E("setParameter %s %s : %s" + % (self.param_name[index_param],value_param[index_param], err)) + assert out == "Done", log.F("setParameter %s %s" + %(self.param_name[index_param],value_param[index_param])) + log.I("Check parameter %s value" + %(self.param_name[index_param])) + out,err = self.pfw.sendCmd("getParameter",self.param_name[index_param]) + assert err == None, log.E("getParameter %s : %s" + % (self.block_name, err)) + assert out == value_param[index_param], log.F("getParameter %s - Expected : %s Found : %s" + %(self.param_name[index_param],value_param[index_param], out)) + log.I("Check filesystem value") + assert (commands.getoutput("cat %s" % (self.filesystem_name[index_param])) + == filesystem_value[index_param]), log.F("FILESYSTEM : parameter update error for %s after setting %s " + %(self.block_name, self.param_name[index_param])) + + + def test_Set_Block_Directly_Case(self): + """ + Testing error BLOCK_PARAMETER : set block value directly + -------------------------------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - set Param block directly without setting parameters : + - BLOCK_PARAMETER = Dec : 1000000 Hexa : 0xF4240 + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - Unable to set directly a parameter block + - FILESYSTEM parameters set to nominal value + """ + log.D(self.test_Set_Block_Directly_Case.__doc__) + + value = "1000000" + + log.I("Load the initial value of parameters") + init_value_param = [] + init_filesystem_value = [] + + for index_param in range(len(self.param_name)): + out,err = self.pfw.sendCmd("getParameter",self.param_name[index_param]) + init_value_param.append(out) + init_filesystem_value.append(commands.getoutput("cat %s" + %(self.filesystem_name[index_param]))) + + log.I("Try to set parameter %s to %s, failed expected" + %(self.block_name,value)) + out,err = self.pfw.sendCmd("setParameter",self.block_name, value) + assert err == None, log.E("setParameter %s %s : %s" + % (self.block_name, value, err)) + assert out != "Done", log.F("Error not detected when setting directly the block %s" + % (self.block_name)) + log.I("Try to get parameter %s to %s, failed expected" + %(self.block_name,value)) + out,err = self.pfw.sendCmd("getParameter",self.block_name, value) + assert err == None, log.E("getParameter %s : %s" + % (self.block_name, err)) + assert out != value, log.F("Error not detected when getting directly the block %s" + % (self.block_name)) + log.I("Check filesystem value") + for index_param in range(len(self.param_name)): + assert (commands.getoutput("cat %s"%(self.filesystem_name[index_param])) + == init_filesystem_value[index_param]), log.F("FILESYSTEM : parameter update error for %s" + %(self.block_name)) + + log.I("Check Param value") + for index_param in range(len(self.param_name)): + out,err = self.pfw.sendCmd("getParameter",self.param_name[index_param]) + assert (out == init_value_param[index_param]), log.F("BLACKBOARD: Forbidden change value for parameter %s - Expected : %s Found : %s" + %(self.param_name[index_param],init_value_param[index_param],out)) + + def test_Out_Of_Bound_Param_Value_Case(self): + """ + Testing error BLOCK_PARAMETER : Out of range TestCase + ----------------------------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - set param UINT16 to 65536 + - check parameter UINT16 value + - check parameter UINT8 value + - check parameter UINT32 value + - check block Filesystem value + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - Error detected when setting UINT16_1 to wrong value + - FILESYSTEM parameters set to nominal value + """ + log.D(self.test_Out_Of_Bound_Param_Value_Case.__doc__) + + param_value = "65536" + + log.I("Load the initial value of parameters") + init_value_param = [] + init_filesystem_value = [] + + for index_param in range(len(self.param_name)): + out,err = self.pfw.sendCmd("getParameter",self.param_name[index_param]) + init_value_param.append(out) + init_filesystem_value.append(commands.getoutput("cat %s" + %(self.filesystem_name[index_param]))) + + log.I("set parameter %s to %s, failed expected" + %(self.param_name[1],param_value)) + out,err = self.pfw.sendCmd("setParameter",self.param_name[1],param_value) + assert err == None, log.E("setParameter %s %s : %s" + % (self.param_name[1],param_value, err)) + assert out != "Done", log.F("Error not detected when setting parameter %s to out of bound value %s" + % (self.param_name[1],param_value)) + log.I("Check parameter value") + for index_param in range(len(self.param_name)): + out,err = self.pfw.sendCmd("getParameter",self.param_name[index_param]) + assert out == init_value_param[index_param], log.F("BLACKBOARD: Forbidden change value for %s - Expected : %s Found : %s" + %(self.param_name[index_param],init_value_param[index_param],out)) + log.I("Check filesystem value") + assert (commands.getoutput("cat %s"%(self.filesystem_name[index_param])) + == init_filesystem_value[index_param]), log.F("FILESYSTEM : parameter update error for %s" + %(self.block_name)) + + def test_Undefined_Param_Case(self): + """ + Testing error BLOCK_PARAMETER : Out of range TestCase + ----------------------------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - set parameter PARAM_UNDEF to 1 + - check block parameter Filesystem value + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - Error detected when setting PARAM_UNDEF + - FILESYSTEM parameters set to nominal value + """ + log.D(self.test_Undefined_Param_Case.__doc__) + + param_value = "1" + param_undefined_name = self.block_name + "/PARAM_UNDEF" + + log.I("Load the initial value of parameters") + init_value_param=[] + init_filesystem_value=[] + + for index_param in range(len(self.param_name)) : + out,err = self.pfw.sendCmd("getParameter",self.param_name[index_param]) + init_value_param.append(out) + init_filesystem_value.append(commands.getoutput("cat %s" + %(self.filesystem_name[index_param]))) + + log.I("set parameter %s to %s, failed expected" + %(param_undefined_name,param_value)) + out,err = self.pfw.sendCmd("setParameter",param_undefined_name,param_value) + assert err == None, log.E("setParameter %s %s : %s" + % (param_undefined_name,param_value, err)) + assert out != "Done", log.F("Error not detected when setting parameter %s to out of bound value %s" + % (param_undefined_name,param_value)) + log.I("Check parameter value") + for index_param in range(len(self.param_name)): + out,err = self.pfw.sendCmd("getParameter",self.param_name[index_param]) + assert out == init_value_param[index_param], log.F("BLACKBOARD: Forbidden change value for %s - Expected : %s Found : %s" + %(self.param_name[index_param],init_value_param[index_param],out)) + log.I("Check filesystem value") + assert (commands.getoutput("cat %s"%(self.filesystem_name[index_param])) + == init_filesystem_value[index_param]), log.F("FILESYSTEM : parameter update error for %s" + %(self.block_name)) diff --git a/test/functional-tests/PfwTestCase/Types/tRAW.py b/test/functional-tests/PfwTestCase/Types/tRAW.py new file mode 100644 index 0000000..6c96bfa --- /dev/null +++ b/test/functional-tests/PfwTestCase/Types/tRAW.py @@ -0,0 +1,722 @@ +# -*-coding:utf-8 -* + +# Copyright (c) 2011-2015, Intel Corporation +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, +# are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation and/or +# other materials provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its contributors +# may be used to endorse or promote products derived from this software without +# specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +""" +Raw Value testcases. + +List of tested functions : +-------------------------- + - [setParameter] function + - [getParameter] function + +Initial Settings : +------------------ + UINT16_MAX : + - 16 bits Unsigned Integer + - range [0x0, 0xFFFF] + UINT_16 : + - 16 bits Unsigned Integer + - range [0x0, 0x03E8] + +Test cases : +------------ + - Testing setValueSpace/getValueSpace functions + - Testing setOutputRawFormat/getOutputRawFormat functions + - UINT16_max parameter in nominal case = 50 / 0x32 : + - Writing Raw / Reading Hex + - Writing Raw / Reading Dec + - Writing Real / Reading Hex + - UINT16_max parameter min value = 0 : + - Writing Raw / Reading Hex + - Writing Raw / Reading Dec + - Writing Real / Reading Hex + - UINT16_max parameter max value = 65535 / 0xFFFF : + - Writing Raw / Reading Hex + - Writing Raw / Reading Dec + - Writing Real / Reading Hex + - UINT16_max parameter max value out of bounds = 0x10000 : + - Writing Raw + - UINT16 parameter max value out of bounds = 0x03E9 : + - Writing Raw +""" +import commands +from Util.PfwUnitTestLib import PfwTestCase +from Util import ACTLogging +log=ACTLogging.Logger() + +# Test of type UINT16 - range [0, 1000] +class TestCases(PfwTestCase): + def setUp(self): + self.param_name = "/Test/Test/TEST_DIR/UINT16_Max" + self.filesystem_name="$PFW_FILESYSTEM/UINT16_Max" + self.param_name_2 = "/Test/Test/TEST_DIR/UINT16" + self.filesystem_name_2="$PFW_FILESYSTEM/UINT16" + self.pfw.sendCmd("setTuningMode", "on") + + def tearDown(self): + self.pfw.sendCmd("setTuningMode", "off") + + + def test_01_SettingOutputRawFormat(self): + """ + Testing RAW - setOutputRawFormat/getOutputRawFormat functions + ------------------------------------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - set hex in output raw format + - get output raw format + - set dec in output raw format + - get output raw format + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setOutputRawFormat] function + - [getOutputRawFormat] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - getOutputRawFormat return hex after setting hex + - getOutputRawFormat return dec after setting dec + """ + log.D(self.test_01_SettingOutputRawFormat.__doc__) + value = "hex" + log.I("Setting %s in output raw format" + %(value)) + out, err = self.pfw.sendCmd("setOutputRawFormat", value) + assert err == None, log.E("When setting output raw format : %s" + % (err)) + assert out == "Done", log.F("setOutputRawFormat - expected : Done , found : %s" + % (out)) + log.I("Check output raw format state") + out, err = self.pfw.sendCmd("getOutputRawFormat","") + assert err == None, log.E("When getting output raw format : %s" + % (err)) + assert out == value, log.F("getOutputRawFormat - expected : %s , found : %s" + % (value,out)) + value = "dec" + log.I("Setting %s in output raw format" + %(value)) + out, err = self.pfw.sendCmd("setOutputRawFormat", value) + assert err == None, log.E("When setting output raw format : %s" + % (err)) + assert out == "Done", log.F("setOutputRawFormat - expected : Done , found : %s" + % (out)) + log.I("Check output raw format state") + out, err = self.pfw.sendCmd("getOutputRawFormat","") + assert err == None, log.E("When getting output raw format : %s" + % (err)) + assert out == value, log.F("getOutputRawFormat - expected : %s , found : %s" + % (value,out)) + + def test_02_SettingValueSpace(self): + """ + Testing RAW - setValueSpace/getValueSpace functions + --------------------------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - set raw in value space + - get value space + - set real in value space + - get value space + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setValueSpace] function + - [getValueSpace] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - getValueSpace return 'raw' after setting raw + - getValueSpace return 'real' after setting real + """ + log.D(self.test_02_SettingValueSpace.__doc__) + value = "raw" + log.I("Setting %s in value space" + % (value)) + out, err = self.pfw.sendCmd("setValueSpace", value) + assert err == None, log.E("When setting value space : %s" + % (err)) + assert out == "Done", log.F("setValueSpace - expected : done , found : %s" + % (out)) + log.I("check value space state") + out, err = self.pfw.sendCmd("getValueSpace","") + assert err == None, log.E("When setting value space : %s" + % (err)) + assert out == value, log.F("getValueSpace - expected : %s , found : %s" + % (value,out)) + value = "real" + log.I("Setting %s in value space" % (value)) + out, err = self.pfw.sendCmd("setValueSpace", value) + assert err == None, log.E("When setting value space : %s" + % (err)) + assert out == "Done", log.F("setValueSpace - expected : done , found : %s" + % (out)) + log.I("check value space state") + out, err = self.pfw.sendCmd("getValueSpace","") + assert err == None, log.E("When setting value space : %s" + % (err)) + assert out == value, log.F("getValueSpace - expected : %s , found : %s" + % (value,out)) + + def test_03_WRaw_RHex_Nominal_Case(self): + """ + Testing RAW - Nominal Case - UINT16_Max - Writing Raw / Reading Hex + ------------------------------------------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - UINT16_Max parameter in nominal case = 0x32 + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - UINT16_Max parameter set to 0x32 + - Blackboard and filesystem values checked + """ + log.D(self.test_03_WRaw_RHex_Nominal_Case.__doc__) + value = "0xFF00" + filesystem_value = "0xFF00" + blackboard_value = "0xFF00" + value_space = "raw" + outputraw_format = "hex" + + log.I("UINT16_Max parameter in nominal case = %s" + %(value)) + log.I("Value space = %s - Output Raw Format = %s" + %(value_space,outputraw_format)) + self.pfw.sendCmd("setValueSpace", value_space) + self.pfw.sendCmd("setOutputRawFormat", outputraw_format) + #Set parameter value + out, err = self.pfw.sendCmd("setParameter", self.param_name, value) + assert err == None, log.E("When setting parameter %s : %s" + % (self.param_name, err)) + assert out == "Done", log.F("setParameter - Unable to set the value %s for the parameter %s" + % (value,self.param_name)) + #Check parameter value on blackboard + out, err = self.pfw.sendCmd("getParameter", self.param_name, "") + assert err == None, log.E("When setting parameter %s : %s" + % (self.param_name, err)) + assert out == blackboard_value, log.F("BLACKBOARD : Incorrect value for %s, expected: %s, found: %s" + % (self.param_name, blackboard_value, out)) + #Check parameter value on filesystem + assert commands.getoutput("cat %s"%(self.filesystem_name)) == filesystem_value, log.F("FILESYSTEM : parameter update error for %s" + % (self.param_name)) + + def test_04_WReal_RHex_Nominal_Case(self): + """ + Testing RAW - Nominal Case - UINT16_Max - Writing Real / Reading Hex + -------------------------------------------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - UINT16_Max parameter in nominal case = 0x32 + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - UINT16_Max parameter set to 0x32 + - Blackboard and filesystem values checked + - When value space setting to Real, Output Raw Format is + disabled. Even if Output Raw Format is setting to Hex, the + output is in decimal. + """ + log.D(self.test_04_WReal_RHex_Nominal_Case.__doc__) + value = "50" + filesystem_value = "0x32" + blackboard_value = "50" + value_space = "real" + outputraw_format = "hex" + + log.I("UINT16_Max parameter in nominal case = %s" + %(value)) + log.I("Value space = %s - Output Raw Format = %s" + %(value_space,outputraw_format)) + self.pfw.sendCmd("setValueSpace", value_space) + self.pfw.sendCmd("setOutputRawFormat", outputraw_format) + #Set parameter value + out, err = self.pfw.sendCmd("setParameter", self.param_name, value) + assert err == None, log.E("When setting parameter %s : %s" + % (self.param_name, err)) + assert out == "Done", log.F("setParameter - Unable to set the value %s for the parameter %s" + % (value,self.param_name)) + #Check parameter value on blackboard + out, err = self.pfw.sendCmd("getParameter", self.param_name, "") + assert err == None, log.E("When setting parameter %s : %s" + % (self.param_name, err)) + assert out == blackboard_value, log.F("BLACKBOARD : Incorrect value for %s, expected: %s, found: %s" + % (self.param_name, blackboard_value, out)) + #Check parameter value on filesystem + assert commands.getoutput("cat %s"%(self.filesystem_name)) == filesystem_value, log.F("FILESYSTEM : parameter update error for %s" + %(self.param_name)) + + def test_05_WRaw_RDec_Nominal_Case(self): + """ + Testing RAW - Nominal Case - UINT16_Max - Writing Raw / Reading Dec + ------------------------------------------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - UINT16_Max parameter in nominal case = 0x32 + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + - [setValueSpace] function + - [setOutputRawFormat] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - UINT16_Max parameter set to 0x32 + - Blackboard and filesystem values checked + """ + log.D(self.test_05_WRaw_RDec_Nominal_Case.__doc__) + value = "0x32" + filesystem_value = "0x32" + blackboard_value = "50" + value_space = "raw" + outputraw_format = "dec" + + log.I("UINT16_Max parameter in nominal case = %s" + %(value)) + log.I("Value space = %s - Output Raw Format = %s" + %(value_space,outputraw_format)) + self.pfw.sendCmd("setValueSpace", value_space) + self.pfw.sendCmd("setOutputRawFormat", outputraw_format) + #Set parameter value + out, err = self.pfw.sendCmd("setParameter", self.param_name, value) + assert err == None, log.E("When setting parameter %s : %s" + % (self.param_name, err)) + assert out == "Done", log.F("setParameter - Unable to set the value %s for the parameter %s" + % (value,self.param_name)) + #Check parameter value on blackboard + out, err = self.pfw.sendCmd("getParameter", self.param_name, "") + assert err == None, log.E("When setting parameter %s : %s" + % (self.param_name, err)) + assert out == blackboard_value, log.F("BLACKBOARD : Incorrect value for %s, expected: %s, found: %s" + % (self.param_name, blackboard_value, out)) + #Check parameter value on filesystem + assert commands.getoutput("cat %s"%(self.filesystem_name)) == filesystem_value, log.F("FILESYSTEM : parameter update error for %s" + %(self.param_name)) + + + + def test_06_WRaw_RHex_TypeMin_Case(self): + """ + Testing RAW - Minimum Case - UINT16_Max - Writing Raw / Reading Hex + ------------------------------------------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - UINT16_Max parameter in nominal case = 0x0 + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + - [setValueSpace] function + - [setOutputRawFormat] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - UINT16_Max parameter set to 0x0 + - Blackboard and filesystem values checked + + """ + log.D(self.test_06_WRaw_RHex_TypeMin_Case.__doc__) + value = "0x0" + filesystem_value = "0x0" + blackboard_value = "0x0000" + value_space = "raw" + outputraw_format = "hex" + + log.I("UINT16_Max parameter in nominal case = %s" + %(value)) + log.I("Value space = %s - Output Raw Format = %s" + %(value_space,outputraw_format)) + self.pfw.sendCmd("setValueSpace", value_space) + self.pfw.sendCmd("setOutputRawFormat", outputraw_format) + #Set parameter value + out, err = self.pfw.sendCmd("setParameter", self.param_name, value) + assert err == None, log.E("When setting parameter %s : %s" + % (self.param_name, err)) + assert out == "Done", log.F("setParameter - Unable to set the value %s for the parameter %s" + %(value,self.param_name)) + #Check parameter value on blackboard + out, err = self.pfw.sendCmd("getParameter", self.param_name, "") + assert err == None, log.E("When setting parameter %s : %s" + % (self.param_name, err)) + assert out == blackboard_value, log.F("BLACKBOARD : Incorrect value for %s, expected: %s, found: %s" + % (self.param_name, blackboard_value, out)) + #Check parameter value on filesystem + assert commands.getoutput("cat %s"%(self.filesystem_name)) == filesystem_value, log.F("FILESYSTEM : parameter update error for %s" + %(self.param_name)) + + def test_07_WReal_RHex_TypeMin_Case(self): + """ + Testing RAW - Minimum Case - UINT16_Max - Writing Real / Reading Hex + -------------------------------------------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - UINT16_Max parameter in nominal case = 0x0 + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + - [setValueSpace] function + - [setOutputRawFormat] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - UINT16_Max parameter set to 0x0 + - Blackboard and filesystem values checked + - When value space setting to Real, Output Raw Format is + disabled. Even if Output Raw Format is setting to Hex, the + output is in decimal. + """ + log.D(self.test_07_WReal_RHex_TypeMin_Case.__doc__) + value = "0" + filesystem_value = "0x0" + blackboard_value = "0" + value_space = "real" + outputraw_format = "hex" + + log.I("UINT16_Max parameter in nominal case = %s" + %(value)) + log.I("Value space = %s - Output Raw Format = %s" + %(value_space,outputraw_format)) + self.pfw.sendCmd("setValueSpace", value_space) + self.pfw.sendCmd("setOutputRawFormat", outputraw_format) + #Set parameter value + out, err = self.pfw.sendCmd("setParameter", self.param_name, value) + assert err == None, log.E("When setting parameter %s : %s" + % (self.param_name, err)) + assert out == "Done", log.F("setParameter - Unable to set the value %s for the parameter %s" + % (value,self.param_name)) + #Check parameter value on blackboard + out, err = self.pfw.sendCmd("getParameter", self.param_name, "") + assert err == None, log.E("When setting parameter %s : %s" + % (self.param_name, err)) + assert out == blackboard_value, log.F("BLACKBOARD : Incorrect value for %s, expected: %s, found: %s" + % (self.param_name, blackboard_value, out)) + #Check parameter value on filesystem + assert commands.getoutput("cat %s"%(self.filesystem_name)) == filesystem_value, log.F("FILESYSTEM : parameter update error for %s" + %(self.param_name)) + + def test_08_WRaw_RDec_TypeMin_Case(self): + """ + Testing RAW - Minimum Case - UINT16_Max - Writing raw / Reading dec + ------------------------------------------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - UINT16_Max parameter in nominal case = 0x0 + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + - [setValueSpace] function + - [setOutputRawFormat] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - UINT16_Max parameter set to 0x0 + - Blackboard and filesystem values checked + - When value space setting to Real, Output Raw Format is + disabled. Even if Output Raw Format is setting to Hex, the + output is in decimal. + """ + log.D(self.test_08_WRaw_RDec_TypeMin_Case.__doc__) + value = "0x0" + filesystem_value = "0x0" + blackboard_value = "0" + value_space = "raw" + outputraw_format = "dec" + + log.I("UINT16_Max parameter in nominal case = %s" + %(value)) + log.I("Value space = %s - Output Raw Format = %s" + %(value_space,outputraw_format)) + self.pfw.sendCmd("setValueSpace", value_space) + self.pfw.sendCmd("setOutputRawFormat", outputraw_format) + #Set parameter value + out, err = self.pfw.sendCmd("setParameter", self.param_name, value) + assert err == None, log.E("When setting parameter %s : %s" + % (self.param_name, err)) + assert out == "Done", log.F("setParameter - Unable to set the value %s for the parameter %s" + % (value,self.param_name)) + #Check parameter value on blackboard + out, err = self.pfw.sendCmd("getParameter", self.param_name, "") + assert err == None, log.E("When setting parameter %s : %s" + % (self.param_name, err)) + assert out == blackboard_value, log.F("BLACKBOARD : Incorrect value for %s, expected: %s, found: %s" + % (self.param_name, blackboard_value, out)) + #Check parameter value on filesystem + assert commands.getoutput("cat %s"%(self.filesystem_name)) == filesystem_value, log.F("FILESYSTEM : parameter update error for %s" + %(self.param_name)) + + + def test_09_WRaw_RHex_TypeMax_Case(self): + """ + Testing RAW - Maximum Case - UINT16_Max - Writing Raw / Reading Hex + ------------------------------------------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - UINT16_Max parameter in nominal case = 0xFFFF / 65535 + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + - [setValueSpace] function + - [setOutputRawFormat] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - UINT16_Max parameter set to 0xFFFF + - Blackboard and filesystem values checked + """ + log.D(self.test_09_WRaw_RHex_TypeMax_Case.__doc__) + value = "0xFFFF" + filesystem_value = "0xffff" + blackboard_value = "0xFFFF" + value_space = "raw" + outputraw_format = "hex" + + log.I("UINT16_Max parameter in nominal case = %s" + %(value)) + log.I("Value space = %s - Output Raw Format = %s" + %(value_space,outputraw_format)) + self.pfw.sendCmd("setValueSpace", value_space) + self.pfw.sendCmd("setOutputRawFormat", outputraw_format) + #Set parameter value + out, err = self.pfw.sendCmd("setParameter", self.param_name, value) + assert err == None, log.E("When setting parameter %s : %s" + % (self.param_name, err)) + assert out == "Done", log.F("setParameter - Unable to set the value %s for the parameter %s" + % (value,self.param_name)) + #Check parameter value on blackboard + out, err = self.pfw.sendCmd("getParameter", self.param_name, "") + assert err == None, log.E("When setting parameter %s : %s" + % (self.param_name, err)) + assert out == blackboard_value, log.F("BLACKBOARD : Incorrect value for %s, expected: %s, found: %s" + % (self.param_name, blackboard_value, out)) + #Check parameter value on filesystem + assert commands.getoutput("cat %s"%(self.filesystem_name)) == filesystem_value, log.F("FILESYSTEM : parameter update error for %s" + %(self.param_name)) + + def test_10_WReal_RHex_TypeMax_Case(self): + """ + Testing RAW - Maximum Case - UINT16_Max - Writing Real / Reading Hex + -------------------------------------------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - UINT16_Max parameter in nominal case = 0xFFFF / 65535 + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + - [setValueSpace] function + - [setOutputRawFormat] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - UINT16_Max parameter set to 0xFFFF + - Blackboard and filesystem values checked + - When value space setting to Real, Output Raw Format is + disabled. Even if Output Raw Format is setting to Hex, the + output is in decimal. + """ + log.D(self.test_10_WReal_RHex_TypeMax_Case.__doc__) + value = "65535" + filesystem_value = "0xffff" + blackboard_value = "65535" + value_space = "real" + outputraw_format = "hex" + + log.I("UINT16_Max parameter in nominal case = %s" + %(value)) + log.I("Value space = %s - Output Raw Format = %s" + %(value_space,outputraw_format)) + self.pfw.sendCmd("setValueSpace", value_space) + self.pfw.sendCmd("setOutputRawFormat", outputraw_format) + #Set parameter value + out, err = self.pfw.sendCmd("setParameter", self.param_name, value) + assert err == None, log.E("When setting parameter %s : %s" + % (self.param_name, err)) + assert out == "Done", log.F("setParameter - Unable to set the value %s for the parameter %s" + % (value,self.param_name)) + #Check parameter value on blackboard + out, err = self.pfw.sendCmd("getParameter", self.param_name, "") + assert err == None, log.E("When setting parameter %s : %s" + % (self.param_name, err)) + assert out == blackboard_value, log.F("BLACKBOARD : Incorrect value for %s, expected: %s, found: %s" + % (self.param_name, blackboard_value, out)) + #Check parameter value on filesystem + assert commands.getoutput("cat %s"%(self.filesystem_name)) == filesystem_value, log.F("FILESYSTEM : parameter update error for %s" + %(self.param_name)) + + def test_11_WRaw_RDec_TypeMax_Case(self): + """ + Testing RAW - Maximum Case - UINT16_Max - Writing Real / Reading Hex + -------------------------------------------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - UINT16_Max parameter in nominal case = 0xFFFF / 65535 + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + - [setValueSpace] function + - [setOutputRawFormat] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - UINT16_Max parameter set to 0xFFFF + - Blackboard and filesystem values checked + - When value space setting to Real, Output Raw Format is + disabled. Even if Output Raw Format is setting to Hex, the + output is in decimal. + """ + log.D(self.test_11_WRaw_RDec_TypeMax_Case.__doc__) + value = "0xFFFF" + filesystem_value = "0xffff" + blackboard_value = "65535" + value_space = "raw" + outputraw_format = "dec" + + log.I("UINT16_Max parameter in nominal case = %s" + %(value)) + log.I("Value space = %s - Output Raw Format = %s" + %(value_space,outputraw_format)) + self.pfw.sendCmd("setValueSpace", value_space) + self.pfw.sendCmd("setOutputRawFormat", outputraw_format) + #Set parameter value + out, err = self.pfw.sendCmd("setParameter", self.param_name, value) + assert err == None, log.E("When setting parameter %s : %s" + % (self.param_name, err)) + assert out == "Done", log.F("setParameter - Unable to set the value %s for the parameter %s" + % (value,self.param_name)) + #Check parameter value on blackboard + out, err = self.pfw.sendCmd("getParameter", self.param_name, "") + assert err == None, log.E("When setting parameter %s : %s" + % (self.param_name, err)) + assert out == blackboard_value, log.F("BLACKBOARD : Incorrect value for %s, expected: %s, found: %s" + % (self.param_name, blackboard_value, out)) + #Check parameter value on filesystem + assert commands.getoutput("cat %s"%(self.filesystem_name)) == filesystem_value, log.F("FILESYSTEM : parameter update error for %s" + %(self.param_name)) + + + def test_12_WRaw_UINT16_Max_OutOfBound(self): + """ + Testing RAW - Out of range Case - UINT16_Max - Writing Raw + ---------------------------------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - UINT16_Max parameter in nominal case = 0x10000 / 65536 + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + - [setValueSpace] function + - [setOutputRawFormat] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - error detected + - UINT16_max parameter not updated + - Blackboard and filesystem values checked + """ + log.D(self.test_12_WRaw_UINT16_Max_OutOfBound.__doc__) + value = "0x10000" + filesystem_value = commands.getoutput("cat %s"%(self.filesystem_name)) + value_space = "raw" + outputraw_format = "hex" + + log.I("UINT16_Max parameter max value out of bound = %s"%(value)) + log.I("Value space = %s - Output Raw Format = %s" + %(value_space,outputraw_format)) + self.pfw.sendCmd("setValueSpace", value_space) + self.pfw.sendCmd("setOutputRawFormat", outputraw_format) + #Set parameter value + out, err = self.pfw.sendCmd("setParameter", self.param_name, value) + assert err == None, log.E("when setting parameter %s -> %s" + % (self.param_name, err)) + assert out != "Done", log.F("Error not detected when setting parameter %s out of bound" + % (self.param_name)) + #Check parameter value on blackboard + assert commands.getoutput("cat %s"%(self.filesystem_name)) == filesystem_value, "FILESYSTEM : Forbiden parameter change" + + + def test_13_WRaw_UINT16_OutOfBound(self): + """ + Testing RAW - Out of range Case - UINT16 - Writing Raw + ------------------------------------------------------ + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - UINT16_Max parameter in nominal case = 0x03E9 / 1001 + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + - [setValueSpace] function + - [setOutputRawFormat] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - error detected + - UINT16 parameter not updated + - Blackboard and filesystem values checked + """ + log.D(self.test_13_WRaw_UINT16_OutOfBound.__doc__) + value = "0x03E9" + filesystem_value = commands.getoutput("cat %s"%(self.filesystem_name_2)) + value_space = "raw" + outputraw_format = "hex" + + log.I("UINT16_Max parameter max value out of bound = %s"%(value)) + log.I("Value space = %s - Output Raw Format = %s" + %(value_space,outputraw_format)) + self.pfw.sendCmd("setValueSpace", value_space) + self.pfw.sendCmd("setOutputRawFormat", outputraw_format) + #Set parameter value + out, err = self.pfw.sendCmd("setParameter", self.param_name_2, value) + assert err == None, log.E("when setting parameter %s -> %s" + % (self.param_name_2, err)) + assert out != "Done", log.F("Error not detected when setting parameter %s out of bound" + % (self.param_name_2)) + #Check parameter value on blackboard + assert commands.getoutput("cat %s"%(self.filesystem_name_2)) == filesystem_value, "FILESYSTEM : Forbiden parameter change" diff --git a/test/functional-tests/PfwTestCase/Types/tSTRING_128.py b/test/functional-tests/PfwTestCase/Types/tSTRING_128.py new file mode 100644 index 0000000..6ef1876 --- /dev/null +++ b/test/functional-tests/PfwTestCase/Types/tSTRING_128.py @@ -0,0 +1,290 @@ +# -*-coding:utf-8 -* + +# Copyright (c) 2011-2015, Intel Corporation +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, +# are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation and/or +# other materials provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its contributors +# may be used to endorse or promote products derived from this software without +# specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +import commands, string, random +from Util.PfwUnitTestLib import PfwTestCase +from Util import ACTLogging +log=ACTLogging.Logger() + +# Test of type UINT8_S - range [-100, 100] +class TestCases(PfwTestCase): + + def setUp(self): + self.param_name = "/Test/Test/TEST_DIR/STR_CHAR128" + self.pfw.sendCmd("setTuningMode", "on") + self.size_max=128 + + def tearDown(self): + self.pfw.sendCmd("setTuningMode", "off") + + def test_Digits_String_Case(self): + """ + |============================================================| + | Testing data types - String | + | max number of char = 128 | + |============================================================| + | File : tSTRING_128.py | + | Version : 01 | + | | + | Test cases : | + | - STR_CHAR128 parameter nominal value = string_Conf_0 | + | - STR_CHAR128 parameter empty value = '' | + | - STR_CHAR128 parameter full value = generate randomly 128 | + | letters characters | + | - STR_CHAR128 parameter space character value = test string| + | - STR_CHAR128 parameter full digits value = generate | + | randomly 128 digits char | + | - STR_CHAR128 parameter oversize value = generate randomly | + | 129 char | + | | + |============================================================| + | STR_CHAR128 parameter in digits case = 128 digits char | + |============================================================| + | Test Case description : | + | - STR_CHAR128 parameter in digit case = 128 digits char | + | Tested commands : | + | * setParameter | + | - getParameter | + | Expected result : | + | - STR_CHAR128 parameter set to the same 128 digits char | + | (blackboard and filesystem values checked) | + |============================================================| + """ + log.D(self.test_Digits_String_Case.__doc__) + log.I("STR_CHAR128 parameter initial state = string_Conf_0") + value = "" + for i in range(self.size_max-1): + value=value+str(random.choice(string.digits)) + #Set parameter value + out, err = self.pfw.sendCmd("setParameter", self.param_name, value) + assert err == None, log.E("when setting parameter %s -> %s" % (self.param_name, err)) + assert out == "Done", log.F(out) + #Check parameter value on blackboard + out, err = self.pfw.sendCmd("getParameter", self.param_name, "") + assert err == None, log.E("when getting parameter %s -> %s" % (self.param_name, err)) + assert out == value, log.F("BLACKBOARD : Incorrect value for %s, expected: %s, found: %s" % (self.param_name, value, out)) + #Check parameter value on filesystem + assert commands.getoutput('cat $PFW_FILESYSTEM/STR_CHAR128') == value, log.F("FILESYSTEM : parameter update error") + + def test_Empty_String_Case(self): + """ + |============================================================| + | STR_CHAR128 parameter empty string = \'\' | + |============================================================| + | Test Case description : | + | - STR_CHAR128 parameter in empty string case = \'\' | + | Tested commands : | + | * setParameter | + | - getParameter | + | Expected result : | + | - STR_CHAR128 parameter set empty | + | (blackboard and filesystem values checked) | + |============================================================| + """ + log.D(self.test_Empty_String_Case.__doc__) + log.I("STR_CHAR128 parameter empty string = \'\'") + value = "\"\"" + #Set parameter value + out, err = self.pfw.sendCmd("setParameter", self.param_name, value) + assert err == None, log.E("when setting parameter %s -> %s" % (self.param_name, err)) + assert out == "Done", log.F(out) + #Check parameter value on blackboard + out, err = self.pfw.sendCmd("getParameter", self.param_name, "") + assert err == None, log.E("when getting parameter %s -> %s" % (self.param_name, err)) + assert out == "", log.F("BLACKBOARD : Incorrect value for %s, expected: %s, found: %s" % (self.param_name, value, out)) + #Check parameter value on filesystem + assert commands.getoutput('cat $PFW_FILESYSTEM/STR_CHAR128') == "", log.F("FILESYSTEM : parameter update error") + + def test_OverSize_String_Case(self): + """ + |============================================================| + | STR_CHAR128 parameter oversize | + |============================================================| + | Test Case description : | + | - STR_CHAR128 parameter in oversize case = 129 random char | + | Tested commands : | + | * setParameter | + | - getParameter | + | Expected result : | + | - error detected | + | - STR_CHAR128 parameter not updated | + |============================================================| + """ + log.D(self.test_OverSize_String_Case.__doc__) + log.I("STR_CHAR128 parameter size max=128 character") + value="" + for i in range(self.size_max+1): + value=value+str(random.choice(string.letters)) + param_check = commands.getoutput('cat $PFW_FILESYSTEM/STR_CHAR128') + #Set parameter value + out, err = self.pfw.sendCmd("setParameter", self.param_name, value) + assert err == None, log.E("when setting parameter %s -> %s" % (self.param_name, err)) + assert out != "Done", log.F("Error not detected when setting parameter %s over size" % (self.param_name)) + #Check parameter value on filesystem + assert commands.getoutput('cat $PFW_FILESYSTEM/STR_CHAR128') == param_check, log.F("FILESYSTEM : Forbiden parameter change") + + def test_Full_Letters_String_Case(self): + """ + |============================================================| + | STR_CHAR128 parameter full size test case | + |============================================================| + | Test Case description : | + | - STR_CHAR128 parameter in fullsize case = 128 random char | + | Tested commands : | + | * setParameter | + | - getParameter | + | Expected result : | + | - STR_CHAR128 parameter set to the same 128 letters char | + | (blackboard and filesystem values checked) | + |============================================================| + """ + log.D(self.test_Full_Letters_String_Case.__doc__) + log.I("STR_CHAR128 parameter initial state : string") + value = "" + for i in range(self.size_max-1): + value=value+str(random.choice(string.letters)) + #Set parameter value + out, err = self.pfw.sendCmd("setParameter", self.param_name, value) + assert err == None, log.E("when setting parameter %s -> %s" % (self.param_name, err)) + assert out == "Done", log.F("Expected : Done, result : %s" % (out)) + #Check parameter value on blackboard + out, err = self.pfw.sendCmd("getParameter", self.param_name, "") + assert err == None, log.E("When setting parameter %s : %s" % (self.param_name, err)) + assert out == value, log.F("BLACKBOARD : Incorrect value for %s, expected: %s, found: %s" % (self.param_name, value, out)) + #Check parameter value on filesystem + assert commands.getoutput('cat $PFW_FILESYSTEM/STR_CHAR128') == value, log.F("FILESYSTEM : parameter update error") + + def test_Nominal_String_Case(self): + """ + |============================================================| + | STR_CHAR128 parameter Nominal test case | + |============================================================| + | Test Case description : | + | - STR_CHAR128 parameter in nominal case = TestString | + | Tested commands : | + | * setParameter | + | - getParameter | + | Expected result : | + | - STR_CHAR128 parameter set to TestString | + | (blackboard and filesystem values checked) | + |============================================================| + """ + log.D(self.test_Nominal_String_Case.__doc__) + log.I("STR_CHAR128 parameter nominal string = TestString") + value = "TestString" + #Set parameter value + out, err = self.pfw.sendCmd("setParameter", self.param_name, value) + assert err == None, log.E("When setting parameter %s -> %s" % (self.param_name, err)) + assert out == "Done", log.F("Expected : Done, found : %s" % (out)) + #Check parameter value on blackboard + out, err = self.pfw.sendCmd("getParameter", self.param_name, "") + assert err == None, log.E("When setting parameter %s -> %s" % (self.param_name, err)) + assert out == value, log.F("BLACKBOARD : Incorrect value for %s, expected: %s, found: %s" % (self.param_name, value, out)) + #Check parameter value on filesystem + assert commands.getoutput('cat $PFW_FILESYSTEM/STR_CHAR128') == value, log.F("FILESYSTEM : parameter update error") + + def test_Punctuation_Empty_Parenthese_String_Case(self): + """ + |============================================================| + | STR_CHAR128 parameter empty Parenthese char test case | + |============================================================| + | Test Case description : | + | - STR_CHAR128 parameter = TestParenthese() | + | Tested commands : | + | * setParameter | + | - getParameter | + | Expected result : | + | - Not Determined now | + |============================================================| + """ + log.D(self.test_Punctuation_Empty_Parenthese_String_Case.__doc__) + value = "ParentheseTest()" + log.I("STR_CHAR128 parameter Parenthese Char = %s" % (value)) + param_check = commands.getoutput('cat $PFW_FILESYSTEM/STR_CHAR128') + #Set parameter value + out, err = self.pfw.sendCmd("setParameter", self.param_name, value) + assert err == None, log.E("When setting parameter %s : %s" % (self.param_name, err)) + assert out == value, log.F("BLACKBOARD : Incorrect value for %s, expected: %s, found: %s" % (self.param_name, value, out)) + #Check parameter value on filesystem + assert commands.getoutput('cat $PFW_FILESYSTEM/STR_CHAR128') == value, log.F("FILESYSTEM : parameter update error") + + def test_Punctuation_Full_Parenthese_String_Case(self): + """ + |============================================================| + | STR_CHAR128 parameter full Parenthese char test case | + |============================================================| + | Test Case description : | + | - STR_CHAR128 parameter = TestParenthese(test) | + | Tested commands : | + | * setParameter | + | - getParameter | + | Expected result : | + | - Not Determined now | + |============================================================| + """ + log.D(self.test_Punctuation_Full_Parenthese_String_Case.__doc__) + value = "ParentheseTest(test)" + log.I("STR_CHAR128 parameter Parenthese Char = %s" % (value)) + param_check = commands.getoutput('cat $PFW_FILESYSTEM/STR_CHAR128') + #Set parameter value + out, err = self.pfw.sendCmd("setParameter", self.param_name, value) + assert err == None, log.E("When setting parameter %s : %s" % (self.param_name, err)) + assert out == value, log.F("BLACKBOARD : Incorrect value for %s, expected: %s, found: %s" % (self.param_name, value, out)) + #Check parameter value on filesystem + assert commands.getoutput('cat $PFW_FILESYSTEM/STR_CHAR128') == value, log.F("FILESYSTEM : parameter update error") + + def test_SpaceChar_String_Case(self): + """ + |============================================================| + | STR_CHAR128 parameter space char test case | + |============================================================| + | Test Case description : | + | - STR_CHAR128 parameter = Test String | + | Tested commands : | + | * setParameter | + | - getParameter | + | Expected result : | + | - Not Determined now | + |============================================================| + """ + log.D(self.test_SpaceChar_String_Case.__doc__) + value = "Test String" + log.I("STR_CHAR128 parameter Parenthese Char = %s" % (value)) + value_check = "Test String" + #Set parameter value + out, err = self.pfw.sendCmd("setParameter", self.param_name, value) + assert err == None, log.E("When setting parameter %s : %s" % (self.param_name, err)) + assert out == "Done", log.F("Expected : Done, found : %s" % (out)) + #Check parameter value on blackboard + out, err = self.pfw.sendCmd("getParameter", self.param_name, "") + assert err == None, log.E("When setting parameter %s : %s" % (self.param_name, err)) + assert out == value, log.F("BLACKBOARD : Incorrect value for %s, expected: %s, found: %s" % (self.param_name, value_check, out)) + #Check parameter value on filesystem + assert commands.getoutput('cat $PFW_FILESYSTEM/STR_CHAR128') == value_check, log.F("FILESYSTEM : parameter update error") diff --git a/test/functional-tests/PfwTestCase/Types/tUINT16.py b/test/functional-tests/PfwTestCase/Types/tUINT16.py new file mode 100644 index 0000000..5be2189 --- /dev/null +++ b/test/functional-tests/PfwTestCase/Types/tUINT16.py @@ -0,0 +1,249 @@ +#!/usr/bin/python2 +# -*-coding:utf-8 -* + +# Copyright (c) 2011-2015, Intel Corporation +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, +# are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation and/or +# other materials provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its contributors +# may be used to endorse or promote products derived from this software without +# specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +""" +Integer parameter type testcases - UINT16 + +List of tested functions : +-------------------------- + - [setParameter] function + - [getParameter] function + +Initial Settings : +------------------ + UINT16 : + - unsigned + - size = 16 + - range : [0, 1000] + +Test cases : +------------ + - UINT16 parameter min value = 0 + - UINT16 parameter min value out of bounds = -1 + - UINT16 parameter max value = 1000 + - UINT16 parameter max value out of bounds = 1001 + - UINT16 parameter in nominal case = 50 +""" +import commands +from Util.PfwUnitTestLib import PfwTestCase +from Util import ACTLogging +log=ACTLogging.Logger() + + +# Test of type UINT16 - range [0, 1000] +class TestCases(PfwTestCase): + def setUp(self): + self.param_name = "/Test/Test/TEST_DIR/UINT16" + self.pfw.sendCmd("setTuningMode", "on") + + def tearDown(self): + self.pfw.sendCmd("setTuningMode", "off") + + def test_Nominal_Case(self): + """ + Testing UINT16 in nominal case = 50 + ----------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - set UINT16 parameter in nominal case = 50 + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - UINT16 parameter set to 50 + - Blackboard and filesystem values checked + """ + log.D(self.test_Nominal_Case.__doc__) + log.I("UINT16 parameter in nominal case = 50") + value = "50" + hex_value = "0x32" + #Set parameter value + out, err = self.pfw.sendCmd("setParameter", self.param_name, value) + assert err == None, log.E("when setting parameter %s : %s" + % (self.param_name, err)) + assert out == "Done", log.F("when setting parameter %s : %s" + % (self.param_name, out)) + #Check parameter value on blackboard + out, err = self.pfw.sendCmd("getParameter", self.param_name, "") + assert err == None, log.E("when setting parameter %s : %s" + % (self.param_name, err)) + assert out == value, log.F("BLACKBOARD : Incorrect value for %s, expected: %s, found: %s" + % (self.param_name, value, out)) + #Check parameter value on filesystem + assert commands.getoutput('cat $PFW_FILESYSTEM/UINT16') == hex_value, log.F("FILESYSTEM : parameter update error") + log.I("test OK") + + def test_TypeMin(self): + """ + Testing UINT16 minimal value = 0 + -------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - set UINT16 parameter min value = 0 + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - UINT16 parameter set to 0 + - Blackboard and filesystem values checked + """ + log.D(self.test_TypeMin.__doc__) + log.I("UINT16 parameter min value = 0") + value = "0" + hex_value = "0x0" + #Set parameter value + out, err = self.pfw.sendCmd("setParameter", self.param_name, value) + assert err == None, log.E("when setting parameter %s : %s" + % (self.param_name, err)) + assert out == "Done", log.F("when setting parameter %s : %s" + % (self.param_name, out)) + #Check parameter value on blackboard + out, err = self.pfw.sendCmd("getParameter", self.param_name, "") + assert err == None, log.E("when setting parameter %s : %s" + % (self.param_name, err)) + assert out == value, log.F("BLACKBOARD : Incorrect value for %s, expected: %s, found: %s" + % (self.param_name, value, out)) + #Check parameter value on filesystem + assert commands.getoutput('cat $PFW_FILESYSTEM/UINT16') == hex_value, log.F("FILESYSTEM : parameter update error") + log.I("test OK") + + def test_TypeMin_Overflow(self): + """ + Testing UINT16 parameter value out of negative range + ---------------------------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - set UINT16 to -1 + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - error detected + - UINT16 parameter not updated + - Blackboard and filesystem values checked + """ + log.D(self.test_TypeMin_Overflow.__doc__) + log.I("UINT16 parameter min value out of bounds = -1") + value = "-1" + param_check = commands.getoutput('cat $PFW_FILESYSTEM/UINT16') + #Set parameter value + out, err = self.pfw.sendCmd("setParameter", self.param_name, value) + assert err == None, log.E("when setting parameter %s : %s" + % (self.param_name, err)) + assert out != "Done", log.F("PFW : Error not detected when setting parameter %s out of bounds" + % (self.param_name)) + #Check parameter value on filesystem + assert commands.getoutput('cat $PFW_FILESYSTEM/UINT16') == param_check, log.F("FILESYSTEM : Forbiden parameter change") + log.I("test OK") + + def test_TypeMax(self): + """ + Testing UINT16 parameter maximum value + -------------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - set UINT16 to 1000 + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - UINT16 parameter set to 1000 + - Blackboard and filesystem values checked + """ + log.D(self.test_TypeMax.__doc__) + log.I("UINT16 parameter max value = 1000") + value = "1000" + hex_value = "0x3e8" + #Set parameter value + out, err = self.pfw.sendCmd("setParameter", self.param_name, value) + assert err == None, log.E("when setting parameter %s : %s" + % (self.param_name, err)) + assert out == "Done", log.F("when setting parameter %s : %s" + % (self.param_name, out)) + #Check parameter value on blackboard + out, err = self.pfw.sendCmd("getParameter", self.param_name, "") + assert err == None, log.E("when setting parameter %s : %s" + % (self.param_name, err)) + assert out == value, log.F("BLACKBOARD : Incorrect value for %s, expected: %s, found: %s" + % (self.param_name, value, out)) + #Check parameter value on filesystem + assert commands.getoutput('cat $PFW_FILESYSTEM/UINT16') == hex_value, log.F("FILESYSTEM : parameter update error") + log.I("test OK") + + def test_TypeMax_Overflow(self): + """ + Testing UINT16 parameter value out of positive range + ---------------------------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - set UINT16 to 1001 + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - error detected + - UINT16 parameter not updated + - Blackboard and filesystem values checked + """ + log.D(self.test_TypeMax_Overflow.__doc__) + log.I("UINT16 parameter max value out of bounds = 1001") + value = "1001" + param_check = commands.getoutput('cat $PFW_FILESYSTEM/UINT16') + #Set parameter value + out, err = self.pfw.sendCmd("setParameter", self.param_name, value) + assert err == None, log.E("when setting parameter %s : %s" + % (self.param_name, err)) + assert out != "Done", log.F("PFW : Error not detected when setting parameter %s out of bounds" + % (self.param_name)) + #Check parameter value on filesystem + assert commands.getoutput('cat $PFW_FILESYSTEM/UINT16') == param_check, log.F("FILESYSTEM : Forbiden parameter change") + log.I("test OK") diff --git a/test/functional-tests/PfwTestCase/Types/tUINT16_Max.py b/test/functional-tests/PfwTestCase/Types/tUINT16_Max.py new file mode 100644 index 0000000..30f25a9 --- /dev/null +++ b/test/functional-tests/PfwTestCase/Types/tUINT16_Max.py @@ -0,0 +1,248 @@ +#!/usr/bin/python2 +# -*-coding:utf-8 -* + +# Copyright (c) 2011-2015, Intel Corporation +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, +# are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation and/or +# other materials provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its contributors +# may be used to endorse or promote products derived from this software without +# specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +""" +Integer parameter type testcases - UINT16_Max + +List of tested functions : +-------------------------- + - [setParameter] function + - [getParameter] function + +Initial Settings : +------------------ + UINT16_Max : + - unsigned + - size = 16 + - range : [0, 65535] + +Test cases : +------------ + - UINT16_Max parameter min value = 0 + - UINT16_Max parameter min value out of bounds = -1 + - UINT16_Max parameter max value = 65535 + - UINT16_Max parameter max value out of bounds = 65536 + - UINT16_Max parameter in nominal case = 50 +""" +import commands +from Util.PfwUnitTestLib import PfwTestCase +from Util import ACTLogging +log=ACTLogging.Logger() + + +# Test of type UINT16_Max - range [0, 65535] +class TestCases(PfwTestCase): + def setUp(self): + self.param_name = "/Test/Test/TEST_DIR/UINT16_Max" + self.pfw.sendCmd("setTuningMode", "on") + + def tearDown(self): + self.pfw.sendCmd("setTuningMode", "off") + + def test_Nominal_Case(self): + """ + Testing UINT16_Max in nominal case = 50 + --------------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - set UINT16_Max parameter in nominal case = 50 + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - UINT16_Max parameter set to 50 + - Blackboard and filesystem values checked + """ + log.D(self.test_Nominal_Case.__doc__) + log.I("UINT16_Max parameter in nominal case = 50") + value = "50" + hex_value = "0x32" + #Set parameter value + out, err = self.pfw.sendCmd("setParameter", self.param_name, value) + assert err == None, log.E("when setting parameter %s : %s" + % (self.param_name, err)) + assert out == "Done", log.F("when setting parameter %s : %s" + % (self.param_name, out)) + #Check parameter value on blackboard + out, err = self.pfw.sendCmd("getParameter", self.param_name, "") + assert err == None, log.E("when setting parameter %s : %s" + % (self.param_name, err)) + assert out == value, log.F("BLACKBOARD : Incorrect value for %s, expected: %s, found: %s" + % (self.param_name, value, out)) + #Check parameter value on filesystem + assert commands.getoutput('cat $PFW_FILESYSTEM/UINT16_Max') == hex_value, log.F("FILESYSTEM : parameter update error") + log.I("test OK") + + def test_TypeMin(self): + """ + Testing UINT16_Max minimal value = 0 + ------------------------------------ + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - set UINT16_Max parameter min value = 0 + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - UINT16_Max parameter set to 0 + - Blackboard and filesystem values checked + """ + log.D(self.test_TypeMin.__doc__) + log.I("UINT16_Max parameter min value = 0") + value = "0" + hex_value = "0x0" + #Set parameter value + out, err = self.pfw.sendCmd("setParameter", self.param_name, value) + assert err == None, log.E("when setting parameter %s : %s" + % (self.param_name, err)) + assert out == "Done", log.F("when setting parameter %s : %s" + % (self.param_name, out)) + #Check parameter value on blackboard + out, err = self.pfw.sendCmd("getParameter", self.param_name, "") + assert err == None, log.E("when setting parameter %s : %s" + % (self.param_name, err)) + assert out == value, log.F("BLACKBOARD : Incorrect value for %s, expected: %s, found: %s" + % (self.param_name, value, out)) + #Check parameter value on filesystem + assert commands.getoutput('cat $PFW_FILESYSTEM/UINT16_Max') == hex_value, log.F("FILESYSTEM : parameter update error") + log.I("test OK") + + def test_TypeMin_Overflow(self): + """ + Testing UINT16_Max parameter value out of negative range + -------------------------------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - set UINT16_Max to -1 + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - error detected + - UINT16_Max parameter not updated + - Blackboard and filesystem values checked + """ + log.D(self.test_TypeMin_Overflow.__doc__) + log.I("UINT16_Max parameter min value out of bounds = -1") + value = "-1" + param_check = commands.getoutput('cat $PFW_FILESYSTEM/UINT16_Max') + #Set parameter value + out, err = self.pfw.sendCmd("setParameter", self.param_name, value) + assert err == None, log.E("when setting parameter %s : %s" + % (self.param_name, err)) + assert out != "Done", log.F("PFW : Error not detected when setting parameter %s out of bounds" + % (self.param_name)) + #Check parameter value on filesystem + assert commands.getoutput('cat $PFW_FILESYSTEM/UINT16_Max') == param_check, log.F("FILESYSTEM : Forbiden parameter change") + log.I("test OK") + + def test_TypeMax(self): + """ + Testing UINT16_Max parameter maximum value + ------------------------------------------ + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - set UINT16_Max to 65535 + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - UINT16_Max parameter set to 65535 + - Blackboard and filesystem values checked + """ + log.D(self.test_TypeMax.__doc__) + log.I("UINT16_Max parameter max value = 65535") + value = "65535" + hex_value = "0xffff" + #Set parameter value + out, err = self.pfw.sendCmd("setParameter", self.param_name, value) + assert err == None, log.E("when setting parameter %s : %s" + % (self.param_name, err)) + assert out == "Done", log.F("when setting parameter %s : %s" + % (self.param_name, out)) + #Check parameter value on blackboard + out, err = self.pfw.sendCmd("getParameter", self.param_name, "") + assert err == None, log.E("when setting parameter %s : %s" + % (self.param_name, err)) + assert out == value, log.F("BLACKBOARD : Incorrect value for %s, expected: %s, found: %s" + % (self.param_name, value, out)) + #Check parameter value on filesystem + assert commands.getoutput('cat $PFW_FILESYSTEM/UINT16_Max') == hex_value, log.F("FILESYSTEM : parameter update error") + log.I("test OK") + + def test_TypeMax_Overflow(self): + """ + Testing UINT16_Max parameter value out of positive range + -------------------------------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - set UINT16_Max to 65536 + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - error detected + - UINT16_Max parameter not updated + - Blackboard and filesystem values checked + """ + log.D(self.test_TypeMax_Overflow.__doc__) + log.I("UINT16_Max parameter max value out of bounds = 65536") + value = "65536" + param_check = commands.getoutput('cat $PFW_FILESYSTEM/UINT16_Max') + #Set parameter value + out, err = self.pfw.sendCmd("setParameter", self.param_name, value) + assert err == None, log.E("when setting parameter %s : %s" + % (self.param_name, err)) + assert out != "Done", log.F("PFW : Error not detected when setting parameter %s out of bounds" + % (self.param_name)) + #Check parameter value on filesystem + assert commands.getoutput('cat $PFW_FILESYSTEM/UINT16_Max') == param_check, log.F("FILESYSTEM : Forbiden parameter change") + log.I("test OK") diff --git a/test/functional-tests/PfwTestCase/Types/tUINT32.py b/test/functional-tests/PfwTestCase/Types/tUINT32.py new file mode 100644 index 0000000..662fe9a --- /dev/null +++ b/test/functional-tests/PfwTestCase/Types/tUINT32.py @@ -0,0 +1,248 @@ +#!/usr/bin/python2 +# -*-coding:utf-8 -* + +# Copyright (c) 2011-2015, Intel Corporation +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, +# are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation and/or +# other materials provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its contributors +# may be used to endorse or promote products derived from this software without +# specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +""" +Integer parameter type testcases - UINT32 + +List of tested functions : +-------------------------- + - [setParameter] function + - [getParameter] function + +Initial Settings : +------------------ + UINT32 : + - unsigned + - size = 32 + - range : [0, 1000] + +Test cases : +------------ + - UINT32 parameter min value = 0 + - UINT32 parameter min value out of bounds = -1 + - UINT32 parameter max value = 1000 + - UINT32 parameter max value out of bounds = 1001 + - UINT32 parameter in nominal case = 50 +""" +import commands +from Util.PfwUnitTestLib import PfwTestCase +from Util import ACTLogging +log=ACTLogging.Logger() + + +# Test of type UINT32 - range [0, 1000] +class TestCases(PfwTestCase): + def setUp(self): + self.param_name = "/Test/Test/TEST_DIR/UINT32" + self.pfw.sendCmd("setTuningMode", "on") + + def tearDown(self): + self.pfw.sendCmd("setTuningMode", "off") + + def test_Nominal_Case(self): + """ + Testing UINT32 in nominal case = 50 + ----------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - set UINT32 parameter in nominal case = 50 + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - UINT32 parameter set to 50 + - Blackboard and filesystem values checked + """ + log.D(self.test_Nominal_Case.__doc__) + log.I("UINT32 parameter in nominal case = 50") + value = "50" + hex_value = "0x32" + #Set parameter value + out, err = self.pfw.sendCmd("setParameter", self.param_name, value) + assert err == None, log.E("when setting parameter %s : %s" + % (self.param_name, err)) + assert out == "Done", log.F("when setting parameter %s : %s" + % (self.param_name, out)) + #Check parameter value on blackboard + out, err = self.pfw.sendCmd("getParameter", self.param_name, "") + assert err == None, log.E("when setting parameter %s : %s" + % (self.param_name, err)) + assert out == value, log.F("BLACKBOARD : Incorrect value for %s, expected: %s, found: %s" + % (self.param_name, value, out)) + #Check parameter value on filesystem + assert commands.getoutput('cat $PFW_FILESYSTEM/UINT32') == hex_value, log.F("FILESYSTEM : parameter update error") + log.I("test OK") + + def test_TypeMin(self): + """ + Testing UINT32 minimal value = 0 + -------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - set UINT32 parameter min value = 0 + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - UINT32 parameter set to 0 + - Blackboard and filesystem values checked + """ + log.D(self.test_TypeMin.__doc__) + log.I("UINT32 parameter min value = 0") + value = "0" + hex_value = "0x0" + #Set parameter value + out, err = self.pfw.sendCmd("setParameter", self.param_name, value) + assert err == None, log.E("when setting parameter %s : %s" + % (self.param_name, err)) + assert out == "Done", log.F("when setting parameter %s : %s" + % (self.param_name, out)) + #Check parameter value on blackboard + out, err = self.pfw.sendCmd("getParameter", self.param_name, "") + assert err == None, log.E("when setting parameter %s : %s" + % (self.param_name, err)) + assert out == value, log.F("BLACKBOARD : Incorrect value for %s, expected: %s, found: %s" + % (self.param_name, value, out)) + #Check parameter value on filesystem + assert commands.getoutput('cat $PFW_FILESYSTEM/UINT32') == hex_value, log.F("FILESYSTEM : parameter update error") + log.I("test OK") + + def test_TypeMin_Overflow(self): + """ + Testing UINT32 parameter value out of negative range + ---------------------------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - set UINT32 to -1 + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - error detected + - UINT32 parameter not updated + - Blackboard and filesystem values checked + """ + log.D(self.test_TypeMin_Overflow.__doc__) + log.I("UINT32 parameter min value out of bounds = -1") + value = "-1" + param_check = commands.getoutput('cat $PFW_FILESYSTEM/UINT32') + #Set parameter value + out, err = self.pfw.sendCmd("setParameter", self.param_name, value) + assert err == None, log.E("when setting parameter %s : %s" + % (self.param_name, err)) + assert out != "Done", log.F("PFW : Error not detected when setting parameter %s out of bounds" + % (self.param_name)) + #Check parameter value on filesystem + assert commands.getoutput('cat $PFW_FILESYSTEM/UINT32') == param_check, log.F("FILESYSTEM : Forbiden parameter change") + log.I("test OK") + + def test_TypeMax(self): + """ + Testing UINT32 parameter maximum value + -------------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - set UINT32 to 1000 + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - UINT32 parameter set to 1000 + - Blackboard and filesystem values checked + """ + log.D(self.test_TypeMax.__doc__) + log.I("UINT32 parameter max value = 1000") + value = "1000" + hex_value = "0x3e8" + #Set parameter value + out, err = self.pfw.sendCmd("setParameter", self.param_name, value) + assert err == None, log.E("when setting parameter %s : %s" + % (self.param_name, err)) + assert out == "Done", log.F("when setting parameter %s : %s" + % (self.param_name, out)) + #Check parameter value on blackboard + out, err = self.pfw.sendCmd("getParameter", self.param_name, "") + assert err == None, log.E("when setting parameter %s : %s" + % (self.param_name, err)) + assert out == value, log.F("BLACKBOARD : Incorrect value for %s, expected: %s, found: %s" + % (self.param_name, value, out)) + #Check parameter value on filesystem + assert commands.getoutput('cat $PFW_FILESYSTEM/UINT32') == hex_value, log.F("FILESYSTEM : parameter update error") + log.I("test OK") + + def test_TypeMax_Overflow(self): + """ + Testing UINT32 parameter value out of positive range + ---------------------------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - set UINT32 to 1001 + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - error detected + - UINT32 parameter not updated + - Blackboard and filesystem values checked + """ + log.D(self.test_TypeMax_Overflow.__doc__) + log.I("UINT32 parameter max value out of bounds = 1001") + value = "1001" + param_check = commands.getoutput('cat $PFW_FILESYSTEM/UINT32') + #Set parameter value + out, err = self.pfw.sendCmd("setParameter", self.param_name, value) + assert err == None, log.E("when setting parameter %s : %s" + % (self.param_name, err)) + assert out != "Done", log.F("PFW : Error not detected when setting parameter %s out of bounds" + % (self.param_name)) + #Check parameter value on filesystem + assert commands.getoutput('cat $PFW_FILESYSTEM/UINT32') == param_check, log.F("FILESYSTEM : Forbiden parameter change") + log.I("test OK") diff --git a/test/functional-tests/PfwTestCase/Types/tUINT32_ARRAY.py b/test/functional-tests/PfwTestCase/Types/tUINT32_ARRAY.py new file mode 100644 index 0000000..ce584ac --- /dev/null +++ b/test/functional-tests/PfwTestCase/Types/tUINT32_ARRAY.py @@ -0,0 +1,324 @@ +#!/usr/bin/python2 +# -*-coding:utf-8 -* + +# Copyright (c) 2011-2015, Intel Corporation +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, +# are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation and/or +# other materials provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its contributors +# may be used to endorse or promote products derived from this software without +# specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +""" +Array parameter type testcases : UINT32 Array + +List of tested functions : +-------------------------- + - [setParameter] function + - [getParameter] function + +Initial Settings : +------------------ + UINT8 Array = 32bits unsigned int array : + - Array size : 10 + - values range : [0, 100] + +Test cases : +------------ + - Testing nominal case + - Testing minimum + - Testing minimum overflow + - Testing maximum + - Testing maximum overflow + - Testing array index out of bounds + - Testing value format error +""" +import commands +from Util.PfwUnitTestLib import PfwTestCase +from Util import ACTLogging +log=ACTLogging.Logger() + +from ctypes import c_uint16 + + +class TestCases(PfwTestCase): + + def setUp(self): + self.param_name = "/Test/Test/TEST_DIR/UINT32_ARRAY" + self.param_short_name = "$PFW_FILESYSTEM/UINT32_ARRAY" + print '\r' + self.pfw.sendCmd("setTuningMode", "on") + print '\r' + self.array_size = 10 + self.array_min = 0 + self.array_max = 100 + + def tearDown(self): + self.pfw.sendCmd("setTuningMode", "off") + + def test_Nominal_Case(self): + """ + Testing UINT32_ARRAY Nominal Case + --------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - Set every UINT32_ARRAY elements to autorized values + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - UINT32_ARRAY array elements correctly recorded + - Blackboard and filesystem values checked + """ + log.D(self.test_Nominal_Case.__doc__) + + for index in range (self.array_size): + indexed_array_value = index + self.array_min + if indexed_array_value>self.array_max: + indexed_array_value=self.array_max + hex_indexed_array_value = hex(c_uint16(indexed_array_value).value) + #Check parameter value setting + indexed_array_value_path = "".join([self.param_name, "/", str(index)]) + out, err = self.pfw.sendCmd("setParameter", str(indexed_array_value_path), str(indexed_array_value)) + assert err == None, log.E("when setting parameter %s[%s]: %s" + % (self.param_name, str(index), err)) + assert out == "Done", log.F("when setting parameter %s[%s]: %s" + % (self.param_name, str(index), out)) + #Check parameter value on blackboard + out, err = self.pfw.sendCmd("getParameter", str(indexed_array_value_path), "") + assert err == None, log.E("when setting parameter %s[%s] : %s" + % (self.param_name, str(index), err)) + assert out == str(indexed_array_value), log.F("BLACKBOARD : Incorrect value for %s[%s], expected: %s, found: %s" + % (self.param_name, str(index), str(indexed_array_value), out)) + #Check parameter value on filesystem + files_system_check = "awk -v ligne="+str(index)+" 'NR == ligne+1 { print $0}' "+self.param_short_name + indexed_files_system_array_value = commands.getoutput(files_system_check) + assert indexed_files_system_array_value == hex_indexed_array_value, log.F("FILESSYSTEM : %s[%s] update error" + % (self.param_name, str(index))) + + def test_Min_Value(self): + """ + Testing UINT32_ARRAY minimum value + ---------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - Set every UINT32_ARRAY elements to minimum values : 0 + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - UINT32_ARRAY array elements correctly recorded + - Blackboard and filesystem values checked + """ + log.D(self.test_Min_Value.__doc__) + index = 0 + indexed_array_value = self.array_min + indexed_array_value_path = "".join([self.param_name, "/", str(index)]) + hex_indexed_array_value = hex(c_uint16(indexed_array_value).value) + #Check parameter value setting + out, err = self.pfw.sendCmd("setParameter", str(indexed_array_value_path), str(indexed_array_value)) + assert err == None, log.E("when setting parameter %s[%s]: %s" + % (self.param_name, str(index), err)) + assert out == "Done", log.E("when setting parameter %s[%s]: %s" + % (self.param_name, str(index), out)) + #Check parameter value on blackboard + out, err = self.pfw.sendCmd("getParameter", str(indexed_array_value_path), "") + assert err == None, log.E("when setting parameter %s[%s] : %s" + % (self.param_name, str(index), err)) + assert out == str(indexed_array_value), log.F("BLACKBOARD : Incorrect value for %s[%s], expected: %s, found: %s" + % (self.param_name, str(index), str(indexed_array_value), out)) + #Check parameter value on filesystem + files_system_check = "awk -v ligne="+str(index)+" 'NR == ligne+1 { print $0}' "+self.param_short_name + indexed_files_system_array_value = commands.getoutput(files_system_check) + assert indexed_files_system_array_value == hex_indexed_array_value, log.F("FILESSYSTEM : %s[%s] update error" + % (self.param_name, str(index))) + + def test_Min_Value_Overflow(self): + """ + Testing UINT32_ARRAY parameter values out of negative range + ----------------------------------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - Set every UINT32_ARRAY elements to -1 + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - UINT32_ARRAY array elements not recorded + - Error correctly detected + """ + log.D(self.test_Min_Value_Overflow.__doc__) + index = 0 + indexed_array_value = self.array_min + indexed_array_value_path = "".join([self.param_name, "/", str(index)]) + #Check initial parameter value setting + out, err = self.pfw.sendCmd("setParameter", str(indexed_array_value_path), str(indexed_array_value)) + assert err == None, log.E("when setting parameter %s[%s]: %s" + % (self.param_name, str(index), err)) + assert out == "Done", log.F("when setting parameter %s[%s]: %s" + % (self.param_name, str(index), out)) + files_system_check = "awk -v ligne="+str(index)+" 'NR == ligne+1 { print $0}' "+self.param_short_name + param_check = commands.getoutput(files_system_check) + #Check final parameter value setting + indexed_array_value = indexed_array_value - 1 + out, err = self.pfw.sendCmd("setParameter", str(indexed_array_value_path), str(indexed_array_value)) + assert err == None, log.E("when setting parameter %s[%s]: %s" + % (self.param_name, str(index), err)) + assert out != "Done", log.F("Error not detected when setting parameter %s[%s] out of bounds" + % (self.param_name, str(index))) + #Check parameter value on filesystem + indexed_files_system_array_value = commands.getoutput(files_system_check) + assert indexed_files_system_array_value == param_check, log.F("FILESSYSTEM : %s[%s] forbiden update" + % (self.param_name, str(index))) + + def test_Max_Value(self): + """ + Testing UINT32_ARRAY maximum value + ---------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - Set every UINT32_ARRAY elements to maximum values : 15 + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - UINT32_ARRAY array elements correctly recorded + - Blackboard and filesystem values checked + """ + log.D(self.test_Max_Value.__doc__) + index = 0 + indexed_array_value = self.array_max + indexed_array_value_path = "".join([self.param_name, "/", str(index)]) + hex_indexed_array_value = hex(c_uint16(indexed_array_value).value) + #Check parameter value setting + out, err = self.pfw.sendCmd("setParameter", str(indexed_array_value_path), str(indexed_array_value)) + assert err == None, log.E("when setting parameter %s[%s]: %s" + % (self.param_name, str(index), err)) + assert out == "Done", log.F("when setting parameter %s[%s]: %s" + % (self.param_name, str(index), out)) + #Check parameter value on blackboard + out, err = self.pfw.sendCmd("getParameter", str(indexed_array_value_path), "") + assert err == None, log.E("when setting parameter %s[%s] : %s" + % (self.param_name, str(index), err)) + assert out == str(indexed_array_value), log.F("BLACKBOARD : Incorrect value for %s[%s], expected: %s, found: %s" + % (self.param_name, str(index), str(indexed_array_value), out)) + #Check parameter value on filesystem + files_system_check = "awk -v ligne="+str(index)+" 'NR == ligne+1 { print $0}' "+self.param_short_name + indexed_files_system_array_value = commands.getoutput(files_system_check) + assert indexed_files_system_array_value == hex_indexed_array_value, log.F("FILESSYSTEM : %s[%s] update error" + % (self.param_name, str(index))) + + def test_Max_Value_Overflow(self): + """ + Testing UINT32_ARRAY parameter values out of positive range + ----------------------------------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - Set every UINT32_ARRAY elements to 16 + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - UINT32_ARRAY array elements not recorded + - Error correctly detected + """ + log.D(self.test_Max_Value_Overflow.__doc__) + index = 0 + indexed_array_value = self.array_max + indexed_array_value_path = "".join([self.param_name, "/", str(index)]) + #Check initial parameter value setting + out, err = self.pfw.sendCmd("setParameter", str(indexed_array_value_path), str(indexed_array_value)) + assert err == None, log.E("when setting parameter %s[%s]: %s" + % (self.param_name, str(index), err)) + assert out == "Done", log.F("when setting parameter %s[%s]: %s" + % (self.param_name, str(index), out)) + files_system_check = "awk -v ligne="+str(index)+" 'NR == ligne+1 { print $0}' "+self.param_short_name + param_check = commands.getoutput(files_system_check) + #Check final parameter value setting + indexed_array_value = indexed_array_value + 1 + out, err = self.pfw.sendCmd("setParameter", str(indexed_array_value_path), str(indexed_array_value)) + assert err == None, log.E("when setting parameter %s[%s]: %s" + % (self.param_name, str(index), err)) + assert out != "Done", log.F("Error not detected when setting parameter %s[%s] out of bounds" + % (self.param_name, str(index))) + #Check parameter value on filesystem + indexed_files_system_array_value = commands.getoutput(files_system_check) + assert indexed_files_system_array_value == param_check, log.F("FILESSYSTEM : %s[%s] forbiden update" + % (self.param_name, str(index))) + + def test_Array_Index_Overflow(self): + """ + Testing Array index out of bounds + --------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - Set an out of bounds array indexed element + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - UINT32_ARRAY array elements not recorded + - Error correctly detected + """ + log.D(self.test_Array_Index_Overflow.__doc__) + index_values = (self.array_size-1, self.array_size+1, -1) + for index in index_values: + print index + indexed_array_value = self.array_max + indexed_array_value_path = "".join([self.param_name, "/", str(index)]) + #Check parameter value setting + out, err = self.pfw.sendCmd("setParameter", str(indexed_array_value_path), str(indexed_array_value)) + if index in [0, self.array_size-1]: + assert err == None, log.E("when setting parameter %s[%s]: %s" + % (self.param_name, str(index), err)) + assert out == "Done", log.F("when setting parameter %s[%s]: %s" + % (self.param_name, str(index), out)) + else: + assert err == None, log.E("when setting parameter %s[%s]: %s" + % (self.param_name, str(index), err)) + assert out != "Done", log.F("Error not detected when setting array %s index out of bounds" + % (self.param_name)) diff --git a/test/functional-tests/PfwTestCase/Types/tUINT32_Max.py b/test/functional-tests/PfwTestCase/Types/tUINT32_Max.py new file mode 100644 index 0000000..b99dd1b --- /dev/null +++ b/test/functional-tests/PfwTestCase/Types/tUINT32_Max.py @@ -0,0 +1,248 @@ +#!/usr/bin/python2 +# -*-coding:utf-8 -* + +# Copyright (c) 2011-2015, Intel Corporation +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, +# are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation and/or +# other materials provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its contributors +# may be used to endorse or promote products derived from this software without +# specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +""" +Integer parameter type testcases - UINT16 + +List of tested functions : +-------------------------- + - [setParameter] function + - [getParameter] function + +Initial Settings : +------------------ + UINT16 : + - unsigned + - size = 32 + - range : [0, 4294967295] + +Test cases : +------------ + - UINT16 parameter min value = 0 + - UINT16 parameter min value out of bounds = -1 + - UINT16 parameter max value = 4294967295 + - UINT16 parameter max value out of bounds = 4294967296 + - UINT16 parameter in nominal case = 50 +""" +import commands +from Util.PfwUnitTestLib import PfwTestCase +from Util import ACTLogging +log=ACTLogging.Logger() + + +# Test of type UINT32_Max - range [0, 4294967295] +class TestCases(PfwTestCase): + def setUp(self): + self.param_name = "/Test/Test/TEST_DIR/UINT32_Max" + self.pfw.sendCmd("setTuningMode", "on") + + def tearDown(self): + self.pfw.sendCmd("setTuningMode", "off") + + def test_Nominal_Case(self): + """ + Testing UINT16 in nominal case = 50 + ----------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - set UINT16 parameter in nominal case = 50 + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - UINT16 parameter set to 50 + - Blackboard and filesystem values checked + """ + log.D(self.test_Nominal_Case.__doc__) + log.I("UINT32_Max parameter in nominal case = 50") + value = "50" + hex_value = "0x32" + #Set parameter value + out, err = self.pfw.sendCmd("setParameter", self.param_name, value) + assert err == None, log.E("when setting parameter %s : %s" + % (self.param_name, err)) + assert out == "Done", log.F("when setting parameter %s : %s" + % (self.param_name, out)) + #Check parameter value on blackboard + out, err = self.pfw.sendCmd("getParameter", self.param_name, "") + assert err == None, log.E("when setting parameter %s : %s" + % (self.param_name, err)) + assert out == value, log.F("BLACKBOARD : Incorrect value for %s, expected: %s, found: %s" + % (self.param_name, value, out)) + #Check parameter value on filesystem + assert commands.getoutput('cat $PFW_FILESYSTEM/UINT32_Max') == hex_value, log.F("FILESYSTEM : parameter update error") + log.I("test OK") + + def test_TypeMin(self): + """ + Testing UINT16 minimal value = 0 + -------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - set UINT16 parameter min value = 0 + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - UINT16 parameter set to 0 + - Blackboard and filesystem values checked + """ + log.D(self.test_TypeMin.__doc__) + log.I("UINT32_Max parameter min value = 0") + value = "0" + hex_value = "0x0" + #Set parameter value + out, err = self.pfw.sendCmd("setParameter", self.param_name, value) + assert err == None, log.E("when setting parameter %s : %s" + % (self.param_name, err)) + assert out == "Done", log.F("when setting parameter %s : %s" + % (self.param_name, out)) + #Check parameter value on blackboard + out, err = self.pfw.sendCmd("getParameter", self.param_name, "") + assert err == None, log.E("when setting parameter %s : %s" + % (self.param_name, err)) + assert out == value, log.F("BLACKBOARD : Incorrect value for %s, expected: %s, found: %s" + % (self.param_name, value, out)) + #Check parameter value on filesystem + assert commands.getoutput('cat $PFW_FILESYSTEM/UINT32_Max') == hex_value, log.F("FILESYSTEM : parameter update error") + log.I("test OK") + + def test_TypeMin_Overflow(self): + """ + Testing UINT16 parameter value out of negative range + ---------------------------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - set UINT16 to -1 + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - error detected + - UINT16 parameter not updated + - Blackboard and filesystem values checked + """ + log.D(self.test_TypeMin_Overflow.__doc__) + log.I("UINT32_Max parameter min value out of bounds = -1") + value = "-1" + param_check = commands.getoutput('cat $PFW_FILESYSTEM/UINT32_Max') + #Set parameter value + out, err = self.pfw.sendCmd("setParameter", self.param_name, value) + assert err == None, log.E("when setting parameter %s : %s" + % (self.param_name, err)) + assert out != "Done", log.F("PFW : Error not detected when setting parameter %s out of bounds" + % (self.param_name)) + #Check parameter value on filesystem + assert commands.getoutput('cat $PFW_FILESYSTEM/UINT32_Max') == param_check, log.F("FILESYSTEM : Forbiden parameter change") + log.I("test OK") + + def test_TypeMax(self): + """ + Testing UINT16 parameter maximum value + -------------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - set UINT16 to 4294967295 + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - UINT16 parameter set to 4294967295 + - Blackboard and filesystem values checked + """ + log.D(self.test_TypeMax.__doc__) + log.I("UINT32_Max parameter max value = 4294967295") + value = "4294967295" + hex_value = "0xffffffff" + #Set parameter value + out, err = self.pfw.sendCmd("setParameter", self.param_name, value) + assert err == None, log.E("when setting parameter %s : %s" + % (self.param_name, err)) + assert out == "Done", log.F("when setting parameter %s : %s" + % (self.param_name, out)) + #Check parameter value on blackboard + out, err = self.pfw.sendCmd("getParameter", self.param_name, "") + assert err == None, log.E("when setting parameter %s : %s" + % (self.param_name, err)) + assert out == value, log.F("BLACKBOARD : Incorrect value for %s, expected: %s, found: %s" + % (self.param_name, value, out)) + #Check parameter value on filesystem + assert commands.getoutput('cat $PFW_FILESYSTEM/UINT32_Max') == hex_value, log.F("FILESYSTEM : parameter update error") + log.I("test OK") + + def test_TypeMax_Overflow(self): + """ + Testing UINT16 parameter value out of positive range + ---------------------------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - set UINT16 to 4294967296 + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - error detected + - UINT16 parameter not updated + - Blackboard and filesystem values checked + """ + log.D(self.test_TypeMax_Overflow.__doc__) + log.I("UINT32_Max parameter max value out of bounds = 4294967296") + value = "4294967296" + param_check = commands.getoutput('cat $PFW_FILESYSTEM/UINT32_Max') + #Set parameter value + out, err = self.pfw.sendCmd("setParameter", self.param_name, value) + assert err == None, log.E("when setting parameter %s : %s" + % (self.param_name, err)) + assert out != "Done", log.F("PFW : Error not detected when setting parameter %s out of bounds" + % (self.param_name)) + #Check parameter value on filesystem + assert commands.getoutput('cat $PFW_FILESYSTEM/UINT32_Max') == param_check, log.F("FILESYSTEM : Forbiden parameter change") + log.I("test OK") diff --git a/test/functional-tests/PfwTestCase/Types/tUINT8.py b/test/functional-tests/PfwTestCase/Types/tUINT8.py new file mode 100644 index 0000000..d65a44e --- /dev/null +++ b/test/functional-tests/PfwTestCase/Types/tUINT8.py @@ -0,0 +1,247 @@ +#!/usr/bin/python2 +# -*-coding:utf-8 -* + +# Copyright (c) 2011-2015, Intel Corporation +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, +# are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation and/or +# other materials provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its contributors +# may be used to endorse or promote products derived from this software without +# specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +""" +Integer parameter type testcases - UINT8 + +List of tested functions : +-------------------------- + - [setParameter] function + - [getParameter] function + +Initial Settings : +------------------ + UINT8 : + - unsigned + - size = 8 + - range : [0, 100] + +Test cases : +------------ + - UINT8 parameter min value = 0 + - UINT8 parameter min value out of bounds = -1 + - UINT8 parameter max value = 100 + - UINT8 parameter max value out of bounds = 101 + - UINT8 parameter in nominal case = 50 +""" +import commands +from Util.PfwUnitTestLib import PfwTestCase +from Util import ACTLogging +log=ACTLogging.Logger() + +# Test of type UINT8 - range [0, 100] +class TestCases(PfwTestCase): + def setUp(self): + self.param_name = "/Test/Test/TEST_DIR/UINT8" + self.pfw.sendCmd("setTuningMode", "on") + + def tearDown(self): + self.pfw.sendCmd("setTuningMode", "off") + + def test_Nominal_Case(self): + """ + Testing UINT8 in nominal case = 50 + ---------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - set UINT8 parameter in nominal case = 50 + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - UINT8 parameter set to 50 + - Blackboard and filesystem values checked + """ + log.D(self.test_Nominal_Case.__doc__) + log.I("UINT8 parameter in nominal case = 50") + value = "50" + hex_value = "0x32" + #Set parameter value + out, err = self.pfw.sendCmd("setParameter", self.param_name, value) + assert err == None, log.E("when setting parameter %s : %s" + % (self.param_name, err)) + assert out == "Done", log.F("when setting parameter %s : %s" + % (self.param_name, out)) + #Check parameter value on blackboard + out, err = self.pfw.sendCmd("getParameter", self.param_name, "") + assert err == None, log.E("when setting parameter %s : %s" + % (self.param_name, err)) + assert out == value, log.F("BLACKBOARD : Incorrect value for %s, expected: %s, found: %s" + % (self.param_name, value, out)) + #Check parameter value on filesystem + assert commands.getoutput('cat $PFW_FILESYSTEM/UINT8') == hex_value, log.F("FILESYSTEM : parameter update error") + log.I("test OK") + + def test_TypeMin(self): + """ + Testing UINT8 minimal value = 0 + ------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - set UINT8 parameter min value = 0 + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - UINT8 parameter set to 0 + - Blackboard and filesystem values checked + """ + log.D(self.test_TypeMin.__doc__) + log.I("UINT8 parameter min value = 0") + value = "0" + hex_value = "0x0" + #Set parameter value + out, err = self.pfw.sendCmd("setParameter", self.param_name, value) + assert err == None, log.E("when setting parameter %s : %s" + % (self.param_name, err)) + assert out == "Done", log.F("when setting parameter %s : %s" + % (self.param_name, out)) + #Check parameter value on blackboard + out, err = self.pfw.sendCmd("getParameter", self.param_name, "") + assert err == None, log.E("when setting parameter %s : %s" + % (self.param_name, err)) + assert out == value, log.F("BLACKBOARD : Incorrect value for %s, expected: %s, found: %s" + % (self.param_name, value, out)) + #Check parameter value on filesystem + assert commands.getoutput('cat $PFW_FILESYSTEM/UINT8') == hex_value, log.F("FILESYSTEM : parameter update error") + log.I("test OK") + + def test_TypeMin_Overflow(self): + """ + Testing UINT8 parameter value out of negative range + --------------------------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - set UINT8 to -1 + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - error detected + - UINT8 parameter not updated + - Blackboard and filesystem values checked + """ + log.D(self.test_TypeMin_Overflow.__doc__) + log.I("UINT8 parameter min value out of bounds = -1") + value = "-1" + param_check = commands.getoutput('cat $PFW_FILESYSTEM/UINT8') + #Set parameter value + out, err = self.pfw.sendCmd("setParameter", self.param_name, value) + assert err == None, log.E("when setting parameter %s : %s" + % (self.param_name, err)) + assert out != "Done", log.F("PFW : Error not detected when setting parameter %s out of bounds" + % (self.param_name)) + #Check parameter value on filesystem + assert commands.getoutput('cat $PFW_FILESYSTEM/UINT8') == param_check, log.F("FILESYSTEM : Forbiden parameter change") + log.I("test OK") + + def test_TypeMax(self): + """ + Testing UINT8 parameter maximum value + ------------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - set UINT8 to 100 + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - UINT8 parameter set to 100 + - Blackboard and filesystem values checked + """ + log.D(self.test_TypeMax.__doc__) + log.I("UINT8 parameter max value = 100") + value = "100" + hex_value = "0x64" + #Set parameter value + out, err = self.pfw.sendCmd("setParameter", self.param_name, value) + assert err == None, log.E("when setting parameter %s : %s" + % (self.param_name, err)) + assert out == "Done", log.F("when setting parameter %s : %s" + % (self.param_name, out)) + #Check parameter value on blackboard + out, err = self.pfw.sendCmd("getParameter", self.param_name, "") + assert err == None, log.E("when setting parameter %s : %s" + % (self.param_name, err)) + assert out == value, log.F("BLACKBOARD : Incorrect value for %s, expected: %s, found: %s" + % (self.param_name, value, out)) + #Check parameter value on filesystem + assert commands.getoutput('cat $PFW_FILESYSTEM/UINT8') == hex_value, log.F("FILESYSTEM : parameter update error") + log.I("test OK") + + def test_TypeMax_Overflow(self): + """ + Testing UINT8 parameter value out of positive range + --------------------------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - set UINT8 to 101 + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - error detected + - UINT8 parameter not updated + - Blackboard and filesystem values checked + """ + log.D(self.test_TypeMax_Overflow.__doc__) + log.I("UINT8 parameter max value out of bounds = 101") + value = "101" + param_check = commands.getoutput('cat $PFW_FILESYSTEM/UINT8') + #Set parameter value + out, err = self.pfw.sendCmd("setParameter", self.param_name, value) + assert err == None, log.E("when setting parameter %s : %s" + % (self.param_name, err)) + assert out != "Done", log.F("PFW : Error not detected when setting parameter %s out of bounds" + % (self.param_name)) + #Check parameter value on filesystem + assert commands.getoutput('cat $PFW_FILESYSTEM/UINT8') == param_check, log.F("FILESYSTEM : Forbiden parameter change") + log.I("test OK") diff --git a/test/functional-tests/PfwTestCase/Types/tUINT8_ARRAY.py b/test/functional-tests/PfwTestCase/Types/tUINT8_ARRAY.py new file mode 100644 index 0000000..9f82a36 --- /dev/null +++ b/test/functional-tests/PfwTestCase/Types/tUINT8_ARRAY.py @@ -0,0 +1,376 @@ +#!/usr/bin/python2 +# -*-coding:utf-8 -* + +# Copyright (c) 2011-2015, Intel Corporation +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, +# are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation and/or +# other materials provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its contributors +# may be used to endorse or promote products derived from this software without +# specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +""" +Array parameter type testcases : UINT8 Array + +List of tested functions : +-------------------------- + - [setParameter] function + - [getParameter] function + +Initial Settings : +------------------ + UINT8 Array = 8bits unsigned int array : + - Array size : 5 + - values range : [0, 15] + +Test cases : +------------ + - Testing nominal case + - Testing minimum + - Testing minimum overflow + - Testing maximum + - Testing maximum overflow + - Testing array index out of bounds + - Testing value format error +""" +import commands +from Util.PfwUnitTestLib import PfwTestCase +from Util import ACTLogging +log=ACTLogging.Logger() + +from ctypes import c_uint16 + + +class TestCases(PfwTestCase): + + def setUp(self): + self.param_name = "/Test/Test/TEST_DIR/UINT8_ARRAY" + self.param_short_name = "$PFW_FILESYSTEM/UINT8_ARRAY" + print '\r' + self.pfw.sendCmd("setTuningMode", "on") + print '\r' + self.array_size = 5 + self.array_min = 0 + self.array_max = 15 + + def tearDown(self): + self.pfw.sendCmd("setTuningMode", "off") + + def test_Nominal_Case(self): + """ + Testing UINT8_ARRAY Nominal Case + -------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - Set every UINT8_ARRAY elements to autorized values + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - UINT8_ARRAY array elements correctly recorded + - Blackboard and filesystem values checked + """ + log.D(self.test_Nominal_Case.__doc__) + + for index in range (self.array_size): + indexed_array_value = index + self.array_min + if indexed_array_value>self.array_max: + indexed_array_value=self.array_max + hex_indexed_array_value = hex(c_uint16(indexed_array_value).value) + #Check parameter value setting + indexed_array_value_path = "".join([self.param_name, "/", str(index)]) + out, err = self.pfw.sendCmd("setParameter", str(indexed_array_value_path), str(indexed_array_value)) + assert err == None, log.E("when setting parameter %s[%s]: %s" + % (self.param_name, str(index), err)) + assert out == "Done", log.F("when setting parameter %s[%s]: %s" + % (self.param_name, str(index), out)) + #Check parameter value on blackboard + out, err = self.pfw.sendCmd("getParameter", str(indexed_array_value_path), "") + assert err == None, log.E("when setting parameter %s[%s] : %s" + % (self.param_name, str(index), err)) + assert out == str(indexed_array_value), log.F("BLACKBOARD : Incorrect value for %s[%s], expected: %s, found: %s" + % (self.param_name, str(index), str(indexed_array_value), out)) + #Check parameter value on filesystem + files_system_check = "awk -v ligne="+str(index)+" 'NR == ligne+1 { print $0}' "+self.param_short_name + indexed_files_system_array_value = commands.getoutput(files_system_check) + assert indexed_files_system_array_value == hex_indexed_array_value, log.F("FILESSYSTEM : %s[%s] update error" + % (self.param_name, str(index))) + + def test_Min_Value(self): + """ + Testing UINT8_ARRAY minimum value + --------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - Set every UINT8_ARRAY elements to minimum values : 0 + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - UINT8_ARRAY array elements correctly recorded + - Blackboard and filesystem values checked + """ + log.D(self.test_Min_Value.__doc__) + index = 0 + indexed_array_value = self.array_min + indexed_array_value_path = "".join([self.param_name, "/", str(index)]) + hex_indexed_array_value = hex(c_uint16(indexed_array_value).value) + #Check parameter value setting + out, err = self.pfw.sendCmd("setParameter", str(indexed_array_value_path), str(indexed_array_value)) + assert err == None, log.E("when setting parameter %s[%s]: %s" + % (self.param_name, str(index), err)) + assert out == "Done", log.E("when setting parameter %s[%s]: %s" + % (self.param_name, str(index), out)) + #Check parameter value on blackboard + out, err = self.pfw.sendCmd("getParameter", str(indexed_array_value_path), "") + assert err == None, log.E("when setting parameter %s[%s] : %s" + % (self.param_name, str(index), err)) + assert out == str(indexed_array_value), log.F("BLACKBOARD : Incorrect value for %s[%s], expected: %s, found: %s" + % (self.param_name, str(index), str(indexed_array_value), out)) + #Check parameter value on filesystem + files_system_check = "awk -v ligne="+str(index)+" 'NR == ligne+1 { print $0}' "+self.param_short_name + indexed_files_system_array_value = commands.getoutput(files_system_check) + assert indexed_files_system_array_value == hex_indexed_array_value, log.F("FILESSYSTEM : %s[%s] update error" + % (self.param_name, str(index))) + + def test_Min_Value_Overflow(self): + """ + Testing UINT8_ARRAY parameter values out of negative range + ---------------------------------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - Set every UINT8_ARRAY elements to -1 + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - UINT8_ARRAY array elements not recorded + - Error correctly detected + """ + log.D(self.test_Min_Value_Overflow.__doc__) + index = 0 + indexed_array_value = self.array_min + indexed_array_value_path = "".join([self.param_name, "/", str(index)]) + #Check initial parameter value setting + out, err = self.pfw.sendCmd("setParameter", str(indexed_array_value_path), str(indexed_array_value)) + assert err == None, log.E("when setting parameter %s[%s]: %s" + % (self.param_name, str(index), err)) + assert out == "Done", log.F("when setting parameter %s[%s]: %s" + % (self.param_name, str(index), out)) + files_system_check = "awk -v ligne="+str(index)+" 'NR == ligne+1 { print $0}' "+self.param_short_name + param_check = commands.getoutput(files_system_check) + #Check final parameter value setting + indexed_array_value = indexed_array_value - 1 + out, err = self.pfw.sendCmd("setParameter", str(indexed_array_value_path), str(indexed_array_value)) + assert err == None, log.E("when setting parameter %s[%s]: %s" + % (self.param_name, str(index), err)) + assert out != "Done", log.F("Error not detected when setting parameter %s[%s] out of bounds" + % (self.param_name, str(index))) + #Check parameter value on filesystem + indexed_files_system_array_value = commands.getoutput(files_system_check) + assert indexed_files_system_array_value == param_check, log.F("FILESSYSTEM : %s[%s] forbiden update" + % (self.param_name, str(index))) + + def test_Max_Value(self): + """ + Testing UINT8_ARRAY maximum value + --------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - Set every UINT8_ARRAY elements to maximum values : 15 + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - UINT8_ARRAY array elements correctly recorded + - Blackboard and filesystem values checked + """ + log.D(self.test_Max_Value.__doc__) + index = 0 + indexed_array_value = self.array_max + indexed_array_value_path = "".join([self.param_name, "/", str(index)]) + hex_indexed_array_value = hex(c_uint16(indexed_array_value).value) + #Check parameter value setting + out, err = self.pfw.sendCmd("setParameter", str(indexed_array_value_path), str(indexed_array_value)) + assert err == None, log.E("when setting parameter %s[%s]: %s" + % (self.param_name, str(index), err)) + assert out == "Done", log.F("when setting parameter %s[%s]: %s" + % (self.param_name, str(index), out)) + #Check parameter value on blackboard + out, err = self.pfw.sendCmd("getParameter", str(indexed_array_value_path), "") + assert err == None, log.E("when setting parameter %s[%s] : %s" + % (self.param_name, str(index), err)) + assert out == str(indexed_array_value), log.F("BLACKBOARD : Incorrect value for %s[%s], expected: %s, found: %s" + % (self.param_name, str(index), str(indexed_array_value), out)) + #Check parameter value on filesystem + files_system_check = "awk -v ligne="+str(index)+" 'NR == ligne+1 { print $0}' "+self.param_short_name + indexed_files_system_array_value = commands.getoutput(files_system_check) + assert indexed_files_system_array_value == hex_indexed_array_value, log.F("FILESSYSTEM : %s[%s] update error" + % (self.param_name, str(index))) + + def test_Max_Value_Overflow(self): + """ + Testing UINT8_ARRAY parameter values out of positive range + ---------------------------------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - Set every UINT8_ARRAY elements to 16 + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - UINT8_ARRAY array elements not recorded + - Error correctly detected + """ + log.D(self.test_Max_Value_Overflow.__doc__) + index = 0 + indexed_array_value = self.array_max + indexed_array_value_path = "".join([self.param_name, "/", str(index)]) + #Check initial parameter value setting + out, err = self.pfw.sendCmd("setParameter", str(indexed_array_value_path), str(indexed_array_value)) + assert err == None, log.E("when setting parameter %s[%s]: %s" + % (self.param_name, str(index), err)) + assert out == "Done", log.F("when setting parameter %s[%s]: %s" + % (self.param_name, str(index), out)) + files_system_check = "awk -v ligne="+str(index)+" 'NR == ligne+1 { print $0}' "+self.param_short_name + param_check = commands.getoutput(files_system_check) + #Check final parameter value setting + indexed_array_value = indexed_array_value + 1 + out, err = self.pfw.sendCmd("setParameter", str(indexed_array_value_path), str(indexed_array_value)) + assert err == None, log.E("when setting parameter %s[%s]: %s" + % (self.param_name, str(index), err)) + assert out != "Done", log.F("Error not detected when setting parameter %s[%s] out of bounds" + % (self.param_name, str(index))) + #Check parameter value on filesystem + indexed_files_system_array_value = commands.getoutput(files_system_check) + assert indexed_files_system_array_value == param_check, log.F("FILESSYSTEM : %s[%s] forbiden update" + % (self.param_name, str(index))) + + def test_Array_Index_Overflow(self): + """ + Testing Array index out of bounds + --------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - Set an out of bounds array indexed element + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - UINT8_ARRAY array elements not recorded + - Error correctly detected + """ + log.D(self.test_Array_Index_Overflow.__doc__) + index_values = (self.array_size-1, self.array_size+1, -1) + for index in index_values: + print index + indexed_array_value = self.array_max + indexed_array_value_path = "".join([self.param_name, "/", str(index)]) + #Check parameter value setting + out, err = self.pfw.sendCmd("setParameter", str(indexed_array_value_path), str(indexed_array_value)) + if index in [0, self.array_size-1]: + assert err == None, log.E("when setting parameter %s[%s]: %s" + % (self.param_name, str(index), err)) + assert out == "Done", log.F("when setting parameter %s[%s]: %s" + % (self.param_name, str(index), out)) + else: + assert err == None, log.E("when setting parameter %s[%s]: %s" + % (self.param_name, str(index), err)) + assert out != "Done", log.F("Error not detected when setting array %s index out of bounds" + % (self.param_name)) + + def test_Value_Format_Error(self): + """ + Testing Array value format error + -------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - Trying to write an int16 into an 8 bits array element + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - UINT8_ARRAY array elements not recorded + - Error correctly detected + """ + log.D(self.test_Value_Format_Error.__doc__) + index = 0 + var_uint16 = c_uint16(5).value + indexed_array_value_1 = 0 + indexed_array_value_2 = 10 + indexed_array_value_path_1 = "".join([self.param_name, "/", str(index)]) + indexed_array_value_path_2 = "".join([self.param_name, "/", str(index+1)]) + #Check initial parameter value setting + out, err = self.pfw.sendCmd("setParameter", str(indexed_array_value_path_1), str(indexed_array_value_1)) + assert err == None, log.E("when setting parameter %s[%s]: %s" + % (self.param_name, str(index), err)) + assert out == "Done", log.F("when setting parameter %s[%s]: %s" + % (self.param_name, str(index), out)) + out, err = self.pfw.sendCmd("setParameter", str(indexed_array_value_path_2), str(indexed_array_value_2)) + assert err == None, log.E("when setting parameter %s[%s]: %s" + % (self.param_name, str(index+1), err)) + assert out == "Done", log.F("when setting parameter %s[%s]: %s" + % (self.param_name, str(index+1), out)) + files_system_check_1 = "awk -v ligne="+str(index)+" 'NR == ligne+1 { print $0}' "+self.param_short_name + param_check_1 = commands.getoutput(files_system_check_1) + files_system_check_2 = "awk -v ligne="+str(index+1)+" 'NR == ligne+1 { print $0}' "+self.param_short_name + param_check_2 = commands.getoutput(files_system_check_2) + #Check final parameter value setting (!= or == ?) + out, err = self.pfw.sendCmd("setParameter", str(indexed_array_value_path_1), str(var_uint16)) + assert err == None, log.E("Error when setting parameter %s[%s]: %s" + % (self.param_name, str(index), err)) + ### TBC : check expected result ### + assert out == "Done", log.F("Error not detected when setting parameter %s[%s] out of bounds" + % (self.param_name, str(index))) + #Check parameter value on filesystem + indexed_files_system_array_value_2 = commands.getoutput(files_system_check_2) + assert indexed_files_system_array_value_2 == param_check_2, log.F("FILESSYSTEM : %s[%s] forbiden update" + % (self.param_name, str(index))) diff --git a/test/functional-tests/PfwTestCase/Types/tUINT8_Max.py b/test/functional-tests/PfwTestCase/Types/tUINT8_Max.py new file mode 100644 index 0000000..1d6b47a --- /dev/null +++ b/test/functional-tests/PfwTestCase/Types/tUINT8_Max.py @@ -0,0 +1,248 @@ +#!/usr/bin/python2 +# -*-coding:utf-8 -* + +# Copyright (c) 2011-2015, Intel Corporation +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, +# are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation and/or +# other materials provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its contributors +# may be used to endorse or promote products derived from this software without +# specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +""" +Integer parameter type testcases - UINT8_Max + +List of tested functions : +-------------------------- + - [setParameter] function + - [getParameter] function + +Initial Settings : +------------------ + UINT8_Max : + - unsigned + - size = 8 + - range : [0, 255] + +Test cases : +------------ + - UINT8_Max parameter min value = 0 + - UINT8_Max parameter min value out of bounds = -1 + - UINT8_Max parameter max value = 255 + - UINT8_Max parameter max value out of bounds = 256 + - UINT8_Max parameter in nominal case = 50 +""" +import commands +from Util.PfwUnitTestLib import PfwTestCase +from Util import ACTLogging +log=ACTLogging.Logger() + + +# Test of type UINT8_Max - range [0, 255] +class TestCases(PfwTestCase): + def setUp(self): + self.param_name = "/Test/Test/TEST_DIR/UINT8_Max" + self.pfw.sendCmd("setTuningMode", "on") + + def tearDown(self): + self.pfw.sendCmd("setTuningMode", "off") + + def test_Nominal_Case(self): + """ + Testing UINT8_Max in nominal case = 50 + -------------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - set UINT8_Max parameter in nominal case = 50 + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - UINT8_Max parameter set to 50 + - Blackboard and filesystem values checked + """ + log.D(self.test_Nominal_Case.__doc__) + log.I("UINT8_Max parameter in nominal case = 50") + value = "50" + hex_value = "0x32" + #Set parameter value + out, err = self.pfw.sendCmd("setParameter", self.param_name, value) + assert err == None, log.E("when setting parameter %s : %s" + % (self.param_name, err)) + assert out == "Done", log.F("when setting parameter %s : %s" + % (self.param_name, out)) + #Check parameter value on blackboard + out, err = self.pfw.sendCmd("getParameter", self.param_name, "") + assert err == None, log.E("when setting parameter %s : %s" + % (self.param_name, err)) + assert out == value, log.F("BLACKBOARD : Incorrect value for %s, expected: %s, found: %s" + % (self.param_name, value, out)) + #Check parameter value on filesystem + assert commands.getoutput('cat $PFW_FILESYSTEM/UINT8_Max') == hex_value, log.F("FILESYSTEM : parameter update error") + log.I("test OK") + + def test_TypeMin(self): + """ + Testing UINT8_Max minimal value = 0 + ----------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - set UINT8_Max parameter min value = 0 + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - UINT8_Max parameter set to 0 + - Blackboard and filesystem values checked + """ + log.D(self.test_TypeMin.__doc__) + log.I("UINT8_Max parameter min value = 0") + value = "0" + hex_value = "0x0" + #Set parameter value + out, err = self.pfw.sendCmd("setParameter", self.param_name, value) + assert err == None, log.E("when setting parameter %s : %s" + % (self.param_name, err)) + assert out == "Done", log.F("when setting parameter %s : %s" + % (self.param_name, out)) + #Check parameter value on blackboard + out, err = self.pfw.sendCmd("getParameter", self.param_name, "") + assert err == None, log.E("when setting parameter %s : %s" + % (self.param_name, err)) + assert out == value, log.F("BLACKBOARD : Incorrect value for %s, expected: %s, found: %s" + % (self.param_name, value, out)) + #Check parameter value on filesystem + assert commands.getoutput('cat $PFW_FILESYSTEM/UINT8_Max') == hex_value, log.F("FILESYSTEM : parameter update error") + log.I("test OK") + + def test_TypeMin_Overflow(self): + """ + Testing UINT8_Max parameter value out of negative range + ------------------------------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - set UINT8_Max to -1 + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - error detected + - UINT8_Max parameter not updated + - Blackboard and filesystem values checked + """ + log.D(self.test_TypeMin_Overflow.__doc__) + log.I("UINT8_Max parameter min value out of bounds = -1") + value = "-1" + param_check = commands.getoutput('cat $PFW_FILESYSTEM/UINT8_Max') + #Set parameter value + out, err = self.pfw.sendCmd("setParameter", self.param_name, value) + assert err == None, log.E("when setting parameter %s : %s" + % (self.param_name, err)) + assert out != "Done", log.F("PFW : Error not detected when setting parameter %s out of bounds" + % (self.param_name)) + #Check parameter value on filesystem + assert commands.getoutput('cat $PFW_FILESYSTEM/UINT8_Max') == param_check, log.F("FILESYSTEM : Forbiden parameter change") + log.I("test OK") + + def test_TypeMax(self): + """ + Testing UINT8_Max parameter maximum value + ----------------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - set UINT8_Max to 255 + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - UINT8_Max parameter set to 255 + - Blackboard and filesystem values checked + """ + log.D(self.test_TypeMax.__doc__) + log.I("UINT8_Max parameter max value = 255") + value = "255" + hex_value = "0xff" + #Set parameter value + out, err = self.pfw.sendCmd("setParameter", self.param_name, value) + assert err == None, log.E("when setting parameter %s : %s" + % (self.param_name, err)) + assert out == "Done", log.F("when setting parameter %s : %s" + % (self.param_name, out)) + #Check parameter value on blackboard + out, err = self.pfw.sendCmd("getParameter", self.param_name, "") + assert err == None, log.E("when setting parameter %s : %s" + % (self.param_name, err)) + assert out == value, log.F("BLACKBOARD : Incorrect value for %s, expected: %s, found: %s" + % (self.param_name, value, out)) + #Check parameter value on filesystem + assert commands.getoutput('cat $PFW_FILESYSTEM/UINT8_Max') == hex_value, log.F("FILESYSTEM : parameter update error") + log.I("test OK") + + def test_TypeMax_Overflow(self): + """ + Testing UINT8_Max parameter value out of positive range + ------------------------------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - set UINT8_Max to 256 + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - error detected + - UINT8_Max parameter not updated + - Blackboard and filesystem values checked + """ + log.D(self.test_TypeMax_Overflow.__doc__) + log.I("UINT8_Max parameter max value out of bounds = 256") + value = "256" + param_check = commands.getoutput('cat $PFW_FILESYSTEM/UINT8_Max') + #Set parameter value + out, err = self.pfw.sendCmd("setParameter", self.param_name, value) + assert err == None, log.E("when setting parameter %s : %s" + % (self.param_name, err)) + assert out != "Done", log.F("PFW : Error not detected when setting parameter %s out of bounds" + % (self.param_name)) + #Check parameter value on filesystem + assert commands.getoutput('cat $PFW_FILESYSTEM/UINT8_Max') == param_check, log.F("FILESYSTEM : Forbiden parameter change") + log.I("test OK") diff --git a/test/functional-tests/PfwTestCase/__init__.py b/test/functional-tests/PfwTestCase/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/test/functional-tests/PfwTestCase/__init__.py diff --git a/test/functional-tests/Util/ACTLogging.py b/test/functional-tests/Util/ACTLogging.py new file mode 100644 index 0000000..fdc71ef --- /dev/null +++ b/test/functional-tests/Util/ACTLogging.py @@ -0,0 +1,48 @@ +# -*-coding:utf-8 -* + +# Copyright (c) 2011-2015, Intel Corporation +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, +# are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation and/or +# other materials provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its contributors +# may be used to endorse or promote products derived from this software without +# specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +class Logger(object) : + def E(self, string): + print "\nERROR: %s\n" % (string) + return "ERROR: %s" % (string) + + def F(self, string): + print "\nFAIL : %s\n" % (string) + return "FAIL : %s" % (string) + + def I(self, string): + print "INFO : %s" % (string) + return "INFO : %s" % (string) + + def D(self, string): + print "\n======================================================================" + print "%s" %(string) + print "======================================================================" + return string diff --git a/test/functional-tests/Util/PfwUnitTestLib.py b/test/functional-tests/Util/PfwUnitTestLib.py new file mode 100644 index 0000000..d9c2f8c --- /dev/null +++ b/test/functional-tests/Util/PfwUnitTestLib.py @@ -0,0 +1,110 @@ +# -*-coding:utf-8 -* + +# Copyright (c) 2011-2015, Intel Corporation +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, +# are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation and/or +# other materials provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its contributors +# may be used to endorse or promote products derived from this software without +# specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +import subprocess +import unittest +import time + +class RemoteCli(object): + def sendCmd(self, cmd, *args): + shell_cmd = " ".join([self.platform_command, cmd]) + if args is not None: + shell_cmd += " " + " ".join(args) + print "CMD :", + print "[" + shell_cmd + "]" + try: + p = subprocess.Popen(shell_cmd, shell=True, stdout=subprocess.PIPE) + except Exception as (errno, strerror): + return None, strerror + out, err = p.communicate() + if out is not None: + out = out.strip() + return out, err + +class Pfw(RemoteCli): + def __init__(self): + self.platform_command = "remote-process localhost 5000 " + +class Hal(RemoteCli): + def __init__(self): + self.platform_command = "remote-process localhost 5001 " + + # Starts the HAL exe + def startHal(self): + cmd= "test-platform $PFW_TEST_CONFIGURATION" + subprocess.Popen(cmd, shell=True) + pass + + # Send command "stop" to the HAL + def stopHal(self): + subprocess.call("remote-process localhost 5001 exit", shell=True) + + def createInclusiveCriterion(self, name, nb): + self.sendCmd("createInclusiveSelectionCriterion", name, nb) + + def createExclusiveCriterion(self, name, nb): + self.sendCmd("createExclusiveSelectionCriterion", name, nb) + + # Starts the Pfw + def start(self): + self.sendCmd("start") + +# A PfwTestCase gather tests performed on one instance of the PFW. +class PfwTestCase(unittest.TestCase): + + hal = Hal() + + def __init__(self, argv): + super(PfwTestCase, self).__init__(argv) + self.pfw = Pfw() + + @classmethod + def setUpClass(cls): + cls.startHal() + + @classmethod + def tearDownClass(cls): + cls.stopHal() + + @classmethod + def startHal(cls): + # set up the Hal & pfw + cls.hal.startHal() + time.sleep(0.1) + # create criterions + cls.hal.createInclusiveCriterion("Crit_0", "2") + cls.hal.createExclusiveCriterion("Crit_1", "2") + # start the Pfw + cls.hal.start() + + @classmethod + def stopHal(cls): + cls.hal.stopHal() + time.sleep(0.1) diff --git a/test/functional-tests/Util/__init__.py b/test/functional-tests/Util/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/test/functional-tests/Util/__init__.py diff --git a/test/functional-tests/xml/TestConfigurableDomains.xml b/test/functional-tests/xml/TestConfigurableDomains.xml new file mode 100644 index 0000000..fdc77e1 --- /dev/null +++ b/test/functional-tests/xml/TestConfigurableDomains.xml @@ -0,0 +1,141 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ConfigurableDomains xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="/home/lab/ICS/hardware/intel/PRIVATE/parameter-framework/test/configuration/Schemas/ConfigurableDomains.xsd" SystemClassName="Test"> + <ConfigurableDomain Name="Domain_0"> + <Configurations> + <Configuration Name="Conf_0"> + <CompoundRule Type="All"> + <SelectionCriterionRule SelectionCriterion="Crit_0" MatchesWhen="Includes" Value="State_0x1"/> + <SelectionCriterionRule SelectionCriterion="Crit_1" MatchesWhen="Is" Value="State_1"/> + </CompoundRule> + </Configuration> + <Configuration Name="Conf_1"> + <CompoundRule Type="Any"> + <SelectionCriterionRule SelectionCriterion="Crit_0" MatchesWhen="Includes" Value="State_0x2"/> + <SelectionCriterionRule SelectionCriterion="Crit_1" MatchesWhen="IsNot" Value="State_1"/> + </CompoundRule> + </Configuration> + </Configurations> + + <ConfigurableElements> + <ConfigurableElement Path="/Test/Test/TEST_DIR" /> + <ConfigurableElement Path="/Test/Test/TEST_TYPES" /> + </ConfigurableElements> + + <Settings> + <Configuration Name="Conf_0"> + <ConfigurableElement Path="/Test/Test/TEST_DIR"> + <Component Name="TEST_DIR"> + <!-- Tested Booleans --> + <BooleanParameter Name="BOOL">0</BooleanParameter> + <!-- Tested FixedPoints --> + <FixedPointParameter Name="FP8_Q0.7">0</FixedPointParameter> + <FixedPointParameter Name="FP8_Q7.0">0</FixedPointParameter> + <FixedPointParameter Name="FP8_Q3.4">0</FixedPointParameter> + <FixedPointParameter Name="FP16_Q0.15">0</FixedPointParameter> + <FixedPointParameter Name="FP16_Q15.0">0</FixedPointParameter> + <FixedPointParameter Name="FP16_Q7.8">0</FixedPointParameter> + <FixedPointParameter Name="FP32_Q0.31">0</FixedPointParameter> + <FixedPointParameter Name="FP32_Q31.0">0</FixedPointParameter> + <FixedPointParameter Name="FP32_Q15.16">0</FixedPointParameter> + <FixedPointParameter Name="FP32_Q8.20">0</FixedPointParameter> + <!-- Tested Integers --> + <IntegerParameter Name="UINT32">0</IntegerParameter> + <IntegerParameter Name="INT32">0</IntegerParameter> + <IntegerParameter Name="UINT32_Max">0</IntegerParameter> + <IntegerParameter Name="INT32_Max">0</IntegerParameter> + <IntegerParameter Name="UINT16">0</IntegerParameter> + <IntegerParameter Name="INT16">0</IntegerParameter> + <IntegerParameter Name="UINT16_Max">0</IntegerParameter> + <IntegerParameter Name="INT16_Max">0</IntegerParameter> + <IntegerParameter Name="UINT8">0</IntegerParameter> + <IntegerParameter Name="INT8">0</IntegerParameter> + <IntegerParameter Name="UINT8_Max">0</IntegerParameter> + <IntegerParameter Name="INT8_Max">0</IntegerParameter> + <!-- Tested Arrays --> + <IntegerParameter Name="UINT32_ARRAY">0</IntegerParameter> + <IntegerParameter Name="INT16_ARRAY">0</IntegerParameter> + <IntegerParameter Name="UINT8_ARRAY">0</IntegerParameter> + <IntegerParameter Name="UINT8_Max_ARRAY">0</IntegerParameter> + <!-- Tested String--> + <StringParameter Name="STR_CHAR128">string_Conf_0</StringParameter> + </Component> + </ConfigurableElement> + <ConfigurableElement Path="/Test/Test/TEST_TYPES"> + <Component Name="TEST_TYPES"> + <EnumParameter Name="ENUM">ENUM_NOMINAL</EnumParameter> + <BitParameterBlock Name="BLOCK_8BIT"> + <BitParameter Name="BIT_0_3">0</BitParameter> + <BitParameter Name="BIT_3_1">0</BitParameter> + <BitParameter Name="BIT_4_1">0</BitParameter> + <BitParameter Name="BIT_6_2">0</BitParameter> + <BitParameter Name="BIT_7_1">0</BitParameter> + </BitParameterBlock> + <ParameterBlock Name="BLOCK_PARAMETER"> + <IntegerParameter Name="UINT8">0</IntegerParameter> + <IntegerParameter Name="UINT16">0</IntegerParameter> + <IntegerParameter Name="UINT32">0</IntegerParameter> + </ParameterBlock> + </Component> + </ConfigurableElement> + </Configuration> + <Configuration Name="Conf_1"> + <ConfigurableElement Path="/Test/Test/TEST_DIR"> + <Component Name="TEST_DIR"> + <!-- Tested Booleans --> + <BooleanParameter Name="BOOL">1</BooleanParameter> + <!-- Tested FixedPoints --> + <FixedPointParameter Name="FP8_Q0.7">0.9</FixedPointParameter> + <FixedPointParameter Name="FP8_Q7.0">1</FixedPointParameter> + <FixedPointParameter Name="FP8_Q3.4">1</FixedPointParameter> + <FixedPointParameter Name="FP16_Q0.15">0.9</FixedPointParameter> + <FixedPointParameter Name="FP16_Q15.0">1</FixedPointParameter> + <FixedPointParameter Name="FP16_Q7.8">1</FixedPointParameter> + <FixedPointParameter Name="FP32_Q0.31">0.9</FixedPointParameter> + <FixedPointParameter Name="FP32_Q31.0">1</FixedPointParameter> + <FixedPointParameter Name="FP32_Q15.16">1</FixedPointParameter> + <FixedPointParameter Name="FP32_Q8.20">1</FixedPointParameter> + <!-- Tested Integers --> + <IntegerParameter Name="UINT32">1</IntegerParameter> + <IntegerParameter Name="INT32">1</IntegerParameter> + <IntegerParameter Name="UINT32_Max">1</IntegerParameter> + <IntegerParameter Name="INT32_Max">1</IntegerParameter> + <IntegerParameter Name="UINT16">1</IntegerParameter> + <IntegerParameter Name="INT16">1</IntegerParameter> + <IntegerParameter Name="UINT16_Max">1</IntegerParameter> + <IntegerParameter Name="INT16_Max">1</IntegerParameter> + <IntegerParameter Name="UINT8">1</IntegerParameter> + <IntegerParameter Name="INT8">1</IntegerParameter> + <IntegerParameter Name="UINT8_Max">1</IntegerParameter> + <IntegerParameter Name="INT8_Max">1</IntegerParameter> + <!-- Tested Arrays --> + <IntegerParameter Name="UINT32_ARRAY">1</IntegerParameter> + <IntegerParameter Name="INT16_ARRAY">1</IntegerParameter> + <IntegerParameter Name="UINT8_ARRAY">1</IntegerParameter> + <IntegerParameter Name="UINT8_Max_ARRAY">1</IntegerParameter> + <!-- Tested String--> + <StringParameter Name="STR_CHAR128">string_Conf_1</StringParameter> + </Component> + </ConfigurableElement> + <ConfigurableElement Path="/Test/Test/TEST_TYPES"> + <Component Name="TEST_TYPES"> + <!--Tested Enum--> + <EnumParameter Name="ENUM">ENUM_MIN</EnumParameter> + <!--Tested Bit parameter block--> + <BitParameterBlock Name="BLOCK_8BIT"> + <BitParameter Name="BIT_0_3">0</BitParameter> + <BitParameter Name="BIT_3_1">0</BitParameter> + <BitParameter Name="BIT_4_1">0</BitParameter> + <BitParameter Name="BIT_6_2">0</BitParameter> + <BitParameter Name="BIT_7_1">0</BitParameter> + </BitParameterBlock> + <ParameterBlock Name="BLOCK_PARAMETER"> + <IntegerParameter Name="UINT8">0</IntegerParameter> + <IntegerParameter Name="UINT16">0</IntegerParameter> + <IntegerParameter Name="UINT32">0</IntegerParameter> + </ParameterBlock> + </Component> + </ConfigurableElement> + </Configuration> + </Settings> + </ConfigurableDomain> +</ConfigurableDomains> diff --git a/test/functional-tests/xml/XML_Test/Reference_Compliant.xml b/test/functional-tests/xml/XML_Test/Reference_Compliant.xml new file mode 100644 index 0000000..48b1720 --- /dev/null +++ b/test/functional-tests/xml/XML_Test/Reference_Compliant.xml @@ -0,0 +1,182 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ConfigurableDomains xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="/home/lab/ICS/hardware/intel/PRIVATE/parameter-framework/test/configuration/Schemas/ConfigurableDomains.xsd" SystemClassName="Test"> + <ConfigurableDomain Name="Domain_1"> + <Configurations> + <Configuration Name="Conf_1_0"> + <CompoundRule Type="All"> + <SelectionCriterionRule SelectionCriterion="Crit_0" MatchesWhen="Includes" Value="State_0x1"/> + <SelectionCriterionRule SelectionCriterion="Crit_1" MatchesWhen="Is" Value="State_1"/> + </CompoundRule> + </Configuration> + <Configuration Name="Conf_1_1"> + <CompoundRule Type="Any"> + <SelectionCriterionRule SelectionCriterion="Crit_0" MatchesWhen="Includes" Value="State_0x2"/> + <SelectionCriterionRule SelectionCriterion="Crit_1" MatchesWhen="IsNot" Value="State_1"/> + </CompoundRule> + </Configuration> + </Configurations> + <ConfigurableElements> + <ConfigurableElement Path="/Test/Test/TEST_DIR" /> + </ConfigurableElements> + <Settings> + <Configuration Name="Conf_1_1"> + <ConfigurableElement Path="/Test/Test/TEST_DIR"> + <Component Name="TEST_DIR"> + <!-- Tested Booleans --> + <BooleanParameter Name="BOOL">0</BooleanParameter> + <!-- Tested FixedPoints --> + <FixedPointParameter Name="FP8_Q0.7">0.1</FixedPointParameter> + <FixedPointParameter Name="FP8_Q7.0">2</FixedPointParameter> + <FixedPointParameter Name="FP8_Q3.4">2.1</FixedPointParameter> + <FixedPointParameter Name="FP16_Q0.15">0.1</FixedPointParameter> + <FixedPointParameter Name="FP16_Q15.0">2</FixedPointParameter> + <FixedPointParameter Name="FP16_Q7.8">2</FixedPointParameter> + <FixedPointParameter Name="FP32_Q0.31">0.1</FixedPointParameter> + <FixedPointParameter Name="FP32_Q31.0">2</FixedPointParameter> + <FixedPointParameter Name="FP32_Q15.16">2.1</FixedPointParameter> + <FixedPointParameter Name="FP32_Q8.20">2.1</FixedPointParameter> + <!-- Tested Integers --> + <IntegerParameter Name="UINT32">0</IntegerParameter> + <IntegerParameter Name="INT32">0</IntegerParameter> + <IntegerParameter Name="UINT32_Max">0</IntegerParameter> + <IntegerParameter Name="INT32_Max">0</IntegerParameter> + <IntegerParameter Name="UINT16">0</IntegerParameter> + <IntegerParameter Name="INT16">0</IntegerParameter> + <IntegerParameter Name="UINT16_Max">0</IntegerParameter> + <IntegerParameter Name="INT16_Max">0</IntegerParameter> + <IntegerParameter Name="UINT8">0</IntegerParameter> + <IntegerParameter Name="INT8">0</IntegerParameter> + <IntegerParameter Name="UINT8_Max">0</IntegerParameter> + <IntegerParameter Name="INT8_Max">0</IntegerParameter> + <!-- Tested Arrays --> + <IntegerParameter Name="UINT32_ARRAY">0</IntegerParameter> + <IntegerParameter Name="INT16_ARRAY">0</IntegerParameter> + <IntegerParameter Name="UINT8_ARRAY">0</IntegerParameter> + <IntegerParameter Name="UINT8_Max_ARRAY">0</IntegerParameter> + <!-- Tested String--> + <StringParameter Name="STR_CHAR128">string_Conf_1_1</StringParameter> + </Component> + </ConfigurableElement> + </Configuration> + <Configuration Name="Conf_1_0"> + <ConfigurableElement Path="/Test/Test/TEST_DIR"> + <Component Name="TEST_DIR"> + <!-- Tested Booleans --> + <BooleanParameter Name="BOOL">1</BooleanParameter> + <!-- Tested FixedPoints --> + <FixedPointParameter Name="FP8_Q0.7">0.2</FixedPointParameter> + <FixedPointParameter Name="FP8_Q7.0">1</FixedPointParameter> + <FixedPointParameter Name="FP8_Q3.4">1.2</FixedPointParameter> + <FixedPointParameter Name="FP16_Q0.15">0.2</FixedPointParameter> + <FixedPointParameter Name="FP16_Q15.0">1</FixedPointParameter> + <FixedPointParameter Name="FP16_Q7.8">1.2</FixedPointParameter> + <FixedPointParameter Name="FP32_Q0.31">0.2</FixedPointParameter> + <FixedPointParameter Name="FP32_Q31.0">1</FixedPointParameter> + <FixedPointParameter Name="FP32_Q15.16">1.2</FixedPointParameter> + <FixedPointParameter Name="FP32_Q8.20">1.2</FixedPointParameter> + <!-- Tested Integers --> + <IntegerParameter Name="UINT32">1</IntegerParameter> + <IntegerParameter Name="INT32">-1</IntegerParameter> + <IntegerParameter Name="UINT32_Max">1</IntegerParameter> + <IntegerParameter Name="INT32_Max">-1</IntegerParameter> + <IntegerParameter Name="UINT16">1</IntegerParameter> + <IntegerParameter Name="INT16">-1</IntegerParameter> + <IntegerParameter Name="UINT16_Max">1</IntegerParameter> + <IntegerParameter Name="INT16_Max">-1</IntegerParameter> + <IntegerParameter Name="UINT8">1</IntegerParameter> + <IntegerParameter Name="INT8">-1</IntegerParameter> + <IntegerParameter Name="UINT8_Max">1</IntegerParameter> + <IntegerParameter Name="INT8_Max">-1</IntegerParameter> + <!-- Tested Arrays --> + <IntegerParameter Name="UINT32_ARRAY">1</IntegerParameter> + <IntegerParameter Name="INT16_ARRAY">-1</IntegerParameter> + <IntegerParameter Name="UINT8_ARRAY">1</IntegerParameter> + <IntegerParameter Name="UINT8_Max_ARRAY">1</IntegerParameter> + <!-- Tested String--> + <StringParameter Name="STR_CHAR128">string_Conf_1_0</StringParameter> + </Component> + </ConfigurableElement> + </Configuration> + </Settings> + </ConfigurableDomain> + + <ConfigurableDomain Name="Domain_2"> + <Configurations> + <Configuration Name="Conf_2_0"> + <CompoundRule Type="All"> + <SelectionCriterionRule SelectionCriterion="Crit_0" MatchesWhen="Includes" Value="State_0x1"/> + <SelectionCriterionRule SelectionCriterion="Crit_1" MatchesWhen="Is" Value="State_1"/> + </CompoundRule> + </Configuration> + <Configuration Name="Conf_2_1"> + <CompoundRule Type="Any"> + <SelectionCriterionRule SelectionCriterion="Crit_0" MatchesWhen="Includes" Value="State_0x2"/> + <SelectionCriterionRule SelectionCriterion="Crit_1" MatchesWhen="IsNot" Value="State_1"/> + </CompoundRule> + </Configuration> + </Configurations> + <ConfigurableElements> + <ConfigurableElement Path="/Test/Test/TEST_DOMAIN_0" /> + </ConfigurableElements> + <Settings> + <Configuration Name="Conf_2_1"> + <ConfigurableElement Path="/Test/Test/TEST_DOMAIN_0"> + <Component Name="TEST_DOMAIN_0"> + <IntegerParameter Name="Param_00">4</IntegerParameter> + <IntegerParameter Name="Param_01">4</IntegerParameter> + <IntegerParameter Name="Param_02">4</IntegerParameter> + </Component> + </ConfigurableElement> + </Configuration> + <Configuration Name="Conf_2_0"> + <ConfigurableElement Path="/Test/Test/TEST_DOMAIN_0"> + <Component Name="TEST_DOMAIN_0"> + <IntegerParameter Name="Param_00">5</IntegerParameter> + <IntegerParameter Name="Param_01">5</IntegerParameter> + <IntegerParameter Name="Param_02">5</IntegerParameter> + </Component> + </ConfigurableElement> + </Configuration> + </Settings> + </ConfigurableDomain> + + <ConfigurableDomain Name="Domain_3"> + <Configurations> + <Configuration Name="Conf_3_0"> + <CompoundRule Type="All"> + <SelectionCriterionRule SelectionCriterion="Crit_0" MatchesWhen="Includes" Value="State_0x1"/> + <SelectionCriterionRule SelectionCriterion="Crit_1" MatchesWhen="Is" Value="State_1"/> + </CompoundRule> + </Configuration> + <Configuration Name="Conf_3_1"> + <CompoundRule Type="Any"> + <SelectionCriterionRule SelectionCriterion="Crit_0" MatchesWhen="Includes" Value="State_0x2"/> + <SelectionCriterionRule SelectionCriterion="Crit_1" MatchesWhen="IsNot" Value="State_1"/> + </CompoundRule> + </Configuration> + </Configurations> + <ConfigurableElements> + <ConfigurableElement Path="/Test/Test/TEST_DOMAIN_1" /> + </ConfigurableElements> + <Settings> + <Configuration Name="Conf_3_1"> + <ConfigurableElement Path="/Test/Test/TEST_DOMAIN_1"> + <Component Name="TEST_DOMAIN_1"> + <IntegerParameter Name="Param_10">4</IntegerParameter> + <IntegerParameter Name="Param_11">4</IntegerParameter> + <IntegerParameter Name="Param_12">4</IntegerParameter> + </Component> + </ConfigurableElement> + </Configuration> + <Configuration Name="Conf_3_0"> + <ConfigurableElement Path="/Test/Test/TEST_DOMAIN_1"> + <Component Name="TEST_DOMAIN_1"> + <IntegerParameter Name="Param_10">5</IntegerParameter> + <IntegerParameter Name="Param_11">5</IntegerParameter> + <IntegerParameter Name="Param_12">5</IntegerParameter> + </Component> + </ConfigurableElement> + </Configuration> + </Settings> + </ConfigurableDomain> +</ConfigurableDomains> diff --git a/test/functional-tests/xml/XML_Test/Reference_Criteria.xml b/test/functional-tests/xml/XML_Test/Reference_Criteria.xml new file mode 100644 index 0000000..76664e2 --- /dev/null +++ b/test/functional-tests/xml/XML_Test/Reference_Criteria.xml @@ -0,0 +1,182 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ConfigurableDomains xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../Schemas/ConfigurableDomains.xsd" SystemClassName="Test"> + <ConfigurableDomain Name="Domain_1"> + <Configurations> + <Configuration Name="Conf_1_0"> + <CompoundRule Type="All"> + <SelectionCriterionRule SelectionCriterion="Crit_0" MatchesWhen="Includes" Value="State_0x1"/> + <SelectionCriterionRule SelectionCriterion="Crit_1" MatchesWhen="Is" Value="State_1"/> + </CompoundRule> + </Configuration> + <Configuration Name="Conf_1_1"> + <CompoundRule Type="Any"> + <SelectionCriterionRule SelectionCriterion="Crit_0" MatchesWhen="Excludes" Value="State_0x1"/> + <SelectionCriterionRule SelectionCriterion="Crit_1" MatchesWhen="IsNot" Value="State_1"/> + </CompoundRule> + </Configuration> + </Configurations> + <ConfigurableElements> + <ConfigurableElement Path="/Test/Test/TEST_DIR" /> + </ConfigurableElements> + <Settings> + <Configuration Name="Conf_1_1"> + <ConfigurableElement Path="/Test/Test/TEST_DIR"> + <Component Name="TEST_DIR"> + <!-- Tested Booleans --> + <BooleanParameter Name="BOOL">0</BooleanParameter> + <!-- Tested FixedPoints --> + <FixedPointParameter Name="FP8_Q0.7">0.1</FixedPointParameter> + <FixedPointParameter Name="FP8_Q7.0">1</FixedPointParameter> + <FixedPointParameter Name="FP8_Q3.4">0.1</FixedPointParameter> + <FixedPointParameter Name="FP16_Q0.15">0.1</FixedPointParameter> + <FixedPointParameter Name="FP16_Q15.0">1</FixedPointParameter> + <FixedPointParameter Name="FP16_Q7.8">0.1</FixedPointParameter> + <FixedPointParameter Name="FP32_Q0.31">0.1</FixedPointParameter> + <FixedPointParameter Name="FP32_Q31.0">1</FixedPointParameter> + <FixedPointParameter Name="FP32_Q15.16">0.1</FixedPointParameter> + <FixedPointParameter Name="FP32_Q8.20">0.1</FixedPointParameter> + <!-- Tested Integers --> + <IntegerParameter Name="UINT32">0</IntegerParameter> + <IntegerParameter Name="INT32">0</IntegerParameter> + <IntegerParameter Name="UINT32_Max">0</IntegerParameter> + <IntegerParameter Name="INT32_Max">0</IntegerParameter> + <IntegerParameter Name="UINT16">0</IntegerParameter> + <IntegerParameter Name="INT16">0</IntegerParameter> + <IntegerParameter Name="UINT16_Max">0</IntegerParameter> + <IntegerParameter Name="INT16_Max">0</IntegerParameter> + <IntegerParameter Name="UINT8">0</IntegerParameter> + <IntegerParameter Name="INT8">0</IntegerParameter> + <IntegerParameter Name="UINT8_Max">0</IntegerParameter> + <IntegerParameter Name="INT8_Max">0</IntegerParameter> + <!-- Tested Arrays --> + <IntegerParameter Name="UINT32_ARRAY">0</IntegerParameter> + <IntegerParameter Name="INT16_ARRAY">0</IntegerParameter> + <IntegerParameter Name="UINT8_ARRAY">0</IntegerParameter> + <IntegerParameter Name="UINT8_Max_ARRAY">0</IntegerParameter> + <!-- Tested String--> + <StringParameter Name="STR_CHAR128">string_Conf_1_1</StringParameter> + </Component> + </ConfigurableElement> + </Configuration> + <Configuration Name="Conf_1_0"> + <ConfigurableElement Path="/Test/Test/TEST_DIR"> + <Component Name="TEST_DIR"> + <!-- Tested Booleans --> + <BooleanParameter Name="BOOL">1</BooleanParameter> + <!-- Tested FixedPoints --> + <FixedPointParameter Name="FP8_Q0.7">0.9</FixedPointParameter> + <FixedPointParameter Name="FP8_Q7.0">0.9</FixedPointParameter> + <FixedPointParameter Name="FP8_Q3.4">0.9</FixedPointParameter> + <FixedPointParameter Name="FP16_Q0.15">0.9</FixedPointParameter> + <FixedPointParameter Name="FP16_Q15.0">0.9</FixedPointParameter> + <FixedPointParameter Name="FP16_Q7.8">0.9</FixedPointParameter> + <FixedPointParameter Name="FP32_Q0.31">0.9</FixedPointParameter> + <FixedPointParameter Name="FP32_Q31.0">0.9</FixedPointParameter> + <FixedPointParameter Name="FP32_Q15.16">0.9</FixedPointParameter> + <FixedPointParameter Name="FP32_Q8.20">0.9</FixedPointParameter> + <!-- Tested Integers --> + <IntegerParameter Name="UINT32">1</IntegerParameter> + <IntegerParameter Name="INT32">-1</IntegerParameter> + <IntegerParameter Name="UINT32_Max">1</IntegerParameter> + <IntegerParameter Name="INT32_Max">-1</IntegerParameter> + <IntegerParameter Name="UINT16">1</IntegerParameter> + <IntegerParameter Name="INT16">-1</IntegerParameter> + <IntegerParameter Name="UINT16_Max">1</IntegerParameter> + <IntegerParameter Name="INT16_Max">-1</IntegerParameter> + <IntegerParameter Name="UINT8">1</IntegerParameter> + <IntegerParameter Name="INT8">-1</IntegerParameter> + <IntegerParameter Name="UINT8_Max">1</IntegerParameter> + <IntegerParameter Name="INT8_Max">-1</IntegerParameter> + <!-- Tested Arrays --> + <IntegerParameter Name="UINT32_ARRAY">1</IntegerParameter> + <IntegerParameter Name="INT16_ARRAY">-1</IntegerParameter> + <IntegerParameter Name="UINT8_ARRAY">1</IntegerParameter> + <IntegerParameter Name="UINT8_Max_ARRAY">1</IntegerParameter> + <!-- Tested String--> + <StringParameter Name="STR_CHAR128">string_Conf_1_0</StringParameter> + </Component> + </ConfigurableElement> + </Configuration> + </Settings> + </ConfigurableDomain> + + <ConfigurableDomain Name="Domain_2"> + <Configurations> + <Configuration Name="Conf_2_0"> + <CompoundRule Type="All"> + <SelectionCriterionRule SelectionCriterion="Crit_0" MatchesWhen="Includes" Value="State_0x1"/> + <SelectionCriterionRule SelectionCriterion="Crit_1" MatchesWhen="IsNot" Value="State_1"/> + </CompoundRule> + </Configuration> + <Configuration Name="Conf_2_1"> + <CompoundRule Type="All"> + <SelectionCriterionRule SelectionCriterion="Crit_0" MatchesWhen="Includes" Value="State_0x2"/> + <SelectionCriterionRule SelectionCriterion="Crit_1" MatchesWhen="Is" Value="State_1"/> + </CompoundRule> + </Configuration> + </Configurations> + <ConfigurableElements> + <ConfigurableElement Path="/Test/Test/TEST_DOMAIN_0" /> + </ConfigurableElements> + <Settings> + <Configuration Name="Conf_2_1"> + <ConfigurableElement Path="/Test/Test/TEST_DOMAIN_0"> + <Component Name="TEST_DOMAIN_0"> + <IntegerParameter Name="Param_00">4</IntegerParameter> + <IntegerParameter Name="Param_01">4</IntegerParameter> + <IntegerParameter Name="Param_02">4</IntegerParameter> + </Component> + </ConfigurableElement> + </Configuration> + <Configuration Name="Conf_2_0"> + <ConfigurableElement Path="/Test/Test/TEST_DOMAIN_0"> + <Component Name="TEST_DOMAIN_0"> + <IntegerParameter Name="Param_00">5</IntegerParameter> + <IntegerParameter Name="Param_01">5</IntegerParameter> + <IntegerParameter Name="Param_02">5</IntegerParameter> + </Component> + </ConfigurableElement> + </Configuration> + </Settings> + </ConfigurableDomain> + + <ConfigurableDomain Name="Domain_3"> + <Configurations> + <Configuration Name="Conf_3_0"> + <CompoundRule Type="Any"> + <SelectionCriterionRule SelectionCriterion="Crit_0" MatchesWhen="Includes" Value="State_0x1"/> + <SelectionCriterionRule SelectionCriterion="Crit_1" MatchesWhen="Is" Value="State_0"/> + </CompoundRule> + </Configuration> + <Configuration Name="Conf_3_1"> + <CompoundRule Type="Any"> + <SelectionCriterionRule SelectionCriterion="Crit_0" MatchesWhen="Includes" Value="State_0x2"/> + <SelectionCriterionRule SelectionCriterion="Crit_1" MatchesWhen="Is" Value="State_1"/> + </CompoundRule> + </Configuration> + </Configurations> + <ConfigurableElements> + <ConfigurableElement Path="/Test/Test/TEST_DOMAIN_1" /> + </ConfigurableElements> + <Settings> + <Configuration Name="Conf_3_1"> + <ConfigurableElement Path="/Test/Test/TEST_DOMAIN_1"> + <Component Name="TEST_DOMAIN_1"> + <IntegerParameter Name="Param_10">4</IntegerParameter> + <IntegerParameter Name="Param_11">4</IntegerParameter> + <IntegerParameter Name="Param_12">4</IntegerParameter> + </Component> + </ConfigurableElement> + </Configuration> + <Configuration Name="Conf_3_0"> + <ConfigurableElement Path="/Test/Test/TEST_DOMAIN_1"> + <Component Name="TEST_DOMAIN_1"> + <IntegerParameter Name="Param_10">5</IntegerParameter> + <IntegerParameter Name="Param_11">5</IntegerParameter> + <IntegerParameter Name="Param_12">5</IntegerParameter> + </Component> + </ConfigurableElement> + </Configuration> + </Settings> + </ConfigurableDomain> +</ConfigurableDomains> diff --git a/test/functional-tests/xml/XML_Test/Reference_Split_Domain.xml b/test/functional-tests/xml/XML_Test/Reference_Split_Domain.xml new file mode 100644 index 0000000..7f7edbc --- /dev/null +++ b/test/functional-tests/xml/XML_Test/Reference_Split_Domain.xml @@ -0,0 +1,166 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!--DOMAIN 1 DEFINITION--> +<ConfigurableDomains xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../Schemas/ConfigurableDomains.xsd" SystemClassName="Test"> + <ConfigurableDomain Name="Domain_1"> + <Configurations> + <Configuration Name="Conf_1_0"> + <CompoundRule Type="All"> + <SelectionCriterionRule SelectionCriterion="Crit_0" MatchesWhen="Includes" Value="State_0x1"/> + <SelectionCriterionRule SelectionCriterion="Crit_1" MatchesWhen="Is" Value="State_1"/> + </CompoundRule> + </Configuration> + <Configuration Name="Conf_1_1"> + <CompoundRule Type="Any"> + <SelectionCriterionRule SelectionCriterion="Crit_0" MatchesWhen="Excludes" Value="State_0x1"/> + <SelectionCriterionRule SelectionCriterion="Crit_1" MatchesWhen="IsNot" Value="State_1"/> + </CompoundRule> + </Configuration> + </Configurations> + <ConfigurableElements> + <ConfigurableElement Path="/Test/Test/TEST_MAIN" /> + <!--ConfigurableElement Path="/Test/Test/TEST_MAIN/TEST_DIR_0" /> + <ConfigurableElement Path="/Test/Test/TEST_MAIN/TEST_DIR_1" /> + <ConfigurableElement Path="/Test/Test/TEST_MAIN/TEST_DIR_2" /--> + </ConfigurableElements> + <Settings> + <Configuration Name="Conf_1_1"> + <ConfigurableElement Path="/Test/Test/TEST_MAIN"> + <Component Name="TEST_MAIN"> + <Component Name="TEST_DIR_0"> + <!-- Tested Booleans --> + <BooleanParameter Name="BOOL">0</BooleanParameter> + <!-- Tested FixedPoints --> + <FixedPointParameter Name="FP8_Q0.7">0.1</FixedPointParameter> + <FixedPointParameter Name="FP8_Q7.0">2</FixedPointParameter> + <FixedPointParameter Name="FP8_Q3.4">2.1</FixedPointParameter> + <FixedPointParameter Name="FP16_Q0.15">0.1</FixedPointParameter> + <FixedPointParameter Name="FP16_Q15.0">2</FixedPointParameter> + <FixedPointParameter Name="FP16_Q7.8">2</FixedPointParameter> + <FixedPointParameter Name="FP32_Q0.31">0.1</FixedPointParameter> + <FixedPointParameter Name="FP32_Q31.0">2</FixedPointParameter> + <FixedPointParameter Name="FP32_Q15.16">2.1</FixedPointParameter> + <FixedPointParameter Name="FP32_Q8.20">2.1</FixedPointParameter> + <!-- Tested Integers --> + <IntegerParameter Name="UINT32">0</IntegerParameter> + <IntegerParameter Name="INT32">0</IntegerParameter> + <IntegerParameter Name="UINT32_Max">0</IntegerParameter> + <IntegerParameter Name="INT32_Max">0</IntegerParameter> + <IntegerParameter Name="UINT16">0</IntegerParameter> + <IntegerParameter Name="INT16">0</IntegerParameter> + <IntegerParameter Name="UINT16_Max">0</IntegerParameter> + <IntegerParameter Name="INT16_Max">0</IntegerParameter> + <IntegerParameter Name="UINT8">0</IntegerParameter> + <IntegerParameter Name="INT8">0</IntegerParameter> + <IntegerParameter Name="UINT8_Max">0</IntegerParameter> + <IntegerParameter Name="INT8_Max">0</IntegerParameter> + <!-- Tested Arrays --> + <IntegerParameter Name="UINT32_ARRAY">0</IntegerParameter> + <IntegerParameter Name="INT16_ARRAY">0</IntegerParameter> + <IntegerParameter Name="UINT8_ARRAY">0</IntegerParameter> + <IntegerParameter Name="UINT8_Max_ARRAY">0</IntegerParameter> + <!-- Tested String--> + <StringParameter Name="STR_CHAR128">string_Conf_1_1</StringParameter> + </Component> + <Component Name="TEST_DIR_1"> + <IntegerParameter Name="Param_00">4</IntegerParameter> + <IntegerParameter Name="Param_01">4</IntegerParameter> + <IntegerParameter Name="Param_02">4</IntegerParameter> + </Component> + <Component Name="TEST_DIR_2"> + <IntegerParameter Name="Param_10">4</IntegerParameter> + <IntegerParameter Name="Param_11">4</IntegerParameter> + <IntegerParameter Name="Param_12">4</IntegerParameter> + </Component> + </Component> + </ConfigurableElement> + </Configuration> + <Configuration Name="Conf_1_0"> + <ConfigurableElement Path="/Test/Test/TEST_MAIN"> + <Component Name="TEST_MAIN"> + <Component Name="TEST_DIR_0"> + <!-- Tested Booleans --> + <BooleanParameter Name="BOOL">0</BooleanParameter> + <!-- Tested FixedPoints --> + <FixedPointParameter Name="FP8_Q0.7">0.1</FixedPointParameter> + <FixedPointParameter Name="FP8_Q7.0">2</FixedPointParameter> + <FixedPointParameter Name="FP8_Q3.4">2.1</FixedPointParameter> + <FixedPointParameter Name="FP16_Q0.15">0.1</FixedPointParameter> + <FixedPointParameter Name="FP16_Q15.0">2</FixedPointParameter> + <FixedPointParameter Name="FP16_Q7.8">2</FixedPointParameter> + <FixedPointParameter Name="FP32_Q0.31">0.1</FixedPointParameter> + <FixedPointParameter Name="FP32_Q31.0">2</FixedPointParameter> + <FixedPointParameter Name="FP32_Q15.16">2.1</FixedPointParameter> + <FixedPointParameter Name="FP32_Q8.20">2.1</FixedPointParameter> + <!-- Tested Integers --> + <IntegerParameter Name="UINT32">0</IntegerParameter> + <IntegerParameter Name="INT32">0</IntegerParameter> + <IntegerParameter Name="UINT32_Max">0</IntegerParameter> + <IntegerParameter Name="INT32_Max">0</IntegerParameter> + <IntegerParameter Name="UINT16">0</IntegerParameter> + <IntegerParameter Name="INT16">0</IntegerParameter> + <IntegerParameter Name="UINT16_Max">0</IntegerParameter> + <IntegerParameter Name="INT16_Max">0</IntegerParameter> + <IntegerParameter Name="UINT8">0</IntegerParameter> + <IntegerParameter Name="INT8">0</IntegerParameter> + <IntegerParameter Name="UINT8_Max">0</IntegerParameter> + <IntegerParameter Name="INT8_Max">0</IntegerParameter> + <!-- Tested Arrays --> + <IntegerParameter Name="UINT32_ARRAY">0</IntegerParameter> + <IntegerParameter Name="INT16_ARRAY">0</IntegerParameter> + <IntegerParameter Name="UINT8_ARRAY">0</IntegerParameter> + <IntegerParameter Name="UINT8_Max_ARRAY">0</IntegerParameter> + <!-- Tested String--> + <StringParameter Name="STR_CHAR128">string_Conf_1_1</StringParameter> + </Component> + <Component Name="TEST_DIR_1"> + <IntegerParameter Name="Param_00">5</IntegerParameter> + <IntegerParameter Name="Param_01">5</IntegerParameter> + <IntegerParameter Name="Param_02">5</IntegerParameter> + </Component> + <Component Name="TEST_DIR_2"> + <IntegerParameter Name="Param_10">5</IntegerParameter> + <IntegerParameter Name="Param_11">5</IntegerParameter> + <IntegerParameter Name="Param_12">5</IntegerParameter> + </Component> + </Component> + </ConfigurableElement> + </Configuration> + </Settings> + </ConfigurableDomain> +<!--DOMAIN 2 DEFINITION--> + <ConfigurableDomain Name="Domain_2"> + <Configurations> + <Configuration Name="Conf_2_0"> + <CompoundRule Type="All"> + <SelectionCriterionRule SelectionCriterion="Crit_0" MatchesWhen="Includes" Value="State_0x1"/> + <SelectionCriterionRule SelectionCriterion="Crit_1" MatchesWhen="IsNot" Value="State_1"/> + </CompoundRule> + </Configuration> + <Configuration Name="Conf_2_1"> + <CompoundRule Type="All"> + <SelectionCriterionRule SelectionCriterion="Crit_0" MatchesWhen="Includes" Value="State_0x2"/> + <SelectionCriterionRule SelectionCriterion="Crit_1" MatchesWhen="Is" Value="State_1"/> + </CompoundRule> + </Configuration> + </Configurations> + <ConfigurableElements/> + </ConfigurableDomain> +<!--DOMAIN 3 DEFINITION--> + <ConfigurableDomain Name="Domain_3"> + <Configurations> + <Configuration Name="Conf_3_0"> + <CompoundRule Type="Any"> + <SelectionCriterionRule SelectionCriterion="Crit_0" MatchesWhen="Includes" Value="State_0x1"/> + <SelectionCriterionRule SelectionCriterion="Crit_1" MatchesWhen="Is" Value="State_0"/> + </CompoundRule> + </Configuration> + <Configuration Name="Conf_3_1"> + <CompoundRule Type="Any"> + <SelectionCriterionRule SelectionCriterion="Crit_0" MatchesWhen="Includes" Value="State_0x2"/> + <SelectionCriterionRule SelectionCriterion="Crit_1" MatchesWhen="Is" Value="State_1"/> + </CompoundRule> + </Configuration> + </Configurations> + <ConfigurableElements/> + </ConfigurableDomain> +</ConfigurableDomains> diff --git a/test/functional-tests/xml/XML_Test/Reference_dumpDomains b/test/functional-tests/xml/XML_Test/Reference_dumpDomains new file mode 100644 index 0000000..9277d20 --- /dev/null +++ b/test/functional-tests/xml/XML_Test/Reference_dumpDomains @@ -0,0 +1,12 @@ +- ConfigurableDomains: Test + - ConfigurableDomain: Domain_0_1 = {Sequence aware: no, Last applied configuration: <none>} + - Configuration: Conf_0_0 + - ConfigurableDomain: Domain_1_2 = {Sequence aware: no, Last applied configuration: <none>} + - Configuration: Conf_1_0 + - CompoundRule = All + - SelectionCriterionRule = Crit_0 Includes State_0x1 + - SelectionCriterionRule = Crit_1 Is State_1 + - Configuration: Conf_1_1 + - CompoundRule = Any + - SelectionCriterionRule = Crit_0 Includes State_0x2 + - SelectionCriterionRule = Crit_1 IsNot State_1 diff --git a/test/functional-tests/xml/XML_Test/Reference_dumpDomains.xml b/test/functional-tests/xml/XML_Test/Reference_dumpDomains.xml new file mode 100644 index 0000000..844099e --- /dev/null +++ b/test/functional-tests/xml/XML_Test/Reference_dumpDomains.xml @@ -0,0 +1,62 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ConfigurableDomains xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="/home/lab/ICS/hardware/intel/PRIVATE/parameter-framework/test/configuration/Schemas/ConfigurableDomains.xsd" SystemClassName="Test"> + + <ConfigurableDomain Name="Domain_0_1"> + <Configurations> + <Configuration Name="Conf_0_0"/> + </Configurations> + <ConfigurableElements> + <ConfigurableElement Path="/Test/Test/TEST_DOMAIN_0" /> + </ConfigurableElements> + <Settings> + <Configuration Name="Conf_0_0"> + <ConfigurableElement Path="/Test/Test/TEST_DOMAIN_0"> + <Component Name="TEST_DOMAIN_0"> + <IntegerParameter Name="Param_00">0</IntegerParameter> + <IntegerParameter Name="Param_01">0</IntegerParameter> + <IntegerParameter Name="Param_02">0</IntegerParameter> + </Component> + </ConfigurableElement> + </Configuration> + </Settings> + </ConfigurableDomain> + <ConfigurableDomain Name="Domain_1_2"> + <Configurations> + <Configuration Name="Conf_1_0"> + <CompoundRule Type="All"> + <SelectionCriterionRule SelectionCriterion="Crit_0" MatchesWhen="Includes" Value="State_0x1"/> + <SelectionCriterionRule SelectionCriterion="Crit_1" MatchesWhen="Is" Value="State_1"/> + </CompoundRule> + </Configuration> + <Configuration Name="Conf_1_1"> + <CompoundRule Type="Any"> + <SelectionCriterionRule SelectionCriterion="Crit_0" MatchesWhen="Includes" Value="State_0x2"/> + <SelectionCriterionRule SelectionCriterion="Crit_1" MatchesWhen="IsNot" Value="State_1"/> + </CompoundRule> + </Configuration> + </Configurations> + <ConfigurableElements> + <ConfigurableElement Path="/Test/Test/TEST_DOMAIN_1" /> + </ConfigurableElements> + <Settings> + <Configuration Name="Conf_1_1"> + <ConfigurableElement Path="/Test/Test/TEST_DOMAIN_1"> + <Component Name="TEST_DOMAIN_1"> + <IntegerParameter Name="Param_10">4</IntegerParameter> + <IntegerParameter Name="Param_11">4</IntegerParameter> + <IntegerParameter Name="Param_12">4</IntegerParameter> + </Component> + </ConfigurableElement> + </Configuration> + <Configuration Name="Conf_1_0"> + <ConfigurableElement Path="/Test/Test/TEST_DOMAIN_1"> + <Component Name="TEST_DOMAIN_1"> + <IntegerParameter Name="Param_10">5</IntegerParameter> + <IntegerParameter Name="Param_11">5</IntegerParameter> + <IntegerParameter Name="Param_12">5</IntegerParameter> + </Component> + </ConfigurableElement> + </Configuration> + </Settings> + </ConfigurableDomain> +</ConfigurableDomains> diff --git a/test/functional-tests/xml/XML_Test/Reference_dumpElement b/test/functional-tests/xml/XML_Test/Reference_dumpElement new file mode 100644 index 0000000..37342fa --- /dev/null +++ b/test/functional-tests/xml/XML_Test/Reference_dumpElement @@ -0,0 +1,89 @@ +- SystemClass: Test + - Subsystem: Test + - Component: TEST_DIR + - BooleanParameter: BOOL = 1 + - FixedPointParameter: FP8_Q0.7 = 0.8984375 + - FixedPointParameter: FP8_Q7.0 = 1 + - FixedPointParameter: FP8_Q3.4 = 1.0000 + - FixedPointParameter: FP16_Q0.15 = 0.899993896484375 + - FixedPointParameter: FP16_Q15.0 = 1 + - FixedPointParameter: FP16_Q7.8 = 1.00000000 + - FixedPointParameter: FP32_Q0.31 = 0.8999999999068677425384521484375 + - FixedPointParameter: FP32_Q31.0 = 1 + - FixedPointParameter: FP32_Q15.16 = 1.0000000000000000 + - FixedPointParameter: FP32_Q8.20 = 1.00000000000000000000 + - IntegerParameter: UINT32 = 1 + - IntegerParameter: INT32 = 1 + - IntegerParameter: UINT32_Max = 1 + - IntegerParameter: INT32_Max = 1 + - IntegerParameter: UINT16 = 1 + - IntegerParameter: INT16 = 1 + - IntegerParameter: UINT16_Max = 1 + - IntegerParameter: INT16_Max = 1 + - IntegerParameter: UINT8 = 1 + - IntegerParameter: INT8 = 1 + - IntegerParameter: UINT8_Max = 1 + - IntegerParameter: INT8_Max = 1 + - IntegerParameter: UINT32_ARRAY = 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + - IntegerParameter: INT16_ARRAY = 1 0 0 0 0 + - IntegerParameter: UINT8_ARRAY = 1 0 0 0 0 + - IntegerParameter: UINT8_Max_ARRAY = 1 0 0 0 0 + - StringParameter: STR_CHAR128 = string_Conf_1 + - Component: TEST_DOMAIN_0 + - IntegerParameter: Param_00 = 4 + - IntegerParameter: Param_01 = 4 + - IntegerParameter: Param_02 = 4 + - Component: TEST_DOMAIN_1 + - IntegerParameter: Param_10 = 4 + - IntegerParameter: Param_11 = 4 + - IntegerParameter: Param_12 = 4 + - Component: TEST_TYPES + - EnumParameter: ENUM = ENUM_MIN + - BitParameterBlock: BLOCK_8BIT + - BitParameter: BIT_0_3 = 0 + - BitParameter: BIT_3_1 = 0 + - BitParameter: BIT_4_1 = 0 + - BitParameter: BIT_6_2 = 0 + - BitParameter: BIT_7_1 = 0 + - ParameterBlock: BLOCK_PARAMETER + - IntegerParameter: UINT8 = 0 + - IntegerParameter: UINT16 = 0 + - IntegerParameter: UINT32 = 0 + - Component: TEST_MAIN + - Component: TEST_DIR_0 + - BooleanParameter: BOOL = 0 + - FixedPointParameter: FP8_Q0.7 = 0.1015625 + - FixedPointParameter: FP8_Q7.0 = 2 + - FixedPointParameter: FP8_Q3.4 = 2.1250 + - FixedPointParameter: FP16_Q0.15 = 0.100006103515625 + - FixedPointParameter: FP16_Q15.0 = 2 + - FixedPointParameter: FP16_Q7.8 = 2.00000000 + - FixedPointParameter: FP32_Q0.31 = 0.1000000000931322574615478515625 + - FixedPointParameter: FP32_Q31.0 = 2 + - FixedPointParameter: FP32_Q15.16 = 2.1000061035156250 + - FixedPointParameter: FP32_Q8.20 = 2.10000038146972656250 + - IntegerParameter: UINT32 = 0 + - IntegerParameter: INT32 = 0 + - IntegerParameter: UINT32_Max = 0 + - IntegerParameter: INT32_Max = 0 + - IntegerParameter: UINT16 = 0 + - IntegerParameter: INT16 = 0 + - IntegerParameter: UINT16_Max = 0 + - IntegerParameter: INT16_Max = 0 + - IntegerParameter: UINT8 = 0 + - IntegerParameter: INT8 = 0 + - IntegerParameter: UINT8_Max = 0 + - IntegerParameter: INT8_Max = 0 + - IntegerParameter: UINT32_ARRAY = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + - IntegerParameter: INT16_ARRAY = 0 0 0 0 0 + - IntegerParameter: UINT8_ARRAY = 0 0 0 0 0 + - IntegerParameter: UINT8_Max_ARRAY = 0 0 0 0 0 + - StringParameter: STR_CHAR128 = string_Conf_1_1 + - Component: TEST_DIR_1 + - IntegerParameter: Param_00 = 4 + - IntegerParameter: Param_01 = 4 + - IntegerParameter: Param_02 = 4 + - Component: TEST_DIR_2 + - IntegerParameter: Param_10 = 4 + - IntegerParameter: Param_11 = 4 + - IntegerParameter: Param_12 = 4
\ No newline at end of file diff --git a/test/functional-tests/xml/XML_Test/Uncompliant_OutboundParameter.xml b/test/functional-tests/xml/XML_Test/Uncompliant_OutboundParameter.xml new file mode 100644 index 0000000..339a75c --- /dev/null +++ b/test/functional-tests/xml/XML_Test/Uncompliant_OutboundParameter.xml @@ -0,0 +1,102 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ConfigurableDomains xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../Schemas/ConfigurableDomains.xsd" SystemClassName="Test"> + <ConfigurableDomain Name="Domain_1"> + <Configurations> + <Configuration Name="Conf_1_0"> + <CompoundRule Type="All"> + <SelectionCriterionRule SelectionCriterion="Crit_0" MatchesWhen="Includes" Value="State_0x1"/> + <SelectionCriterionRule SelectionCriterion="Crit_1" MatchesWhen="Is" Value="State_1"/> + </CompoundRule> + </Configuration> + <Configuration Name="Conf_1_1"> + <CompoundRule Type="Any"> + <SelectionCriterionRule SelectionCriterion="Crit_0" MatchesWhen="Includes" Value="State_0x2"/> + <SelectionCriterionRule SelectionCriterion="Crit_1" MatchesWhen="IsNot" Value="State_1"/> + </CompoundRule> + </Configuration> + </Configurations> + <ConfigurableElements> + <ConfigurableElement Path="/Test/Test/TEST_DIR" /> + </ConfigurableElements> + <Settings> + <Configuration Name="Conf_1_1"> + <ConfigurableElement Path="/Test/Test/TEST_DIR"> + <Component Name="TEST_DIR"> + <!-- Tested Booleans --> + <BooleanParameter Name="BOOL">2</BooleanParameter> + <!-- Tested FixedPoints --> + <FixedPointParameter Name="FP8_Q0.7">0.1</FixedPointParameter> + <FixedPointParameter Name="FP8_Q7.0">0.1</FixedPointParameter> + <FixedPointParameter Name="FP8_Q3.4">0.1</FixedPointParameter> + <FixedPointParameter Name="FP16_Q0.15">0.1</FixedPointParameter> + <FixedPointParameter Name="FP16_Q15.0">0.1</FixedPointParameter> + <FixedPointParameter Name="FP16_Q7.8">0.1</FixedPointParameter> + <FixedPointParameter Name="FP32_Q0.31">0.1</FixedPointParameter> + <FixedPointParameter Name="FP32_Q31.0">0.1</FixedPointParameter> + <FixedPointParameter Name="FP32_Q15.16">0.1</FixedPointParameter> + <FixedPointParameter Name="FP32_Q8.20">0.1</FixedPointParameter> + <!-- Tested Integers --> + <IntegerParameter Name="UINT32">0</IntegerParameter> + <IntegerParameter Name="INT32">0</IntegerParameter> + <IntegerParameter Name="UINT32_Max">0</IntegerParameter> + <IntegerParameter Name="INT32_Max">0</IntegerParameter> + <IntegerParameter Name="UINT16">0</IntegerParameter> + <IntegerParameter Name="INT16">0</IntegerParameter> + <IntegerParameter Name="UINT16_Max">0</IntegerParameter> + <IntegerParameter Name="INT16_Max">0</IntegerParameter> + <IntegerParameter Name="UINT8">0</IntegerParameter> + <IntegerParameter Name="INT8">0</IntegerParameter> + <IntegerParameter Name="UINT8_Max">0</IntegerParameter> + <IntegerParameter Name="INT8_Max">0</IntegerParameter> + <!-- Tested Arrays --> + <IntegerParameter Name="UINT32_ARRAY">0</IntegerParameter> + <IntegerParameter Name="INT16_ARRAY">0</IntegerParameter> + <IntegerParameter Name="UINT8_ARRAY">0</IntegerParameter> + <IntegerParameter Name="UINT8_Max_ARRAY">0</IntegerParameter> + <!-- Tested String--> + <StringParameter Name="STR_CHAR128">string_Conf_1_1</StringParameter> + </Component> + </ConfigurableElement> + </Configuration> + <Configuration Name="Conf_1_0"> + <ConfigurableElement Path="/Test/Test/TEST_DIR"> + <Component Name="TEST_DIR"> + <!-- Tested Booleans --> + <BooleanParameter Name="BOOL">1</BooleanParameter> + <!-- Tested FixedPoints --> + <FixedPointParameter Name="FP8_Q0.7">0.9</FixedPointParameter> + <FixedPointParameter Name="FP8_Q7.0">0.9</FixedPointParameter> + <FixedPointParameter Name="FP8_Q3.4">0.9</FixedPointParameter> + <FixedPointParameter Name="FP16_Q0.15">0.9</FixedPointParameter> + <FixedPointParameter Name="FP16_Q15.0">0.9</FixedPointParameter> + <FixedPointParameter Name="FP16_Q7.8">0.9</FixedPointParameter> + <FixedPointParameter Name="FP32_Q0.31">0.9</FixedPointParameter> + <FixedPointParameter Name="FP32_Q31.0">0.9</FixedPointParameter> + <FixedPointParameter Name="FP32_Q15.16">0.9</FixedPointParameter> + <FixedPointParameter Name="FP32_Q8.20">0.9</FixedPointParameter> + <!-- Tested Integers --> + <IntegerParameter Name="UINT32">1</IntegerParameter> + <IntegerParameter Name="INT32">-1</IntegerParameter> + <IntegerParameter Name="UINT32_Max">1</IntegerParameter> + <IntegerParameter Name="INT32_Max">-1</IntegerParameter> + <IntegerParameter Name="UINT16">1</IntegerParameter> + <IntegerParameter Name="INT16">-1</IntegerParameter> + <IntegerParameter Name="UINT16_Max">1</IntegerParameter> + <IntegerParameter Name="INT16_Max">-1</IntegerParameter> + <IntegerParameter Name="UINT8">1</IntegerParameter> + <IntegerParameter Name="INT8">-1</IntegerParameter> + <IntegerParameter Name="UINT8_Max">1</IntegerParameter> + <IntegerParameter Name="INT8_Max">-1</IntegerParameter> + <!-- Tested Arrays --> + <IntegerParameter Name="UINT32_ARRAY">1</IntegerParameter> + <IntegerParameter Name="INT16_ARRAY">-1</IntegerParameter> + <IntegerParameter Name="UINT8_ARRAY">1</IntegerParameter> + <IntegerParameter Name="UINT8_Max_ARRAY">1</IntegerParameter> + <!-- Tested String--> + <StringParameter Name="STR_CHAR128">string_Conf_1_0</StringParameter> + </Component> + </ConfigurableElement> + </Configuration> + </Settings> + </ConfigurableDomain> +</ConfigurableDomains> diff --git a/test/functional-tests/xml/XML_Test/Uncompliant_UndeclaredConfigurableElement.xml b/test/functional-tests/xml/XML_Test/Uncompliant_UndeclaredConfigurableElement.xml new file mode 100644 index 0000000..f8c00be --- /dev/null +++ b/test/functional-tests/xml/XML_Test/Uncompliant_UndeclaredConfigurableElement.xml @@ -0,0 +1,102 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ConfigurableDomains xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../Schemas/ConfigurableDomains.xsd" SystemClassName="Test"> + <ConfigurableDomain Name="Domain_1"> + <Configurations> + <Configuration Name="Conf_1_0"> + <CompoundRule Type="All"> + <SelectionCriterionRule SelectionCriterion="Crit_0" MatchesWhen="Includes" Value="State_0x1"/> + <SelectionCriterionRule SelectionCriterion="Crit_1" MatchesWhen="Is" Value="State_1"/> + </CompoundRule> + </Configuration> + <Configuration Name="Conf_1_1"> + <CompoundRule Type="Any"> + <SelectionCriterionRule SelectionCriterion="Crit_0" MatchesWhen="Includes" Value="State_0x2"/> + <SelectionCriterionRule SelectionCriterion="Crit_1" MatchesWhen="IsNot" Value="State_1"/> + </CompoundRule> + </Configuration> + </Configurations> + <ConfigurableElements> + <ConfigurableElement Path="/Test/Test/ERROR" /> + </ConfigurableElements> + <Settings> + <Configuration Name="Conf_1_1"> + <ConfigurableElement Path="/Test/Test/ERROR"> + <Component Name="TEST_DIR"> + <!-- Tested Booleans --> + <BooleanParameter Name="BOOL">0</BooleanParameter> + <!-- Tested FixedPoints --> + <FixedPointParameter Name="FP8_Q0.7">0.1</FixedPointParameter> + <FixedPointParameter Name="FP8_Q7.0">0.1</FixedPointParameter> + <FixedPointParameter Name="FP8_Q3.4">0.1</FixedPointParameter> + <FixedPointParameter Name="FP16_Q0.15">0.1</FixedPointParameter> + <FixedPointParameter Name="FP16_Q15.0">0.1</FixedPointParameter> + <FixedPointParameter Name="FP16_Q7.8">0.1</FixedPointParameter> + <FixedPointParameter Name="FP32_Q0.31">0.1</FixedPointParameter> + <FixedPointParameter Name="FP32_Q31.0">0.1</FixedPointParameter> + <FixedPointParameter Name="FP32_Q15.16">0.1</FixedPointParameter> + <FixedPointParameter Name="FP32_Q8.20">0.1</FixedPointParameter> + <!-- Tested Integers --> + <IntegerParameter Name="UINT32">0</IntegerParameter> + <IntegerParameter Name="INT32">0</IntegerParameter> + <IntegerParameter Name="UINT32_Max">0</IntegerParameter> + <IntegerParameter Name="INT32_Max">0</IntegerParameter> + <IntegerParameter Name="UINT16">0</IntegerParameter> + <IntegerParameter Name="INT16">0</IntegerParameter> + <IntegerParameter Name="UINT16_Max">0</IntegerParameter> + <IntegerParameter Name="INT16_Max">0</IntegerParameter> + <IntegerParameter Name="UINT8">0</IntegerParameter> + <IntegerParameter Name="INT8">0</IntegerParameter> + <IntegerParameter Name="UINT8_Max">0</IntegerParameter> + <IntegerParameter Name="INT8_Max">0</IntegerParameter> + <!-- Tested Arrays --> + <IntegerParameter Name="UINT32_ARRAY">0</IntegerParameter> + <IntegerParameter Name="INT16_ARRAY">0</IntegerParameter> + <IntegerParameter Name="UINT8_ARRAY">0</IntegerParameter> + <IntegerParameter Name="UINT8_Max_ARRAY">0</IntegerParameter> + <!-- Tested String--> + <StringParameter Name="STR_CHAR128">string_Conf_1_1</StringParameter> + </Component> + </ConfigurableElement> + </Configuration> + <Configuration Name="Conf_1_0"> + <ConfigurableElement Path="/Test/Test/TEST_DIR"> + <Component Name="TEST_DIR"> + <!-- Tested Booleans --> + <BooleanParameter Name="BOOL">1</BooleanParameter> + <!-- Tested FixedPoints --> + <FixedPointParameter Name="FP8_Q0.7">0.9</FixedPointParameter> + <FixedPointParameter Name="FP8_Q7.0">0.9</FixedPointParameter> + <FixedPointParameter Name="FP8_Q3.4">0.9</FixedPointParameter> + <FixedPointParameter Name="FP16_Q0.15">0.9</FixedPointParameter> + <FixedPointParameter Name="FP16_Q15.0">0.9</FixedPointParameter> + <FixedPointParameter Name="FP16_Q7.8">0.9</FixedPointParameter> + <FixedPointParameter Name="FP32_Q0.31">0.9</FixedPointParameter> + <FixedPointParameter Name="FP32_Q31.0">0.9</FixedPointParameter> + <FixedPointParameter Name="FP32_Q15.16">0.9</FixedPointParameter> + <FixedPointParameter Name="FP32_Q8.20">0.9</FixedPointParameter> + <!-- Tested Integers --> + <IntegerParameter Name="UINT32">1</IntegerParameter> + <IntegerParameter Name="INT32">-1</IntegerParameter> + <IntegerParameter Name="UINT32_Max">1</IntegerParameter> + <IntegerParameter Name="INT32_Max">-1</IntegerParameter> + <IntegerParameter Name="UINT16">1</IntegerParameter> + <IntegerParameter Name="INT16">-1</IntegerParameter> + <IntegerParameter Name="UINT16_Max">1</IntegerParameter> + <IntegerParameter Name="INT16_Max">-1</IntegerParameter> + <IntegerParameter Name="UINT8">1</IntegerParameter> + <IntegerParameter Name="INT8">-1</IntegerParameter> + <IntegerParameter Name="UINT8_Max">1</IntegerParameter> + <IntegerParameter Name="INT8_Max">-1</IntegerParameter> + <!-- Tested Arrays --> + <IntegerParameter Name="UINT32_ARRAY">1</IntegerParameter> + <IntegerParameter Name="INT16_ARRAY">-1</IntegerParameter> + <IntegerParameter Name="UINT8_ARRAY">1</IntegerParameter> + <IntegerParameter Name="UINT8_Max_ARRAY">1</IntegerParameter> + <!-- Tested String--> + <StringParameter Name="STR_CHAR128">string_Conf_1_0</StringParameter> + </Component> + </ConfigurableElement> + </Configuration> + </Settings> + </ConfigurableDomain> +</ConfigurableDomains> diff --git a/test/functional-tests/xml/XML_Test/Uncompliant_UndeclaredParameter.xml b/test/functional-tests/xml/XML_Test/Uncompliant_UndeclaredParameter.xml new file mode 100644 index 0000000..f831de5 --- /dev/null +++ b/test/functional-tests/xml/XML_Test/Uncompliant_UndeclaredParameter.xml @@ -0,0 +1,104 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ConfigurableDomains xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../Schemas/ConfigurableDomains.xsd" SystemClassName="Test"> + <ConfigurableDomain Name="Domain_1"> + <Configurations> + <Configuration Name="Conf_1_0"> + <CompoundRule Type="All"> + <SelectionCriterionRule SelectionCriterion="Crit_0" MatchesWhen="Includes" Value="State_0x1"/> + <SelectionCriterionRule SelectionCriterion="Crit_1" MatchesWhen="Is" Value="State_1"/> + </CompoundRule> + </Configuration> + <Configuration Name="Conf_1_1"> + <CompoundRule Type="Any"> + <SelectionCriterionRule SelectionCriterion="Crit_0" MatchesWhen="Includes" Value="State_0x2"/> + <SelectionCriterionRule SelectionCriterion="Crit_1" MatchesWhen="IsNot" Value="State_1"/> + </CompoundRule> + </Configuration> + </Configurations> + <ConfigurableElements> + <ConfigurableElement Path="/Test/Test/TEST_DIR" /> + </ConfigurableElements> + <Settings> + <Configuration Name="Conf_1_1"> + <ConfigurableElement Path="/Test/Test/TEST_DIR"> + <Component Name="TEST_DIR"> + <!-- Tested Booleans --> + <BooleanParameter Name="BOOL">0</BooleanParameter> + <BooleanParameter Name="UNDECLARED">0</BooleanParameter> + <!-- Tested FixedPoints --> + <FixedPointParameter Name="FP8_Q0.7">0.1</FixedPointParameter> + <FixedPointParameter Name="FP8_Q7.0">0.1</FixedPointParameter> + <FixedPointParameter Name="FP8_Q3.4">0.1</FixedPointParameter> + <FixedPointParameter Name="FP16_Q0.15">0.1</FixedPointParameter> + <FixedPointParameter Name="FP16_Q15.0">0.1</FixedPointParameter> + <FixedPointParameter Name="FP16_Q7.8">0.1</FixedPointParameter> + <FixedPointParameter Name="FP32_Q0.31">0.1</FixedPointParameter> + <FixedPointParameter Name="FP32_Q31.0">0.1</FixedPointParameter> + <FixedPointParameter Name="FP32_Q15.16">0.1</FixedPointParameter> + <FixedPointParameter Name="FP32_Q8.20">0.1</FixedPointParameter> + <!-- Tested Integers --> + <IntegerParameter Name="UINT32">0</IntegerParameter> + <IntegerParameter Name="INT32">0</IntegerParameter> + <IntegerParameter Name="UINT32_Max">0</IntegerParameter> + <IntegerParameter Name="INT32_Max">0</IntegerParameter> + <IntegerParameter Name="UINT16">0</IntegerParameter> + <IntegerParameter Name="INT16">0</IntegerParameter> + <IntegerParameter Name="UINT16_Max">0</IntegerParameter> + <IntegerParameter Name="INT16_Max">0</IntegerParameter> + <IntegerParameter Name="UINT8">0</IntegerParameter> + <IntegerParameter Name="INT8">0</IntegerParameter> + <IntegerParameter Name="UINT8_Max">0</IntegerParameter> + <IntegerParameter Name="INT8_Max">0</IntegerParameter> + <!-- Tested Arrays --> + <IntegerParameter Name="UINT32_ARRAY">0</IntegerParameter> + <IntegerParameter Name="INT16_ARRAY">0</IntegerParameter> + <IntegerParameter Name="UINT8_ARRAY">0</IntegerParameter> + <IntegerParameter Name="UINT8_Max_ARRAY">0</IntegerParameter> + <!-- Tested String--> + <StringParameter Name="STR_CHAR128">string_Conf_1_1</StringParameter> + </Component> + </ConfigurableElement> + </Configuration> + <Configuration Name="Conf_1_0"> + <ConfigurableElement Path="/Test/Test/TEST_DIR"> + <Component Name="TEST_DIR"> + <!-- Tested Booleans --> + <BooleanParameter Name="BOOL">1</BooleanParameter> + <BooleanParameter Name="UNDECLARED">0</BooleanParameter> + <!-- Tested FixedPoints --> + <FixedPointParameter Name="FP8_Q0.7">0.9</FixedPointParameter> + <FixedPointParameter Name="FP8_Q7.0">0.9</FixedPointParameter> + <FixedPointParameter Name="FP8_Q3.4">0.9</FixedPointParameter> + <FixedPointParameter Name="FP16_Q0.15">0.9</FixedPointParameter> + <FixedPointParameter Name="FP16_Q15.0">0.9</FixedPointParameter> + <FixedPointParameter Name="FP16_Q7.8">0.9</FixedPointParameter> + <FixedPointParameter Name="FP32_Q0.31">0.9</FixedPointParameter> + <FixedPointParameter Name="FP32_Q31.0">0.9</FixedPointParameter> + <FixedPointParameter Name="FP32_Q15.16">0.9</FixedPointParameter> + <FixedPointParameter Name="FP32_Q8.20">0.9</FixedPointParameter> + <!-- Tested Integers --> + <IntegerParameter Name="UINT32">1</IntegerParameter> + <IntegerParameter Name="INT32">-1</IntegerParameter> + <IntegerParameter Name="UINT32_Max">1</IntegerParameter> + <IntegerParameter Name="INT32_Max">-1</IntegerParameter> + <IntegerParameter Name="UINT16">1</IntegerParameter> + <IntegerParameter Name="INT16">-1</IntegerParameter> + <IntegerParameter Name="UINT16_Max">1</IntegerParameter> + <IntegerParameter Name="INT16_Max">-1</IntegerParameter> + <IntegerParameter Name="UINT8">1</IntegerParameter> + <IntegerParameter Name="INT8">-1</IntegerParameter> + <IntegerParameter Name="UINT8_Max">1</IntegerParameter> + <IntegerParameter Name="INT8_Max">-1</IntegerParameter> + <!-- Tested Arrays --> + <IntegerParameter Name="UINT32_ARRAY">1</IntegerParameter> + <IntegerParameter Name="INT16_ARRAY">-1</IntegerParameter> + <IntegerParameter Name="UINT8_ARRAY">1</IntegerParameter> + <IntegerParameter Name="UINT8_Max_ARRAY">1</IntegerParameter> + <!-- Tested String--> + <StringParameter Name="STR_CHAR128">string_Conf_1_0</StringParameter> + </Component> + </ConfigurableElement> + </Configuration> + </Settings> + </ConfigurableDomain> +</ConfigurableDomains> diff --git a/test/functional-tests/xml/XML_Test/Uncompliant_UnorderConfigurableElement.xml b/test/functional-tests/xml/XML_Test/Uncompliant_UnorderConfigurableElement.xml new file mode 100644 index 0000000..3d9aaa4 --- /dev/null +++ b/test/functional-tests/xml/XML_Test/Uncompliant_UnorderConfigurableElement.xml @@ -0,0 +1,102 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ConfigurableDomains xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../Schemas/ConfigurableDomains.xsd" SystemClassName="Test"> + <ConfigurableDomain Name="Domain_1"> + <Configurations> + <Configuration Name="Conf_1_0"> + <CompoundRule Type="All"> + <SelectionCriterionRule SelectionCriterion="Crit_0" MatchesWhen="Includes" Value="State_0x1"/> + <SelectionCriterionRule SelectionCriterion="Crit_1" MatchesWhen="Is" Value="State_1"/> + </CompoundRule> + </Configuration> + <Configuration Name="Conf_1_1"> + <CompoundRule Type="Any"> + <SelectionCriterionRule SelectionCriterion="Crit_0" MatchesWhen="Includes" Value="State_0x2"/> + <SelectionCriterionRule SelectionCriterion="Crit_1" MatchesWhen="IsNot" Value="State_1"/> + </CompoundRule> + </Configuration> + </Configurations> + <ConfigurableElements> + <ConfigurableElement Path="/Test/Test/TEST_DIR" /> + </ConfigurableElements> + <Settings> + <Configuration Name="Conf_1_1"> + <ConfigurableElement Path="/Test/Test/TEST_DOMAIN_0"> + <Component Name="TEST_DOMAIN_0"> + <!-- Tested Booleans --> + <BooleanParameter Name="BOOL">0</BooleanParameter> + <!-- Tested FixedPoints --> + <FixedPointParameter Name="FP8_Q0.7">0.1</FixedPointParameter> + <FixedPointParameter Name="FP8_Q7.0">0.1</FixedPointParameter> + <FixedPointParameter Name="FP8_Q3.4">0.1</FixedPointParameter> + <FixedPointParameter Name="FP16_Q0.15">0.1</FixedPointParameter> + <FixedPointParameter Name="FP16_Q15.0">0.1</FixedPointParameter> + <FixedPointParameter Name="FP16_Q7.8">0.1</FixedPointParameter> + <FixedPointParameter Name="FP32_Q0.31">0.1</FixedPointParameter> + <FixedPointParameter Name="FP32_Q31.0">0.1</FixedPointParameter> + <FixedPointParameter Name="FP32_Q15.16">0.1</FixedPointParameter> + <FixedPointParameter Name="FP32_Q8.20">0.1</FixedPointParameter> + <!-- Tested Integers --> + <IntegerParameter Name="UINT32">0</IntegerParameter> + <IntegerParameter Name="INT32">0</IntegerParameter> + <IntegerParameter Name="UINT32_Max">0</IntegerParameter> + <IntegerParameter Name="INT32_Max">0</IntegerParameter> + <IntegerParameter Name="UINT16">0</IntegerParameter> + <IntegerParameter Name="INT16">0</IntegerParameter> + <IntegerParameter Name="UINT16_Max">0</IntegerParameter> + <IntegerParameter Name="INT16_Max">0</IntegerParameter> + <IntegerParameter Name="UINT8">0</IntegerParameter> + <IntegerParameter Name="INT8">0</IntegerParameter> + <IntegerParameter Name="UINT8_Max">0</IntegerParameter> + <IntegerParameter Name="INT8_Max">0</IntegerParameter> + <!-- Tested Arrays --> + <IntegerParameter Name="UINT32_ARRAY">0</IntegerParameter> + <IntegerParameter Name="INT16_ARRAY">0</IntegerParameter> + <IntegerParameter Name="UINT8_ARRAY">0</IntegerParameter> + <IntegerParameter Name="UINT8_Max_ARRAY">0</IntegerParameter> + <!-- Tested String--> + <StringParameter Name="STR_CHAR128">string_Conf_1_1</StringParameter> + </Component> + </ConfigurableElement> + </Configuration> + <Configuration Name="Conf_1_0"> + <ConfigurableElement Path="/Test/Test/TEST_DIR"> + <Component Name="TEST_DIR"> + <!-- Tested Booleans --> + <BooleanParameter Name="BOOL">1</BooleanParameter> + <!-- Tested FixedPoints --> + <FixedPointParameter Name="FP8_Q0.7">0.9</FixedPointParameter> + <FixedPointParameter Name="FP8_Q7.0">0.9</FixedPointParameter> + <FixedPointParameter Name="FP8_Q3.4">0.9</FixedPointParameter> + <FixedPointParameter Name="FP16_Q0.15">0.9</FixedPointParameter> + <FixedPointParameter Name="FP16_Q15.0">0.9</FixedPointParameter> + <FixedPointParameter Name="FP16_Q7.8">0.9</FixedPointParameter> + <FixedPointParameter Name="FP32_Q0.31">0.9</FixedPointParameter> + <FixedPointParameter Name="FP32_Q31.0">0.9</FixedPointParameter> + <FixedPointParameter Name="FP32_Q15.16">0.9</FixedPointParameter> + <FixedPointParameter Name="FP32_Q8.20">0.9</FixedPointParameter> + <!-- Tested Integers --> + <IntegerParameter Name="UINT32">1</IntegerParameter> + <IntegerParameter Name="INT32">-1</IntegerParameter> + <IntegerParameter Name="UINT32_Max">1</IntegerParameter> + <IntegerParameter Name="INT32_Max">-1</IntegerParameter> + <IntegerParameter Name="UINT16">1</IntegerParameter> + <IntegerParameter Name="INT16">-1</IntegerParameter> + <IntegerParameter Name="UINT16_Max">1</IntegerParameter> + <IntegerParameter Name="INT16_Max">-1</IntegerParameter> + <IntegerParameter Name="UINT8">1</IntegerParameter> + <IntegerParameter Name="INT8">-1</IntegerParameter> + <IntegerParameter Name="UINT8_Max">1</IntegerParameter> + <IntegerParameter Name="INT8_Max">-1</IntegerParameter> + <!-- Tested Arrays --> + <IntegerParameter Name="UINT32_ARRAY">1</IntegerParameter> + <IntegerParameter Name="INT16_ARRAY">-1</IntegerParameter> + <IntegerParameter Name="UINT8_ARRAY">1</IntegerParameter> + <IntegerParameter Name="UINT8_Max_ARRAY">1</IntegerParameter> + <!-- Tested String--> + <StringParameter Name="STR_CHAR128">string_Conf_1_0</StringParameter> + </Component> + </ConfigurableElement> + </Configuration> + </Settings> + </ConfigurableDomain> +</ConfigurableDomains> diff --git a/test/functional-tests/xml/configuration/ParameterFrameworkConfiguration.xml b/test/functional-tests/xml/configuration/ParameterFrameworkConfiguration.xml new file mode 100644 index 0000000..85e9a0a --- /dev/null +++ b/test/functional-tests/xml/configuration/ParameterFrameworkConfiguration.xml @@ -0,0 +1,12 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ParameterFrameworkConfiguration SystemClassName="Test" ServerPort="5000" TuningAllowed="true"> + <SubsystemPlugins> + <Location Folder=""> + <Plugin Name="libtest-subsystem.so"/> + </Location> + </SubsystemPlugins> + <StructureDescriptionFileLocation Path="Structure/Test/TestClass.xml"/> + <SettingsConfiguration> + <ConfigurableDomainsFileLocation Path="Settings/Test/TestConfigurableDomains.xml"/> + </SettingsConfiguration> +</ParameterFrameworkConfiguration> diff --git a/test/functional-tests/xml/configuration/Settings/Test/TestConfigurableDomains.xml b/test/functional-tests/xml/configuration/Settings/Test/TestConfigurableDomains.xml new file mode 100644 index 0000000..fdc77e1 --- /dev/null +++ b/test/functional-tests/xml/configuration/Settings/Test/TestConfigurableDomains.xml @@ -0,0 +1,141 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ConfigurableDomains xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="/home/lab/ICS/hardware/intel/PRIVATE/parameter-framework/test/configuration/Schemas/ConfigurableDomains.xsd" SystemClassName="Test"> + <ConfigurableDomain Name="Domain_0"> + <Configurations> + <Configuration Name="Conf_0"> + <CompoundRule Type="All"> + <SelectionCriterionRule SelectionCriterion="Crit_0" MatchesWhen="Includes" Value="State_0x1"/> + <SelectionCriterionRule SelectionCriterion="Crit_1" MatchesWhen="Is" Value="State_1"/> + </CompoundRule> + </Configuration> + <Configuration Name="Conf_1"> + <CompoundRule Type="Any"> + <SelectionCriterionRule SelectionCriterion="Crit_0" MatchesWhen="Includes" Value="State_0x2"/> + <SelectionCriterionRule SelectionCriterion="Crit_1" MatchesWhen="IsNot" Value="State_1"/> + </CompoundRule> + </Configuration> + </Configurations> + + <ConfigurableElements> + <ConfigurableElement Path="/Test/Test/TEST_DIR" /> + <ConfigurableElement Path="/Test/Test/TEST_TYPES" /> + </ConfigurableElements> + + <Settings> + <Configuration Name="Conf_0"> + <ConfigurableElement Path="/Test/Test/TEST_DIR"> + <Component Name="TEST_DIR"> + <!-- Tested Booleans --> + <BooleanParameter Name="BOOL">0</BooleanParameter> + <!-- Tested FixedPoints --> + <FixedPointParameter Name="FP8_Q0.7">0</FixedPointParameter> + <FixedPointParameter Name="FP8_Q7.0">0</FixedPointParameter> + <FixedPointParameter Name="FP8_Q3.4">0</FixedPointParameter> + <FixedPointParameter Name="FP16_Q0.15">0</FixedPointParameter> + <FixedPointParameter Name="FP16_Q15.0">0</FixedPointParameter> + <FixedPointParameter Name="FP16_Q7.8">0</FixedPointParameter> + <FixedPointParameter Name="FP32_Q0.31">0</FixedPointParameter> + <FixedPointParameter Name="FP32_Q31.0">0</FixedPointParameter> + <FixedPointParameter Name="FP32_Q15.16">0</FixedPointParameter> + <FixedPointParameter Name="FP32_Q8.20">0</FixedPointParameter> + <!-- Tested Integers --> + <IntegerParameter Name="UINT32">0</IntegerParameter> + <IntegerParameter Name="INT32">0</IntegerParameter> + <IntegerParameter Name="UINT32_Max">0</IntegerParameter> + <IntegerParameter Name="INT32_Max">0</IntegerParameter> + <IntegerParameter Name="UINT16">0</IntegerParameter> + <IntegerParameter Name="INT16">0</IntegerParameter> + <IntegerParameter Name="UINT16_Max">0</IntegerParameter> + <IntegerParameter Name="INT16_Max">0</IntegerParameter> + <IntegerParameter Name="UINT8">0</IntegerParameter> + <IntegerParameter Name="INT8">0</IntegerParameter> + <IntegerParameter Name="UINT8_Max">0</IntegerParameter> + <IntegerParameter Name="INT8_Max">0</IntegerParameter> + <!-- Tested Arrays --> + <IntegerParameter Name="UINT32_ARRAY">0</IntegerParameter> + <IntegerParameter Name="INT16_ARRAY">0</IntegerParameter> + <IntegerParameter Name="UINT8_ARRAY">0</IntegerParameter> + <IntegerParameter Name="UINT8_Max_ARRAY">0</IntegerParameter> + <!-- Tested String--> + <StringParameter Name="STR_CHAR128">string_Conf_0</StringParameter> + </Component> + </ConfigurableElement> + <ConfigurableElement Path="/Test/Test/TEST_TYPES"> + <Component Name="TEST_TYPES"> + <EnumParameter Name="ENUM">ENUM_NOMINAL</EnumParameter> + <BitParameterBlock Name="BLOCK_8BIT"> + <BitParameter Name="BIT_0_3">0</BitParameter> + <BitParameter Name="BIT_3_1">0</BitParameter> + <BitParameter Name="BIT_4_1">0</BitParameter> + <BitParameter Name="BIT_6_2">0</BitParameter> + <BitParameter Name="BIT_7_1">0</BitParameter> + </BitParameterBlock> + <ParameterBlock Name="BLOCK_PARAMETER"> + <IntegerParameter Name="UINT8">0</IntegerParameter> + <IntegerParameter Name="UINT16">0</IntegerParameter> + <IntegerParameter Name="UINT32">0</IntegerParameter> + </ParameterBlock> + </Component> + </ConfigurableElement> + </Configuration> + <Configuration Name="Conf_1"> + <ConfigurableElement Path="/Test/Test/TEST_DIR"> + <Component Name="TEST_DIR"> + <!-- Tested Booleans --> + <BooleanParameter Name="BOOL">1</BooleanParameter> + <!-- Tested FixedPoints --> + <FixedPointParameter Name="FP8_Q0.7">0.9</FixedPointParameter> + <FixedPointParameter Name="FP8_Q7.0">1</FixedPointParameter> + <FixedPointParameter Name="FP8_Q3.4">1</FixedPointParameter> + <FixedPointParameter Name="FP16_Q0.15">0.9</FixedPointParameter> + <FixedPointParameter Name="FP16_Q15.0">1</FixedPointParameter> + <FixedPointParameter Name="FP16_Q7.8">1</FixedPointParameter> + <FixedPointParameter Name="FP32_Q0.31">0.9</FixedPointParameter> + <FixedPointParameter Name="FP32_Q31.0">1</FixedPointParameter> + <FixedPointParameter Name="FP32_Q15.16">1</FixedPointParameter> + <FixedPointParameter Name="FP32_Q8.20">1</FixedPointParameter> + <!-- Tested Integers --> + <IntegerParameter Name="UINT32">1</IntegerParameter> + <IntegerParameter Name="INT32">1</IntegerParameter> + <IntegerParameter Name="UINT32_Max">1</IntegerParameter> + <IntegerParameter Name="INT32_Max">1</IntegerParameter> + <IntegerParameter Name="UINT16">1</IntegerParameter> + <IntegerParameter Name="INT16">1</IntegerParameter> + <IntegerParameter Name="UINT16_Max">1</IntegerParameter> + <IntegerParameter Name="INT16_Max">1</IntegerParameter> + <IntegerParameter Name="UINT8">1</IntegerParameter> + <IntegerParameter Name="INT8">1</IntegerParameter> + <IntegerParameter Name="UINT8_Max">1</IntegerParameter> + <IntegerParameter Name="INT8_Max">1</IntegerParameter> + <!-- Tested Arrays --> + <IntegerParameter Name="UINT32_ARRAY">1</IntegerParameter> + <IntegerParameter Name="INT16_ARRAY">1</IntegerParameter> + <IntegerParameter Name="UINT8_ARRAY">1</IntegerParameter> + <IntegerParameter Name="UINT8_Max_ARRAY">1</IntegerParameter> + <!-- Tested String--> + <StringParameter Name="STR_CHAR128">string_Conf_1</StringParameter> + </Component> + </ConfigurableElement> + <ConfigurableElement Path="/Test/Test/TEST_TYPES"> + <Component Name="TEST_TYPES"> + <!--Tested Enum--> + <EnumParameter Name="ENUM">ENUM_MIN</EnumParameter> + <!--Tested Bit parameter block--> + <BitParameterBlock Name="BLOCK_8BIT"> + <BitParameter Name="BIT_0_3">0</BitParameter> + <BitParameter Name="BIT_3_1">0</BitParameter> + <BitParameter Name="BIT_4_1">0</BitParameter> + <BitParameter Name="BIT_6_2">0</BitParameter> + <BitParameter Name="BIT_7_1">0</BitParameter> + </BitParameterBlock> + <ParameterBlock Name="BLOCK_PARAMETER"> + <IntegerParameter Name="UINT8">0</IntegerParameter> + <IntegerParameter Name="UINT16">0</IntegerParameter> + <IntegerParameter Name="UINT32">0</IntegerParameter> + </ParameterBlock> + </Component> + </ConfigurableElement> + </Configuration> + </Settings> + </ConfigurableDomain> +</ConfigurableDomains> diff --git a/test/functional-tests/xml/configuration/Structure/Test/TestClass.xml b/test/functional-tests/xml/configuration/Structure/Test/TestClass.xml new file mode 100644 index 0000000..480aa05 --- /dev/null +++ b/test/functional-tests/xml/configuration/Structure/Test/TestClass.xml @@ -0,0 +1,4 @@ +<?xml version="1.0" encoding="UTF-8"?> +<SystemClass Name="Test"> + <SubsystemInclude Path="TestSubsystem.xml"/> +</SystemClass> diff --git a/test/functional-tests/xml/configuration/Structure/Test/TestSubsystem.xml b/test/functional-tests/xml/configuration/Structure/Test/TestSubsystem.xml new file mode 100644 index 0000000..839b418 --- /dev/null +++ b/test/functional-tests/xml/configuration/Structure/Test/TestSubsystem.xml @@ -0,0 +1,84 @@ +<?xml version="1.0" encoding="UTF-8"?> +<Subsystem xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="/home/lab/ICS/hardware/intel/PRIVATE/parameter-framework/test/configuration/Schemas/Subsystem.xsd" Name="Test" Type="TEST" Endianness="Little"> + <ComponentLibrary> + <ComponentType Name="TEST_DIR"> + <!-- Tested Booleans --> + <BooleanParameter Name="BOOL" Mapping="Binary:BOOL"/> + <!-- Tested FixedPoints --> + <FixedPointParameter Name="FP8_Q0.7" Size="8" Integral="0" Fractional="7" Mapping="Binary:FP8_Q.7"/> + <FixedPointParameter Name="FP8_Q7.0" Size="8" Integral="7" Fractional="0" Mapping="Binary:FP8_7.0"/> + <FixedPointParameter Name="FP8_Q3.4" Size="8" Integral="3" Fractional="4" Mapping="Binary:FP8_3.4"/> + <FixedPointParameter Name="FP16_Q0.15" Size="16" Integral="0" Fractional="15" Mapping="Binary:FP16_Q.15"/> + <FixedPointParameter Name="FP16_Q15.0" Size="16" Integral="15" Fractional="0" Mapping="Binary:FP16_15.0"/> + <FixedPointParameter Name="FP16_Q7.8" Size="16" Integral="7" Fractional="8" Mapping="Binary:FP16_7.8"/> + <FixedPointParameter Name="FP32_Q0.31" Size="32" Integral="0" Fractional="31" Mapping="Binary:FP32_Q.31"/> + <FixedPointParameter Name="FP32_Q31.0" Size="32" Integral="31" Fractional="0" Mapping="Binary:FP32_31.0"/> + <FixedPointParameter Name="FP32_Q15.16" Size="32" Integral="15" Fractional="16" Mapping="Binary:FP32_15.16"/> + <FixedPointParameter Name="FP32_Q8.20" Size="32" Integral="8" Fractional="20" Mapping="Binary:FP32_Q8.20"/> + <!-- Tested Integers --> + <IntegerParameter Name="UINT32" Size="32" Signed="false" Max="1000" Mapping="Binary:UINT32"/> + <IntegerParameter Name="INT32" Size="32" Signed="true" Min="-1000" Max="1000" Mapping="Binary:INT32"/> + <IntegerParameter Name="UINT32_Max" Size="32" Signed="false" Max="4294967295" Mapping="Binary:UINT32_Max"/> + <IntegerParameter Name="INT32_Max" Size="32" Signed="true" Min="-2147483648" Max="2147483647" Mapping="Binary:INT32"/> + <IntegerParameter Name="UINT16" Size="16" Signed="false" Max="1000" Mapping="Binary:UINT16"/> + <IntegerParameter Name="INT16" Size="16" Signed="true" Min="-1000" Max="1000" Mapping="Binary:INT16"/> + <IntegerParameter Name="UINT16_Max" Size="16" Signed="false" Max="65535" Mapping="Binary:UINT16_Max"/> + <IntegerParameter Name="INT16_Max" Size="16" Signed="true" Min="-32768" Max="32767" Mapping="Binary:INT16_Max"/> + <IntegerParameter Name="UINT8" Size="8" Signed="false" Max="100" Mapping="Binary:UINT8"/> + <IntegerParameter Name="INT8" Size="8" Signed="true" Min="-100" Max="100" Mapping="Binary:INT8"/> + <IntegerParameter Name="UINT8_Max" Size="8" Signed="false" Max="255" Mapping="Binary:UINT8_Max"/> + <IntegerParameter Name="INT8_Max" Size="8" Signed="true" Min="-128" Max="127" Mapping="Binary:INT8_Max"/> + <!-- Tested Arrays --> + <IntegerParameter Name="UINT32_ARRAY" Size="32" Signed="false" ArrayLength="100" Min="0" Max="100" Mapping="Binary:UINT32_ARRAY"/> + <IntegerParameter Name="INT16_ARRAY" Size="16" Signed="true" ArrayLength="5" Min="-50" Max="50" Mapping="Binary:INT16_ARRAY_signed"/> + <IntegerParameter Name="UINT8_ARRAY" Size="8" Signed="false" ArrayLength="5" Min="0" Max="15" Mapping="Binary:UINT8_ARRAY"/> + <IntegerParameter Name="UINT8_Max_ARRAY" Size="8" Signed="false" ArrayLength="5" Min="0" Max="255" Mapping="Binary:UINT8_Max_ARRAY"/> + <!-- Tested String--> + <StringParameter Name="STR_CHAR128" MaxLength="128" Mapping="String:STRING"/> + </ComponentType> + <ComponentType Name="TEST_DOMAIN_0"> + <IntegerParameter Name="Param_00" Size="16" Signed="false" Mapping="Binary:Param_00"/> + <IntegerParameter Name="Param_01" Size="16" Signed="false" Mapping="Binary:Param_01"/> + <IntegerParameter Name="Param_02" Size="16" Signed="false" Mapping="Binary:Param_02"/> + </ComponentType> + <ComponentType Name="TEST_DOMAIN_1"> + <IntegerParameter Name="Param_10" Size="16" Signed="false" Mapping="Binary:Param_10"/> + <IntegerParameter Name="Param_11" Size="16" Signed="false" Mapping="Binary:Param_11"/> + <IntegerParameter Name="Param_12" Size="16" Signed="false" Mapping="Binary:Param_12"/> + </ComponentType> + <ComponentType Name="TEST_TYPES"> + <!-- Tested Enum --> + <EnumParameter Name="ENUM" Size="8" Mapping="Binary:ENUM"> + <ValuePair Literal="ENUM_MIN" Numerical="-128"/> + <ValuePair Literal="ENUM_MAX" Numerical="127"/> + <ValuePair Literal="ENUM_NOMINAL" Numerical="5"/> + <ValuePair Literal="ENUM_OOB" Numerical="255"/> + <ValuePair Literal="ENUM_OOS" Numerical="256"/> + </EnumParameter> + <BitParameterBlock Name="BLOCK_8BIT" Size="8" Mapping="Binary:BLOCK_8BIT"> + <BitParameter Name="BIT_0_3" Size="3" Pos="0"/> + <BitParameter Name="BIT_3_1" Size="1" Pos="3"/> + <BitParameter Name="BIT_4_1" Size="1" Pos="4"/> + <BitParameter Name="BIT_6_2" Size="2" Pos="6"/> + <BitParameter Name="BIT_7_1" Size="1" Pos="7"/> + </BitParameterBlock> + <ParameterBlock Name="BLOCK_PARAMETER"> + <IntegerParameter Name="UINT8" Size="8" Signed="false" Mapping="Binary:BLOCK_UINT8"/> + <IntegerParameter Name="UINT16" Size="16" Signed="false" Mapping="Binary:BLOCK_UINT16"/> + <IntegerParameter Name="UINT32" Size="32" Signed="false" Mapping="Binary:BLOCK_UINT32"/> + </ParameterBlock> + </ComponentType> + <ComponentType Name="TEST_MAIN"> + <Component Name = "TEST_DIR_0" Type="TEST_DIR"/> + <Component Name = "TEST_DIR_1" Type="TEST_DOMAIN_0"/> + <Component Name = "TEST_DIR_2" Type="TEST_DOMAIN_1"/> + </ComponentType> + </ComponentLibrary> + <InstanceDefinition> + <Component Name="TEST_DIR" Type="TEST_DIR" Mapping="Directory:/tmp/test-parameters"/> + <Component Name="TEST_DOMAIN_0" Type="TEST_DOMAIN_0" Mapping="Directory:/tmp/test-parameters"/> + <Component Name="TEST_DOMAIN_1" Type="TEST_DOMAIN_1" Mapping="Directory:/tmp/test-parameters"/> + <Component Name="TEST_TYPES" Type="TEST_TYPES" Mapping="Directory:/tmp/test-parameters"/> + <Component Name="TEST_MAIN" Type="TEST_MAIN" Mapping="Directory:/tmp/test-parameters"/> + </InstanceDefinition> +</Subsystem> |