Skip to content

Commit

Permalink
Added Environ plugin which enables setting environment variables.
Browse files Browse the repository at this point in the history
Modified configparse optionxform str to make option names case sensitive.
Bug fix for ModuleCmd to use io.StringIO.seek() instead of StringIO.StringIO.len().

Signed-off-by: Noah van Dresser <[email protected]>
  • Loading branch information
noahv committed Jul 15, 2016
1 parent c3a4a85 commit cabd8b9
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 2 deletions.
2 changes: 2 additions & 0 deletions pylib/System/TestDef.py
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,8 @@ def configTest(self):
print("Test .ini file not found!: " + testFile)
sys.exit(1)
self.config = configparser.ConfigParser()
# Set the config parser to make option names case sensitive.
self.config.optionxform = str
self.config.read(self.log['inifiles'])
for section in self.config.sections():
if self.logger is not None:
Expand Down
37 changes: 37 additions & 0 deletions pylib/Utilities/Environ.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/usr/bin/env python
#
# Copyright (c) 2015-2016 Intel, Inc. All rights reserved.
# $COPYRIGHT$
#
# Additional copyrights may follow
#
# $HEADER$
#

import shutil
import os
from BaseMTTUtility import *

class Environ(BaseMTTUtility):
def __init__(self):
BaseMTTUtility.__init__(self)
self.options = {}

def print_name(self):
return "Environ"

def print_options(self, testDef, prefix):
lines = testDef.printOptions(self.options)
for line in lines:
print prefix + line
return

def execute(self, log, keyvals, testDef):
testDef.logger.verbose_print("Environ Execute")

# Set any provided key values
kvkeys = keyvals.keys()
for kvkey in kvkeys:
os.environ[kvkey] = keyvals[kvkey]
log['status'] = 0
return
18 changes: 18 additions & 0 deletions pylib/Utilities/Environ.yapsy-plugin
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#
# Copyright (c) 2015-2016 Intel, Inc. All rights reserved.
# $COPYRIGHT$
#
# Additional copyrights may follow
#
# $HEADER$
#

[Core]
Name = Environ
Module = Environ

[Documentation]
Author = Noah van Dresser
Version = 0.1
Website = N/A
Description = Set environment variables
4 changes: 2 additions & 2 deletions pylib/Utilities/ModuleCmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def loadModules(self, modules, testDef):
sys.stdout = saved_stdout
sys.stderr = saved_stderr

status = load_stderr.len
status = load_stderr.seek(0, os.SEEK_END)
stdout = load_stdout.getvalue()
stderr = load_stderr.getvalue()
load_stdout.close()
Expand Down Expand Up @@ -137,7 +137,7 @@ def unloadModules(self, modules, testDef):
sys.stdout = saved_stdout
sys.stderr = saved_stderr

status = unload_stderr.len
status = unload_stderr.seek(0, os.SEEK_END)
stdout = unload_stdout.getvalue()
stderr = unload_stderr.getvalue()
unload_stdout.close()
Expand Down

0 comments on commit cabd8b9

Please sign in to comment.