1*49cdfc7eSAndroid Build Coastguard Worker // SPDX-License-Identifier: GPL-2.0-or-later
2*49cdfc7eSAndroid Build Coastguard Worker /*
3*49cdfc7eSAndroid Build Coastguard Worker * Copyright (c) 2024 Cyril Hrubis <[email protected]>
4*49cdfc7eSAndroid Build Coastguard Worker */
5*49cdfc7eSAndroid Build Coastguard Worker
6*49cdfc7eSAndroid Build Coastguard Worker #include <stdio.h>
7*49cdfc7eSAndroid Build Coastguard Worker #define TST_NO_DEFAULT_MAIN
8*49cdfc7eSAndroid Build Coastguard Worker #include "tst_test.h"
9*49cdfc7eSAndroid Build Coastguard Worker #include "tst_test_macros.h"
10*49cdfc7eSAndroid Build Coastguard Worker
tst_errno_in_set(int err,const int * exp_errs,int exp_errs_cnt)11*49cdfc7eSAndroid Build Coastguard Worker bool tst_errno_in_set(int err, const int *exp_errs, int exp_errs_cnt)
12*49cdfc7eSAndroid Build Coastguard Worker {
13*49cdfc7eSAndroid Build Coastguard Worker int i;
14*49cdfc7eSAndroid Build Coastguard Worker
15*49cdfc7eSAndroid Build Coastguard Worker for (i = 0; i < exp_errs_cnt; i++) {
16*49cdfc7eSAndroid Build Coastguard Worker if (err == exp_errs[i])
17*49cdfc7eSAndroid Build Coastguard Worker return 1;
18*49cdfc7eSAndroid Build Coastguard Worker }
19*49cdfc7eSAndroid Build Coastguard Worker
20*49cdfc7eSAndroid Build Coastguard Worker return 0;
21*49cdfc7eSAndroid Build Coastguard Worker }
22*49cdfc7eSAndroid Build Coastguard Worker
tst_errno_names(char * buf,const int * exp_errs,int exp_errs_cnt)23*49cdfc7eSAndroid Build Coastguard Worker const char *tst_errno_names(char *buf, const int *exp_errs, int exp_errs_cnt)
24*49cdfc7eSAndroid Build Coastguard Worker {
25*49cdfc7eSAndroid Build Coastguard Worker int i;
26*49cdfc7eSAndroid Build Coastguard Worker char *cb = buf;
27*49cdfc7eSAndroid Build Coastguard Worker
28*49cdfc7eSAndroid Build Coastguard Worker for (i = 0; i < exp_errs_cnt-1; i++)
29*49cdfc7eSAndroid Build Coastguard Worker cb += sprintf(cb, "%s, ", tst_strerrno(exp_errs[i]));
30*49cdfc7eSAndroid Build Coastguard Worker
31*49cdfc7eSAndroid Build Coastguard Worker cb += sprintf(cb, "%s", tst_strerrno(exp_errs[i]));
32*49cdfc7eSAndroid Build Coastguard Worker
33*49cdfc7eSAndroid Build Coastguard Worker *cb = '\0';
34*49cdfc7eSAndroid Build Coastguard Worker
35*49cdfc7eSAndroid Build Coastguard Worker return buf;
36*49cdfc7eSAndroid Build Coastguard Worker }
37