Example #1
0
def testFileToFile(t, env):
    """RENAME file into existing file should return NFS4_OK

    FLAGS: rename all
    CODE: RNM15
    """
    name = env.testname(t)
    sess = env.c1.new_client_session(name)
    basedir = env.c1.homedir + [name]
    maketree(sess, [name, 'file1', 'file2'])
    res = rename_obj(sess, basedir + ['file1'], basedir + ['file2'])
    check(res, msg="RENAME file1 into existing file2")
Example #2
0
def testDirToFullDir(t, env):
    """RENAME dir into existing, nonempty dir should return NFS4ERR_EXIST

    FLAGS: rename all
    CODE: RNM16
    """
    name = env.testname(t)
    sess = env.c1.new_client_session(name)
    basedir = env.c1.homedir + [name]
    maketree(sess, [name, ['dir1'], ['dir2', ['foo']]])
    res = rename_obj(sess, basedir + ['dir1'], basedir + ['dir2'])
    checklist(res, [NFS4ERR_EXIST, NFS4ERR_NOTEMPTY], "RENAME dir1 into existing, nonempty dir2")
Example #3
0
def testDirToObj(t, env):
    """RENAME dir into existing nondir should return NFS4ERR_EXIST

    FLAGS: rename all
    CODE: RNM12
    """
    name = env.testname(t)
    sess = env.c1.new_client_session(name)
    basedir = env.c1.homedir + [name]
    maketree(sess, [name, ['dir'], 'file'])
    res = rename_obj(sess, basedir + ['dir'], basedir + ['file'])
    check(res, NFS4ERR_EXIST, "RENAME dir into existing file")
Example #4
0
def testDirToDir(t, env):
    """RENAME dir into existing, empty dir should retrun NFS4_OK

    FLAGS: rename all
    CODE: RNM13
    """
    name = env.testname(t)
    sess = env.c1.new_client_session(name)
    basedir = env.c1.homedir + [name]
    maketree(sess, [name, ['dir1', ['foo']], ['dir2']])
    res = rename_obj(sess, basedir + ['dir1'], basedir + ['dir2'])
    check(res, msg="RENAME dir1 into existing, empty dir2")
Example #5
0
def testFileToFullDir(t, env):
    """RENAME file into existing, nonempty dir should return NFS4ERR_EXIST

    FLAGS: rename all
    CODE: RNM17
    """
    name = env.testname(t)
    sess = env.c1.new_client_session(name)
    basedir = env.c1.homedir + [name]
    maketree(sess, [name, 'file', ['dir', ['foo']]])
    res = rename_obj(sess, basedir + ['file'], basedir + ['dir'])
    check(res, NFS4ERR_EXIST, "RENAME file into existing, nonempty dir")
Example #6
0
def testDirToObj(t, env):
    """RENAME dir into existing nondir should fail

    FLAGS: rename all
    CODE: RNM12
    """
    name = env.testname(t)
    sess = env.c1.new_client_session(name)
    basedir = env.c1.homedir + [name]
    maketree(sess, [name, ['dir'], 'file'])
    res = rename_obj(sess, basedir + ['dir'], basedir + ['file'])
    # note rfc 3530 and 1813 specify EXIST, but posix specifies NOTDIR
    checklist(res, [NFS4ERR_EXIST, NFS4ERR_NOTDIR], "RENAME dir into existing file")
Example #7
0
def testValidDir(t, env):
    """RENAME : normal operation

    FLAGS: rename dir all
    CODE: RNM1d
    """
    name = env.testname(t)
    sess = env.c1.new_client_session(name)
    basedir = env.c1.homedir + [name]
    maketree(sess, [name, ['dir1', ['foo']], ['dir2']])
    res = rename_obj(sess, basedir + ['dir1', 'foo'], basedir + ['dir2', 'bar'])
    check(res, msg="RENAME of directory %s/dir1/foo to %s/dir2/bar" %
          (name, name))
Example #8
0
def testFileToFullDir(t, env):
    """RENAME file into existing, nonempty dir should return NFS4ERR_EXIST

    FLAGS: rename all
    CODE: RNM17
    """
    name = env.testname(t)
    c = env.c1.new_client(name)
    sess = c.create_session()
    basedir = env.c1.homedir + [name]
    maketree(sess, [name, 'file', ['dir', ['foo']]])
    res = rename_obj(sess, basedir + ['file'], basedir + ['dir'])
    check(res, NFS4ERR_EXIST, "RENAME file into existing, nonempty dir")
Example #9
0
def testDirToObj(t, env):
    """RENAME dir into existing nondir should return NFS4ERR_EXIST

    FLAGS: rename all
    CODE: RNM12
    """
    name = env.testname(t)
    c = env.c1.new_client(name)
    sess = c.create_session()
    basedir = env.c1.homedir + [name]
    maketree(sess, [name, ['dir'], 'file'])
    res = rename_obj(sess, basedir + ['dir'], basedir + ['file'])
    check(res, NFS4ERR_EXIST, "RENAME dir into existing file")
Example #10
0
def testFileToFullDir(t, env):
    """RENAME file into existing, nonempty dir should fail

    FLAGS: rename all
    CODE: RNM17
    """
    name = env.testname(t)
    sess = env.c1.new_client_session(name)
    basedir = env.c1.homedir + [name]
    maketree(sess, [name, 'file', ['dir', ['foo']]])
    res = rename_obj(sess, basedir + ['file'], basedir + ['dir'])
    # note rfc 3530 and 1813 specify EXIST, but posix specifies ISDIR
    checklist(res, [NFS4ERR_EXIST, NFS4ERR_ISDIR], "RENAME file into existing, nonempty dir")
Example #11
0
def testBadutf8Newname(t, env):
    """RENAME with non-UTF8 newname should return NFS4ERR_INVAL

    FLAGS: rename utf8
    CODE: RNM9
    """
    name = env.testname(t)
    sess = env.c1.new_client_session(name)
    basedir = env.c1.homedir + [name]
    maketree(sess, [name, [name]])
    for bad_utf8 in get_invalid_utf8strings():
        res = rename_obj(sess, basedir + [name], basedir + [bad_utf8])
        check(res, NFS4ERR_INVAL, "RENAME with non-UTF8 newname %s/%s" %
                                   (name, repr(bad_utf8)[1:-1]))
Example #12
0
def testDotsNewname(t, env):
    """RENAME into . or .. should return _BADNAME or NFS4_OK

    FLAGS: rename dots all
    CODE: RNM11
    """
    name = env.testname(t)
    sess = env.c1.new_client_session(name)
    basedir = env.c1.homedir + [name]
    maketree(sess, [name, [name]])
    res = rename_obj(sess, basedir + [name], basedir + ['.'])
    check(res, NFS4ERR_BADNAME, "RENAME into '.'", [NFS4_OK])
    res = rename_obj(sess, basedir + [name], basedir + ['..'])
    check(res, NFS4ERR_BADNAME, "RENAME into '..'", [NFS4_OK])
Example #13
0
def testValidFile(t, env):
    """RENAME : normal operation

    FLAGS: rename file all
    CODE: RNM1r
    """
    name = env.testname(t)
    c = env.c1.new_client(name)
    sess = c.create_session()
    basedir = env.c1.homedir + [name]
    maketree(sess, [name, ['dir1', 'foo'], ['dir2']])
    res = rename_obj(sess, basedir + ['dir1', 'foo'],
                     basedir + ['dir2', 'bar'])
    check(res, msg="RENAME of file %s/dir1/foo to %s/dir2/bar" % (name, name))
Example #14
0
def testValidLink(t, env):
    """RENAME : normal operation

    FLAGS: rename symlink all
    CODE: RNM1a
    """
    name = env.testname(t)
    sess = env.c1.new_client_session(name)
    basedir = env.c1.homedir + [name]
    maketree(sess, [name, ['dir1'], ['dir2']])
    res = create_obj(sess, basedir + ['dir1', 'foo'], createtype4(NF4LNK, linkdata=env.linkdata))
    check(res)
    res = rename_obj(sess, basedir + ['dir1', 'foo'], basedir + ['dir2', 'bar'])
    check(res, msg="RENAME of symlink %s/dir1/foo to %s/dir2/bar" %
          (name, name))
Example #15
0
def testDotsOldname(t, env):
    """RENAME from nonexistant . or .. should return _NOENT/_BADNAME

    FLAGS: rename dots all
    CODE: RNM10
    """
    name = env.testname(t)
    sess = env.c1.new_client_session(name)
    basedir = env.c1.homedir + [name]
    maketree(sess, [name, [name]])
    res = rename_obj(sess, basedir + ['.'], basedir + [name])
    check(res, NFS4ERR_BADNAME, "RENAME from nonexistant '.'", [NFS4ERR_NOENT])
    res = rename_obj(sess, basedir + ['..'], basedir + [name])
    check(res, NFS4ERR_BADNAME, "RENAME from nonexistant '..'",
          [NFS4ERR_NOENT])
Example #16
0
def testValidSocket(t, env):
    """RENAME : normal operation

    FLAGS: rename socket all
    CODE: RNM1s
    """
    name = env.testname(t)
    sess = env.c1.new_client_session(name)
    basedir = env.c1.homedir + [name]
    maketree(sess, [name, ['dir1'], ['dir2']])
    res = create_obj(sess, basedir + ['dir1', 'foo'], NF4SOCK)
    check(res)
    res = rename_obj(sess, basedir + ['dir1', 'foo'], basedir + ['dir2', 'bar'])
    check(res, msg="RENAME of socket %s/dir1/foo to %s/dir2/bar" %
          (name, name))
Example #17
0
def testValidChar(t, env):
    """RENAME : normal operation

    FLAGS: rename char all
    CODE: RNM1c
    """
    name = env.testname(t)
    sess = env.c1.new_client_session(name)
    basedir = env.c1.homedir + [name]
    maketree(sess, [name, ['dir1'], ['dir2']])
    res = create_obj(sess, basedir + ['dir1', 'foo'], createtype4(NF4BLK, devdata=specdata4(1, 2)))
    check(res)
    res = rename_obj(sess, basedir + ['dir1', 'foo'], basedir + ['dir2', 'bar'])
    check(res, msg="RENAME of character device %s/dir1/foo to %s/dir2/bar" %
          (name, name))
Example #18
0
def testDotsNewname(t, env):
    """RENAME into . or .. should return _BADNAME or NFS4_OK

    FLAGS: rename dots all
    CODE: RNM11
    """
    name = env.testname(t)
    sess = env.c1.new_client_session(name)
    basedir = env.c1.homedir + [name]
    maketree(sess, [name, [name]])
    res = rename_obj(sess, basedir + [name], basedir + ['.'])
    check(res, NFS4ERR_BADNAME, "RENAME into '.'",
          [NFS4_OK])
    res = rename_obj(sess, basedir + [name], basedir + ['..'])
    check(res, NFS4ERR_BADNAME, "RENAME into '..'",
          [NFS4_OK])
Example #19
0
def testDotsOldname(t, env):
    """RENAME from nonexistant . or .. should return _NOENT/_BADNAME

    FLAGS: rename dots all
    CODE: RNM10
    """
    name = env.testname(t)
    sess = env.c1.new_client_session(name)
    basedir = env.c1.homedir + [name]
    maketree(sess, [name, [name]])
    res = rename_obj(sess, basedir + ['.'], basedir + [name])
    check(res, NFS4ERR_BADNAME, "RENAME from nonexistant '.'",
          [NFS4ERR_NOENT])
    res = rename_obj(sess, basedir + ['..'], basedir + [name])
    check(res, NFS4ERR_BADNAME, "RENAME from nonexistant '..'",
          [NFS4ERR_NOENT])
Example #20
0
def testSelfRenameDir(t, env):
    """RENAME that does nothing

    FLAGS: rename all
    CODE: RNM18
    """
    name = env.testname(t)
    sess = env.c1.new_client_session(name)
    maketree(sess, [name])
    basedir = env.c1.homedir + [name]
    res = rename_obj(sess, basedir, basedir)
    check(res)
    scinfo = res.resarray[-1].source_cinfo
    tcinfo = res.resarray[-1].target_cinfo
    if scinfo.before != scinfo.after or tcinfo.before != tcinfo.after:
        t.fail("RENAME of dir %s into itself should do nothing, "
               "but cinfo was changed" % name)
Example #21
0
def testLinkRename(t, env):
    """RENAME of file into its hard link should do nothing

    FLAGS: rename all
    CODE: RNM20
    """
    name = env.testname(t)
    sess = env.c1.new_client_session(name)
    maketree(sess, [name, 'file'])
    basedir = env.c1.homedir + [name]
    res = link(sess, basedir + ['file'], basedir + ['link'])
    check(res)
    res = rename_obj(sess, basedir + ['file'], basedir + ['link'])
    check(res, msg="RENAME of file into its hard link")
    scinfo = res.resarray[-1].source_cinfo
    tcinfo = res.resarray[-1].target_cinfo
    if scinfo.before != scinfo.after or tcinfo.before != tcinfo.after:
        t.fail("RENAME of file into its hard link should do nothing, "
               "but cinfo was changed")