aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChase Qi <chase.qi@linaro.org>2015-07-02 07:18:35 +0800
committerChase Qi <chase.qi@linaro.org>2015-07-02 07:23:12 +0800
commitad0cde2e31c814febf7a5978016b67194470fe2d (patch)
treeb0ee86f4357e79ce87e799275e09edff607370bd
parent3b048d5bf0046ffbc5af9740e3d77beb9f393ef4 (diff)
Sync with upstream and compatible with python2
- Sync with upstream - Fix testsuite to use the right fstype. - Test rmdir of non-empty opaque dir - Set terminal slash value properly for 'run --ov' - Compatible with python2 Change-Id: I78b8671d30e6e4159364a2b2846e11143b169504 Signed-off-by: Chase Qi <chase.qi@linaro.org>
-rw-r--r--.gitreview4
-rw-r--r--context.py42
-rw-r--r--mount_union.py2
-rwxr-xr-xrun20
-rw-r--r--set_up.py9
-rw-r--r--tests/__init__.py0
6 files changed, 50 insertions, 27 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/mount_union.py b/mount_union.py
index e5db16b..17edd3c 100644
--- a/mount_union.py
+++ b/mount_union.py
@@ -30,6 +30,6 @@ def mount_union(ctx):
workdir = upper_mntroot + "/work"
os.mkdir(upperdir)
os.mkdir(workdir)
- system("mount -t overlay overlayfs " + union_mntroot +
+ system("mount -t overlay overlay " + union_mntroot +
" -olowerdir=" + lower_mntroot + ",upperdir=" + upperdir + ",workdir=" + workdir)
ctx.note_upper_fs(upper_mntroot, testdir)
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