// This file is part of BOINC. // http://boinc.berkeley.edu // Copyright (C) 2014 University of California // // BOINC is free software; you can redistribute it and/or modify it // under the terms of the GNU Lesser General Public License // as published by the Free Software Foundation, // either version 3 of the License, or (at your option) any later version. // // BOINC is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. // See the GNU Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with BOINC. If not, see . // A validator that runs scripts to check and compare results, // so that you can do your validation in Python, PHP, Perl, bash, etc. // // cmdline args to this program: // --init_script "scriptname arg1 ... argn" // --compare_script "scriptname arg1 ... argn" // // The init script checks the validity of a result, // e.g. that the output files have the proper format. // It returns zero if the files are valid // // The compare script compares two results. // If returns zero if the output files 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 // // 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. #include #include "validate_util2.h" #include "error_numbers.h" #include "boinc_db.h" #include "sched_util.h" #include "validate_util.h" #include "validator.h" using std::string; using std::vector; vector init_script, compare_script; // first element is script path, other elements are args int validate_handler_init(int argc, char** argv) { // handle project specific arguments here for (int i=1; i paths; int retval; retval = get_output_file_paths(result, paths); if (retval) { fprintf(stderr, "get_output_file_paths() returned %d\n", retval); return retval; } if (init_script.size() == 0) { fprintf(stderr, "init_result() failed: init_script parameter was not specified\n"); return 1; } char cmd[4096]; sprintf(cmd, "../bin/%s", init_script[0].c_str()); for (i=1; i paths1, paths2; int retval; retval = get_output_file_paths(r1, paths1); if (retval) { fprintf(stderr, "get_output_file_paths() returned %d\n", retval); return retval; } retval = get_output_file_paths(r2, paths2); if (retval) { fprintf(stderr, "get_output_file_paths() returned %d\n", retval); return retval; } if (compare_script.size() == 0) { fprintf(stderr, "compare_results() failed: compare_script parameter was not specified\n"); return 1; } char cmd[4096]; sprintf(cmd, "../bin/%s", compare_script[0].c_str()); for (i=1; i