Changes between Version 21 and Version 22 of ValidationSimple
- Timestamp:
- Oct 14, 2014, 10:24:36 AM (10 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
ValidationSimple
v21 v22 1 [[PageOutline]] 1 2 = Developing a custom validator = 2 To create a validator using the BOINC framework, you must supply three functions: 3 4 To create a validator, you must supply three functions: 3 5 4 6 {{{ 5 7 extern int init_result(RESULT& result, void*& data); 6 8 }}} 7 This takes a result, reads its output file(s), parses them into a memory structure, and returns (via the 'data' argument) a pointer to this structure. It returns: 9 This takes a result, reads its output file(s), parses them into a memory structure, 10 and returns (via the 'data' argument) a pointer to this structure. 11 The return value is: 8 12 9 13 * Zero on success, 10 * ERR_OPENDIR if there was a transient error, e.g. the output file is on a network volume that is not available. The validator will try this result again later. 11 * Any other return value indicates a permanent error. Example: an output file is missing, or has a syntax error. The result will be marked as invalid. 14 * ERR_OPENDIR if there was a transient error, e.g. the output file is on a network volume that is not available. 15 The validator will try this result again later. 16 * Any other return value indicates a permanent error. 17 Example: an output file is missing, or has a syntax error. 18 The result will be marked as invalid. 19 20 To locate and open the result's output files, use 21 [wiki:BackendUtilities utility functions] such as '''get_output_file_path()''' and '''try_fopen()''' 22 (see example below). 12 23 13 24 {{{ … … 16 27 ); 17 28 }}} 18 This takes two results and their associated memory structures. It returns (via the 'match' argument) true if the two results are equivalent (within the tolerances of the application). 29 This takes two results and their associated memory structures. 30 It returns (via the 'match' argument) true if the two results are equivalent 31 (within the tolerances of the application). 19 32 20 33 {{{ … … 23 36 This frees the structure pointed to by data, if it's non-NULL. 24 37 25 You must link these functions with the files validator.cpp, validate_util.cpp, and validate_util2.cpp. The result is your custom validator. 38 You must link these functions with the files validator.cpp, validate_util.cpp, and validate_util2.cpp. 39 The result is your custom validator. 26 40 27 41 If for some reason you need to access the WORKUNIT in your init_result() etc. functions: … … 45 59 46 60 == Example == 47 Here's an example in which the output file contains an integer and a double. Two results are considered equivalent if the integer is equal and the doubles differ by no more than 0.01.48 49 T his example uses [wiki:BackendUtilities utility functions] get_output_file_path() and try_fopen().61 Here's an example for an application 62 whose output file contains an integer and a double. 63 Two results are considered equivalent if the integers are equal and the doubles differ by no more than 0.01. 50 64 51 65 {{{ … … 101 115 } 102 116 }}} 117 118 == Testing your validator == 119 120 While you're developing a validator, 121 it's convenient to run it in "standalone mode", 122 i.e. run it manually against particular output files. 123 BOINC provides a test harness that lets you do this: 124 125 * In boinc/sched/, copy '''makefile_validator_test''' to your own file, say '''makefile_vt'''. 126 * Edit this makefile, changing VALIDATOR_SRC to refer to the .cpp file 127 containing your init_result(), compare_result(), and cleanup_result() functions. 128 * Do '''make -f makefile_vt'''. 129 130 This creates a program '''validator_test'''. 131 Do 132 {{{ 133 validator_test file1 file2 134 }}} 135 to test your code against the given output files. 136 It will show the result of each function call. 137 138 Notes: 139 * Currently this assumes that results have a single output file. 140 If you need this generalized, let us know.