aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMilosz Wasilewski <milosz.wasilewski@linaro.org>2015-07-03 11:59:15 +0100
committerMilosz Wasilewski <milosz.wasilewski@linaro.org>2015-07-03 11:59:15 +0100
commitda2418b029392720eec62b63a423519d8170477e (patch)
tree3a5091bdaa8c97512fec827e842d8836bd2aa55f
parent0d249b1989d0649eaca76fdfd52f000ddd00b0c5 (diff)
parentad0cde2e31c814febf7a5978016b67194470fe2d (diff)
Merge branch 'python2-support'HEADmaster
-rw-r--r--.gitreview4
-rw-r--r--context.py42
-rwxr-xr-xrun20
-rw-r--r--set_up.py9
-rw-r--r--tests/__init__.py0
5 files changed, 49 insertions, 26 deletions
diff --git a/.gitreview b/.gitreview
new file mode 100644
index 0000000..0bd30f2
--- /dev/null
+++ b/.gitreview
@@ -0,0 +1,4 @@
+[gerrit]
+host=review.linaro.org
+port=29418
+project=people/milosz.wasilewski/unionmount-testsuite.git
diff --git a/context.py b/context.py
index 1161e05..54f7260 100644
--- a/context.py
+++ b/context.py
@@ -175,10 +175,9 @@ class test_context:
self.__verbose = cfg.is_verbose()
self.__direct_mode = direct_mode
self.__skip_layer_test = cfg.testing_none()
- if cfg.is_termslash():
+ self.__termslash = ""
+ if termslash:
self.__termslash = "/"
- else:
- self.__termslash = ""
def config(self):
return self.__cfg
@@ -425,16 +424,18 @@ class test_context:
try:
self.verbosef("os.rmdir({:s})\n", f)
os.rmdir(f)
- except FileNotFoundError:
- pass
+ except OSError as e:
+ if e.errno == errno.ENOENT:
+ pass
elif not cursor.is_negative():
self.verbosef("os.unlink({:s})\n", f)
os.unlink(f)
try:
self.verbosef("os.unlink({:s})\n", f)
os.unlink(f)
- except FileNotFoundError:
- pass
+ except OSError as e:
+ if e.errno == errno.ENOENT:
+ pass
def rmtree(self, filename):
self.output("- rmtree ", filename, "\n")
@@ -457,9 +458,10 @@ class test_context:
name = dentry.filename()
try:
dev = self.get_dev_id(name)
- except (FileNotFoundError, NotADirectoryError):
- if not dentry.is_negative():
- raise TestError(name + ": File is missing")
+ except OSError as e:
+ if e.errno == errno.ENOENT or e.errno == errno.ENOTDIR:
+ if not dentry.is_negative():
+ raise TestError(name + ": File is missing")
return
if dentry.is_negative():
@@ -872,7 +874,10 @@ class test_context:
try:
self.verbosef("os.link({:s},{:s})\n", filename, filename2)
- os.link(filename, filename2, follow_symlinks=follow_symlinks)
+ if sys.version_info[0] == 2:
+ os.link(filename, filename2)
+ else:
+ os.link(filename, filename2, follow_symlinks=follow_symlinks)
dentry.copied_up()
self.vfs_op_success(filename, dentry, args, copy_up=True)
self.vfs_op_success(filename2, dentry2, args, create=True, filetype=dentry.filetype(),
@@ -968,8 +973,14 @@ class test_context:
dentry = self.vfs_op_prelude(line, filename, args)
try:
- self.verbose("os.truncate(", filename, ",", size, ")\n")
- os.truncate(filename, size)
+ if sys.version_info[0] == 2:
+ self.verbose("os.ftruncate(", filename, ",", size, ")\n")
+ truncate_fd = os.open(filename, os.O_RDWR)
+ os.ftruncate(truncate_fd, size)
+ os.close(truncate_fd)
+ else:
+ self.verbose("os.truncate(", filename, ",", size, ")\n")
+ os.truncate(filename, size)
self.vfs_op_success(filename, dentry, args, copy_up=True)
except OSError as oe:
self.vfs_op_error(oe, filename, dentry, args)
@@ -1007,7 +1018,10 @@ class test_context:
try:
self.verbosef("os.utime({:s},follow_symlinks={:d})\n", filename, follow)
- os.utime(filename, follow_symlinks=follow)
+ if sys.version_info[0] == 2:
+ os.utime(filename, None) # os.utime follow symbolic links by default
+ else:
+ os.utime(filename, follow_symlinks=follow)
self.vfs_op_success(filename, dentry, args, copy_up=True)
except OSError as oe:
self.vfs_op_error(oe, filename, dentry, args)
diff --git a/run b/run
index a08bb28..04288f4 100755
--- a/run
+++ b/run
@@ -108,13 +108,15 @@ if len(args) > 0 and args[0] == "--set-up":
mount_union(ctx)
sys.exit(0)
+
+termslash_list = [ "0", "1" ]
while len(args) > 0 and args[0].startswith("-"):
if args[0] == "-v":
cfg.set_verbose()
elif args[0] == "--ts=0":
- cfg.set_termslash(False)
+ termslash_list = [ "0" ]
elif args[0] == "--ts=1":
- cfg.set_termslash(True)
+ termslash_list = [ "1" ]
else:
show_format("Invalid flag " + args[0])
args = args[1:]
@@ -192,13 +194,6 @@ elif cfg.testing_overlayfs():
else:
test_what = "--no"
-if cfg.is_termslash() == None:
- termslash_list = [ "0", "1" ]
-elif cfg.is_termslash() == True:
- termslash_list = [ "1" ]
-else:
- termslash_list = [ "0" ]
-
for test in tests:
for ts in termslash_list:
print("***");
@@ -210,7 +205,12 @@ for test in tests:
# Construct the union
set_up(ctx)
mount_union(ctx)
- os.sync()
+ if sys.version_info[0] == 2:
+ import ctypes
+ libc = ctypes.CDLL("libc.so.6")
+ libc.sync()
+ else:
+ os.sync()
# Run a test script
script = __import__("tests." + test, globals(), locals(), ['subtests'])
diff --git a/set_up.py b/set_up.py
index b7d3de0..96caacf 100644
--- a/set_up.py
+++ b/set_up.py
@@ -2,7 +2,7 @@
# Create and set up a lower layer for the test scripts to use
#
from tool_box import *
-import os, shutil
+import os, shutil, sys
def create_file(name, content):
fd = open(name, "w")
@@ -15,7 +15,12 @@ def set_up(ctx):
lowerdir = cfg.lowerdir()
testdir = cfg.testdir()
- os.sync()
+ if sys.version_info[0] == 2:
+ import ctypes
+ libc = ctypes.CDLL("libc.so.6")
+ libc.sync()
+ else:
+ os.sync()
# Discard anything already mounted on the mountpoint to avoid contamination
# as unionmount tries to collect all the mounts located there into the
diff --git a/tests/__init__.py b/tests/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/__init__.py