-
Notifications
You must be signed in to change notification settings - Fork 84
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Problem Description : Ruby test was not available on autotest. #100
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<!-- Test configuration for 'ruby' --> | ||
<TEST> | ||
<TYPE>AUTO</TYPE> | ||
<PACKAGE>ruby</PACKAGE> | ||
<COMMAND>ruby.sh</COMMAND> | ||
<DESCRIPTION>Test basic functionality of the ruby program.</DESCRIPTION> | ||
</TEST> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 *~ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
AUTHOR = " Anup Kumar, [email protected] ## " | ||
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) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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, [email protected] ## | ||
""" | ||
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) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. consider using |
||
ret_val = subprocess.Popen(['./ruby.sh'], cwd="%s/ruby" %(test_path)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same here |
||
ret_val.communicate() | ||
if ret_val.returncode != 0: | ||
self.nfail += 1 | ||
|
||
except error.CmdError, e: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please use proper variable name instead of |
||
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 ') | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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, [email protected] ## | ||
################################################################################ | ||
# 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please change this to run from autotest path.