]> git.ipfire.org Git - thirdparty/glibc.git/blame - sysdeps/unix/sysv/linux/tst-socket-consts.py
Update copyright dates with scripts/update-copyrights
[thirdparty/glibc.git] / sysdeps / unix / sysv / linux / tst-socket-consts.py
CommitLineData
7854ebf8
FW
1#!/usr/bin/python3
2# Test that glibc's sys/socket.h SO_* constants match the kernel's.
2b778ceb 3# Copyright (C) 2018-2021 Free Software Foundation, Inc.
7854ebf8
FW
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
5a82c748 18# <https://www.gnu.org/licenses/>.
7854ebf8
FW
19
20import argparse
21import sys
22
23import glibcextract
24
25def main():
26 """The main entry point."""
27 parser = argparse.ArgumentParser(
28 description="Test that glibc's sys/socket.h constants "
29 "match the kernel's.")
30 parser.add_argument('--cc', metavar='CC',
31 help='C compiler (including options) to use')
32 args = parser.parse_args()
33
34 def check(define):
35 return glibcextract.compare_macro_consts(
36 source_1=define + '#include <sys/socket.h>\n',
37 # Some constants in <asm/socket.h> may depend on the size
38 # of pid_t or time_t.
39 source_2='#include <sys/types.h>\n'
40 '#include <asm/socket.h>\n',
41 cc=args.cc,
42 # We cannot compare all macros because some macros cannot
43 # be expanded as constants, and glibcextract currently is
44 # not able to isolate errors.
45 macro_re='SOL?_.*',
46 # <sys/socket.h> and <asm/socket.h> are not a good match.
47 # Most socket-related constants are not defined in any
48 # UAPI header. Check only the intersection of the macros
49 # in both headers. Regular tests ensure that expected
50 # macros for _GNU_SOURCE are present, and the conformance
51 # tests cover most of the other modes.
52 allow_extra_1=True,
53 allow_extra_2=True)
54 # _GNU_SOURCE is defined by include/libc-symbols.h, which is
55 # included by the --cc command. Defining _ISOMAC does not prevent
56 # that.
57 status = max(
58 check(''),
59 check('#undef _GNU_SOURCE\n'),
60 check('#undef _GNU_SOURCE\n'
61 '#define _POSIX_SOURCE 1\n'))
62 sys.exit(status)
63
64if __name__ == '__main__':
65 main()