From 95819ed3681fd91a8e1e7ccb500ff704091a28ac Mon Sep 17 00:00:00 2001 From: David Anderson Date: Sat, 1 Aug 2020 16:00:10 -0700 Subject: [PATCH] script_validator: make scripts optional. You need to supply at least one (init or compare) but you don't have to supply both. --- sched/script_validator.cpp | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/sched/script_validator.cpp b/sched/script_validator.cpp index e53e69a4db..154a87cb88 100644 --- a/sched/script_validator.cpp +++ b/sched/script_validator.cpp @@ -1,6 +1,6 @@ // This file is part of BOINC. // http://boinc.berkeley.edu -// Copyright (C) 2014 University of California +// Copyright (C) 2020 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 @@ -22,6 +22,8 @@ // --init_script "scriptname arg1 ... argn" // --compare_script "scriptname arg1 ... argn" // +// You must specify at least one. +// // 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 @@ -76,9 +78,9 @@ int validate_handler_init(int argc, char** argv) { } } - if (!init_script.size() || !compare_script.size()) { + if (init_script.empty() && compare_script.empty()) { log_messages.printf(MSG_CRITICAL, - "init_script and/or compare_script names are missing from command line\n" + "command line must specify init_script or compare_script\n" ); return 1; } @@ -100,21 +102,21 @@ void validate_handler_usage() { } int init_result(RESULT& result, void*&) { + if (init_script.empty()) { + return 0; + } + unsigned int i, j; char buf[256]; - vector 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()); @@ -141,11 +143,16 @@ int init_result(RESULT& result, void*&) { } int compare_results(RESULT& r1, void*, RESULT const& r2, void*, bool& match) { + if (compare_script.empty()) { + match = true; + return 0; + } + unsigned int i, j; char buf[256]; - vector paths1, paths2; int retval; + retval = get_output_file_paths(r1, paths1); if (retval) { fprintf(stderr, "get_output_file_paths() returned %d\n", retval); @@ -157,11 +164,6 @@ int compare_results(RESULT& r1, void*, RESULT const& r2, void*, bool& match) { 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