3 // Copyright (C) 2004 Enrico Scholz <ensc@delenn.intern.sigma-chemnitz.de>
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; version 2 of the License.
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License
15 // along with this program; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
27 #define TEST_T2F_C(X,Y,Z) assert(vc_text2flag_compat(X,Y)==Z)
28 #define TEST_F2T_C(Y,X) { \
29 char const *x=vc_hiflag2text_compat(X); \
30 assert((x==0 && Y==0) || (x!=0 && Y!=0)); \
31 if (x!=0) assert(strcmp(x, Y)==0); \
34 #define TEST_LIST_C(STR,LEN,EXP,ERR_POS,ERR_LEN) { \
35 char const *err_ptr; \
39 res = vc_list2flag_compat(buf, LEN, &err_ptr, &err_len); \
41 assert(err_len==ERR_LEN); \
42 if (ERR_POS==-1) assert(err_ptr==0); \
43 else assert(err_ptr==buf+(ERR_POS)); \
48 #define TEST_T2F(X,Y,Z) assert(vc_text2flag(X,Y)==Z)
49 #define TEST_F2T(Y,X) { \
50 char const *x=vc_hiflag2text(X); \
51 assert((x==0 && Y==0) || (x!=0 && Y!=0)); \
52 if (x!=0) assert(strcmp(x, Y)==0); \
54 #define TEST_LIST(STR,LEN,EXP_RES,EXP_FLAG,EXP_MASK,ERR_POS,ERR_LEN) { \
55 char const *err_ptr; \
59 uint_least64_t flag=0,mask=0; \
60 res = vc_list2flag(buf, LEN, &err_ptr, &err_len, &flag, &mask); \
61 assert(res==(EXP_RES)); \
62 assert(flag==(EXP_FLAG) && mask==(EXP_MASK)); \
63 assert(err_len==ERR_LEN); \
64 if (ERR_POS==-1) assert(err_ptr==0); \
65 else assert(err_ptr==buf+(ERR_POS)); \
71 TEST_T2F_C("lock", 0, S_CTX_INFO_LOCK);
72 TEST_T2F_C("lockXXXX", 4, S_CTX_INFO_LOCK);
73 TEST_T2F_C("locXXXXX", 3, 0);
74 TEST_T2F_C("sched", 0, S_CTX_INFO_SCHED);
75 TEST_T2F_C("nproc", 0, S_CTX_INFO_NPROC);
76 TEST_T2F_C("private", 0, S_CTX_INFO_PRIVATE);
77 TEST_T2F_C("fakeinit", 0, S_CTX_INFO_INIT);
78 TEST_T2F_C("hideinfo", 0, S_CTX_INFO_HIDEINFO);
79 TEST_T2F_C("ulimit", 0, S_CTX_INFO_ULIMIT);
80 TEST_T2F_C("XXX", 0, 0);
83 TEST_F2T_C("lock", S_CTX_INFO_LOCK);
84 TEST_F2T_C("sched", S_CTX_INFO_SCHED);
85 TEST_F2T_C("nproc", S_CTX_INFO_NPROC);
86 TEST_F2T_C("private", S_CTX_INFO_PRIVATE);
87 TEST_F2T_C("fakeinit", S_CTX_INFO_INIT);
88 TEST_F2T_C("hideinfo", S_CTX_INFO_HIDEINFO);
89 TEST_F2T_C("ulimit", S_CTX_INFO_ULIMIT);
91 TEST_F2T_C("ulimit", 64 | 128 | 23 );
92 TEST_F2T_C("fakeinit", 23);
94 TEST_LIST_C("lock", 0, S_CTX_INFO_LOCK, -1,0);
95 TEST_LIST_C("lock,sched,", 0, S_CTX_INFO_LOCK|S_CTX_INFO_SCHED, -1,0);
96 TEST_LIST_C("lock,XXX", 0, S_CTX_INFO_LOCK, 5,3);
97 TEST_LIST_C("", 0, 0, -1,0);
98 TEST_LIST_C("X", 0, 0, 0,1);
99 TEST_LIST_C("lock,sched,", 10, S_CTX_INFO_LOCK|S_CTX_INFO_SCHED, -1,0);
103 TEST_T2F("fakeinit", 0, S_CTX_INFO_INIT);
104 TEST_T2F("XXX", 0, 0);
107 TEST_F2T("fakeinit", S_CTX_INFO_INIT);
110 TEST_LIST("fakeinit", 0, 0, S_CTX_INFO_INIT, S_CTX_INFO_INIT,-1,0);
111 TEST_LIST("~fakeinit", 0, 0, 0, S_CTX_INFO_INIT,-1,0);
112 TEST_LIST("!fakeinit", 0, 0, 0, S_CTX_INFO_INIT,-1,0);
113 TEST_LIST("fakeinit,XXX", 0, -1, S_CTX_INFO_INIT, S_CTX_INFO_INIT, 9,3);
114 TEST_LIST("", 0, 0, 0, 0, -1,0);
115 TEST_LIST("X", 0, -1, 0, 0, 0,1);