Changes between Version 21 and Version 22 of ValidationSimple


Ignore:
Timestamp:
Oct 14, 2014, 10:24:36 AM (10 years ago)
Author:
davea
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • ValidationSimple

    v21 v22  
     1[[PageOutline]]
    12= Developing a custom validator =
    2 To create a validator using the BOINC framework, you must supply three functions:
     3
     4To create a validator, you must supply three functions:
    35
    46{{{
    57extern int init_result(RESULT& result, void*& data);
    68}}}
    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:
     9This takes a result, reads its output file(s), parses them into a memory structure,
     10and returns (via the 'data' argument) a pointer to this structure.
     11The return value is:
    812
    913 * 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
     20To 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).
    1223
    1324{{{
     
    1627);
    1728}}}
    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).
     29This takes two results and their associated memory structures.
     30It returns (via the 'match' argument) true if the two results are equivalent
     31(within the tolerances of the application).
    1932
    2033{{{
     
    2336This frees the structure pointed to by data, if it's non-NULL.
    2437
    25 You must link these functions with the files validator.cpp, validate_util.cpp, and validate_util2.cpp. The result is your custom validator.
     38You must link these functions with the files validator.cpp, validate_util.cpp, and validate_util2.cpp.
     39The result is your custom validator.
    2640
    2741If for some reason you need to access the WORKUNIT in your init_result() etc. functions:
     
    4559
    4660== 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 This example uses [wiki:BackendUtilities utility functions] get_output_file_path() and try_fopen().
     61Here's an example for an application
     62whose output file contains an integer and a double.
     63Two results are considered equivalent if the integers are equal and the doubles differ by no more than 0.01.
    5064
    5165{{{
     
    101115}
    102116}}}
     117
     118== Testing your validator ==
     119
     120While you're developing a validator,
     121it's convenient to run it in "standalone mode",
     122i.e. run it manually against particular output files.
     123BOINC 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
     130This creates a program '''validator_test'''.
     131Do
     132{{{
     133validator_test file1 file2
     134}}}
     135to test your code against the given output files.
     136It will show the result of each function call.
     137
     138Notes:
     139 * Currently this assumes that results have a single output file.
     140   If you need this generalized, let us know.