1*c33452fbSAndroid Build Coastguard Worker#!/usr/bin/python2 2*c33452fbSAndroid Build Coastguard Worker# -*-coding:utf-8 -* 3*c33452fbSAndroid Build Coastguard Worker 4*c33452fbSAndroid Build Coastguard Worker# Copyright (c) 2011-2015, Intel Corporation 5*c33452fbSAndroid Build Coastguard Worker# All rights reserved. 6*c33452fbSAndroid Build Coastguard Worker# 7*c33452fbSAndroid Build Coastguard Worker# Redistribution and use in source and binary forms, with or without modification, 8*c33452fbSAndroid Build Coastguard Worker# are permitted provided that the following conditions are met: 9*c33452fbSAndroid Build Coastguard Worker# 10*c33452fbSAndroid Build Coastguard Worker# 1. Redistributions of source code must retain the above copyright notice, this 11*c33452fbSAndroid Build Coastguard Worker# list of conditions and the following disclaimer. 12*c33452fbSAndroid Build Coastguard Worker# 13*c33452fbSAndroid Build Coastguard Worker# 2. Redistributions in binary form must reproduce the above copyright notice, 14*c33452fbSAndroid Build Coastguard Worker# this list of conditions and the following disclaimer in the documentation and/or 15*c33452fbSAndroid Build Coastguard Worker# other materials provided with the distribution. 16*c33452fbSAndroid Build Coastguard Worker# 17*c33452fbSAndroid Build Coastguard Worker# 3. Neither the name of the copyright holder nor the names of its contributors 18*c33452fbSAndroid Build Coastguard Worker# may be used to endorse or promote products derived from this software without 19*c33452fbSAndroid Build Coastguard Worker# specific prior written permission. 20*c33452fbSAndroid Build Coastguard Worker# 21*c33452fbSAndroid Build Coastguard Worker# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 22*c33452fbSAndroid Build Coastguard Worker# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 23*c33452fbSAndroid Build Coastguard Worker# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 24*c33452fbSAndroid Build Coastguard Worker# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 25*c33452fbSAndroid Build Coastguard Worker# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26*c33452fbSAndroid Build Coastguard Worker# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 27*c33452fbSAndroid Build Coastguard Worker# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 28*c33452fbSAndroid Build Coastguard Worker# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29*c33452fbSAndroid Build Coastguard Worker# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 30*c33452fbSAndroid Build Coastguard Worker# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31*c33452fbSAndroid Build Coastguard Worker 32*c33452fbSAndroid Build Coastguard Worker""" 33*c33452fbSAndroid Build Coastguard WorkerCreate a test suite for all tests about SET/GET commands 34*c33452fbSAndroid Build Coastguard Worker 35*c33452fbSAndroid Build Coastguard WorkerUses PfwSetTsetSuite to create a single instance of the HAL 36*c33452fbSAndroid Build Coastguard Workerfor all the SET/GEt commands. 37*c33452fbSAndroid Build Coastguard Worker 38*c33452fbSAndroid Build Coastguard WorkerThese commands are tested using the methods of the classes 39*c33452fbSAndroid Build Coastguard Worker"BooleanTestCase", etc... 40*c33452fbSAndroid Build Coastguard Worker""" 41*c33452fbSAndroid Build Coastguard Worker 42*c33452fbSAndroid Build Coastguard Workerimport sys 43*c33452fbSAndroid Build Coastguard Workerimport os 44*c33452fbSAndroid Build Coastguard Workerimport unittest 45*c33452fbSAndroid Build Coastguard Workerimport shutil 46*c33452fbSAndroid Build Coastguard Workerfrom Util import PfwUnitTestLib 47*c33452fbSAndroid Build Coastguard Worker 48*c33452fbSAndroid Build Coastguard Workerclass Logger(object): 49*c33452fbSAndroid Build Coastguard Worker 50*c33452fbSAndroid Build Coastguard Worker def __init__(self, filename="Default.log"): 51*c33452fbSAndroid Build Coastguard Worker self.terminal = sys.stdout 52*c33452fbSAndroid Build Coastguard Worker self.log = open(filename, "a") 53*c33452fbSAndroid Build Coastguard Worker 54*c33452fbSAndroid Build Coastguard Worker def write(self, message): 55*c33452fbSAndroid Build Coastguard Worker self.terminal.write(message) 56*c33452fbSAndroid Build Coastguard Worker self.log.write(message) 57*c33452fbSAndroid Build Coastguard Worker 58*c33452fbSAndroid Build Coastguard Workerdef testsRunner(testDirectory): 59*c33452fbSAndroid Build Coastguard Worker 60*c33452fbSAndroid Build Coastguard Worker tests = unittest.defaultTestLoader.discover(testDirectory, pattern='t*.py') 61*c33452fbSAndroid Build Coastguard Worker runner = unittest.TextTestRunner(verbosity=2) 62*c33452fbSAndroid Build Coastguard Worker 63*c33452fbSAndroid Build Coastguard Worker return runner.run(tests).wasSuccessful() 64*c33452fbSAndroid Build Coastguard Worker 65*c33452fbSAndroid Build Coastguard Workerdef main(): 66*c33452fbSAndroid Build Coastguard Worker 67*c33452fbSAndroid Build Coastguard Worker pfw_root = os.environ["PFW_ROOT"] 68*c33452fbSAndroid Build Coastguard Worker pfw_result = os.environ["PFW_RESULT"] 69*c33452fbSAndroid Build Coastguard Worker xml_path = "xml/configuration/ParameterFrameworkConfiguration.xml" 70*c33452fbSAndroid Build Coastguard Worker 71*c33452fbSAndroid Build Coastguard Worker os.environ["PFW_TEST_TOOLS"] = os.path.dirname(os.path.abspath(__file__)) 72*c33452fbSAndroid Build Coastguard Worker os.environ["PFW_TEST_CONFIGURATION"] = os.path.join(pfw_root, xml_path) 73*c33452fbSAndroid Build Coastguard Worker 74*c33452fbSAndroid Build Coastguard Worker try: 75*c33452fbSAndroid Build Coastguard Worker # This directory must not exist. An exception will be raised if it does. 76*c33452fbSAndroid Build Coastguard Worker os.makedirs(pfw_result) 77*c33452fbSAndroid Build Coastguard Worker 78*c33452fbSAndroid Build Coastguard Worker isAlive = os.path.join(pfw_result,"isAlive") 79*c33452fbSAndroid Build Coastguard Worker with open(isAlive, 'w') as fout: 80*c33452fbSAndroid Build Coastguard Worker fout.write('true') 81*c33452fbSAndroid Build Coastguard Worker 82*c33452fbSAndroid Build Coastguard Worker needResync = os.path.join(pfw_result,"needResync") 83*c33452fbSAndroid Build Coastguard Worker with open(needResync, 'w') as fout: 84*c33452fbSAndroid Build Coastguard Worker fout.write('false') 85*c33452fbSAndroid Build Coastguard Worker 86*c33452fbSAndroid Build Coastguard Worker success = testsRunner('PfwTestCase') 87*c33452fbSAndroid Build Coastguard Worker 88*c33452fbSAndroid Build Coastguard Worker finally: 89*c33452fbSAndroid Build Coastguard Worker shutil.rmtree(pfw_result) 90*c33452fbSAndroid Build Coastguard Worker 91*c33452fbSAndroid Build Coastguard Worker sys.exit(0 if success else 1) 92*c33452fbSAndroid Build Coastguard Worker 93*c33452fbSAndroid Build Coastguard Workerif __name__ == "__main__": 94*c33452fbSAndroid Build Coastguard Worker main() 95