예제 #1
0
def test_timespec_behavior():
    if not _have_bup_utime_ns:
        return
    tmpdir = tempfile.mkdtemp(prefix='bup-tmetadata-')
    try:
        path = tmpdir + '/foo'
        open(path, 'w').close()
        frac_ts = (0, 10**9 / 2)
        _helpers.bup_utime_ns(path, (frac_ts, frac_ts))
        st = _helpers.stat(path)
        atime_ts = st[8]
        mtime_ts = st[9]
        WVPASSEQ(atime_ts[0], 0)
        WVPASS(atime_ts[1] == 0 or atime_ts[1] == frac_ts[1])
        WVPASSEQ(mtime_ts[0], 0)
        WVPASS(mtime_ts[1] == 0 or mtime_ts[1] == frac_ts[1])
        if(mtime_ts[1] == frac_ts[1]):
            # Sub-second resolution -- check behavior of negative timespecs.
            neg_ts = (-43, 10**9 / 2)
            _helpers.bup_utime_ns(path, (neg_ts, neg_ts))
            st = _helpers.stat(path)
            atime_ts = st[8]
            mtime_ts = st[9]
            WVPASSEQ(atime_ts, neg_ts)
            WVPASSEQ(mtime_ts, neg_ts)
    finally:
        subprocess.call(['rm', '-rf', tmpdir])
예제 #2
0
def test_bup_lutimes(tmpdir):
    if not xstat._bup_lutimes:
        return
    path = tmpdir + b'/foo'
    open(path, 'w').close()
    frac_ts = (0, 10**6 // 2)
    xstat._bup_lutimes(path, (frac_ts, frac_ts))
    st = _helpers.stat(path)
    atime_ts = st[8]
    mtime_ts = st[9]
    WVPASSEQ(atime_ts[0], 0)
    WVPASS(atime_ts[1] == 0 or atime_ts[1] == frac_ts[1] * 1000)
    WVPASSEQ(mtime_ts[0], 0)
    WVPASS(mtime_ts[1] == 0 or mtime_ts[1] == frac_ts[1] * 1000)
예제 #3
0
def test_bup_utimensat(tmpdir):
    if not xstat._bup_utimensat:
        return
    path = tmpdir + b'/foo'
    open(path, 'w').close()
    frac_ts = (0, 10**9 // 2)
    xstat._bup_utimensat(_helpers.AT_FDCWD, path, (frac_ts, frac_ts), 0)
    st = _helpers.stat(path)
    atime_ts = st[8]
    mtime_ts = st[9]
    WVPASSEQ(atime_ts[0], 0)
    WVPASS(atime_ts[1] == 0 or atime_ts[1] == frac_ts[1])
    WVPASSEQ(mtime_ts[0], 0)
    WVPASS(mtime_ts[1] == 0 or mtime_ts[1] == frac_ts[1])
예제 #4
0
파일: txstat.py 프로젝트: tforsberg/bup
def test_bup_lutimes():
    if not xstat._bup_lutimes:
        return
    with no_lingering_errors(), test_tempdir('bup-txstat-') as tmpdir:
        path = tmpdir + '/foo'
        open(path, 'w').close()
        frac_ts = (0, 10**6 / 2)
        xstat._bup_lutimes(path, (frac_ts, frac_ts))
        st = _helpers.stat(path)
        atime_ts = st[8]
        mtime_ts = st[9]
        WVPASSEQ(atime_ts[0], 0)
        WVPASS(atime_ts[1] == 0 or atime_ts[1] == frac_ts[1] * 1000)
        WVPASSEQ(mtime_ts[0], 0)
        WVPASS(mtime_ts[1] == 0 or mtime_ts[1] == frac_ts[1] * 1000)
예제 #5
0
파일: txstat.py 프로젝트: bup/bup
def test_bup_utimes():
    if not xstat._bup_utimes:
        return
    with no_lingering_errors():
        with test_tempdir('bup-txstat-') as tmpdir:
            path = tmpdir + '/foo'
            open(path, 'w').close()
            frac_ts = (0, 10**6 / 2)
            xstat._bup_utimes(path, (frac_ts, frac_ts))
            st = _helpers.stat(path)
            atime_ts = st[8]
            mtime_ts = st[9]
            WVPASSEQ(atime_ts[0], 0)
            WVPASS(atime_ts[1] == 0 or atime_ts[1] == frac_ts[1] * 1000)
            WVPASSEQ(mtime_ts[0], 0)
            WVPASS(mtime_ts[1] == 0 or mtime_ts[1] == frac_ts[1] * 1000)
예제 #6
0
파일: txstat.py 프로젝트: xiaofeng283-t/bup
def test_bup_utimensat():
    if not xstat._bup_utimensat:
        return
    with no_lingering_errors():
        with test_tempdir('bup-txstat-') as tmpdir:
            path = tmpdir + '/foo'
            open(path, 'w').close()
            frac_ts = (0, 10**9 / 2)
            xstat._bup_utimensat(_helpers.AT_FDCWD, path, (frac_ts, frac_ts), 0)
            st = _helpers.stat(path)
            atime_ts = st[8]
            mtime_ts = st[9]
            WVPASSEQ(atime_ts[0], 0)
            WVPASS(atime_ts[1] == 0 or atime_ts[1] == frac_ts[1])
            WVPASSEQ(mtime_ts[0], 0)
            WVPASS(mtime_ts[1] == 0 or mtime_ts[1] == frac_ts[1])
예제 #7
0
파일: txstat.py 프로젝트: kwharrigan/bup
def test_bup_lutimes():
    if not xstat._bup_lutimes:
        return
    tmpdir = tempfile.mkdtemp(prefix="bup-tmetadata-")
    try:
        path = tmpdir + "/foo"
        open(path, "w").close()
        frac_ts = (0, 10 ** 6 / 2)
        xstat._bup_lutimes(path, (frac_ts, frac_ts))
        st = _helpers.stat(path)
        atime_ts = st[8]
        mtime_ts = st[9]
        WVPASSEQ(atime_ts[0], 0)
        WVPASS(atime_ts[1] == 0 or atime_ts[1] == frac_ts[1] * 1000)
        WVPASSEQ(mtime_ts[0], 0)
        WVPASS(mtime_ts[1] == 0 or mtime_ts[1] == frac_ts[1] * 1000)
    finally:
        subprocess.call(["rm", "-rf", tmpdir])
예제 #8
0
파일: txstat.py 프로젝트: wheelcomplex/bup
def test_bup_utimes():
    initial_failures = wvfailure_count()
    if not xstat._bup_utimes:
        return
    tmpdir = tempfile.mkdtemp(dir=bup_tmp, prefix='bup-txstat-')
    path = tmpdir + '/foo'
    open(path, 'w').close()
    frac_ts = (0, 10**6 / 2)
    xstat._bup_utimes(path, (frac_ts, frac_ts))
    st = _helpers.stat(path)
    atime_ts = st[8]
    mtime_ts = st[9]
    WVPASSEQ(atime_ts[0], 0)
    WVPASS(atime_ts[1] == 0 or atime_ts[1] == frac_ts[1] * 1000)
    WVPASSEQ(mtime_ts[0], 0)
    WVPASS(mtime_ts[1] == 0 or mtime_ts[1] == frac_ts[1] * 1000)
    if wvfailure_count() == initial_failures:
        subprocess.call(['rm', '-rf', tmpdir])
예제 #9
0
파일: txstat.py 프로젝트: joshmoore/bup
def test_bup_utimensat():
    if not xstat._bup_utimensat:
        return
    tmpdir = tempfile.mkdtemp(prefix='bup-tmetadata-')
    try:
        path = tmpdir + '/foo'
        open(path, 'w').close()
        frac_ts = (0, 10**9 / 2)
        xstat._bup_utimensat(_helpers.AT_FDCWD, path, (frac_ts, frac_ts), 0)
        st = _helpers.stat(path)
        atime_ts = st[8]
        mtime_ts = st[9]
        WVPASSEQ(atime_ts[0], 0)
        WVPASS(atime_ts[1] == 0 or atime_ts[1] == frac_ts[1])
        WVPASSEQ(mtime_ts[0], 0)
        WVPASS(mtime_ts[1] == 0 or mtime_ts[1] == frac_ts[1])
    finally:
        subprocess.call(['rm', '-rf', tmpdir])
예제 #10
0
파일: txstat.py 프로젝트: 3v/bup
def test_bup_utimes():
    initial_failures = wvfailure_count()
    if not xstat._bup_utimes:
        return
    tmpdir = tempfile.mkdtemp(dir=bup_tmp, prefix='bup-txstat-')
    path = tmpdir + '/foo'
    open(path, 'w').close()
    frac_ts = (0, 10**6 / 2)
    xstat._bup_utimes(path, (frac_ts, frac_ts))
    st = _helpers.stat(path)
    atime_ts = st[8]
    mtime_ts = st[9]
    WVPASSEQ(atime_ts[0], 0)
    WVPASS(atime_ts[1] == 0 or atime_ts[1] == frac_ts[1] * 1000)
    WVPASSEQ(mtime_ts[0], 0)
    WVPASS(mtime_ts[1] == 0 or mtime_ts[1] == frac_ts[1] * 1000)
    if wvfailure_count() == initial_failures:
        subprocess.call(['rm', '-rf', tmpdir])
예제 #11
0
파일: xstat.py 프로젝트: ultilix/catawampus
def stat(path):
    return stat_result.from_xstat_rep(_helpers.stat(path))
예제 #12
0
파일: xstat.py 프로젝트: Kelimion/bup
def stat(path):
    return stat_result.from_xstat_rep(_helpers.stat(path))