]>
Commit | Line | Data |
---|---|---|
6c0eedd9 AZ |
1 | #!/usr/bin/python3 |
2 | # Test that glibc's sys/mount.h constants match the kernel's. | |
3 | # Copyright (C) 2022 Free Software Foundation, Inc. | |
4 | # This file is part of the GNU C Library. | |
5 | # | |
6 | # The GNU C Library is free software; you can redistribute it and/or | |
7 | # modify it under the terms of the GNU Lesser General Public | |
8 | # License as published by the Free Software Foundation; either | |
9 | # version 2.1 of the License, or (at your option) any later version. | |
10 | # | |
11 | # The GNU C Library is distributed in the hope that it will be useful, | |
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
14 | # Lesser General Public License for more details. | |
15 | # | |
16 | # You should have received a copy of the GNU Lesser General Public | |
17 | # License along with the GNU C Library; if not, see | |
18 | # <https://www.gnu.org/licenses/>. | |
19 | ||
20 | import argparse | |
21 | import sys | |
22 | ||
23 | import glibcextract | |
24 | import glibcsyscalls | |
25 | ||
26 | ||
27 | def main(): | |
28 | """The main entry point.""" | |
29 | parser = argparse.ArgumentParser( | |
30 | description="Test that glibc's sys/mount.h constants " | |
31 | "match the kernel's.") | |
32 | parser.add_argument('--cc', metavar='CC', | |
33 | help='C compiler (including options) to use') | |
34 | args = parser.parse_args() | |
35 | ||
36 | linux_version_headers = glibcsyscalls.linux_kernel_version(args.cc) | |
37 | # Constants in glibc were updated to match Linux v5.16. When glibc | |
38 | # constants are updated this value should be updated to match the | |
39 | # released kernel version from which the constants were taken. | |
40 | linux_version_glibc = (5, 16) | |
41 | def check(cte, exclude=None): | |
42 | return glibcextract.compare_macro_consts( | |
43 | '#include <sys/mount.h>\n', | |
44 | '#include <asm/fcntl.h>\n' | |
45 | '#include <linux/mount.h>\n', | |
46 | args.cc, | |
47 | cte, | |
48 | exclude, | |
49 | linux_version_glibc > linux_version_headers, | |
50 | linux_version_headers > linux_version_glibc) | |
51 | ||
7eae6a91 AZ |
52 | # Skip testing FS_CONFIG commands since they are only enums in the kernel |
53 | # header. | |
b4deb7be AZ |
54 | status = max( |
55 | check('FSOPEN_.*'), | |
5b41b265 AZ |
56 | check('FSMOUNT_.*'), |
57 | # MOVE_MOUNT__MASK may vary depending of the kernel version. | |
58 | check('MOVE_MOUNT_.*', 'MOVE_MOUNT__MASK')) | |
6c0eedd9 AZ |
59 | sys.exit(status) |
60 | ||
61 | if __name__ == '__main__': | |
62 | main() |