From 947e9a2576935e77deaa04b6339311294e1f906b Mon Sep 17 00:00:00 2001 From: toole1 <toole1@6fbd10e7-183d-0410-a318-cb416676e4f2> Date: Sat, 23 Jul 2011 07:37:14 +0000 Subject: [PATCH] jack git-svn-id: https://subversion.cs.illinois.edu/svn/cs225@3384 6fbd10e7-183d-0410-a318-cb416676e4f2 --- proxy.cpp | 58 +++++++++++++++++++++------------------------------ proxy.h | 14 ++++++++----- regression.sh | 2 +- 3 files changed, 34 insertions(+), 40 deletions(-) diff --git a/proxy.cpp b/proxy.cpp index b4d475a..5cd4e05 100755 --- a/proxy.cpp +++ b/proxy.cpp @@ -66,8 +66,6 @@ int main(int argc, char ** argv) namespace proxy { -int8_t RunTimeEnvironment::singleton = 0; - // class add_unit_test add_unit_test::add_unit_test(int8_t MPpart, const char * name, unit_test::function func, int32_t points_in_part, int32_t points_in_total, long timeout, @@ -138,6 +136,7 @@ RunTimeEnvironment::RunTimeEnvironment(vector<unit_test> *& init_tests, { // Copy globals to the RunTimeEnvironment space // And remove them from the global scope + static int8_t singleton = 0; EXIT_IF_ERROR(singleton++ != 0, "There may only be one runtime environment"); EXIT_IF_ERROR(heap_tests == NULL, "No test cases found"); if (output_checks == NULL) @@ -404,15 +403,11 @@ void test_execution::child() if (do_valgrind) { - // We're giving up control to valgrind, so we can't - // Use anything but the cout pipe now - fmsg_pipe.close_write(); - nums_pipe.close_write(); child_valgrind(); } else // if (!test.is_valgrind) { - child_test(fmsg_pipe, nums_pipe); + child_test(); } } @@ -432,22 +427,22 @@ void test_execution::parent() void test_execution::after_success(int8_t return_code) { if (do_valgrind) - { - fmsg_pipe.close_read(); - nums_pipe.close_read(); - valgrind_test_exit(return_code); - } - else // if (!test.is_valgrind) - { - test_exit(fmsg_pipe, nums_pipe); - } + after_valgrind_success(return_code); + else + after_test_success(); } void test_execution::after_failure(int8_t signal_number) { fmsg_pipe.close_read(); nums_pipe.close_read(); - test_signaled(signal_number); + if (environment.is_timeout_signal(signal_number)) + { + test.errormsg = string("Timed out") + " (" + to_string(test.timeout) + "ms)"; + test.time = test.timeout; + } + else + test.errormsg = strsignal(signal_number); } @@ -496,16 +491,20 @@ bool fork_execute(F & executor) void test_execution::child_valgrind() { + // We're giving up control to valgrind, so we can't + // Use anything but the cout pipe now + fmsg_pipe.close_write(); + nums_pipe.close_write(); + start_timeout(); execl("/usr/bin/valgrind", "/usr/bin/valgrind", "--trace-children=yes", /*"--log-fd=-1",*/ "-q", "./proxy", test.name, NULL); // Execl failed - cerr << "valgrind execute failed" << endl; - exit(-1); + EXIT_IF_ERROR(true, "valgrind execute failed"); } -void test_execution::child_test(pipestream & fmsg_pipe, pipestream & nums_pipe) +void test_execution::child_test() { test.checkstream->close_read(); // Execute test @@ -529,8 +528,11 @@ void test_execution::child_test(pipestream & fmsg_pipe, pipestream & nums_pipe) } -void test_execution::valgrind_test_exit(int8_t return_code) +void test_execution::after_valgrind_success(int8_t return_code) { + fmsg_pipe.close_read(); + nums_pipe.close_read(); + size_t last_endl = findNthLast(test.output, '\n', 2); if (last_endl == string::npos) test.errormsg = "Test did not complete"; @@ -549,7 +551,7 @@ void test_execution::valgrind_test_exit(int8_t return_code) } -void test_execution::test_exit(pipestream & fmsg_pipe, pipestream & nums_pipe) +void test_execution::after_test_success() { fmsg_pipe >> test.errormsg; fmsg_pipe.close(); @@ -585,18 +587,6 @@ void test_execution::test_exit(pipestream & fmsg_pipe, pipestream & nums_pipe) } -void test_execution::test_signaled(int8_t signum) -{ - if (signum == environment.timeout_signum0 || signum == environment.timeout_signum1) - { - test.errormsg = string("Timed out") + " (" + to_string(test.timeout) + "ms)"; - test.time = test.timeout; - } - else - test.errormsg = strsignal(signum); -} - - int32_t get_valgrind_flags(bool test_failed) { // Check for valgrind errors or leaks (if running under valgrind) diff --git a/proxy.h b/proxy.h index 93ae408..b88ab4f 100755 --- a/proxy.h +++ b/proxy.h @@ -71,10 +71,15 @@ namespace proxy RunTimeEnvironment(std::vector<unit_test> *& init_tests, output_check_map *& init_output_checks); + bool is_timeout_signal(int8_t signal_number) + { + return signal_number == timeout_signum0 || + signal_number == timeout_signum1; + } + private: RunTimeEnvironment(const RunTimeEnvironment & other); RunTimeEnvironment & operator=(RunTimeEnvironment & other); - static int8_t singleton; }; class RunTests @@ -135,11 +140,10 @@ namespace proxy void after_failure(int8_t signal_number); private: + void child_test(); void child_valgrind(); - void child_test(util::pipestream & fmsg_pipe, util::pipestream & nums_pipe); - void valgrind_test_exit(int8_t return_code); - void test_exit(util::pipestream & fmsg_pipe, util::pipestream & nums_pipe); - void test_signaled(int8_t signum); + void after_test_success(); + void after_valgrind_success(int8_t return_code); void start_timeout(); long end_timeout(); diff --git a/regression.sh b/regression.sh index 0bcf959..4d90463 100755 --- a/regression.sh +++ b/regression.sh @@ -4,7 +4,7 @@ testcases="mp1 lab02 lab03 lab04 lab06 lab07 lab10 lab12" #make for assign in $testcases do - ./monad $assign --newtests --solution --staff &>/dev/null + ./monad $assign --newtests --solution --noupdate --staff &>/dev/null score=$? if [ $score -lt 100 ] || [ $score -eq 255 ] then -- GitLab