2019-11-03 10:35:03 +03:00
|
|
|
#!/usr/bin/python3
|
|
|
|
#
|
|
|
|
# Basic bcachefs functionality tests.
|
|
|
|
|
|
|
|
import re
|
2021-10-12 00:23:09 +03:00
|
|
|
from tests import util
|
2019-11-03 10:35:03 +03:00
|
|
|
|
|
|
|
def test_help():
|
|
|
|
ret = util.run_bch(valgrind=True)
|
|
|
|
|
|
|
|
assert ret.returncode == 1
|
|
|
|
assert "missing command" in ret.stdout
|
|
|
|
assert len(ret.stderr) == 0
|
|
|
|
|
|
|
|
def test_format(tmpdir):
|
|
|
|
dev = util.device_1g(tmpdir)
|
|
|
|
ret = util.run_bch('format', dev, valgrind=True)
|
|
|
|
|
|
|
|
assert ret.returncode == 0
|
|
|
|
assert len(ret.stdout) > 0
|
|
|
|
assert len(ret.stderr) == 0
|
|
|
|
|
|
|
|
def test_fsck(tmpdir):
|
2019-11-10 06:00:56 +03:00
|
|
|
dev = util.format_1g(tmpdir)
|
2019-11-03 10:35:03 +03:00
|
|
|
|
|
|
|
ret = util.run_bch('fsck', dev, valgrind=True)
|
|
|
|
|
|
|
|
assert ret.returncode == 0
|
|
|
|
assert len(ret.stdout) > 0
|
|
|
|
assert len(ret.stderr) == 0
|
|
|
|
|
|
|
|
def test_list(tmpdir):
|
2019-11-10 06:00:56 +03:00
|
|
|
dev = util.format_1g(tmpdir)
|
2019-11-03 10:35:03 +03:00
|
|
|
|
|
|
|
ret = util.run_bch('list', dev, valgrind=True)
|
|
|
|
|
|
|
|
assert ret.returncode == 0
|
|
|
|
assert len(ret.stderr) == 0
|
|
|
|
assert "recovering from clean shutdown" in ret.stdout
|
2021-06-05 01:28:17 +03:00
|
|
|
|
2019-11-03 10:35:03 +03:00
|
|
|
def test_list_inodes(tmpdir):
|
2019-11-10 06:00:56 +03:00
|
|
|
dev = util.format_1g(tmpdir)
|
2019-11-03 10:35:03 +03:00
|
|
|
|
|
|
|
ret = util.run_bch('list', '-b', 'inodes', dev, valgrind=True)
|
|
|
|
|
|
|
|
assert ret.returncode == 0
|
|
|
|
assert len(ret.stderr) == 0
|
2024-02-21 10:27:40 +03:00
|
|
|
assert len(ret.stdout.splitlines()) == (67)
|
2019-11-03 10:35:03 +03:00
|
|
|
|
|
|
|
def test_list_dirent(tmpdir):
|
2019-11-10 06:00:56 +03:00
|
|
|
dev = util.format_1g(tmpdir)
|
2019-11-03 10:35:03 +03:00
|
|
|
|
|
|
|
ret = util.run_bch('list', '-b', 'dirents', dev, valgrind=True)
|
|
|
|
|
|
|
|
assert ret.returncode == 0
|
|
|
|
assert len(ret.stderr) == 0
|
2024-02-21 10:39:27 +03:00
|
|
|
assert len(ret.stdout.splitlines()) == (6) # See example:
|
2019-11-03 10:35:03 +03:00
|
|
|
|
|
|
|
# Example:
|
2024-02-21 10:39:27 +03:00
|
|
|
# mounting version 1.6: btree_subvolume_children opts=ro,errors=continue,degraded,nochanges,norecovery,read_only
|
|
|
|
# recovering from clean shutdown, journal seq 9
|
|
|
|
# alloc_read... done
|
|
|
|
# stripes_read... done
|
|
|
|
# snapshots_read... done
|
|
|
|
# u64s 8 type dirent 4096:453699834857023875:U32_MAX len 0 ver 0: lost+found -> 4097 type dir
|
2024-02-23 09:50:18 +03:00
|
|
|
last = ret.stdout.splitlines()[0]
|
2019-11-03 10:35:03 +03:00
|
|
|
assert re.match(r'^.*type dirent.*: lost\+found ->.*$', last)
|