From 60a257e711e9555a61605595e4cbb323a5307576 Mon Sep 17 00:00:00 2001 From: Karl Chen Date: Wed, 11 Jun 2003 23:09:11 +0000 Subject: [PATCH] more test suite stuff svn path=/trunk/boinc/; revision=1383 --- apps/upper_case.C | 40 ++++++++++++++++----------------- checkin_notes | 15 +++++++++++-- test/Makefile.am | 9 +++++++- test/Makefile.in | 10 ++++++++- test/boinc_db.inc | 37 ++++++++++++++++++++++++++++++ test/db_def_to_php | 19 ++++++++++++++++ test/test.inc | 32 +++++++++++++++++--------- test/test_1sec.php | 4 ++-- test/test_backend.php | 2 +- test/test_concat.php | 4 ++-- test/test_download_backoff.php | 2 +- test/test_limit.php | 2 +- test/test_masterurl_failure.php | 2 +- test/test_mdownload_backoff.php | 2 +- test/test_pers.php | 2 +- test/test_rsc.php | 28 ++++++++++------------- test/test_sched_failure.php | 2 +- test/test_sticky.php | 2 +- test/test_time.php | 2 +- test/test_uc.php | 8 ++++--- test/test_upload_backoff.php | 2 +- 21 files changed, 159 insertions(+), 67 deletions(-) create mode 100644 test/boinc_db.inc create mode 100755 test/db_def_to_php diff --git a/apps/upper_case.C b/apps/upper_case.C index 50fcf2c6a5..a8378c0b10 100755 --- a/apps/upper_case.C +++ b/apps/upper_case.C @@ -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, - "\n%s\n\n", uc_aid.app_preferences - ); + // fprintf(stderr, + // "\n%s\n\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); diff --git a/checkin_notes b/checkin_notes index d515cd3e81..6a01776b40 100755 --- a/checkin_notes +++ b/checkin_notes @@ -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 diff --git a/test/Makefile.am b/test/Makefile.am index 68035d63dd..e9ca2fc532 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -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 diff --git a/test/Makefile.in b/test/Makefile.in index c77bd12e8a..94403e18bb 100644 --- a/test/Makefile.in +++ b/test/Makefile.in @@ -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: diff --git a/test/boinc_db.inc b/test/boinc_db.inc new file mode 100644 index 0000000000..445d283c2e --- /dev/null +++ b/test/boinc_db.inc @@ -0,0 +1,37 @@ + diff --git a/test/db_def_to_php b/test/db_def_to_php new file mode 100755 index 0000000000..7a540fd514 --- /dev/null +++ b/test/db_def_to_php @@ -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 ") { + if (/^\s*#define\s+([^\s]+)\s+([0-9]+)\s*$/) { + print qq/ define("$1", $2);\n/; + } +} + +print "?>\n"; diff --git a/test/test.inc b/test/test.inc index b00f200f88..7c3af41b19 100644 --- a/test/test.inc +++ b/test/test.inc @@ -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; diff --git a/test/test_1sec.php b/test/test_1sec.php index 47d14a0b43..d131edc06b 100644 --- a/test/test_1sec.php +++ b/test/test_1sec.php @@ -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"); diff --git a/test/test_backend.php b/test/test_backend.php index 319f5360b3..df7b7f1918 100644 --- a/test/test_backend.php +++ b/test/test_backend.php @@ -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); diff --git a/test/test_concat.php b/test/test_concat.php index ea846fa66e..03f721e022 100644 --- a/test/test_concat.php +++ b/test/test_concat.php @@ -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"); diff --git a/test/test_download_backoff.php b/test/test_download_backoff.php index ed0ba9e583..e9d205e245 100644 --- a/test/test_download_backoff.php +++ b/test/test_download_backoff.php @@ -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); diff --git a/test/test_limit.php b/test/test_limit.php index 71463ccc62..9160ee31a8 100644 --- a/test/test_limit.php +++ b/test/test_limit.php @@ -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); diff --git a/test/test_masterurl_failure.php b/test/test_masterurl_failure.php index 2b634f7022..9c54bfb3bc 100644 --- a/test/test_masterurl_failure.php +++ b/test/test_masterurl_failure.php @@ -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); diff --git a/test/test_mdownload_backoff.php b/test/test_mdownload_backoff.php index 084ba7b87a..33ca7f072d 100644 --- a/test/test_mdownload_backoff.php +++ b/test/test_mdownload_backoff.php @@ -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); diff --git a/test/test_pers.php b/test/test_pers.php index a52566129c..992ba91465 100644 --- a/test/test_pers.php +++ b/test/test_pers.php @@ -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); diff --git a/test/test_rsc.php b/test/test_rsc.php index 13f33336e2..0ff829a863 100644 --- a/test/test_rsc.php +++ b/test/test_rsc.php @@ -1,30 +1,26 @@ -#! /usr/local/bin/php -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(); +} ?> diff --git a/test/test_sched_failure.php b/test/test_sched_failure.php index 7fe669dccb..bec5b6e59c 100644 --- a/test/test_sched_failure.php +++ b/test/test_sched_failure.php @@ -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); diff --git a/test/test_sticky.php b/test/test_sticky.php index 0f8a98fec7..9856cb98e5 100644 --- a/test/test_sticky.php +++ b/test/test_sticky.php @@ -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"); diff --git a/test/test_time.php b/test/test_time.php index 89132c58ac..83146e3c66 100644 --- a/test/test_time.php +++ b/test/test_time.php @@ -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"); diff --git a/test/test_uc.php b/test/test_uc.php index 189b94ef50..12c08488e1 100644 --- a/test/test_uc.php +++ b/test/test_uc.php @@ -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"); diff --git a/test/test_upload_backoff.php b/test/test_upload_backoff.php index cdcaa7658c..6539cd00c5 100644 --- a/test/test_upload_backoff.php +++ b/test/test_upload_backoff.php @@ -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);