-
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
Adding ruby tests for autotest-client-tests. #102
Open
anupkumk
wants to merge
1
commit into
autotest:master
Choose a base branch
from
anupkumk:ruby_test1
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
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.) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#!/bin/python | ||
import os | ||
import subprocess | ||
import logging | ||
|
||
from autotest.client.shared import error | ||
|
||
|
||
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"] = os.path.join(test_path, "shared") | ||
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 as err: | ||
self.nfail += 1 | ||
logging.error("Test Failed: %s", err) | ||
|
||
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 ') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 include the suggestion from previous review for os.path.join() here