source: rtems/cpukit/libtest/t-test-checks-eno.c @ cfcc2cbf

5
Last change on this file since cfcc2cbf was cfcc2cbf, checked in by Sebastian Huber <sebastian.huber@…>, on 01/31/19 at 13:45:31

Add RTEMS Test Framework

Update #3199.

  • Property mode set to 100644
File size: 4.1 KB
Line 
1/*
2 * SPDX-License-Identifier: BSD-2-Clause
3 *
4 * Copyright (C) 2018 embedded brains GmbH
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 *    notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 *    notice, this list of conditions and the following disclaimer in the
13 *    documentation and/or other materials provided with the distribution.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
19 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 * POSSIBILITY OF SUCH DAMAGE.
26 */
27
28#include <t.h>
29
30#include <errno.h>
31
32#define T_STRERROR_CASE(eno) case eno: return #eno
33
34const char *T_strerror(int eno)
35{
36        switch (eno) {
37        case 0:
38                return "0";
39        T_STRERROR_CASE(E2BIG);
40        T_STRERROR_CASE(EACCES);
41        T_STRERROR_CASE(EADDRINUSE);
42        T_STRERROR_CASE(EADDRNOTAVAIL);
43        T_STRERROR_CASE(EAFNOSUPPORT);
44        T_STRERROR_CASE(EAGAIN);
45        T_STRERROR_CASE(EALREADY);
46        T_STRERROR_CASE(EBADF);
47        T_STRERROR_CASE(EBADMSG);
48        T_STRERROR_CASE(EBUSY);
49        T_STRERROR_CASE(ECANCELED);
50        T_STRERROR_CASE(ECHILD);
51        T_STRERROR_CASE(ECONNABORTED);
52        T_STRERROR_CASE(ECONNREFUSED);
53        T_STRERROR_CASE(ECONNRESET);
54        T_STRERROR_CASE(EDEADLK);
55        T_STRERROR_CASE(EDESTADDRREQ);
56        T_STRERROR_CASE(EDOM);
57        T_STRERROR_CASE(EDQUOT);
58        T_STRERROR_CASE(EEXIST);
59        T_STRERROR_CASE(EFAULT);
60        T_STRERROR_CASE(EFBIG);
61        T_STRERROR_CASE(EHOSTDOWN);
62        T_STRERROR_CASE(EHOSTUNREACH);
63        T_STRERROR_CASE(EIDRM);
64        T_STRERROR_CASE(EILSEQ);
65        T_STRERROR_CASE(EINPROGRESS);
66        T_STRERROR_CASE(EINTR);
67        T_STRERROR_CASE(EINVAL);
68        T_STRERROR_CASE(EIO);
69        T_STRERROR_CASE(EISCONN);
70        T_STRERROR_CASE(EISDIR);
71        T_STRERROR_CASE(ELOOP);
72        T_STRERROR_CASE(EMFILE);
73        T_STRERROR_CASE(EMLINK);
74        T_STRERROR_CASE(EMSGSIZE);
75        T_STRERROR_CASE(EMULTIHOP);
76        T_STRERROR_CASE(ENAMETOOLONG);
77        T_STRERROR_CASE(ENETDOWN);
78        T_STRERROR_CASE(ENETRESET);
79        T_STRERROR_CASE(ENETUNREACH);
80        T_STRERROR_CASE(ENFILE);
81        T_STRERROR_CASE(ENOBUFS);
82#ifdef ENODATA
83        T_STRERROR_CASE(ENODATA);
84#endif
85        T_STRERROR_CASE(ENODEV);
86        T_STRERROR_CASE(ENOENT);
87        T_STRERROR_CASE(ENOEXEC);
88        T_STRERROR_CASE(ENOLCK);
89        T_STRERROR_CASE(ENOLINK);
90        T_STRERROR_CASE(ENOMEM);
91        T_STRERROR_CASE(ENOMSG);
92        T_STRERROR_CASE(ENOPROTOOPT);
93        T_STRERROR_CASE(ENOSPC);
94#ifdef ENOSR
95        T_STRERROR_CASE(ENOSR);
96#endif
97#ifdef ENOSTR
98        T_STRERROR_CASE(ENOSTR);
99#endif
100        T_STRERROR_CASE(ENOSYS);
101        T_STRERROR_CASE(ENOTCONN);
102        T_STRERROR_CASE(ENOTDIR);
103        T_STRERROR_CASE(ENOTEMPTY);
104        T_STRERROR_CASE(ENOTRECOVERABLE);
105        T_STRERROR_CASE(ENOTSOCK);
106#if ENOTSUP != EOPNOTSUPP
107        T_STRERROR_CASE(ENOTSUP);
108#endif
109        T_STRERROR_CASE(ENOTTY);
110        T_STRERROR_CASE(ENXIO);
111        T_STRERROR_CASE(EOPNOTSUPP);
112        T_STRERROR_CASE(EOVERFLOW);
113        T_STRERROR_CASE(EOWNERDEAD);
114        T_STRERROR_CASE(EPERM);
115        T_STRERROR_CASE(EPFNOSUPPORT);
116        T_STRERROR_CASE(EPIPE);
117        T_STRERROR_CASE(EPROTO);
118        T_STRERROR_CASE(EPROTONOSUPPORT);
119        T_STRERROR_CASE(EPROTOTYPE);
120        T_STRERROR_CASE(ERANGE);
121        T_STRERROR_CASE(EROFS);
122        T_STRERROR_CASE(ESPIPE);
123        T_STRERROR_CASE(ESRCH);
124        T_STRERROR_CASE(ESTALE);
125#ifdef ETIME
126        T_STRERROR_CASE(ETIME);
127#endif
128        T_STRERROR_CASE(ETIMEDOUT);
129        T_STRERROR_CASE(ETOOMANYREFS);
130        T_STRERROR_CASE(ETXTBSY);
131        T_STRERROR_CASE(EXDEV);
132        default:
133                return "?";
134        }
135}
136
137void T_check_eno(int a, const T_check_context *t, int e)
138{
139        T_check_true(a == e, t, "%s == %s", T_strerror(a), T_strerror(e));
140}
141
142void T_check_eno_success(int a, const T_check_context *t)
143{
144        T_check_eno(a, t, 0);
145}
Note: See TracBrowser for help on using the repository browser.