xref: /aosp_15_r20/external/zstd/tests/check_size.py (revision 01826a4963a0d8a59bc3812d29bdf0fb76416722)
1*01826a49SYabin Cui#!/usr/bin/env python3
2*01826a49SYabin Cui# ################################################################
3*01826a49SYabin Cui# Copyright (c) Meta Platforms, Inc. and affiliates.
4*01826a49SYabin Cui# All rights reserved.
5*01826a49SYabin Cui#
6*01826a49SYabin Cui# This source code is licensed under both the BSD-style license (found in the
7*01826a49SYabin Cui# LICENSE file in the root directory of this source tree) and the GPLv2 (found
8*01826a49SYabin Cui# in the COPYING file in the root directory of this source tree).
9*01826a49SYabin Cui# You may select, at your option, one of the above-listed licenses.
10*01826a49SYabin Cui# ################################################################
11*01826a49SYabin Cui
12*01826a49SYabin Cuiimport os
13*01826a49SYabin Cuiimport subprocess
14*01826a49SYabin Cuiimport sys
15*01826a49SYabin Cui
16*01826a49SYabin Cuiif len(sys.argv) != 3:
17*01826a49SYabin Cui	print(f"Usage: {sys.argv[0]} FILE SIZE_LIMIT")
18*01826a49SYabin Cui	sys.exit(1)
19*01826a49SYabin Cui
20*01826a49SYabin Cuifile = sys.argv[1]
21*01826a49SYabin Cuilimit = int(sys.argv[2])
22*01826a49SYabin Cui
23*01826a49SYabin Cuiif not os.path.exists(file):
24*01826a49SYabin Cui	print(f"{file} does not exist")
25*01826a49SYabin Cui	sys.exit(1)
26*01826a49SYabin Cui
27*01826a49SYabin Cuisize = os.path.getsize(file)
28*01826a49SYabin Cui
29*01826a49SYabin Cuiif size > limit:
30*01826a49SYabin Cui	print(f"file {file} is {size} bytes, which is greater than the limit of {limit} bytes")
31*01826a49SYabin Cui	sys.exit(1)
32