コード例 #1
0
def check(res, stat=NFS4_OK, msg=None, warnlist=[]):

    if type(stat) is str:
        raise "You forgot to put 'msg=' in front of check's string arg"

    statlist = stat
    if type(statlist) == int:
        statlist = [stat]

    log.debug("checking %r == %r" % (res, statlist))
    if res.status in statlist:
        if not (debug_fail and msg):
            return

    statnames = [nfsstat4[stat] for stat in statlist]
    desired = ' or '.join(statnames)
    if not desired:
        desired = 'one of <none>'

    received = nfsstat4[res.status]
    if msg:
        failedop_name = msg
    elif res.resarray:
        failedop_name = nfs_opnum4[res.resarray[-1].resop]
    else:
        failedop_name = 'Compound'
    msg = "%s should return %s, instead got %s" % \
          (failedop_name, desired, received)
    if res.status in warnlist:
        raise testmod.WarningException(msg)
    else:
        raise testmod.FailureException(msg)
コード例 #2
0
def checkdict(expected, got, translate={}, failmsg=''):
    if failmsg: failmsg += ': '
    for k in expected:
        if k not in got:
            try:
                name = translate[k]
            except KeyError:
                name = str(k)
            raise testmod.FailureException(
                failmsg + "For %s expected %s, but no value returned" %
                (name, str(expected[k])))
        if expected[k] != got[k]:
            try:
                name = translate[k]
            except KeyError:
                name = str(k)
            raise testmod.FailureException(
                failmsg + "For %s expected %s, got %s" %
                (name, str(expected[k]), str(got[k])))
コード例 #3
0
def checklist(res, statlist, msg=None):
    if res.status in statlist:
        return
    statnames = [nfsstat3[stat] for stat in statlist]
    desired = ' or '.join(statnames)
    if not desired:
        desired = 'one of <none>'
    received = nfsstat3[res.status]
    if msg:
        failedop_name = msg
    msg = "%s should return %s, instead got %s" % \
      (failedop_name, desired, received)
    raise testmod.FailureException(msg)
コード例 #4
0
def check(res, stat=NFS3_OK, msg=None, warnlist=[]):
    if res.status == stat:
        if not (debug_fail and msg):
            return
    if type(stat) is str:
        raise "You forgot to put 'msg=' in front of check's string arg"
    desired = nfsstat3[stat]
    received = nfsstat3[res.status]
    if msg:
        msg = "%s should return %s, instead got %s" % (msg, desired, received)
    if res.status in warnlist:
        raise testmod.WarningException(msg)
    else:
        raise testmod.FailureException(msg)
コード例 #5
0
ファイル: environment.py プロジェクト: liuying1001/newpynfs
def checklist(res, statlist, msg=None):
    if res.status in statlist:
        return
    statnames = [nfsstat4[stat] for stat in statlist]
    desired = ' or '.join(statnames)
    if not desired:
        desired = 'one of <none>'
    received = nfsstat4[res.status]
    if msg:
        failedop_name = msg
    elif res.resarray:
        failedop_name = nfs_opnum4[res.resarray[-1].resop]
    else:
        failedop_name = 'Compound'
    msg = "%s should return %s, instead got %s" % \
          (failedop_name, desired, received)
    raise testmod.FailureException(msg)
コード例 #6
0
ファイル: environment.py プロジェクト: liuying1001/newpynfs
def check(res, stat=NFS4_OK, msg=None, warnlist=[]):
    #if res.status == stat:
    #    return
    if res.status == stat:
        if not (debug_fail and msg):
            return
    if type(stat) is str:
        raise "You forgot to put 'msg=' in front of check's string arg"
    desired = nfsstat4[stat]
    received = nfsstat4[res.status]
    if msg:
        failedop_name = msg
    elif res.resarray:
        failedop_name = nfs_opnum4[res.resarray[-1].resop]
    else:
        failedop_name = 'Compound'
    msg = "%s should return %s, instead got %s" % \
          (failedop_name, desired, received)
    if res.status in warnlist:
        raise testmod.WarningException(msg)
    else:
        raise testmod.FailureException(msg)
コード例 #7
0
def fail(msg):
    raise testmod.FailureException(msg)
コード例 #8
0
def checkvalid(cond, failmsg):
    if not cond: raise testmod.FailureException(failmsg)