From 2e2dbd53a67971a9381e96e7a63cc7ad046f684b Mon Sep 17 00:00:00 2001 From: Anup Kumar Date: Fri, 21 Apr 2017 04:58:28 -0500 Subject: [PATCH] Problem Description : ruby test was not available on autotest. Fix : Added ruby test suits to autotest. Signed-off By: Anup Kumar --- linux-tools/ruby/00_Description.txt | 20 +++++ linux-tools/ruby/Description.xml | 7 ++ linux-tools/ruby/Makefile | 33 ++++++++ linux-tools/ruby/control | 11 +++ linux-tools/ruby/ruby.py | 49 ++++++++++++ linux-tools/ruby/ruby.sh | 112 ++++++++++++++++++++++++++++ 6 files changed, 232 insertions(+) create mode 100755 linux-tools/ruby/00_Description.txt create mode 100755 linux-tools/ruby/Description.xml create mode 100755 linux-tools/ruby/Makefile create mode 100644 linux-tools/ruby/control create mode 100644 linux-tools/ruby/ruby.py create mode 100755 linux-tools/ruby/ruby.sh diff --git a/linux-tools/ruby/00_Description.txt b/linux-tools/ruby/00_Description.txt new file mode 100755 index 000000000..9229aa712 --- /dev/null +++ b/linux-tools/ruby/00_Description.txt @@ -0,0 +1,20 @@ +Ruby is the interpreted scripting language for quick and easy object-oriented programming. It has many features to process text files and to do system management tasks (as in Perl). It is simple, straight-forward, and extensible. + +Features of Ruby + +* Simple Syntax +* *Normal* Object-Oriented features(ex. class, method calls) +* *Advanced* Object-Oriented features(ex. Mix-in, Singleton-method) +* Operator Overloading +* Exception Handling +* Iterators and Closures +* Garbage Collection +* Dynamic Loading of Object files(on some architecture) +* Highly Portable (works on many Unix-like/POSIX compatible platforms + as well as Windows, Mac OS X, BeOS etc.) + + +usage: +------ +cd /opt/fiv/ltp/testcases/fivextra/ruby +./ruby.sh diff --git a/linux-tools/ruby/Description.xml b/linux-tools/ruby/Description.xml new file mode 100755 index 000000000..9cb533b48 --- /dev/null +++ b/linux-tools/ruby/Description.xml @@ -0,0 +1,7 @@ + + + AUTO + ruby + ruby.sh + Test basic functionality of the ruby program. + diff --git a/linux-tools/ruby/Makefile b/linux-tools/ruby/Makefile new file mode 100755 index 000000000..75fbf1fa3 --- /dev/null +++ b/linux-tools/ruby/Makefile @@ -0,0 +1,33 @@ +########################################################################################### +## Copyright 2003, 2016 IBM Corp ## +## ## +## 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. ## +## ## +## THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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. ## +############################################################################################ +TARGETS=ruby.sh + +all: + +install: + for i in $(TARGETS) ; do ln -f $$i ../../bin/$$i || break ; done + +uninstall: + for j in $(TARGETS) ; do rm -f ../../bin/$$j ; done + +clean: + @rm -f *~ diff --git a/linux-tools/ruby/control b/linux-tools/ruby/control new file mode 100644 index 000000000..bfaaa9f65 --- /dev/null +++ b/linux-tools/ruby/control @@ -0,0 +1,11 @@ +AUTHOR = " Anup Kumar, anupkumk@linux.vnet.ibm.com ## " +NAME = "ruby" +TEST_CATEGORY = "Functional" +TEST_CLASS = "Linux Tools" +TEST_TYPE = "client" +TIME = 'SHORT' +DOC = ''' + Test ruby package + ''' +path = '' +job.run_test('ruby',test_path=path) diff --git a/linux-tools/ruby/ruby.py b/linux-tools/ruby/ruby.py new file mode 100644 index 000000000..18bb8c697 --- /dev/null +++ b/linux-tools/ruby/ruby.py @@ -0,0 +1,49 @@ +#!/bin/python +import os, subprocess +import shutil +import logging + +from autotest.client import test, utils +from autotest.client.shared import error, software_manager + +class ruby(test.test): + + """ + Autotest module for testing basic functionality + of ruby + + @author Anup Kumar, anupkumk@linux.vnet.ibm.com ## + """ + version = 1 + nfail = 0 + path = '' + + def initialize(self): + """ + Sets the overall failure counter for the test. + """ + self.nfail = 0 + logging.info('\n Test initialize successfully') + + def run_once(self, test_path=''): + """ + Trigger test run + """ + try: + os.environ["LTPBIN"] = "%s/shared" %(test_path) + ret_val = subprocess.Popen(['./ruby.sh'], cwd="%s/ruby" %(test_path)) + ret_val.communicate() + if ret_val.returncode != 0: + self.nfail += 1 + + except error.CmdError, e: + self.nfail += 1 + logging.error("Test Failed: %s", e) + + def postprocess(self): + if self.nfail != 0: + logging.info('\n nfails is non-zero') + raise error.TestError('\nTest failed') + else: + logging.info('\n Test completed successfully ') + diff --git a/linux-tools/ruby/ruby.sh b/linux-tools/ruby/ruby.sh new file mode 100755 index 000000000..6138d8152 --- /dev/null +++ b/linux-tools/ruby/ruby.sh @@ -0,0 +1,112 @@ +#!/bin/bash +################################################################################ +## ## +##copyright 2003, 2016 IBM Corp ## +## ## +## This program is free software; you can redistribute it and or modify ## +## it under the terms of the GNU General Public License as published by ## +## the Free Software Foundation; either version 2 of the License, or ## +## (at your option) any later version. ## +## ## +## This program is distributed in the hope that it will be useful, but ## +## WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY ## +## or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License ## +## for more details. ## +## ## +## You should have received a copy of the GNU General Public Licens ## +## along with this program; if not, write to the Free Software ## +## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ## +## ## +## File : ruby.sh ## +## ## +## Description: This testcase tests ruby package ## +## ## +## Author: Anup Kumar, anupkumk@linux.vnet.ibm.com ## +################################################################################ +# source the utility functions +#cd $(dirname $0) +#LTPBIN=${LTPBIN%/shared}/ruby +source $LTPBIN/tc_utils.source +FIVDIR="${LTPBIN%/shared}/ruby" +TEST_DIR="${LTPBIN%/shared}/ruby/ruby_test" +REQUIRED="erb gem irb ri ruby testrb cp ln" + +################################################################################ +# Testcase functions +################################################################################ + +function tc_local_setup() +{ + tc_root_or_break || exit + tc_exec_or_break $REQUIRED || return + + # search the ruby packages + rpm -q "ruby" >$stdout 2>$stderr + tc_break_if_bad $? "ruby package is not installed" + + # backup of entire test directory and removing the failure test out from suit + cp -r $FIVDIR/ruby_test $FIVDIR/ruby_test_backup &>/dev/null + pushd $TEST_DIR &>/dev/null + + rm -f test/dtrace/test_array_create.rb test/dtrace/test_cmethod.rb test/dtrace/test_function_entry.rb test/dtrace/test_hash_create.rb test/dtrace/test_load.rb \ + test/dtrace/test_object_create_start.rb test/dtrace/test_raise.rb test/dtrace/test_require.rb test/dtrace/test_singleton_function.rb test/dtrace/test_string.rb \ + test/dbm/test_dbm.rb test/test_find.rb test/gdbm/test_gdbm.rb test/irb/test_completion.rb test/minitest/test_minitest_unit.rb test/pathname/test_pathname.rb \ + test/rdoc/test_rdoc_options.rb test/rdoc/test_rdoc_rdoc.rb lib/rdoc/task.rb test/sdbm/test_sdbm.rb test/openssl/test_x509cert.rb test/openssl/test_x509req.rb \ + test/ruby/test_fiber.rb test/json/test_json_generate.rb test/ruby/test_rubyoptions.rb test/-ext-/test_bug-3571.rb test/-ext-/load/test_dot_dot.rb \ + test/-ext-/exception/test_ensured.rb test/mkmf/test_convertible.rb test/mkmf/test_have_func.rb test/mkmf/test_have_library.rb test/mkmf/test_have_macro.rb \ + test/mkmf/test_signedness.rb test/mkmf/test_sizeof.rb test/mkmf/test_constant.rb test/ruby/test_time_tz.rb test/ripper/test_files.rb + + popd &>/dev/null + # remove the existing binary and replace with actual in the server + pushd $TEST_DIR/bin &>/dev/null + rm -rf erb gem irb rdoc ri testrb &>/dev/null + ln -s `which erb` erb + ln -s `which gem` gem + ln -s `which irb` irb + ln -s `which rdoc` rdoc + ln -s `which ri` ri + ln -s `which testrb` testrb + popd &>/dev/null + + #check the openssl package version + rpm -qa | grep -i openssl &>/dev/null + if [ $? -eq 0 ]; then + openssl_vf1=$(openssl version -v | awk -F'-' '{print $1}' | awk '{print $2}' | awk -F'.' '{print $1}') + openssl_vf2=$(openssl version -v | awk -F'-' '{print $1}' | awk '{print $2}' | awk -F'.' '{print $2}') + openssl_vf3=$(openssl version -v | awk -F'-' '{print $1}' | awk '{print $2}' | awk -F'.' '{print $3}' | rev | cut -c 2- | rev) + if [[ ("$openssl_vf1" -ge "1") && ("$openssl_vf2" -ge "0") && ("$openssl_vf3" -ge "1") ]]; then + # removing the npn protocol comparison string with sdpy protocol for openssl version higher than 1.0.1 + sed -i "/assert_equal(advertised.send(which), ssl.npn_protocol)/ s//#&/" $TEST_DIR/test/openssl/test_ssl.rb + sed -i "/assert_equal(selected, ssl.npn_protocol)/ s//#&/" $TEST_DIR/test/openssl/test_ssl.rb + fi + fi + + + # remove the ruby binary as well + rm -rf $TEST_DIR/ruby + ln -s `which ruby` $TEST_DIR/ruby +} + +function tc_local_cleanup() +{ + # remove the test directory and restore this original + rm -rf $FIVDIR/ruby_test &>/dev/null + cp -r $FIVDIR/ruby_test_backup $FIVDIR/ruby_test && rm -rf $FIVDIR/ruby_test_backup + +} + +function run_test() +{ + tc_info "calling the test through miniruby utility " + # start the miniruby suit + pushd $TEST_DIR >$stdout 2>$stderr + tc_register "running the miniruby suit" + ./miniruby ./tool/runruby.rb "./test/runner.rb" >$stdout 2>$stderr + tc_pass_or_fail $? "some tests are either failed or some error occured" || return + popd &>/dev/null +} +# +# main +# +tc_setup && \ +run_test