1 #ifndef TEST_H 2 #define TEST_H 3 4 #include <stdio.h> 5 #include <sys/time.h> 6 #include "svc.h" 7 8 /* Convenience macros and functions for testcases */ 9 10 #define EXIT(ret) svc1(__NR_exit, ret) 11 12 /* X must be a string constant */ 13 #define SAY(x) say(x"\n", sizeof x) 14 15 /* Test COND and if it happens to be true, say so */ 16 #define TEST(cond) do { if (cond) SAY(#cond); } while (0) 17 18 #define BRASLCLOBBER "0","1","2","3","4","5","14", \ 19 "f0","f1","f2","f3","f4","f5","f6","f7" 20 21 int say(const char *text, unsigned long num_chars) 22 { 23 return svc3(4, 1, (unsigned long) text, num_chars); 24 } 25 26 #define get_cc() \ 27 ({ \ 28 char __cc; \ 29 /* dont use IPM to better test spechelpers */ \ 30 asm volatile( " brc 8,1f\n\t" \ 31 " brc 4,2f\n\t" \ 32 " brc 2,3f\n\t" \ 33 " brc 1,4f\n\t" \ 34 " mvi %0,4\n\t" \ 35 " j 0f\n\t" \ 36 "1: mvi %0,0\n\t" \ 37 " j 0f\n\t" \ 38 "2: mvi %0,1\n\t" \ 39 " j 0f\n\t" \ 40 "3: mvi %0,2\n\t" \ 41 " j 0f\n\t" \ 42 "4: mvi %0,3\n\t" \ 43 " j 0f\n\t" \ 44 "0: bcr 0,0 /*nop*/\n\t" \ 45 :"=m" (__cc)::"memory"); \ 46 __cc; \ 47 }) 48 49 static inline void dump_field(void *field, int size) 50 { 51 int i; 52 for (i=0; i < size; i++) 53 printf("%2.2X ", ((char *) field)[i]); 54 } 55 56 static inline void mysleep(long sec, long usec) 57 { 58 struct timeval tv; 59 60 tv.tv_sec = sec; 61 tv.tv_usec = usec; 62 63 svc5(SYS_select, 0,0,0,0,(unsigned long) &tv); 64 } 65 66 #endif /* TEST_H */ 67