more test suite stuff

svn path=/trunk/boinc/; revision=1383
This commit is contained in:
Karl Chen 2003-06-11 23:09:11 +00:00
parent 0af5768cd1
commit 60a257e711
21 changed files with 159 additions and 67 deletions

View File

@ -1,19 +1,19 @@
// The contents of this file are subject to the Mozilla Public License
// Version 1.0 (the "License"); you may not use this file except in
// compliance with the License. You may obtain a copy of the License at
// http://www.mozilla.org/MPL/
//
// http://www.mozilla.org/MPL/
//
// Software distributed under the License is distributed on an "AS IS"
// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
// License for the specific language governing rights and limitations
// under the License.
//
// The Original Code is the Berkeley Open Infrastructure for Network Computing.
//
// under the License.
//
// The Original Code is the Berkeley Open Infrastructure for Network Computing.
//
// The Initial Developer of the Original Code is the SETI@home project.
// Portions created by the SETI@home project are Copyright (C) 2002
// University of California at Berkeley. All Rights Reserved.
//
// Portions created by the SETI@home project are Copyright (C) 2002, 2003
// University of California at Berkeley. All Rights Reserved.
//
// Contributor(s):
//
@ -80,7 +80,7 @@ int do_checkpoint(MFILE& mf, int nchars) {
FILE *app_time=NULL, *client_time=NULL;
if (cpu_time) {
app_time = fopen("app.time", "w"),
app_time = fopen("app.time", "w"),
client_time = fopen("client.time", "w");
boinc_get_init_data(uc_aid);
}
@ -139,20 +139,20 @@ int main(int argc, char **argv) {
char resolved_name[512];
MFILE out, time_file;
FILE* state, *in;
my_start_time = time(0);
strcpy(the_char, "(none)\0");
retval = boinc_init();
if (retval) exit(retval);
retval = boinc_init_opengl();
if (retval) exit(retval);
boinc_get_init_data(uc_aid);
fprintf(stderr,
"<app prefs>\n%s\n</app_prefs>\n", uc_aid.app_preferences
);
// fprintf(stderr,
// "<app prefs>\n%s\n</app_prefs>\n", uc_aid.app_preferences
// );
boinc_resolve_filename("in", resolved_name, sizeof(resolved_name));
fprintf(stderr, "APP: upper_case: starting, argc %d\n", argc);
@ -207,8 +207,8 @@ int main(int argc, char **argv) {
if (run_slow) {
boinc_sleep(1.);
}
#ifdef SIGNAL_H
#ifdef SIGNAL_H
if (raise_signal) {
raise(SIGHUP);
}
@ -235,10 +235,10 @@ int main(int argc, char **argv) {
time_file.printf("%f\n", cur_cpu);
time_file.flush();
time_file.close();
boinc_finish_opengl();
boinc_finish(0);
return 0;
}
@ -261,7 +261,7 @@ bool app_render(int xs, int ys, double time_of_day)
yPos += yDelta;
if (xPos < -1 || xPos > 1) xDelta *= -1;
if (yPos < -1 || yPos > 1) yDelta *= -1;
glRasterPos2f(-0.9, 0.9);
glPrint(main_font, "User: %s", uc_aid.user_name);

View File

@ -4654,10 +4654,21 @@ Karl 2003/06/11
configure.ac
test/
Makefile.am
db_def_to_php
boinc_db.inc
version.inc.in
test.inc
test_1sec.php
test_backend.php
test_concat.php
test_download_backoff.php
test_limit.php
test_masterurl_failure.php
test_mdownload_backoff.php
test_pers.php
test_sanity.php
test_rsc.php
test_sched_failure.php
test_sticky.php
test_time.php
test_uc.php
version.inc.in
test_upload_backoff.php

View File

@ -2,8 +2,15 @@
include $(top_srcdir)/Makefile.incl
TESTS = test_sanity.php test_uc.php test_concat.php test_1sec.php
TESTS = test_sanity.php \
test_uc.php \
test_concat.php \
test_1sec.php \
test_rsc.php
EXTRA_DIST = \
*.xml *.php *wu *result *output \
*input *.inc *.in
boinc_db.inc: ../db/boinc_db.h
./db_def_to_php < ../db/boinc_db.h > boinc_db.inc

View File

@ -168,7 +168,12 @@ RSA_LIBS = \
# programs linking to it:
LIBRSA = $(top_builddir)/RSAEuro/source/librsaeuro.a
TESTS = test_sanity.php test_uc.php test_concat.php test_1sec.php
TESTS = test_sanity.php \
test_uc.php \
test_concat.php \
test_1sec.php \
test_rsc.php
EXTRA_DIST = \
*.xml *.php *wu *result *output \
@ -393,6 +398,9 @@ uninstall-am: uninstall-info-am
$(LIBRSA):
cd $(top_builddir)/RSAEuro/source; ${MAKE} librsaeuro.a
boinc_db.inc: ../db/boinc_db.h
./db_def_to_php < ../db/boinc_db.h > boinc_db.inc
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:

37
test/boinc_db.inc Normal file
View File

@ -0,0 +1,37 @@
<?php
// Generated by db_def_to_php on Wed Jun 11 15:32:05 PDT 2003
define("MAX_BLOB_SIZE", 4096);
define("TEAM_TYPE_CLUB", 1);
define("TEAM_TYPE_COMPANY", 2);
define("TEAM_TYPE_PRIMARY", 3);
define("TEAM_TYPE_SECONDARY", 4);
define("TEAM_TYPE_JUNIOR_COLLEGE", 5);
define("TEAM_TYPE_UNIVERSITY", 6);
define("TEAM_TYPE_GOVERNMENT", 7);
define("FILE_DELETE_INIT", 0);
define("FILE_DELETE_READY", 1);
define("FILE_DELETE_DONE", 2);
define("ASSIMILATE_INIT", 0);
define("ASSIMILATE_READY", 1);
define("ASSIMILATE_DONE", 2);
define("WU_ERROR_COULDNT_SEND_RESULT", 1);
define("WU_ERROR_TOO_MANY_ERROR_RESULTS", 2);
define("WU_ERROR_TOO_MANY_RESULTS", 4);
define("RESULT_SERVER_STATE_INACTIVE", 1);
define("RESULT_SERVER_STATE_UNSENT", 2);
define("RESULT_SERVER_STATE_UNSENT_SEQ", 3);
define("RESULT_SERVER_STATE_IN_PROGRESS", 4);
define("RESULT_SERVER_STATE_OVER", 5);
define("RESULT_OUTCOME_INIT", 0);
define("RESULT_OUTCOME_SUCCESS", 1);
define("RESULT_OUTCOME_COULDNT_SEND", 2);
define("RESULT_OUTCOME_CLIENT_ERROR", 3);
define("RESULT_OUTCOME_NO_REPLY", 4);
define("RESULT_OUTCOME_DIDNT_NEED", 5);
define("VALIDATE_STATE_INIT", 0);
define("VALIDATE_STATE_VALID", 1);
define("VALIDATE_STATE_INVALID", 2);
define("WORKSEQ_STATE_UNASSIGNED", 0);
define("WORKSEQ_STATE_ASSIGNED", 1);
define("WORKSEQ_STATE_DONE", 2);
?>

19
test/db_def_to_php Executable file
View File

@ -0,0 +1,19 @@
#!/usr/bin/env perl
## $Id$
## parse the db #defines to php.
## syntax: ./db_def_to_php < ../db/boinc_db.h > boinc_db.inc
print "<?php\n";
print " // Generated by db_def_to_php on ";
system('date');
while (<>) {
if (/^\s*#define\s+([^\s]+)\s+([0-9]+)\s*$/) {
print qq/ define("$1", $2);\n/;
}
}
print "?>\n";

View File

@ -11,6 +11,7 @@
// See doc/test.html for details
include_once("version.inc");
include_once("boinc_db.inc");
ob_end_flush(); // let us see what's going on
@ -107,8 +108,6 @@ function verbose_XPassThru($cmd, $failok=0)
return XPassThru($cmd, $failok);
}
define("RESULT_STATE_OVER", 5);
define("KEY_DIR" , get_env_var("BOINC_KEY_DIR"));
define("SHMEM_KEY" , get_env_var("BOINC_SHMEM_KEY"));
define("PROJECTS_DIR" , get_env_var("BOINC_PROJECTS_DIR"));
@ -771,22 +770,30 @@ class Project {
unlink($this->project_dir."/cgi/stop_server");
}
function check_results($ntarget, $result) {
function check_results($ntarget, $matchresult) {
$n = 0;
db_open($this->db_name);
$result = mysql_query("select * from result");
while ($x = mysql_fetch_object($result)) {
$n++;
if ($result->server_state != null && $result->server_state != $x->server_state) {
error("result $x->id: unexpected state $x->server_state");
if ($matchresult->server_state != null && $matchresult->server_state != $x->server_state) {
error("result $x->id: unexpected state $x->server_state (expected $matchresult->server_state)");
}
if ($result->stderr_out != null) {
if (substr($result->stderr_out, $x->stderr_out)==0) {
error("result $x->id: unexpected stderr_out $x->stderr_out\n");
if ($matchresult->stderr_out != null) {
// need to use === to differentiate FALSE from 0. php sucks.
if (strpos($x->stderr_out,$matchresult->stderr_out)===FALSE) {
error("result $x->id: unexpected stderr_out:
$x->stderr_out
expected:
$matchresult->stderr_out
");
}
}
if ($result->exit_state != null && $result->exit_status != $x->exit_status) {
error("result $x->id: unexpected exit_status $x->exit_status\n");
if ($matchresult->exit_state != null && $matchresult->exit_status != $x->exit_status) {
error("result $x->id: unexpected exit_status $x->exit_status (expected $matchresult->exit_status)");
}
}
if ($n != $ntarget) {
@ -1053,6 +1060,11 @@ class Work {
}
}
function test_msg($msg)
{
echo "-- Testing " . $msg . ' ' . str_repeat('-', 78 - strlen($msg)-12) . "\n";
}
function test_done()
{
global $errors;

View File

@ -9,7 +9,7 @@
include_once("test.inc");
echo "-- Testing multiple projects --------------------------------------------------\n";
test_msg("multiple projects with resource share");
$project1 = new Project;
$project2 = new Project;
@ -57,7 +57,7 @@
$project1->stop(1);
$project2->stop();
$result->server_state = RESULT_STATE_OVER;
$result->server_state = RESULT_SERVER_STATE_OVER;
$project1->check_results(5, $result);
$project1->compare_file("uc_wu_0_0", "uc_correct_output");
$project1->compare_file("uc_wu_1_0", "uc_correct_output");

View File

@ -65,7 +65,7 @@
sleep(30);
// *** DO CHECKS HERE
$result->server_state = RESULT_STATE_OVER;
$result->server_state = RESULT_SERVER_STATE_OVER;
$result->exit_status = 0;
$project->check_results(500, $result);

View File

@ -5,7 +5,7 @@
include_once("test.inc");
echo "-- Testing standard concat application ----------------------------------------\n";
test_msg("standard concat application");
$project = new Project;
$project->add_core_and_version();
@ -33,7 +33,7 @@
$host->run("-exit_when_idle -skip_cpu_benchmarks");
$project->stop();
$result->server_state = RESULT_STATE_OVER;
$result->server_state = RESULT_SERVER_STATE_OVER;
$project->check_results(2, $result);
$project->compare_file("concat_wu_0_0", "concat_correct_output");
$project->compare_file("concat_wu_1_0", "concat_correct_output");

View File

@ -44,7 +44,7 @@
pcntl_waitpid($pid, $status, 0);
$project->stop();
$result->server_state = RESULT_STATE_OVER;
$result->server_state = RESULT_SERVER_STATE_OVER;
$result->stderr_out = "APP: upper_case: starting, argc 1";
$result->exit_status = 0;
$project->check_results(2, $result);

View File

@ -59,7 +59,7 @@
sleep(1); // make sure feeder has a chance to run
$host->run("-exit_when_idle -skip_cpu_benchmarks");
$result->server_state = RESULT_STATE_OVER;
$result->server_state = RESULT_SERVER_STATE_OVER;
$result->stderr_out = "APP: upper_case: starting, argc 1";
$result->exit_status = 0;
$project->check_results(1, $result);

View File

@ -47,7 +47,7 @@
pcntl_waitpid($pid,$status,0);
$project->stop();
$result->server_state = RESULT_STATE_OVER;
$result->server_state = RESULT_SERVER_STATE_OVER;
$result->stderr_out = "APP: upper_case: starting, argc 1";
$result->exit_status = 0;
$project->check_results(2, $result);

View File

@ -49,7 +49,7 @@
pcntl_waitpid($pid,$status,0);
$project->stop();
$result->server_state = RESULT_STATE_OVER;
$result->server_state = RESULT_SERVER_STATE_OVER;
$result->stderr_out = "APP: upper_case: starting, argc 1";
$result->exit_status = 0;
$project->check_results(2, $result);

View File

@ -139,7 +139,7 @@ while(1)
$project->stop();
$result->server_state = RESULT_STATE_OVER;
$result->server_state = RESULT_SERVER_STATE_OVER;
$result->stderr_out = "APP: upper_case: starting, argc 1";
$result->exit_status = 0;
$project->check_results(2, $result);

View File

@ -1,30 +1,26 @@
#! /usr/local/bin/php
<?php
// test whether the scheduling server filters out
// work units too big for client
#!/usr/local/bin/php -q
<?php {
// $Id$
// test whether the scheduling server filters out work units too big for
// client
include_once("test.inc");
$retval = 0;
test_msg("resource filtering for large work units");
$project = new Project;
$user = new User();
$host = new Host($user);
$app = new App("upper_case");
$app_version = new App_Version($app);
$project->add_app_and_version("upper_case");
$project->add_user($user);
$project->add_app($app);
$project->add_app_version($app_version);
$project->install(); // must install projects before adding to hosts
$project->install_feeder();
$host->log_flags = "log_flags.xml";
$host->add_user($user,$project);
$host->install();
echo "adding work\n";
$work = new Work($app);
$work->wu_template = "uc_wu";
$work->result_template = "uc_result";
@ -38,8 +34,8 @@
$host->run("-exit_when_idle -skip_cpu_benchmarks");
$project->stop();
$result->server_state = RESULT_STATE_OVER;
$project->check_results(0, $result);
$result->server_state = RESULT_SERVER_STATE_UNSENT;
$project->check_results(1, $result);
exit($retval);
?>
test_done();
} ?>

View File

@ -48,7 +48,7 @@
pcntl_waitpid($pid,$status,0);
$project->stop();
$result->server_state = RESULT_STATE_OVER;
$result->server_state = RESULT_SERVER_STATE_OVER;
$result->stderr_out = "APP: upper_case: starting, argc 1";
$result->exit_status = 0;
$project->check_results(2, $result);

View File

@ -33,7 +33,7 @@
$host->run("-exit_when_idle -skip_cpu_benchmarks");
$project->stop();
$result->server_state = RESULT_STATE_OVER;
$result->server_state = RESULT_SERVER_STATE_OVER;
$project->check_results(2, $result);
$project->compare_file("uc_wu_sticky_0_0", "uc_correct_output");
$project->compare_file("uc_wu_sticky_1_0", "uc_correct_output");

View File

@ -35,7 +35,7 @@
$host->run("-exit_when_idle");
$project->stop();
$result->server_state = RESULT_STATE_OVER;
$result->server_state = RESULT_SERVER_STATE_OVER;
$project->check_results(1, $result);
$project->compare_file("uccpu_wu_0_0", "uc_small_correct_output");
$client_time = $host->read_cpu_time_file("client_time");

View File

@ -8,7 +8,7 @@
include_once("test.inc");
echo "-- Testing standard upper_case application ------------------------------------\n";
test_msg("standard upper_case application");
$project = new Project;
$project->add_core_and_version();
@ -48,8 +48,10 @@
$host->run("-exit_when_idle -skip_cpu_benchmarks");
$project->validate(2);
$result->server_state = RESULT_STATE_OVER;
$result->stderr_out = "APP: upper_case: starting, argc 1";
$result->server_state = RESULT_SERVER_STATE_OVER;
$result->stderr_out = "APP: upper_case: starting, argc 1
APP: upper_case: argv[0] is upper_case
APP: upper_case ending, wrote ";
$result->exit_status = 0;
$project->check_results(2, $result);
$project->compare_file("uc_wu_0_0", "uc_correct_output");

View File

@ -49,7 +49,7 @@
pcntl_waitpid($pid, $status,0);
$project->stop();
$result->server_state = RESULT_STATE_OVER;
$result->server_state = RESULT_SERVER_STATE_OVER;
$result->stderr_out = "APP: upper_case: starting, argc 1";
$result->exit_status = 0;
$project->check_results(2, $result);