From 30ff6afe596eddafacf22b1a5b2d1a3d6254ea15 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 27 Apr 2024 15:14:44 +0200 Subject: Adding upstream version 2.36.1. Signed-off-by: Daniel Baumann --- tests/helpers/test_strerror.c | 44 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 tests/helpers/test_strerror.c (limited to 'tests/helpers/test_strerror.c') diff --git a/tests/helpers/test_strerror.c b/tests/helpers/test_strerror.c new file mode 100644 index 0000000..f51f698 --- /dev/null +++ b/tests/helpers/test_strerror.c @@ -0,0 +1,44 @@ +/* + * This test program prints errno messages to allow for portable + * verification of error messages. + * + * Copyright (C) 2019 Patrick Steinhardt +#include +#include +#include + +#define E(x) { #x, x } +static struct { + const char *str; + int error; +} errors[] = { + E(ENOENT), + E(ENOTTY), + E(EILSEQ) +}; + +int main(int argc, const char *argv[]) +{ + size_t i; + + if (argc != 2) { + fprintf(stderr, "USAGE: %s \n", argv[0]); + return -1; + } + + for (i = 0; i < sizeof(errors)/sizeof(*errors); i++) { + if (strcmp(errors[i].str, argv[1]) != 0) + continue; + puts(strerror(errors[i].error)); + return 0; + } + + fprintf(stderr, "Invalid errno: %s\n", argv[1]); + return -1; +} -- cgit v1.2.3