diff --git a/linux-tools/autotest-build-tools/FYI/README.txt b/linux-tools/autotest-build-tools/FYI/README.txt new file mode 100644 index 000000000..565baac23 --- /dev/null +++ b/linux-tools/autotest-build-tools/FYI/README.txt @@ -0,0 +1,33 @@ +#========================================================================================================== +## +## FILE: README.txt +## +## DESCRIPTION: This File contains the steps of build and test autotest tests for all Linux Distribution +## +## OPTIONS: --- +## REQUIREMENTS: --- +## BUGS: --- +## NOTES: --- +## AUTHOR: IBM LTC Test Team +## COMPANY: IBM +## VERSION: 1.0 +## CREATED: 16-Feb-2017 Abhishek Sharma < abhisshm@in.ibm.com > +## REVISION: 22-Feb-2017 Abhishek Sharma < abhisshm@in.ibm.com > +##========================================================================================================== + + +Supported Linux Destro : Redhat,Ubuntu,suse,CentOS + Supported Arch : Intel X86_64 and ia32 + IBM Power (ppc,ppc64,ppc64le,ppcnf) + IBM Z box( s390x) + +Below steps are automted in run.py script, for better understanding steps are written down. + +1) Git clone the latest autotest and autotest-linux-tools +2) Based on the arguments build the required packages and copy to autotest-linux-tools/linux-tools +3) Run Autotest-client-tests + + +NOTE : Before running the run.py script please verify modules/build_conf.py script + This is a configuration file to execute run.py + Before executing modify the data based on your requirement diff --git a/linux-tools/autotest-build-tools/FYI/chromedriver b/linux-tools/autotest-build-tools/FYI/chromedriver new file mode 100755 index 000000000..7136ba6ba Binary files /dev/null and b/linux-tools/autotest-build-tools/FYI/chromedriver differ diff --git a/linux-tools/autotest-build-tools/FYI/sources.list b/linux-tools/autotest-build-tools/FYI/sources.list new file mode 100644 index 000000000..f042a573e --- /dev/null +++ b/linux-tools/autotest-build-tools/FYI/sources.list @@ -0,0 +1,43 @@ +# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to +# newer versions of the distribution. +deb http://archive.ubuntu.com/ubuntu CHANGE_ME main restricted +deb-src http://archive.ubuntu.com/ubuntu CHANGE_ME main #restricted + +## Major bug fix updates produced after the final release of the +## distribution. +deb http://archive.ubuntu.com/ubuntu CHANGE_ME-updates main restricted +deb-src http://archive.ubuntu.com/ubuntu CHANGE_ME-updates main #restricted + +## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu +## team. Also, please note that software in universe WILL NOT receive any +## review or updates from the Ubuntu security team. +deb http://archive.ubuntu.com/ubuntu CHANGE_ME universe +deb-src http://archive.ubuntu.com/ubuntu CHANGE_ME universe +deb http://archive.ubuntu.com/ubuntu CHANGE_ME-updates universe +deb-src http://archive.ubuntu.com/ubuntu CHANGE_ME-updates universe + +## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu +## team, and may not be under a free licence. Please satisfy yourself as to +## your rights to use the software. Also, please note that software in +## multiverse WILL NOT receive any review or updates from the Ubuntu +## security team. +deb http://archive.ubuntu.com/ubuntu CHANGE_ME multiverse +deb-src http://archive.ubuntu.com/ubuntu CHANGE_ME multiverse +deb http://archive.ubuntu.com/ubuntu CHANGE_ME-updates multiverse +deb-src http://archive.ubuntu.com/ubuntu CHANGE_ME-updates multiverse + +## N.B. software from this repository may not have been tested as +## extensively as that contained in the main release, although it includes +## newer versions of some applications which may provide useful features. +## Also, please note that software in backports WILL NOT receive any review +## or updates from the Ubuntu security team. +deb http://archive.ubuntu.com/ubuntu CHANGE_ME-backports main restricted universe multiverse +deb-src http://archive.ubuntu.com/ubuntu CHANGE_ME-backports main restricted universe multiverse + +deb http://security.ubuntu.com/ubuntu CHANGE_ME-security main restricted +deb-src http://security.ubuntu.com/ubuntu CHANGE_ME-security main restricted +deb http://security.ubuntu.com/ubuntu CHANGE_ME-security universe +deb-src http://security.ubuntu.com/ubuntu CHANGE_ME-security universe +deb http://security.ubuntu.com/ubuntu CHANGE_ME-security multiverse +deb-src http://security.ubuntu.com/ubuntu CHANGE_ME-security multiverse + diff --git a/linux-tools/autotest-build-tools/input_file b/linux-tools/autotest-build-tools/input_file new file mode 100644 index 000000000..cd9f49320 --- /dev/null +++ b/linux-tools/autotest-build-tools/input_file @@ -0,0 +1,98 @@ +libclass-singleton-perl +libenv-sanctify-perl +liblocale-gettext-perl +libperl6-export-perl +libdigest-hmac-perl +liblatex-encode-perl +liblwp-protocol-https-perl +libacme-constant-perl +libxml-parser-perl +libanyevent-dbd-pg-perl +libasyncns0 +perl-doc +libparse-yapp-perl +perl-modules +libxml-parser-perl +libtest-carp-perl +libasound2 +libsub-uplevel-perl +claws-mail-perl-filter +libtext-unidecode-perl +bc +libhttp-tiny-perl +librose-uri-perl +bridge-utils +libnet-ssleay-perl +openhpid +libxml-dom-perl +libemail-thread-perl +libavahi +perl-doc-html +libatk +liblwp-mediatypes-perl +augeas-tools +libtext-iconv-perl +nscd +libtie-ixhash-perl +libwww-curl-perl +libnet-http-perl +libbusiness-isbn-perl +perl-doc +libclass-std-storable-perl +libcarp-clan-perl +libio-socket-ip-perl +libcompress-raw-bzip2-perl +libxml-sax-writer-perl +libcompress-raw-zlib-perl +libio-compress-perl +libxml-sax-perl +libconfig-general-perl +libconvert-asn1-perl +libcrypt-ssleay-perl +liblwp-authen-negotiate-perl +libauthen-sasl-perl +libscalar-list-utils-perl +libbit-vector-perl +perl-modules +libnet-ldap-perl +libxml-xql-perl +libbusiness-isbn-data-perl +perl-doc +libdata-dumper-simple-perl +libxml-sax-expatxs-perl +libxml-simple-perl +libdate-calc-perl +libxml-dumper-perl +libdate-manip-perl +libtext-soundex-perl +libdigest-sha-perl +libwww-robotrules-perl +libencode-locale-perl +libpod-simple-perl +libfile-which-perl +libfile-path-tiny-perl +libfile-fu-perl +libfont-afm-perl + libperl4-corelibs-perl +libtemplate-plugin-number-format-perl +libio-socket-ip-perl +libhtml-parser-perl +libhtml-parser-perl +libhtml-tree-perl +libhttp-cookies-perl +libhttp-daemon-ssl-perl +libghc-http-date-dev +libhttp-message-perl +libstring-crc32-perl +liblwp-protocol-https-perl +libtool-bin +arptables +at +autofs +libnetfilter-conntrack3 +libmnl0 +kpartx +python-slip +libgstreamer0 +libdaemon0 +libevent diff --git a/linux-tools/autotest-build-tools/modules/.src_dest_file.py.swp b/linux-tools/autotest-build-tools/modules/.src_dest_file.py.swp new file mode 100644 index 000000000..69344b0ee Binary files /dev/null and b/linux-tools/autotest-build-tools/modules/.src_dest_file.py.swp differ diff --git a/linux-tools/autotest-build-tools/modules/__init__.py b/linux-tools/autotest-build-tools/modules/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/linux-tools/autotest-build-tools/modules/build_conf.py b/linux-tools/autotest-build-tools/modules/build_conf.py new file mode 100644 index 000000000..9016ac43b --- /dev/null +++ b/linux-tools/autotest-build-tools/modules/build_conf.py @@ -0,0 +1,50 @@ +#!/usr/bin/python + +######################################################### +# +# THIS IS BUILD CONF FILE , MODIFY BASED ON YOUR NEED +# +######################################################### + +class generic_conf: + build_type = "UBUNTU" # Give CUSTOM/UBUNTU/CENTOS/RHEL for respective build + basedir = "/var/tmp/ubuntu_build" # Change this baseed on your requirement + logdir = "%s/logs" %basedir + logfile = "%s/final_report.logs" %logdir + package_list_file = "/home/ubuntu/autotest-build-tools/input_file" # This file will contain the package name to be build + binary_src_dir = "%s/autotest-binaries" %basedir # All the compile binaries will be copied in this location, you can change based on your requirement + sms_notofication = "n" # 'n' for no, this feature is only available for INDIA + mobile_number = "" # Only applicable for india number + python_modules = [ 'pyvirtualdisplay','selenium',] + + + +class ubuntu_conf: + build_src_distribution = ['xenial'] # for rhel or suse mentioned the distribution name or distribution version rhel7.4 for building + #build_src_distribution = ['zesty'] # for rhel or suse mentioned the distribution name or distribution version rhel7.4 for building + supported_release = [ 'precise','trusty','xenial','yakkety','zesty' ] + prerequisite_packages = ['packaging-dev','python-pip'] # If you want to add more packages to be part of your prerequisite add like ['pkg1','pkg2'] + repo_file = "/etc/apt/sources.list" # Default repo file for ubuntu + template_repo_file = "FYI/sources.list" # Update your src repo entries in case default data is not enough to build the packages + chroot_path = "/var/cache/pbuilder" + pbuilder_script_file = "/usr/lib/pbuilder/pbuilder-buildpackage" # Do not change the file or else build is fail for all packages + pbuilder_build_path = "/var/cache/pbuilder/build/*/build/*" + + + +class rhel_conf: + build_src_distribution = [] # for rhel or suse mentioned the distribution name or distribution version rhel7.4 for building + supported_release = [ '7.1','7.2','7.3' ] + +class suse_conf: + build_src_distribution = [] # for rhel or suse mentioned the distribution name or distribution version rhel7.4 for building + supported_release = [ ] + + +class custom_conf: + #build_tag = [ 'ALL' ] # for specific build tag mentioned like mcp8_1-ppc64le + build_tag = [ '','' ] # for specific build tag mentioned like mcp8_1-ppc64le + input_file = "" # This file will contain the packges to be build for autotest + build_supporting_tags = ['','','','ALL'] + sleep_tag = "3600" # After instance will sleep for these many sec, you can modify based on your requirement + num_of_build_per_cycle = "14" diff --git a/linux-tools/autotest-build-tools/modules/centos_module.py b/linux-tools/autotest-build-tools/modules/centos_module.py new file mode 100644 index 000000000..e69de29bb diff --git a/linux-tools/autotest-build-tools/modules/custom_module.py b/linux-tools/autotest-build-tools/modules/custom_module.py new file mode 100644 index 000000000..4c31bfcfe --- /dev/null +++ b/linux-tools/autotest-build-tools/modules/custom_module.py @@ -0,0 +1,65 @@ +#!/usr/bin/python +import os,sys,logging,time + + +# Import custom modules +from build_conf import * +from generic_module import * + +#################################################### +# Capture all variables based on build conf file +#################################################### +SLEEP_TAG = custom_conf.sleep_tag +BUILD_NUMS = custom_conf.num_of_build_per_cycle +BASEDIR = generic_conf.basedir +LOGDIR = generic_conf.logdir +return_code = os.system("ls -ld %s >/dev/null 2>&1" %LOGDIR) +if return_code != 0: + create_status = os.system("mkdir -p %s >/dev/null 2>&1 " %LOGDIR) + if create_status != 0: + print col.red + "\nERROR: Failed while creating directory %s\n" %LOGDIR + col.norm + sys.exit(0) + + +LOGFILE = generic_conf.logfile +logging.basicConfig(filename=LOGFILE,format='%(asctime)s - [ %(levelname)s ] - %(message)s',level=logging.DEBUG) + +try: + LOCAL_BUILD_TAG = custom_conf.build_tag +except: + display_message_fn("Seems like build_tag is commented or deleted in conf file","ERROR") + footer_fn(BASEDIR,LOGDIR,LOGFILE) + sys.exit(0) + +try: + BUILD_SUPPORTED_TAG = custom_conf.build_supporting_tags +except: + display_message_fn("Seems like build_supporting_tags is commented or deleted in conf file","ERROR") + footer_fn(BASEDIR,LOGDIR,LOGFILE) + sys.exit(0) + + + + + + +#################################################### +# Function to verify given input is valid or not +#################################################### +def varify_build_fn(): + for input_tags in LOCAL_BUILD_TAG: + if input_tags in BUILD_SUPPORTED_TAG: + continue + else: + display_message_fn("Given input tag \"%s\" is not supported right now" %input_tags,"ERROR") + footer_fn(BASEDIR,LOGDIR,LOGFILE) + sys.exit(0) + + + +########################################################## +# Funtion to setup required environment +########################################################## + +varify_build_fn() +footer_fn(BASEDIR,LOGDIR,LOGFILE) diff --git a/linux-tools/autotest-build-tools/modules/generic_module.py b/linux-tools/autotest-build-tools/modules/generic_module.py new file mode 100644 index 000000000..fe1a7e773 --- /dev/null +++ b/linux-tools/autotest-build-tools/modules/generic_module.py @@ -0,0 +1,164 @@ +#!/usr/bin/python +import os,sys,logging +from build_conf import * +############################################# +# Create a class for define colors +############################################# +class col: + red = '\033[1;91m' + blue = '\033[1;94m' + bold = '\033[1m' + under_line = '\033[1;4m' + yellow = '\033[1;93m' + norm = '\033[0m' + green = '\033[1;92m' + cyan = '\033[1;36m' + + + +################################################### +# Function to display the logs file information +################################################### +def footer_fn(arg1,arg2,arg3,arg4,basedir,logdir,logfile,binary_path,total_count,success_count,skipped_count,failed_count): + l_hostname = arg1 + l_dist_name = arg2 + l_dist_ver = arg3 + l_build_req = arg4 + local_basedir = basedir + local_logdir = logdir + local_logfile = logfile + l_total = total_count + l_success = success_count + l_skipped = skipped_count + l_failed = failed_count + l_binary_path = binary_path + + print """ + + + + ====================================================================================== + A U T O T E S T B I N A R Y B U I L D T O O L + + HOSTNAME : %s + CURRENT DISTRIBUTION NAME : %s + CURRENT DISTRIBUTION VERSION : %s + BUILD REQUESTED FOR : %s + + + + BASEDIR : %s + LOGDIR : %s + LOGFILE : %s + TEST BINARIES : %s + + + TOTAL PACKAGE TO BE BUILD : %s + SUCCESS BUILD : %s + SKIPPED BUILD : %s + FAILED BUILD : %s + + + ======================================================================================= + + +""" %(l_hostname,l_dist_name,l_dist_ver,l_build_req,local_basedir,local_logdir,local_logfile,l_binary_path,l_total,l_success,l_skipped,l_failed) + + +##################################################### +# Function to display header of script +##################################################### +def header_fn(arg1,arg2,arg3,arg4): + l_hostname = arg1 + l_dist_name = arg2 + l_dist_ver = arg3 + l_build_req = arg4 + print """ + + + ============================================================================================== + A U T O T E S T B I N A R Y B U I L D T O O L + + H O S T N A M E : %s + C U R R E N T D I S T R I B U T I O N N A M E : %s + C U R R E N T D I S T R I B U T I O N V E R S I O N : %s + B U I L D R E Q U E S T : %s + + + + =============================================================================================== + + +"""%(l_hostname,l_dist_name,l_dist_ver,l_build_req) + + + +def display_message_fn(arg1,arg2): + TEXT= arg1 + MSG= arg2 + cmd = "echo %s | awk -v msg=\"%s\" '{printf(\"%%5s %%-100s %%10s\",\"\",$0,\"[ \"msg\" ]\")}'" %(TEXT,MSG) + data_to_display = os.popen(cmd).read() + if MSG == "ERROR": + print col.red + data_to_display + col.norm + logging.error(TEXT) + elif MSG == "OK": + print col.green + data_to_display + col.norm + logging.info(TEXT) + elif MSG == "INFO": + print col.bold + data_to_display + col.norm + logging.info(TEXT) + elif MSG == "WARN": + print col.cyan + data_to_display + col.norm + logging.warning(TEXT) + elif MSG == "SKIPPED": + print col.cyan + data_to_display + col.norm + logging.info(TEXT) + else: + print data_to_display + + + +def install_python_module_fn(): + LISTS = generic_conf.python_modules + for list in LISTS: + status = os.system("python -c \"import %s\" >/dev/null 2>&1" %list) + if status != 0: + display_message_fn("Python module %s is not installed, installing it.. please wait." %list,"WARN") + command_check = os.system("sudo pip install %s >/dev/null 2>&1"%list) + if command_check == 0: + display_message_fn("Successfully installed module %s " %list,"OK") + else: + display_message_fn("Failed while installing module %s , please check and rerun the script" %list,"ERROR") + sys.exit(0) + else: + display_message_fn("Python module %s is already installed" %list,"OK") + + +def send_sms_fn(num,text): + value = os.system("dpkg --list|grep google-chrome >/dev/null 2>&1") + if value != 0: + display_message_fn("To run this sms feature you should install google chrome","INFO") + sys.exit(0) + + + from selenium import webdriver + from selenium.webdriver.common.keys import Keys + import time + from pyvirtualdisplay import Display + display = Display(visible=0, size=(800, 800)) + display.start() + number_l = num + message_l = text + chrome_path = "FYI/chromedriver" + driver = webdriver.Chrome(chrome_path) + driver.get("http://site24.way2sms.com/content/index.html") + driver.find_element_by_xpath("""//*[@id="username"]""").send_keys("8147894264") + driver.find_element_by_xpath("""//*[@id="password"]""").send_keys("Letmein") + driver.find_element_by_id("loginBTN").click() + driver.find_element_by_css_selector(".button.br3").click() + driver.find_element_by_id("sendSMS").click() + frame = driver.find_element_by_xpath('//*[@id="frame"]') + driver.switch_to.frame(frame) + driver.find_element_by_id("mobile").send_keys(number_l) + driver.find_element_by_id("message").send_keys(message_l) + driver.find_element_by_id("Send").click() diff --git a/linux-tools/autotest-build-tools/modules/rhel_module.py b/linux-tools/autotest-build-tools/modules/rhel_module.py new file mode 100644 index 000000000..e69de29bb diff --git a/linux-tools/autotest-build-tools/modules/src_dest_file.py b/linux-tools/autotest-build-tools/modules/src_dest_file.py new file mode 100644 index 000000000..df3f09c3d --- /dev/null +++ b/linux-tools/autotest-build-tools/modules/src_dest_file.py @@ -0,0 +1,19 @@ +#!/usr/bin/python +############################################################################################ +# +# Description : This file will contain and of all test binaries +# +# : Once build is done, what need to copied. +# : Source need to be copied in a specfic autotest folder to test. +# +############################################################################################# + + +############################################################################################# +# This class contain the packages name and what need to copied and where need to be copied +############################################################################################# +class ubuntu_src_dest: + libffi6 = {'TEST_SOURCE': ['testsuite'],'DESTINATION': ['']} + libmnl0 = {'TEST_SOURCE': ['examples/genl/.libs','examples/netfilter/.libs','examples/rtnl/.libs/'],'DESTINATION': ['tests']} + libnetfilter-conntrack3 = {'TEST_SOURCE': ['utils/.libs/'],'DESTINATION': ['utils']} + parted = {'TEST_SOURCE': ['tests/.libs','tests','build-aux'],'DESTINATION': ['']} diff --git a/linux-tools/autotest-build-tools/modules/ubuntu_module.py b/linux-tools/autotest-build-tools/modules/ubuntu_module.py new file mode 100644 index 000000000..b5b48d7b9 --- /dev/null +++ b/linux-tools/autotest-build-tools/modules/ubuntu_module.py @@ -0,0 +1,345 @@ +#!/usr/bin/python + +############################## +# Import global modules +############################## +import os,sys,logging + + +################################## +# Import local modules +################################## +from build_conf import * +from generic_module import * + +####################################################################### +# Initializing the Global and local variable used in this modules +####################################################################### +SRC_DIST = ubuntu_conf.build_src_distribution +BASEDIR = generic_conf.basedir +LOGDIR = generic_conf.logdir +REPO_FILE = ubuntu_conf.repo_file +PBUILD_SCRIPT = ubuntu_conf.pbuilder_script_file +PBUILD_BUILD_PATH = ubuntu_conf.pbuilder_build_path +NOTIFICATION_ACTION = generic_conf.sms_notofication +MOBILE_NUM = generic_conf.mobile_number +repo_return_code = os.system("ls -ld %s >/dev/null 2>&1" %REPO_FILE) +if repo_return_code != 0: + print col.red + "\nERROR: REPO File %s is missing, please check and rerun\n" %REPO_FILE + col.norm + sys.exit(0) + + + +TEMPLATE_REPO_FILE = ubuntu_conf.template_repo_file +repo_return = os.system("ls -ld %s >/dev/null 2>&1" %TEMPLATE_REPO_FILE) +if repo_return != 0: + print col.red + "\nERROR: TEMPLATE REPO File %s is missing, please check and rerun\n" %TEMPLATE_REPO_FILE + col.norm + sys.exit(0) + + + +BINARY_LOCATION = generic_conf.binary_src_dir +return_code = os.system("ls -ld %s >/dev/null 2>&1" %LOGDIR) +if return_code != 0: + create_status = os.system("mkdir -p %s >/dev/null 2>&1 " %LOGDIR) + if create_status != 0: + print col.red + "\nERROR: Failed while creating directory %s\n" %LOGDIR + col.norm + sys.exit(0) + +LOGFILE = generic_conf.logfile +logging.basicConfig(filename=LOGFILE,format='%(asctime)s - [ %(levelname)s ] - %(message)s',level=logging.DEBUG) +PACKAGE_LIST= generic_conf.package_list_file +PREREQUISITE_LIST = ubuntu_conf.prerequisite_packages +SUPPORTED_DIST = ubuntu_conf.supported_release +if PACKAGE_LIST == "": + display_message_fn("package_list_file variable is epmty, please provide a valid input file","ERROR") + sys.exit(0) + + +L_HOSTNAME = os.popen("hostname").read() +for l_name in SRC_DIST: + input_build_name = l_name + + +CHROOT_PATH = ubuntu_conf.chroot_path + +############################################# +# Check given input is exits or not +############################################# +return_status = os.system("cat %s >/dev/null 2>&1"%PACKAGE_LIST) +if return_status != 0: + display_message_fn("Given input file %s is not exits, please check your build_conf file and rerun"%PACKAGE_LIST,"ERROR") + sys.exit(0) + +os.system("sudo cp -r %s %s_bkp"%(PBUILD_SCRIPT,PBUILD_SCRIPT)) +TOTAL_COUNT = os.popen("cat %s 2>/dev/null |wc -l"%PACKAGE_LIST).read() +SUCCESS_COUNT = 0 +FAILED_COUNT = 0 +SKIPPED_COUNT = 0 +###################################################### +# Module to check given release is supported or not +###################################################### +def verify_distro_release_fn(): + for input_tag in SRC_DIST: + if input_tag in SUPPORTED_DIST: + continue + else: + display_message_fn("This %s tag is currently Supported" %input_tag,"ERROR") + sys.exit(0) + + +############################################# +# Check current destro +############################################# +def check_local_distro_release_fn(args): + if args == "name": + output = os.popen("awk -F\"=\" '$1~/DISTRIB_CODENAME/ {print $2}' /etc/*-release").read() + elif args == "version": + output = os.popen("awk -F\"=\" '$1~/DISTRIB_RELEASE/ {print $2}' /etc/*-release").read() + + return output.strip() + + +#################################################### +# Module to build package for same distro +#################################################### +def same_distro_build_fn(args): + local_package_name = args + RC = os.system("grep \"^deb-src\" %s"%REPO_FILE) + if RC != 0: + display_message_fn("please enable deb-src in %s file, and update the repo"%REPO_FILE,"ERROR") + sys.exit(0) + + display_message_fn("Building package for %s , this might take few minutes..." %local_package_name,"INFO") + download_status = os.system("sudo apt-get build-dep %s -y >/dev/null 2>&1"%local_package_name) + if download_status != 0: + return 1 + + compile_status = os.system("sudo apt-get source --compile %s >/dev/null 2>&1 "%local_package_name) + if compile_status != 0: + return 1 + + + return 0 + + + + +######################################################### +# Modify repo based on the required distribution version +######################################################### +def update_source_list_fn(arg1): + l_distro_type = arg1 + display_message_fn("Updating %s entries on %s file"%(l_distro_type,REPO_FILE),"INFO") + copy_status = os.system("sudo cp %s %s_bkp "%(REPO_FILE,REPO_FILE)) + if copy_status != 0: + display_message_fn("Failed wahile taking the backup of %s file"%REPO_FILE,"ERROR") + sys.exit(0) + + + template_status = os.system("sudo cp %s %s"%(TEMPLATE_REPO_FILE,REPO_FILE)) + if template_status != 0: + display_message_fn("Failed while uploading the tempate file %s "%TEMPLATE_REPO_FILE,"ERROR") + sys.exit(0) + + os.system("sudo sed -i 's/CHANGE_ME/%s/g' %s"%(l_distro_type,REPO_FILE)) + display_message_fn("Updating latest repo changes \( sudo apt-get update \) ,this might take few minures","INFO") + update_status = os.system("sudo apt-get update >/dev/null 2>&1") + if update_status != 0: + display_message_fn("Failed while uploading the apt-get repo, please check manualy and rerun the script","ERROR") + sys.exit(0) + + + + + + + + + +######################################################################### +# Module to revert back all the system changes one the task is finished +######################################################################### +def revert_back_changes_fn(): + display_message_fn("Reverting back all the changes ","INFO") + os.system("sudo cp %s_bkp %s "%(REPO_FILE,REPO_FILE)) + display_message_fn("Updating old repo changes \( sudo apt-get update \) ,this might take few minures","INFO") + value = os.system("sudo apt-get update >/dev/null 2>&1") + if value == 0: + display_message_fn("Successfully uploaded the old apt-get repo ","OK") + + + + + +################################################# +# Module to create chroot env for ubuntu +################################################# +def make_chroot_fn(): + display_message_fn("Creating chroot env for %s , this might take few minutes" %input_build_name,"INFO") + ls_status = os.system("ls -l %s >/dev/null 2>&1"%CHROOT_FILE) + if ls_status == 0: + display_message_fn("Chroot %s is already exits , skipping...."%CHROOT_FILE,"SKIPPED") + else: + create_status = os.system("pbuilder-dist %s create --basetgz %s >/dev/null 2>&1" %(input_build_name,CHROOT_FILE)) + if create_status == 0: + display_message_fn("Successfully created chroot for %s distribution"%input_build_name,"OK") + else: + display_message_fn("Failed while creating the chroot environment for %s distribution, please check and rerun the script"%input_build_name,"ERROR") + sys.exit(0) + + + + +#################################################### +# Module to build package for different distro +#################################################### +def diff_distro_build_fn(arg1): + l_pkg = arg1 + display_message_fn("Building package for %s , this might take few minutes..." %l_pkg,"INFO") + skip_output = os.system("ls -ld %s >/dev/null 2>&1"%INPUT_DIR) + if skip_output == 0: + return 3 + else: + os.system("mkdir -p %s"%TEMP_DIR) + + os.chdir(TEMP_DIR) + download_src = os.system("apt-get source %s >/dev/null 2>&1"%l_pkg) + if download_src != 0: + os.chdir(CURRENT_DIR) + return 2 + + os.chdir(TEMP_DIR) + build_status = os.system("sudo pbuilder --build --distribution %s --basetgz %s *.dsc >/dev/null 2>&1"%(input_build_name,CHROOT_FILE)) + if build_status != 0: + os.chdir(CURRENT_DIR) + return 1 + + return 0 + + + +##################################################### +# Install package module +##################################################### +def install_package_fn(args): + l_name = args + status = os.system("sudo apt-get install -y %s >/dev/null 2>&1" %l_name) + if status == 0: + return 0 + else: + return 1 + + + + + +########################################### +# Clean function +########################################### +def clean_fn(): + os.system("sudo rm -rf *.deb *.xz *.bz2 *.dsc *.changes *.gz *.udeb /var/cache/pbuilder/result/ >/dev/null 2>&1") + + + + +##################################################### +# Function to check prerequisite +##################################################### +def check_prerequisite_fn(): + for list in PREREQUISITE_LIST: + status = os.system("dpkg --list|grep %s >/dev/null 2>&1" %list) + if status != 0: + display_message_fn("Package %s is not installed, installing it.. please wait." %list,"WARN") + command_check = install_package_fn(list) + if command_check == 0: + print "Successfully installed package %s " %list + else: + display_message_fn("Failed while installing package %s , please check and rerun the script" %list,"ERROR") + sys.exit(0) + else: + display_message_fn("Package %s is already installed" %list,"OK") + + +CHROOT_FILE = "%s/%s-base.tgz" %(CHROOT_PATH,input_build_name) +CURRENT_DIR = os.popen("pwd").read().strip() +verify_distro_release_fn() +local_name = check_local_distro_release_fn("name") +local_version = check_local_distro_release_fn("version") +check_prerequisite_fn() +install_python_module_fn() +if local_name in SRC_DIST: + with open(PACKAGE_LIST) as f: + for line in f: + line = line.strip() + INPUT_DIR = "%s/%s/%s" %(BINARY_LOCATION,local_name,line) + skip_output = os.system("ls -ld %s >/dev/null 2>&1"%INPUT_DIR) + if skip_output == 0: + display_message_fn("Binaries are already available for package %s"%line, "SKIPPED") + SKIPPED_COUNT = SKIPPED_COUNT + 1 + continue + + + os.system("mkdir -p %s"%INPUT_DIR) + os.chdir(INPUT_DIR) + VALUE = same_distro_build_fn(line) + if VALUE == 0: + display_message_fn("Successfully compilied the binary for %s package"%line,"OK") + clean_fn() + os.chdir(CURRENT_DIR) + SUCCESS_COUNT = SUCCESS_COUNT + 1 + else: + display_message_fn("Failed while building the binary for %s package"%line,"ERROR") + clean_fn() + os.chdir(CURRENT_DIR) + FAILED_COUNT = FAILED_COUNT + 1 + +else: + #update_source_list_fn(input_build_name) + make_chroot_fn() + with open(PACKAGE_LIST) as f: + for line in f: + line = line.strip() + INPUT_DIR = "%s/%s/%s" %(BINARY_LOCATION,input_build_name,line) + TEMP_DIR = "%s/%s/%s/temp" %(BINARY_LOCATION,input_build_name,line) + check_retuen_code = os.system("sudo sed -i \"/# final cleanup/ccp -r %s %s\n# final cleanup\" %s"%(PBUILD_BUILD_PATH,INPUT_DIR,PBUILD_SCRIPT)) + if check_retuen_code != 0: + display_message_fn("Failed while modifying the copy changes to %s file"%PBUILD_SCRIPT,"ERROR") + sys.exit(0) + + return_code = diff_distro_build_fn(line) + if return_code == 3: + display_message_fn("Binaries are already available for package %s"%line, "SKIPPED") + SKIPPED_COUNT = SKIPPED_COUNT + 1 + os.system("sudo cp -r %s_bkp %s"%(PBUILD_SCRIPT,PBUILD_SCRIPT)) + continue + + + if return_code == 2: + display_message_fn("Failed while downloading the source file for %s package"%line,"ERROR") + FAILED_COUNT = FAILED_COUNT + 1 + os.chdir(INPUT_DIR) + clean_fn() + os.system("rm -rf %s"%TEMP_DIR) + os.chdir(CURRENT_DIR) + elif return_code == 1: + display_message_fn("Failed while building the binary for %s package"%line,"ERROR") + FAILED_COUNT = FAILED_COUNT + 1 + os.chdir(INPUT_DIR) + os.system("rm -rf %s"%TEMP_DIR) + clean_fn() + os.chdir(CURRENT_DIR) + elif return_code == 0: + display_message_fn("Successfully build the binary for %s package"%line,"OK") + SUCCESS_COUNT = SUCCESS_COUNT + 1 + os.chdir(INPUT_DIR) + clean_fn() + os.system("rm -rf %s"%TEMP_DIR) + os.chdir(CURRENT_DIR) + + os.system("sudo cp -r %s_bkp %s"%(PBUILD_SCRIPT,PBUILD_SCRIPT)) + + #revert_back_changes_fn() +footer_fn(L_HOSTNAME,local_name,local_version,input_build_name,BASEDIR,LOGDIR,LOGFILE,BINARY_LOCATION,TOTAL_COUNT,SUCCESS_COUNT,SKIPPED_COUNT,FAILED_COUNT) +if NOTIFICATION_ACTION == "y": + send_sms_fn(MOBILE_NUM,"Build activity on Ubuntu : Out of Total %s : SUCCESS = %s , SKIPPED = %s , FAILED = %s"%(TOTAL_COUNT,SUCCESS_COUNT,SKIPPED_COUNT,FAILED_COUNT)) diff --git a/linux-tools/autotest-build-tools/readme b/linux-tools/autotest-build-tools/readme new file mode 120000 index 000000000..7728085e3 --- /dev/null +++ b/linux-tools/autotest-build-tools/readme @@ -0,0 +1 @@ +FYI/README.txt \ No newline at end of file diff --git a/linux-tools/autotest-build-tools/run.py b/linux-tools/autotest-build-tools/run.py new file mode 100755 index 000000000..3f22f35f5 --- /dev/null +++ b/linux-tools/autotest-build-tools/run.py @@ -0,0 +1,52 @@ +#========================================================================================================== +# +# FILE: run.py +# +# Usage: python run.py +# +# +# DESCRIPTION: Script to build/test autotest test packages and run regression +# +# OPTIONS: --- +# REQUIREMENTS: --- +# BUGS: --- +# NOTES: --- +# AUTHOR: IBM LTC Test Team +# COMPANY: IBM +# VERSION: 1.0 +# CREATED: 22-Feb-2017 Abhishek Sharma < abhisshm@in.ibm.com > +# REVISION: --- +#========================================================================================================== + +#========================================================= +# Importing python predefine and user defined modules +#========================================================= +import os,sys,getopt,os.path # importing OS module for performing os related activity. +#if sys.version[0:3] == "2.7": +# import subprocess + +#################################################### +# Import generic modules +#################################################### +from modules.generic_module import * +from modules.build_conf import * + +os.system('clear') +############################################### +# Import custom modules based on conf file +############################################### +ACTION = generic_conf.build_type +if ACTION == "CUSTOM": + from modules.custom_module import * +elif ACTION == "REDHAT": + from modules.rhel_module import * +elif ACTION == "SUSE": + from modules.suse_module import * +elif ACTION == "UBUNTU": + from modules.ubuntu_module import * +elif ACTION == "CENTOS": + from modules.centos_module import * +else: + print "build_type under modules/build_conf.py is either empty or not configured properly, please configure and rerun" + + diff --git a/linux-tools/autotest-build-tools/run.py_bkp b/linux-tools/autotest-build-tools/run.py_bkp new file mode 100755 index 000000000..a9a9bdd2a --- /dev/null +++ b/linux-tools/autotest-build-tools/run.py_bkp @@ -0,0 +1,67 @@ +#========================================================================================================== +# +# FILE: run.py +# +# Usage: run.py -c run.conf +# +# -c run.conf file will contain the steps to execute run.py, you can modify based +# -d Full path of datafile, which hold the detail of filesystem to be created +# -h help +# +# DESCRIPTION: Script to build/test autotest test packages and run regression +# +# OPTIONS: --- +# REQUIREMENTS: --- +# BUGS: --- +# NOTES: --- +# AUTHOR: IBM LTC Test Team +# COMPANY: IBM +# VERSION: 1.0 +# CREATED: 22-Feb-2017 Abhishek Sharma < abhisshm@in.ibm.com > +# REVISION: --- +#========================================================================================================== + +#========================================================= +# Importing python predefine and user defined modules +#========================================================= +import os,sys,getopt,os.path # importing OS module for performing os related activity. +if sys.version[0:3] == "2.7": + import subprocess + +from modules.generic_module import * +from build_conf import * + +os.system('clear') + +def main(argv): + conf_file = '' + try: + option,argument = getopt.getopt(argv,"h:c:",["conf_file"]) + except getopt.GetoptError: + print col.red + '\n%s -c run.conf\n' %prog_name + col.norm + sys.exit(2) + for opt,argu in option: + if opt == '-h': + print col.red + '\n%s -c run.conf\n' %prog_name + col.red + elif opt in ("-c","conf_file"): + conf_file = argu + else: + print col.red + '\n%s -c run.conf\n' %prog_name + col.red + sys.exit(2) + + if os.path.isfile(conf_file): + print col.green + "\nWelcome, config file is %s \n"%conf_file + col.norm + print os.environ['BUILD_TYPE'] + else: + print col.red + "\nconfig file \"%s\" is not exits, check and rerun \n"%conf_file + col.norm + sys.exit(2) + + +if __name__ == "__main__": + prog_name = sys.argv[0] + count=len(sys.argv[1:]) + if count < 2: + print col.red + "\n%30s -c run.conf \n" %prog_name + col.norm + sys.exit(2) + else: + main(sys.argv[1:]) diff --git a/linux-tools/elfutils/elfutils.sh b/linux-tools/elfutils/elfutils.sh index 246acc47c..f2d5aaeb5 100755 --- a/linux-tools/elfutils/elfutils.sh +++ b/linux-tools/elfutils/elfutils.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash ############################################################################################ ## Copyright 2003, 2015 IBM Corp ## ## ## @@ -54,6 +54,8 @@ function tc_local_setup() # Following paths are needed for running the tests export libdir=$(dirname $Libpath) export bindir=/usr/bin + # Change the shell to bash so that code can work on ubuntu too + sed -i "1s/.*/#\!\/bin\/bash/" $TESTDIR/test-wrapper.sh } # diff --git a/linux-tools/passwd/passwd.sh b/linux-tools/passwd/passwd.sh index 2b36334d5..018a591a3 100755 --- a/linux-tools/passwd/passwd.sh +++ b/linux-tools/passwd/passwd.sh @@ -46,9 +46,12 @@ function tc_local_setup() function test01() { - tc_register "passwd --stdin" - echo PASSW0RD | passwd --stdin $TC_TEMP_USER 1>$stdout 2>$stderr - tc_pass_or_fail $? "Password setting using --stdin failed for $TC_TEMP_USER" + grep -i "ubuntu" /etc/*-release >/dev/null 2>&1 + if [ $? -ne 0 ];then # Start of OS check + tc_register "passwd --stdin" + echo PASSW0RD | passwd --stdin $TC_TEMP_USER 1>$stdout 2>$stderr + tc_pass_or_fail $? "Password setting using --stdin failed for $TC_TEMP_USER" + fi tc_register "passwd --lock" passwd --lock $TC_TEMP_USER 1>$stdout 2>$stderr @@ -61,17 +64,20 @@ function test01() function test02() { - tc_register "passwd --maximum" - passwd --maximum=90 $TC_TEMP_USER 1>$stdout 2>$stderr - tc_pass_or_fail $? "Setting maximum password lifetime to 90 Days failed" + grep -i "ubuntu" /etc/*-release >/dev/null 2>&1 + if [ $? -ne 0 ];then # Start of OS check + tc_register "passwd --maximum" + passwd --maximum=90 $TC_TEMP_USER 1>$stdout 2>$stderr + tc_pass_or_fail $? "Setting maximum password lifetime to 90 Days failed" - tc_register "passwd --minimum" - passwd --minimum=30 $TC_TEMP_USER 1>$stdout 2>$stderr - tc_pass_or_fail $? "Setting minimum password lifetime to 30 days failed" + tc_register "passwd --minimum" + passwd --minimum=30 $TC_TEMP_USER 1>$stdout 2>$stderr + tc_pass_or_fail $? "Setting minimum password lifetime to 30 days failed" - tc_register "passwd --warning" - passwd --warning=9 $TC_TEMP_USER 1>$stdout 2>$stderr - tc_pass_or_fail $? "settings to warn user before 9 days of password expiration failed" + tc_register "passwd --warning" + passwd --warning=9 $TC_TEMP_USER 1>$stdout 2>$stderr + tc_pass_or_fail $? "settings to warn user before 9 days of password expiration failed" + fi tc_register "passwd --inactive" passwd --inactive=2 $TC_TEMP_USER 1>$stdout 2>$stderr @@ -79,30 +85,40 @@ function test02() } function test03() { - #--keep-tokens is used to indicate that the update should only - #be for expired authentication tokens(passwords) - tc_register "passwd --keep-tokens" - tc_info "Expecting \"Authentication token manipulation error\"" - echo PASSW0RD | passwd --keep-tokens $TC_TEMP_USER 1>$stdout - if [ $? -eq 0 ]; then - tc_fail "Non expired password got changed using option --keep-tokens!"||return + grep -i "ubuntu" /etc/*-release >/dev/null 2>&1 + if [ $? -ne 0 ];then # Start of OS check + #--keep-tokens is used to indicate that the update should only + #be for expired authentication tokens(passwords) + tc_register "passwd --keep-tokens" + tc_info "Expecting \"Authentication token manipulation error\"" + echo PASSW0RD | passwd --keep-tokens $TC_TEMP_USER 1>$stdout + if [ $? -eq 0 ]; then + tc_fail "Non expired password got changed using option --keep-tokens!"||return + fi + tc_pass + + #Force to unlock user password which is empty + tc_register "passwd --force" + passwd --unlock --force $TC_TEMP_USER 1>$stdout 2>$stderr + tc_pass_or_fail $? "Failed to force unlock passwd for $TC_TEMP_USER" fi - tc_pass + tc_register "passwd --delete" passwd --delete $TC_TEMP_USER 1>$stdout 2>$stderr tc_pass_or_fail $? "Passwd deletion failed for $TC_TEMP_USER" - #Force to unlock user password which is empty - tc_register "passwd --force" - passwd --unlock --force $TC_TEMP_USER 1>$stdout 2>$stderr - tc_pass_or_fail $? "Failed to force unlock passwd for $TC_TEMP_USER" } ################################################################################ # main ################################################################################ tc_setup -TST_TOTAL=10 +grep -i "ubuntu" /etc/*-release >/dev/null 2>&1 +if [ $? -ne 0 ];then + TST_TOTAL=10 +else + TST_TOTAL=4 +fi test01 test02 test03 diff --git a/linux-tools/patchutils/patchutils.sh b/linux-tools/patchutils/patchutils.sh index a72e8943f..7d940d8ca 100755 --- a/linux-tools/patchutils/patchutils.sh +++ b/linux-tools/patchutils/patchutils.sh @@ -31,13 +31,20 @@ #LTPBIN=${LTPBIN%/shared}/patchutils source $LTPBIN/tc_utils.source PATCHUTILS_TESTS_DIR="${LTPBIN%/shared}/patchutils" -REQUIRED="sed awk interdiff combinediff filterdiff fixcvsdiff lsdiff splitdiff rediff \ - grepdiff recountdiff unwrapdiff dehtmldiff flipdiff espdiff editdiff" +grep -i "ubuntu" /etc/*-release >/dev/null 2>&1 +if [ $? -eq 0 ];then # Start of OS check + REQUIRED="sed awk interdiff combinediff filterdiff fixcvsdiff lsdiff splitdiff rediff \ + grepdiff recountdiff unwrapdiff dehtmldiff flipdiff editdiff" +else + REQUIRED="sed awk interdiff combinediff filterdiff fixcvsdiff lsdiff splitdiff rediff \ + grepdiff recountdiff unwrapdiff dehtmldiff espdiff flipdiff editdiff" +fi + function tc_local_setup() { - tc_check_package "patchutils" + tc_check_package "patchutils" tc_break_if_bad $? "patchutils not installed" || return tc_exec_or_break $REQUIRED sed -i 's:${top_builddir}/src/::g' $PATCHUTILS_TESTS_DIR/tests/common.sh @@ -56,7 +63,12 @@ function tc_local_cleanup() function run_test() { pushd $PATCHUTILS_TESTS_DIR >$stdout 2>$stderr -TST_TOTAL=`ls tests -I common.sh -I soak-test | wc -l` +grep -i "ubuntu" /etc/*-release >/dev/null 2>&1 +if [ $? -eq 0 ];then # Start of OS check + TST_TOTAL=`expr $TST_TOTAL - 1` +else + TST_TOTAL=`ls tests -I common.sh -I soak-test | wc -l` +fi for dir in `cd tests; find . -mindepth 1 -type d -not -name delhunk5 -not -name delhunk6` do test_name=`echo $dir | awk -F/ '{print $2}'` diff --git a/linux-tools/perl_Bit_Vector/perl-Bit-Vector.sh b/linux-tools/perl_Bit_Vector/perl-Bit-Vector.sh index afdd4a632..f6e5e3a0d 100755 --- a/linux-tools/perl_Bit_Vector/perl-Bit-Vector.sh +++ b/linux-tools/perl_Bit_Vector/perl-Bit-Vector.sh @@ -72,7 +72,9 @@ function run_test() for test in $TESTS; do tc_register "Test $test" perl $test >$stdout 2>$stderr - tc_pass_or_fail $? "$test failed" + RC="$?" + tc_ignore_warnings "Argument" + tc_pass_or_fail "$RC" "$test failed" done popd >$stdout 2>$stderr diff --git a/linux-tools/perl_HTTP_Negotiate/perl-HTTP-Negotiate.sh b/linux-tools/perl_HTTP_Negotiate/perl-HTTP-Negotiate.sh index 7575fbb25..ac944c80e 100755 --- a/linux-tools/perl_HTTP_Negotiate/perl-HTTP-Negotiate.sh +++ b/linux-tools/perl_HTTP_Negotiate/perl-HTTP-Negotiate.sh @@ -54,7 +54,9 @@ function run_test() for test in $TESTS; do tc_register "Test $test" perl $test >$stdout 2>$stderr - tc_pass_or_fail $? "$test failed" + RC="$?" + tc_ignore_warnings "Evaluating Canadian English (ct='text/html')" + tc_pass_or_fail "$RC" "$test failed" done popd >$stdout 2>$stderr } diff --git a/linux-tools/prelink/prelink.sh b/linux-tools/prelink/prelink.sh index 6dc0a20d2..88605799a 100755 --- a/linux-tools/prelink/prelink.sh +++ b/linux-tools/prelink/prelink.sh @@ -89,7 +89,13 @@ function tc_local_setup() { tc_exec_or_break $REQUIRED || return - tc_exist_or_break /etc/prelink.conf /etc/sysconfig/prelink || return + # /etc/sysconfig/prelink file is not appicable on ubuntu, Ubuntu has /usr/sbin/prelink + grep -i "ubuntu" /etc/*-release >/dev/null 2>&1 + if [ $? -eq 0 ];then # Start of OS check + tc_exist_or_break /etc/prelink.conf /usr/sbin/prelink || return + else + tc_exist_or_break /etc/prelink.conf /etc/sysconfig/prelink || return + fi tc_get_os_arch userlibdir=/usr/lib @@ -97,6 +103,13 @@ function tc_local_setup() [ $TC_OS_ARCH = "x86_64" ] || [ $TC_OS_ARCH = "ppc64" ] || [ $TC_OS_ARCH = "s390x" ] \ && userlibdir=/usr/lib64/ && \ libdir=/lib64/ + # On Ubuntu usrlib and lib paths are diff, so modified the code based on that + grep -i "ubuntu" /etc/*-release >/dev/null 2>&1 + if [ $? -eq 0 ];then # Start of OS check + userlibdir="/usr/lib/*-linux-gnu/" + libdir="/lib/*-linux-gnu/" + fi + PRELINK="/usr/sbin/prelink -c ./prelink.conf -C ./prelink.cache --ld-library-path=." cat >> $TSTDIR/prelink.conf <<-EOF @@ -182,9 +195,14 @@ function test02() tc_fail "prelink failed on bogus library dependency" || return fi - - grep -q "^`echo $PRELINK | sed 's/ .*$/: .*has a dependency cycle/'`" $BINS.log - tc_fail_if_bad $? "prelink failed on cycle1" || return + + # cycle1lib1.so libs are not part of Ubuntu, so excluding this test + # This is only for test purpose + grep -i "ubuntu" /etc/*-release >/dev/null 2>&1 + if [ $? -ne 0 ];then # Start of OS check + grep -q "^`echo $PRELINK | sed 's/ .*$/: .*has a dependency cycle/'`" $BINS.log + tc_fail_if_bad $? "prelink failed on cycle1" || return + fi LD_LIBRARY_PATH=. ./$BINS tc_fail_if_bad $? "Failed to execute the binary" || return