Home | History | Annotate | Download | only in Documentation
      1 DEFINITIONS TESTING
      2 ===================
      3 A variety of header file definitions are listed in the POSIX Base Definitions
      4 document.  The steps below describe how to test the various types of
      5 definitions that appear.
      6 
      7 Definitions Testing -> STRUCTURES
      8 ---------------------------------
      9 To test that a structure has been correctly defined, we add two tests into
     10 one .c file.  The first test tests that the structure has been declared, and
     11 the second that all elements of the structure are correctly defined.
     12 
     13 To make the first test and setup the second, delcare the structure as:
     14 
     15 struct <structure under test> this_type_should_exist, t;
     16 
     17 To make the second test, create a dummy function and assign elements of
     18 the correct structure to t or assign t to certain elements:
     19 
     20 int dummyfcn (void)
     21 {
     22 	t.<field> = <value>;
     23 	<variable> = t.<field>;
     24 }
     25 
     26 For assignment, some rules of thumb are:
     27 - For variables of a defined type, assign t.<field> to these values.
     28 ex.
     29 sigset_t *set;
     30 set = &t.sa_mask;
     31 
     32 - For variables which are other functions, assign a function to t.<field>.
     33 ex.
     34 extern void signal_handler(int);
     35 t.sa_handler = signal_handler;
     36 
     37 For examples, see posixtestsuite/conformance/definitions/signal/15-1.c
     38 
     39 Definitions Testing -> MACROS
     40 -----------------------------
     41 Macros are tested to see if they are defined.  This is done via the
     42 #ifdef preprocessor lines.
     43 
     44 ex.
     45 #include <include file with definitions.h>
     46 
     47 #ifndef <Macro name>
     48 #error <Macro name> not defined
     49 #endif
     50 
     51 For examples, see posixtestsuite/conformance/definitions/signal/22-*.c
     52 
     53 Definitions Testing -> FUNCTIONS
     54 --------------------------------
     55 To test functions, declare a typedef of a test function identical to the
     56 function under test, create a variable of that typedef, and try to assign
     57 it to the function under test.
     58 
     59 ex.
     60 typedef int (*fcn_test)(char *, char *);
     61 int dummyfcn (void)
     62 {
     63 	fcn_test dummyvar;
     64 	dummyvar = fcn;
     65 	return 0;
     66 }
     67 
     68 For examples, see posixtestsuite/conformance/definitions/signal/43-1.c
     69 
     70 Contributors:  	Inaky.Perez-Gonzalez REMOVE-THIS AT intel DOT com
     71 		Julie.N.Fleischer REMOVE-THIS AT intel DOT com
     72 
     73 
     74