Updated ValidationSimple (markdown)

David Anderson 2024-01-10 18:37:30 -08:00
parent c455911009
commit ed1260465a
1 changed files with 2 additions and 84 deletions

@ -1,6 +1,5 @@
# Developing a custom validator
To create a validator, you must supply three functions:
You can create a validators in C++.
To do so, you must supply three functions:
```c
extern int init_result(RESULT& result, void*& data);
@ -121,85 +120,4 @@ int cleanup_result(RESULT const& r, void* data) {
Developed your validators outside the BOINC source tree;
a see the Makefile in boinc/sched/Makefile.example.
## Using scripting languages
The validator **script_validator** allows you to write your validation logic
in your language of choice (Python, PHP, Perl, Java, bash).
**script_validator** takes two additional command-line arguments:
### **--init_script "filename arg1 ... argn"**
script to check the validity of a result. Exit zero if valid.
### **--compare_script "filename arg1 ... argn"**
script to compare two results. Exit zero if outputs are equivalent.
**arg1 ... argn** represent cmdline args to be passed to the scripts.
The options for init_script are:
### **files**
list of paths of output files of the result
### **result_id**
result ID
### **runtime**
task runtime in seconds
Additional options for compare_script, for the second result:
### **files2**
list of paths of output files
### **result_id2**
result ID
### **runtime2**
task runtime
**arg1 ... argn** can be omitted,
in which case only the output file paths are passed to the scripts.
The scripts must be put in your project's bin/ directory.
For applications that don't use replication, the compare script need not be given.
For applications that don't need output file syntax checking, the init script need not be given.
As an example, the following PHP script, used as a compare script,
would require that results match exactly:
```php
#/usr/bin/env
<?php
$f1 = $argv[1];
$f2 = $argv[2];
if (md5_file($f1) != md5_file($f2)) {
fwrite(STDERR, "$f1 and $f2 don't match\n");
exit(1);
}
?>
```
The corresponding entry in config.xml would look like
```xml
<daemon>
<cmd>script_validator --app uppercase -d 3 --compare_script compare.php</cmd>
</daemon>
```
## Testing your validator
While you're developing a validator,
it's convenient to run it in "standalone mode",
i.e. run it manually against particular output files.
BOINC provides a test harness that lets you do this:
* In boinc/sched/, copy **makefile_validator_test** to your own file, say **makefile_vt**.
* Edit this makefile, changing VALIDATOR_SRC to refer to the .cpp file
containing your init_result(), compare_result(), and cleanup_result() functions.
* Do **make -f makefile_vt**.
This creates a program **validator_test**.
Do
```
validator_test file1 file2
```
to test your code against the given output files.
It will show the result of each function call.
Notes:
* Currently this assumes that results have a single output file.
If you need this generalized, let us know.