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(X,Y,Z) assert(vc_text2flag(X,Y)==Z)
28 #define TEST_F2T(Y,X) { \
29 char const *x=vc_hiflag2text(X); \
30 assert((x==0 && Y==0) || (x!=0 && Y!=0)); \
31 if (x!=0) assert(strcmp(x, Y)==0); \
34 #define TEST_LIST(STR,LEN,EXP,ERR_POS,ERR_LEN) { \
35 char const *err_ptr; \
39 res = vc_textlist2flag(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)); \
49 TEST_T2F("lock", 0, S_CTX_INFO_LOCK);
50 TEST_T2F("lockXXXX", 4, S_CTX_INFO_LOCK);
51 TEST_T2F("locXXXXX", 3, 0);
52 TEST_T2F("sched", 0, S_CTX_INFO_SCHED);
53 TEST_T2F("nproc", 0, S_CTX_INFO_NPROC);
54 TEST_T2F("private", 0, S_CTX_INFO_PRIVATE);
55 TEST_T2F("fakeinit", 0, S_CTX_INFO_INIT);
56 TEST_T2F("hideinfo", 0, S_CTX_INFO_HIDEINFO);
57 TEST_T2F("ulimit", 0, S_CTX_INFO_ULIMIT);
58 TEST_T2F("XXX", 0, 0);
61 TEST_F2T("lock", S_CTX_INFO_LOCK);
62 TEST_F2T("sched", S_CTX_INFO_SCHED);
63 TEST_F2T("nproc", S_CTX_INFO_NPROC);
64 TEST_F2T("private", S_CTX_INFO_PRIVATE);
65 TEST_F2T("fakeinit", S_CTX_INFO_INIT);
66 TEST_F2T("hideinfo", S_CTX_INFO_HIDEINFO);
67 TEST_F2T("ulimit", S_CTX_INFO_ULIMIT);
69 TEST_F2T("ulimit", 64 | 128 | 23 );
70 TEST_F2T("fakeinit", 23);
72 TEST_LIST("lock", 0, S_CTX_INFO_LOCK, -1,0);
73 TEST_LIST("lock,sched,", 0, S_CTX_INFO_LOCK|S_CTX_INFO_SCHED, -1,0);
74 TEST_LIST("lock,XXX", 0, S_CTX_INFO_LOCK, 5,3);
75 TEST_LIST("", 0, 0, -1,0);
76 TEST_LIST("X", 0, 0, 0,1);
77 TEST_LIST("lock,sched,", 10, S_CTX_INFO_LOCK|S_CTX_INFO_SCHED, -1,0);