diff options
| author | Joseph Myers <josmyers@redhat.com> | 2024-09-03 13:53:01 +0000 |
|---|---|---|
| committer | Joseph Myers <josmyers@redhat.com> | 2024-09-03 13:53:01 +0000 |
| commit | 96d0bf98cafd0b63721f369ca21ec64590551d47 (patch) | |
| tree | b246b03aa68b66903283e7155ad702e2f290f477 /support/support_open_and_compare_file_string.c | |
| parent | 1927f718fcc48bdaea03086bdc2adf11279d655b (diff) | |
| download | glibc-96d0bf98cafd0b63721f369ca21ec64590551d47.tar.xz glibc-96d0bf98cafd0b63721f369ca21ec64590551d47.zip | |
Add support/ code for checking file contents
For use in freopen tests, add various support/ helper interfaces for
use in checking file contents.
Tested for x86_64.
Diffstat (limited to 'support/support_open_and_compare_file_string.c')
| -rw-r--r-- | support/support_open_and_compare_file_string.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/support/support_open_and_compare_file_string.c b/support/support_open_and_compare_file_string.c new file mode 100644 index 0000000000..2b596d4c88 --- /dev/null +++ b/support/support_open_and_compare_file_string.c @@ -0,0 +1,32 @@ +/* Compare string from a file. + Copyright (C) 2024 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <https://www.gnu.org/licenses/>. */ + +#include <string.h> + +#include <support/file_contents.h> +#include <support/xstdio.h> + +/* Check that a not-currently-open file has exactly the given string + as contents, starting at the current offset. */ + +int +support_open_and_compare_file_string (const char *file, const char *contents) +{ + return support_open_and_compare_file_bytes (file, contents, + strlen (contents)); +} |
