From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2012) id 87334385842D; Tue, 13 Jun 2023 18:58:33 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 87334385842D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1686682713; bh=qVmoUZNTC0utg3Ct3tRUeq1gHq89lgT++SHz8xKlfvA=; h=From:To:Subject:Date:From; b=V24UehAmlfmfkIHXtNqY+mSQGEIdxlEhhROb31aWXbu1cKXw40Lcg9c5jpr1xMg6S J4uvlg7yqDupvPgaDeQvY9mbxIqiWLJAF7mfZzZtclF9T5f9f7K0/iD3kyoD888d8a 9hZoGpBBINwMohBwl1C2x6O+wDq77uAdGw1wLgK4= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Arjun Shankar To: glibc-cvs@sourceware.org Subject: [glibc] posix: Add test case for gai_strerror() X-Act-Checkin: glibc X-Git-Author: Dridi Boukelmoune X-Git-Refname: refs/heads/master X-Git-Oldrev: 658f601f2ae3230559f7e9c629053bd2890dcf82 X-Git-Newrev: 127c21c0e2f669454835f78fc03079866282c19b Message-Id: <20230613185833.87334385842D@sourceware.org> Date: Tue, 13 Jun 2023 18:58:33 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=127c21c0e2f669454835f78fc03079866282c19b commit 127c21c0e2f669454835f78fc03079866282c19b Author: Dridi Boukelmoune Date: Tue Jun 13 12:08:28 2023 +0200 posix: Add test case for gai_strerror() Signed-off-by: Dridi Boukelmoune Reviewed-by: Arjun Shankar Diff: --- posix/Makefile | 1 + posix/tst-gai_strerror.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/posix/Makefile b/posix/Makefile index e19b74cd67..ad43cbdec6 100644 --- a/posix/Makefile +++ b/posix/Makefile @@ -275,6 +275,7 @@ tests := \ tst-fnmatch6 \ tst-fnmatch7 \ tst-fork \ + tst-gai_strerror \ tst-getaddrinfo \ tst-getaddrinfo2 \ tst-getaddrinfo3 \ diff --git a/posix/tst-gai_strerror.c b/posix/tst-gai_strerror.c new file mode 100644 index 0000000000..7d886df2a4 --- /dev/null +++ b/posix/tst-gai_strerror.c @@ -0,0 +1,43 @@ +/* Test for gai_strerror() + Copyright The GNU Toolchain Authors. + 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 + . */ + +#include +#include +#include +#include +#include + +#include +#include + +static int +do_test (void) +{ + unsetenv ("LANGUAGE"); + + xsetlocale (LC_ALL, "C"); + + TEST_COMPARE_STRING (gai_strerror (1), "Unknown error"); + TEST_COMPARE_STRING (gai_strerror (0), "Success"); + TEST_COMPARE_STRING (gai_strerror (EAI_OVERFLOW), + "Result too large for supplied buffer"); + + return 0; +} + +#include