Skip to content

Commit

Permalink
- fix many problems with validator_test
Browse files Browse the repository at this point in the history
svn path=/trunk/boinc/; revision=25582
  • Loading branch information
davidpanderson committed Apr 19, 2012
1 parent c34093e commit 9c15448
Show file tree
Hide file tree
Showing 11 changed files with 68 additions and 30 deletions.
14 changes: 14 additions & 0 deletions checkin_notes
Original file line number Diff line number Diff line change
Expand Up @@ -3363,3 +3363,17 @@ David 19 Apr 2012
cc_config.cpp,h
client/
log_flags.cpp

David 19 Apr 2012
- fix many problems with validator_test

sched/
sched_util.h
makefile_validator_test
sample_dummy_assimilator.cpp
single_job_assimilator.cpp
sched_util.cpp
sample_bitwise_validator.cpp
validate_util.cpp,h
validator_test.cpp
sample_assimilator.cpp
10 changes: 8 additions & 2 deletions sched/makefile_validator_test
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
validator_test: validator_test.cpp sample_trivial_validator.cpp
g++ -I.. -I../lib -I../db -o validator_test validator_test.cpp sample_trivial_validator.cpp
# the compiled file containing result_init() etc
VALIDATOR_OBJ = sample_bitwise_validator.o

# where libmysqlclient is
MYSQL_LIB_DIR = /usr/lib64/mysql

validator_test: validator_test.cpp $(VALIDATOR_OBJ)
g++ -g -I.. -I../lib -I../db -o validator_test validator_test.cpp $(VALIDATOR_OBJ) validate_util.o -L . -lsched -L ../lib -lboinc -L $(MYSQL_LIB_DIR) -lmysqlclient
4 changes: 2 additions & 2 deletions sched/sample_assimilator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,13 @@ int assimilate_handler(
if (retval) return retval;

if (wu.canonical_resultid) {
vector<FILE_INFO> output_files;
vector<OUTPUT_FILE_INFO> output_files;
const char *copy_path;
get_output_file_infos(canonical_result, output_files);
unsigned int n = output_files.size();
bool file_copied = false;
for (i=0; i<n; i++) {
FILE_INFO& fi = output_files[i];
OUTPUT_FILE_INFO& fi = output_files[i];
if (n==1) {
copy_path = config.project_path("sample_results/%s", wu.name);
} else {
Expand Down
4 changes: 2 additions & 2 deletions sched/sample_bitwise_validator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ bool files_match(FILE_CKSUM_LIST& f1, FILE_CKSUM_LIST& f2) {
int init_result(RESULT& result, void*& data) {
int retval;
FILE_CKSUM_LIST* fcl = new FILE_CKSUM_LIST;
vector<FILE_INFO> files;
vector<OUTPUT_FILE_INFO> files;
char md5_buf[MD5_LEN];
double nbytes;

Expand All @@ -61,7 +61,7 @@ int init_result(RESULT& result, void*& data) {
}

for (unsigned int i=0; i<files.size(); i++) {
FILE_INFO& fi = files[i];
OUTPUT_FILE_INFO& fi = files[i];
if (fi.no_validate) continue;
retval = md5_file(fi.path.c_str(), md5_buf, nbytes);
if (retval) {
Expand Down
2 changes: 1 addition & 1 deletion sched/sample_dummy_assimilator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ int assimilate_handler(
SCOPE_MSG_LOG scope_messages(log_messages, MSG_NORMAL);
scope_messages.printf("[%s] Assimilating\n", wu.name);
if (wu.canonical_resultid) {
FILE_INFO output_file;
OUTPUT_FILE_INFO output_file;

scope_messages.printf("[%s] Found canonical result\n", wu.name);
log_messages.printf_multiline(
Expand Down
4 changes: 3 additions & 1 deletion sched/sched_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -308,9 +308,11 @@ bool app_plan_uses_gpu(const char* plan_class) {
// This could be used, for example, so that late workunits
// are sent only to cloud or cluster resources
//
int restrict_wu_to_user(DB_WORKUNIT& wu, int userid) {
int restrict_wu_to_user(WORKUNIT& _wu, int userid) {
DB_RESULT result;
DB_ASSIGNMENT asg;
DB_WORKUNIT wu;
wu = _wu;
char buf[256];
int retval;

Expand Down
4 changes: 2 additions & 2 deletions sched/sched_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#ifndef SCHED_UTIL_H
#define SCHED_UTIL_H

#include "boinc_db.h"
#include "boinc_db_types.h"
#include "util.h"

// "average credit" uses an exponential decay so that recent
Expand Down Expand Up @@ -91,7 +91,7 @@ extern bool is_arg(const char*, const char*);

extern bool app_plan_uses_gpu(const char* plan_class);

extern int restrict_wu_to_user(DB_WORKUNIT& wu, int userid);
extern int restrict_wu_to_user(WORKUNIT& wu, int userid);

#ifdef GCL_SIMULATOR
extern void simulator_signal_handler(int signum);
Expand Down
4 changes: 2 additions & 2 deletions sched/single_job_assimilator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,12 @@ int assimilate_handler(
canonical_result.hostid,
canonical_result.cpu_time
);
vector<FILE_INFO> output_files;
vector<OUTPUT_FILE_INFO> output_files;
char copy_path[256];
get_output_file_infos(canonical_result, output_files);
unsigned int n = output_files.size();
for (i=0; i<n; i++) {
FILE_INFO& fi = output_files[i];
OUTPUT_FILE_INFO& fi = output_files[i];
string logical_name;
retval = get_logical_name(canonical_result, fi.path, logical_name);
if (retval) {
Expand Down
36 changes: 24 additions & 12 deletions sched/validate_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,11 @@
using std::vector;
using std::string;

bool standalone = false;

////////// functions for locating output files ///////////////

int FILE_INFO::parse(XML_PARSER& xp) {
int OUTPUT_FILE_INFO::parse(XML_PARSER& xp) {
bool found=false;
optional = false;
no_validate = false;
Expand All @@ -58,7 +60,7 @@ int FILE_INFO::parse(XML_PARSER& xp) {
return ERR_XML_PARSE;
}

int get_output_file_info(RESULT& result, FILE_INFO& fi) {
int get_output_file_info(RESULT& result, OUTPUT_FILE_INFO& fi) {
char path[1024];
string name;
MIOFILE mf;
Expand All @@ -69,17 +71,22 @@ int get_output_file_info(RESULT& result, FILE_INFO& fi) {
if (xp.match_tag("file_ref")) {
int retval = fi.parse(xp);
if (retval) return retval;
dir_hier_path(
fi.name.c_str(), config.upload_dir, config.uldl_dir_fanout, path
);
if (standalone) {
strcpy(path, fi.name.c_str());
} else {
dir_hier_path(
fi.name.c_str(), config.upload_dir,
config.uldl_dir_fanout, path
);
}
fi.path = path;
return 0;
}
}
return ERR_XML_PARSE;
}

int get_output_file_infos(RESULT& result, vector<FILE_INFO>& fis) {
int get_output_file_infos(RESULT& result, vector<OUTPUT_FILE_INFO>& fis) {
char path[1024];
MIOFILE mf;
string name;
Expand All @@ -89,12 +96,17 @@ int get_output_file_infos(RESULT& result, vector<FILE_INFO>& fis) {
while (!xp.get_tag()) {
if (!xp.is_tag) continue;
if (xp.match_tag("file_ref")) {
FILE_INFO fi;
OUTPUT_FILE_INFO fi;
int retval = fi.parse(xp);
if (retval) return retval;
dir_hier_path(
fi.name.c_str(), config.upload_dir, config.uldl_dir_fanout, path
);
if (standalone) {
strcpy(path, fi.name.c_str());
} else {
dir_hier_path(
fi.name.c_str(), config.upload_dir,
config.uldl_dir_fanout, path
);
}
fi.path = path;
fis.push_back(fi);
}
Expand All @@ -103,15 +115,15 @@ int get_output_file_infos(RESULT& result, vector<FILE_INFO>& fis) {
}

int get_output_file_path(RESULT& result, string& path) {
FILE_INFO fi;
OUTPUT_FILE_INFO fi;
int retval = get_output_file_info(result, fi);
if (retval) return retval;
path = fi.path;
return 0;
}

int get_output_file_paths(RESULT& result, vector<string>& paths) {
vector<FILE_INFO> fis;
vector<OUTPUT_FILE_INFO> fis;
int retval = get_output_file_infos(result, fis);
if (retval) return retval;
paths.clear();
Expand Down
8 changes: 5 additions & 3 deletions sched/validate_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
// bit of a misnomer - this actually taken from the <file_ref> elements
// of result.xml_doc_in
//
struct FILE_INFO {
struct OUTPUT_FILE_INFO {
std::string name;
std::string path;
bool optional;
Expand All @@ -35,13 +35,15 @@ struct FILE_INFO {
int parse(XML_PARSER&);
};

extern int get_output_file_info(RESULT& result, FILE_INFO&);
extern int get_output_file_infos(RESULT& result, std::vector<FILE_INFO>&);
extern int get_output_file_info(RESULT& result, OUTPUT_FILE_INFO&);
extern int get_output_file_infos(RESULT& result, std::vector<OUTPUT_FILE_INFO>&);
extern int get_output_file_path(RESULT& result, std::string&);
extern int get_output_file_paths(RESULT& result, std::vector<std::string>&);
extern int get_logical_name(
RESULT& result, std::string& path, std::string& name
);

extern int get_credit_from_wu(WORKUNIT&, std::vector<RESULT>& results, double&);

extern bool standalone;
#endif
8 changes: 5 additions & 3 deletions sched/validator_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ void usage(char* prog) {
exit(1);
}

int get_output_file_info(RESULT r, FILE_INFO& fi) {
int get_output_file_info(RESULT r, OUTPUT_FILE_INFO& fi) {
fi.path = r.name;
return 0;
}
Expand All @@ -49,8 +49,10 @@ int main(int argc, char** argv) {
RESULT r1, r2;
bool match;

strcpy(r1.name, argv[1]);
strcpy(r2.name, argv[2]);
standalone = true;

sprintf(r1.xml_doc_in, "<file_ref><file_name>%s</file_name></file_ref>", argv[1]);
sprintf(r2.xml_doc_in, "<file_ref><file_name>%s</file_name></file_ref>", argv[2]);
int retval;
retval = init_result(r1, data1);
if (retval) {
Expand Down

0 comments on commit 9c15448

Please sign in to comment.