diff --git a/.monadid b/.monadid index 75735182b72e6132359a4ae80acc22f429d75992..237f224fe86b3448b85b58d1b43a961e75d310b6 100644 --- a/.monadid +++ b/.monadid @@ -1,4 +1,4 @@ -monad identification file +-e monad identification file This file is used for monad directory identification -Built by toole1 on linux4.ews.illinois.edu -Build Date: Sun Sep 18 21:12:20 CDT 2011 +Built by jacktoole1 on mobile-106-45.near.uiuc.edu +Build Date: Wed Sep 21 17:17:26 CDT 2011 diff --git a/monad b/monad index 12910e6549e50e556005ff73cfdd0445f17971e8..62ce646edd713bf367ad276074b245e26aca9b69 100755 Binary files a/monad and b/monad differ diff --git a/proxy.cpp b/proxy.cpp index be1bfd4af9701cd2d49b83534795c80cbb845e44..2e4c764a80d46580de3b1d7cf54579a62db8b223 100755 --- a/proxy.cpp +++ b/proxy.cpp @@ -134,9 +134,7 @@ add_output_check::add_output_check(const char * name, output_check func) // class Run_Time_Environment RunTimeEnvironment::RunTimeEnvironment(vector<unit_test> *& init_tests, output_check_map *& init_output_checks) - : itimer_number0(ITIMER_PROF), - itimer_number1(ITIMER_REAL), - timeout_signum0(SIGPROF), + : timeout_signum0(SIGPROF), timeout_signum1(SIGALRM), max_output_length(8*1024), //arbitrary single_test_passed_string("Result: passed"), @@ -643,29 +641,50 @@ const char * get_valgrind_string(int32_t flags) if (errors) return "Invalid read/write errors"; if (leaked) return "Directly lost memory leaks"; if (dubious) return "Possibly lost memory leaks"; - if (reachable) return "Still-reachable memory leaks"; + // For now we will ignore reachable errors, as they are always present on Mac + if (reachable) return unit_test::pass_string; //"Still-reachable memory leaks"; return "Unknown memory errors"; } +bool test_execution::prof_timeout_enabled() +{ + struct itimerval temp; + if (getitimer(ITIMER_PROF, &temp) == 0) + return true; + if (errno == EINVAL) + return false; + cerr << __FILE__ << ":" << __LINE__ << ": ERROR: getitimer failed" << endl; + exit(-1); +} void test_execution::start_timeout() { + static const bool prof_enabled = prof_timeout_enabled(); + struct itimerval timeout; timeout.it_interval.tv_sec = 0; timeout.it_interval.tv_usec = 0; timeout.it_value.tv_sec = test.timeout/1000; timeout.it_value.tv_usec = (test.timeout%1000) * 1000; - EXIT_IF_ERROR(setitimer(environment.itimer_number0, &timeout, NULL)); - - // second real time signal in case the student calls a blocking call - timeout.it_value.tv_sec *= 10; - EXIT_IF_ERROR(setitimer(environment.itimer_number1, &timeout, NULL)); + if (prof_enabled) + { + EXIT_IF_ERROR(setitimer(ITIMER_PROF, &timeout, NULL)); + // second real time signal in case the student calls a blocking call + timeout.it_value.tv_sec *= 10; + EXIT_IF_ERROR(setitimer(ITIMER_REAL, &timeout, NULL)); + } + else + { + EXIT_IF_ERROR(setitimer(ITIMER_REAL, &timeout, NULL)); + } } long test_execution::end_timeout() { + static const bool prof_enabled = prof_timeout_enabled(); + struct itimerval timeout; timeout.it_interval.tv_sec = 0; timeout.it_interval.tv_usec = 0; @@ -673,8 +692,15 @@ long test_execution::end_timeout() timeout.it_value.tv_usec = 0; struct itimerval remaining; - EXIT_IF_ERROR(setitimer(environment.itimer_number0, &timeout, &remaining)); - EXIT_IF_ERROR(setitimer(environment.itimer_number1, &timeout, NULL)); + if (prof_enabled) + { + EXIT_IF_ERROR(setitimer(ITIMER_PROF, &timeout, &remaining)); + EXIT_IF_ERROR(setitimer(ITIMER_REAL, &timeout, NULL)); + } + else + { + EXIT_IF_ERROR(setitimer(ITIMER_REAL, &timeout, &remaining)); + } // There seems to be a strange -1 error here. I may just be tired, // but I can't figure out why right now diff --git a/proxy.h b/proxy.h index b88ab4f946bd8ea51952754e5eb698576fab690d..f23c240034fd3280b5d52bd80c15759a6eafac05 100755 --- a/proxy.h +++ b/proxy.h @@ -58,8 +58,8 @@ namespace proxy struct RunTimeEnvironment { public: - const int itimer_number0; - const int itimer_number1; + //!!const int itimer_number0; + //!!const int itimer_number1; const int timeout_signum0; const int timeout_signum1; const size_t max_output_length; @@ -146,6 +146,7 @@ namespace proxy void after_valgrind_success(int8_t return_code); void start_timeout(); long end_timeout(); + static bool prof_timeout_enabled(); private: test_execution(const test_execution & other); diff --git a/util.cpp b/util.cpp index 34fbcf62d488c7c853845b06941631c4a66826fc..c540542b80961ac1aa66d6e924f9e2679085892e 100644 --- a/util.cpp +++ b/util.cpp @@ -80,9 +80,29 @@ int8_t exec(int redirect_fd, const char * command, struct itimerval remaining_real; struct itimerval remaining_virtual; struct itimerval remaining_prof; + bool supports_virtual = true; + bool supports_prof = true; EXIT_IF_ERROR(getitimer(ITIMER_REAL, &remaining_real)); - EXIT_IF_ERROR(getitimer(ITIMER_VIRTUAL, &remaining_virtual)); - EXIT_IF_ERROR(getitimer(ITIMER_PROF, &remaining_prof)); + if (getitimer(ITIMER_VIRTUAL, &remaining_virtual) != 0) + { + if (errno == EINVAL) + { + supports_virtual = false; + errno = 0; + } + else + internal::exit_if_error_output(__FILE__, __LINE__, "getitimer(ITIMER_VIRTUAL) failed"); + } + if (getitimer(ITIMER_PROF, &remaining_prof) != 0) + { + if (errno == EINVAL) + { + supports_prof = false; + errno = 0; + } + else + internal::exit_if_error_output(__FILE__, __LINE__, "getitimer(ITIMER_PROF) failed"); + } pid = fork(); @@ -90,9 +110,9 @@ int8_t exec(int redirect_fd, const char * command, { // Restore timers - EXIT_IF_ERROR(setitimer(ITIMER_REAL, &remaining_real, NULL)); - EXIT_IF_ERROR(setitimer(ITIMER_VIRTUAL, &remaining_virtual, NULL)); - EXIT_IF_ERROR(setitimer(ITIMER_PROF, &remaining_prof, NULL)); + EXIT_IF_ERROR(setitimer(ITIMER_REAL, &remaining_real, NULL)); + if (supports_virtual) EXIT_IF_ERROR(setitimer(ITIMER_VIRTUAL, &remaining_virtual, NULL)); + if (supports_prof) EXIT_IF_ERROR(setitimer(ITIMER_PROF, &remaining_prof, NULL)); if (redirect_fd == -1) {