-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Expand file tree
/
Copy pathdb-dump-corrupt.py
More file actions
executable file
·34 lines (29 loc) · 1.64 KB
/
db-dump-corrupt.py
File metadata and controls
executable file
·34 lines (29 loc) · 1.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/env python3
from mosq_test_helper import *
def do_test(file, stderr, rc_expected):
cmd = [
mosquitto_db_dump_path,
Path(test_dir, "apps", "db_dump", "data", file)
]
env = mosq_test.env_add_ld_library_path()
res = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, timeout=1, encoding='utf-8', env=env)
if res.stderr != stderr:
print(res.stderr)
raise mosq_test.TestError
if res.returncode != rc_expected:
print(file)
print(res.returncode)
raise mosq_test.TestError
do_test('missing.test-db', f"Error: Unable to open {str(Path(test_dir, 'apps', 'db_dump', 'data', 'missing.test-db'))}\n", 0)
do_test('bad-magic.test-db', "Error: Unrecognised file format.\n", 1)
do_test('short.test-db', "", 1)
do_test('bad-dbid-size.test-db', "Error: Incompatible database configuration (dbid size is 5 bytes, expected 8)", 1)
do_test('bad-chunk.test-db', 'Warning: Unsupported chunk "2816" of length 65696 in persistent database file at position 29. Ignoring.\n', 0)
do_test('v3-corrupt.test-db', "Error: Corrupt persistent database.\n", 1)
do_test('v4-corrupt.test-db', "Error: Corrupt persistent database.\n", 1)
do_test('v5-corrupt.test-db', "Error: Corrupt persistent database.\n", 1)
do_test('v6-corrupt.test-db', "Error: Corrupt persistent database.\n", 1)
do_test('v6-corrupt-client.test-db', "Error: Corrupt persistent database.\n", 1)
do_test('v6-corrupt-cmsg.test-db', "Error: Corrupt persistent database.\n", 1)
do_test('v6-corrupt-retain.test-db', "Error: Corrupt persistent database.\n", 1)
do_test('v6-corrupt-sub.test-db', "Error: Corrupt persistent database.\n", 1)