Debian Codegraph @

vendored-meson/meson/test cases/rust/5 polyglot static/overflow_size_checks.py

raw
1 #!/usr/bin/env python3
2 # SPDX-License-Identifier: Apache-2.0
3 # Copyright © 2023 Intel Corporation
4
5 from __future__ import annotations
6 import argparse
7 import os
8 import typing as T
9
10 if T.TYPE_CHECKING:
11 class Arguments(T.Protocol):
12 checks_off: str
13 checks_on: str
14
15
16 def main() -> None:
17 parser = argparse.ArgumentParser()
18 parser.add_argument('checks_off')
19 parser.add_argument('checks_on')
20 args: Arguments = parser.parse_args()
21
22 off = os.stat(args.checks_off).st_size
23 on = os.stat(args.checks_on).st_size
24
25 assert on > off, f'Expected binary built with overflow-checks to be bigger, but it was smaller. with: "{on}"B, without: "{off}"B'
26
27
28 if __name__ == "__main__":
29 main()