Skip to content

Commit

Permalink
adding option and full implementation for _buildtest run --systempkg …
Browse files Browse the repository at this point in the history
…for running system package test suite
  • Loading branch information
shahzebsiddiqui committed Oct 3, 2018
1 parent 6d18986 commit fc060c9
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 4 deletions.
13 changes: 10 additions & 3 deletions buildtest/test/run/app.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
############################################################################
#
# Copyright 2017-2018
#
# https://github.com/HPC-buildtest/buildtest-framework
#
# This file is part of buildtest.
#
# buildtest is free software: you can redistribute it and/or modify
Expand All @@ -13,10 +19,11 @@
# You should have received a copy of the GNU General Public License
# along with buildtest. If not, see <http://www.gnu.org/licenses/>.
#############################################################################

"""
This module will run test scripts via buildtest and capture output and additional
metrics that will be stored in json format
This module will run an entire test suite for an application. This implements
_buildtest run --app
:author: Shahzeb Siddiqui
Expand Down Expand Up @@ -56,7 +63,7 @@ def run_app_test(app_name):
app_root_testdir = os.path.join(config_opts["BUILDTEST_TESTDIR"],"ebapp")

tests = [ f.path for f in os.scandir(os.path.join(app_root_testdir,app_name)) if os.path.splitext(f)[1] in [".sh", ".bash", ".csh"]]

count_test = len(tests)

for test in tests:
Expand Down
62 changes: 62 additions & 0 deletions buildtest/test/run/system.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
############################################################################
#
# Copyright 2017-2018
#
# https://github.com/HPC-buildtest/buildtest-framework
#
# This file is part of buildtest.
#
# buildtest 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 3 of the License, or
# (at your option) any later version.
#
# buildtest 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 License
# along with buildtest. If not, see <http://www.gnu.org/licenses/>.
#############################################################################

"""
This module will run an entire test suite for a system package. This implements
_buildtest run --system
:author: Shahzeb Siddiqui
"""

import os
import sys
from buildtest.tools.config import config_opts, BUILDTEST_SHELLTYPES
def run_system_choices():
"""
generate choice field for _buildtest run --app
"""

system_root_testdir = os.path.join(config_opts["BUILDTEST_TESTDIR"],"system")
systempkg_list = [ os.path.basename(f.path) for f in os.scandir(system_root_testdir) if f.is_dir()]

return systempkg_list

def run_system_test(systempkg):
"""
implementation for _buildtest run --systempkg to execute all tests in the test directory
"""

system_root_testdir = os.path.join(config_opts["BUILDTEST_TESTDIR"],"system")

tests = [ f.path for f in os.scandir(os.path.join(system_root_testdir,systempkg)) if os.path.splitext(f)[1] in [".sh", ".bash", ".csh"]]

count_test = len(tests)

for test in tests:
print (f"Executing Test: {test}")
print ("---------------------------------------------------------")
os.system(test)
print ("---------------------------------------------------------")

print (f"Executed {count_test} tests for system package: {systempkg}")
7 changes: 7 additions & 0 deletions buildtest/test/run/testname.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
############################################################################
#
# Copyright 2017-2018
#
# https://github.com/HPC-buildtest/buildtest-framework
#
# This file is part of buildtest.
#
# buildtest is free software: you can redistribute it and/or modify
Expand All @@ -13,6 +19,7 @@
# You should have received a copy of the GNU General Public License
# along with buildtest. If not, see <http://www.gnu.org/licenses/>.
#############################################################################

"""
This module will run test scripts via buildtest and capture output and additional
Expand Down
5 changes: 4 additions & 1 deletion buildtest/tools/menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import argcomplete

from buildtest.test.run.app import run_app_choices
from buildtest.test.run.system import run_system_choices
from buildtest.test.python import python_pkg_choices
from buildtest.test.r import r_pkg_choices
from buildtest.test.ruby import ruby_pkg_choices
Expand Down Expand Up @@ -64,6 +65,7 @@ class buildtest_menu():

test_choices = test_list()
app_choices = run_app_choices()
systempkg_choices = run_system_choices()
def __init__(self):

parser = argparse.ArgumentParser(prog='buildtest', usage='%(prog)s [options]')
Expand Down Expand Up @@ -120,7 +122,8 @@ def __init__(self):
parser_run = subparsers.add_parser('run', help='run help')
parser_run.add_argument("-i", "--interactive", help="Run the test interactively", action="store_true")
parser_run.add_argument("-t", "--testname", help="Run a single testscript via buildtest", choices=self.test_choices, metavar='TEST-CHOICES')
parser_run.add_argument("-a", "--app", help="Run test suite by application via buildtest", choices=self.app_choices, metavar='APPLICATION-TEST-SUITE')
parser_run.add_argument("-a", "--app", help="Run test suite for application via buildtest", choices=self.app_choices, metavar='APPLICATION-TEST-SUITE')
parser_run.add_argument("-s", "--systempkg", help="Run test suite for system package via buildtest", choices=self.systempkg_choices, metavar='SYSTEMPACKAGE-TEST-SUITE')
parser_run.set_defaults(func=func_run_subcmd)


Expand Down
3 changes: 3 additions & 0 deletions buildtest/tools/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import sys
from buildtest.test.run.app import run_app_test
from buildtest.test.run.testname import run_test_buildtest
from buildtest.test.run.system import run_system_test
from buildtest.test.run.interactive import runtest_menu

def func_run_subcmd(args):
Expand All @@ -31,4 +32,6 @@ def func_run_subcmd(args):
run_test_buildtest(args.testname)
if args.app:
run_app_test(args.app)
if args.systempkg:
run_system_test(args.systempkg)
sys.exit(0)

0 comments on commit fc060c9

Please sign in to comment.