Пример #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
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
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
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
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
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
def stat(path):
    return stat_result.from_xstat_rep(_helpers.stat(path))
Пример #12
0
def stat(path):
    return stat_result.from_xstat_rep(_helpers.stat(path))