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