path: root/tests
diff options
authorDavid Gibson <dwg@au1.ibm.com>2009-08-20 08:58:17 +1000
committerEric B Munson <ebmunson@us.ibm.com>2009-08-21 10:56:59 +0100
commit6ada2a2aa4bfd9f946a9d21d3a88baaaa8f50276 (patch)
treeae04462f73b8db5aeaf5370c4a8c52c45dab9a97 /tests
parentea893ba0be9639dab821522513c7a22c48e9132b (diff)
libhugetlbfs: Fix some small errors / warts in run_tests.py
This fixes one real bug in run_tests.py and a couple of other places where we do things in a silly way. The real bug is that we clearly want to use the current libhugetlbfs binaries and libraries to run the test, so they should be added to the front of the path, not the back as cmd_env() currently does. In the same piece of code we use Python's `` operators for no good reason, since the string formatting operation we're already using will encode the bits value properly. cmd_env() also takes an optional pagesize parameter. The only time it's not supplied is when it's used to invoke hugeadm, which doesn't really suit use of cmd_env() anyway. So, this patch makes that parameter mandatory which simplifies the logic a bit (in fact that test logic was also wrong, but it didn't really matter). Finally, in bash() we use the dictionary's update() method instead of the manual equivalent. Signed-off-by: David Gibson <dwg@au1.ibm.com> Signed-off-by: Eric B Munson <ebmunson@us.ibm.com>
Diffstat (limited to 'tests')
1 files changed, 7 insertions, 9 deletions
diff --git a/tests/run_tests.py b/tests/run_tests.py
index 3857d71..71ad35f 100755
--- a/tests/run_tests.py
+++ b/tests/run_tests.py
@@ -38,8 +38,7 @@ def bash(cmd, extra_env={}):
Run 'cmd' in the shell and return the exit code and output.
local_env = os.environ.copy()
- for key,value in extra_env.items():
- local_env[key] = value
+ local_env.update(extra_env)
p = subprocess.Popen(cmd, shell=True, env=local_env, \
@@ -186,7 +185,7 @@ def clear_hpages():
except OSError:
-def cmd_env(bits, pagesize=""):
+def cmd_env(bits, pagesize):
Construct test-specific environment settings.
@@ -194,11 +193,10 @@ def cmd_env(bits, pagesize=""):
libhugetlbfs test or utility that is run from within the source tree can
be found. Additionally, tell libhugetlbfs to use the requested page size.
- str = "PATH=$PATH:./obj%s:../obj%s " \
- "LD_LIBRARY_PATH=$LD_LIBRARY_PATH:../obj%s:obj%s " % \
- (`bits`, `bits`, `bits`, `bits`)
- if len(`pagesize`) > 0: str += "HUGETLB_DEFAULT_PAGE_SIZE=%s " % pagesize
- return str
+ return "PATH=./obj%d:../obj%d:$PATH " \
+ "LD_LIBRARY_PATH=../obj%d:obj%d:$LD_LIBRARY_PATH " \
+ % (bits, bits, bits, bits, pagesize)
def get_pagesizes():
@@ -209,7 +207,7 @@ def get_pagesizes():
sizes = set()
out = ""
- (rc, out) = bash(cmd_env('') + "hugeadm --page-sizes")
+ (rc, out) = bash("../obj/hugeadm --page-sizes")
if rc != 0 or out == "": return sizes
for size in out.split("\n"): sizes.add(int(size))