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