Skip to content
Snippets Groups Projects
Commit 947e9a25 authored by toole1's avatar toole1
Browse files

jack

git-svn-id: https://subversion.cs.illinois.edu/svn/cs225@3384 6fbd10e7-183d-0410-a318-cb416676e4f2
parent 8843c13c
No related branches found
No related tags found
No related merge requests found
...@@ -66,8 +66,6 @@ int main(int argc, char ** argv) ...@@ -66,8 +66,6 @@ int main(int argc, char ** argv)
namespace proxy { namespace proxy {
int8_t RunTimeEnvironment::singleton = 0;
// class add_unit_test // class add_unit_test
add_unit_test::add_unit_test(int8_t MPpart, const char * name, unit_test::function func, 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, int32_t points_in_part, int32_t points_in_total, long timeout,
...@@ -138,6 +136,7 @@ RunTimeEnvironment::RunTimeEnvironment(vector<unit_test> *& init_tests, ...@@ -138,6 +136,7 @@ RunTimeEnvironment::RunTimeEnvironment(vector<unit_test> *& init_tests,
{ {
// Copy globals to the RunTimeEnvironment space // Copy globals to the RunTimeEnvironment space
// And remove them from the global scope // 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(singleton++ != 0, "There may only be one runtime environment");
EXIT_IF_ERROR(heap_tests == NULL, "No test cases found"); EXIT_IF_ERROR(heap_tests == NULL, "No test cases found");
if (output_checks == NULL) if (output_checks == NULL)
...@@ -404,15 +403,11 @@ void test_execution::child() ...@@ -404,15 +403,11 @@ void test_execution::child()
if (do_valgrind) 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(); child_valgrind();
} }
else // if (!test.is_valgrind) else // if (!test.is_valgrind)
{ {
child_test(fmsg_pipe, nums_pipe); child_test();
} }
} }
...@@ -432,22 +427,22 @@ void test_execution::parent() ...@@ -432,22 +427,22 @@ void test_execution::parent()
void test_execution::after_success(int8_t return_code) void test_execution::after_success(int8_t return_code)
{ {
if (do_valgrind) if (do_valgrind)
{ after_valgrind_success(return_code);
fmsg_pipe.close_read(); else
nums_pipe.close_read(); after_test_success();
valgrind_test_exit(return_code);
}
else // if (!test.is_valgrind)
{
test_exit(fmsg_pipe, nums_pipe);
}
} }
void test_execution::after_failure(int8_t signal_number) void test_execution::after_failure(int8_t signal_number)
{ {
fmsg_pipe.close_read(); fmsg_pipe.close_read();
nums_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) ...@@ -496,16 +491,20 @@ bool fork_execute(F & executor)
void test_execution::child_valgrind() 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(); start_timeout();
execl("/usr/bin/valgrind", "/usr/bin/valgrind", "--trace-children=yes", /*"--log-fd=-1",*/ "-q", "./proxy", test.name, NULL); execl("/usr/bin/valgrind", "/usr/bin/valgrind", "--trace-children=yes", /*"--log-fd=-1",*/ "-q", "./proxy", test.name, NULL);
// Execl failed // Execl failed
cerr << "valgrind execute failed" << endl; EXIT_IF_ERROR(true, "valgrind execute failed");
exit(-1);
} }
void test_execution::child_test(pipestream & fmsg_pipe, pipestream & nums_pipe) void test_execution::child_test()
{ {
test.checkstream->close_read(); test.checkstream->close_read();
// Execute test // Execute test
...@@ -529,8 +528,11 @@ void test_execution::child_test(pipestream & fmsg_pipe, pipestream & nums_pipe) ...@@ -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); size_t last_endl = findNthLast(test.output, '\n', 2);
if (last_endl == string::npos) if (last_endl == string::npos)
test.errormsg = "Test did not complete"; test.errormsg = "Test did not complete";
...@@ -549,7 +551,7 @@ void test_execution::valgrind_test_exit(int8_t return_code) ...@@ -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 >> test.errormsg;
fmsg_pipe.close(); fmsg_pipe.close();
...@@ -585,18 +587,6 @@ void test_execution::test_exit(pipestream & fmsg_pipe, pipestream & nums_pipe) ...@@ -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) int32_t get_valgrind_flags(bool test_failed)
{ {
// Check for valgrind errors or leaks (if running under valgrind) // Check for valgrind errors or leaks (if running under valgrind)
......
...@@ -71,10 +71,15 @@ namespace proxy ...@@ -71,10 +71,15 @@ namespace proxy
RunTimeEnvironment(std::vector<unit_test> *& init_tests, RunTimeEnvironment(std::vector<unit_test> *& init_tests,
output_check_map *& init_output_checks); output_check_map *& init_output_checks);
bool is_timeout_signal(int8_t signal_number)
{
return signal_number == timeout_signum0 ||
signal_number == timeout_signum1;
}
private: private:
RunTimeEnvironment(const RunTimeEnvironment & other); RunTimeEnvironment(const RunTimeEnvironment & other);
RunTimeEnvironment & operator=(RunTimeEnvironment & other); RunTimeEnvironment & operator=(RunTimeEnvironment & other);
static int8_t singleton;
}; };
class RunTests class RunTests
...@@ -135,11 +140,10 @@ namespace proxy ...@@ -135,11 +140,10 @@ namespace proxy
void after_failure(int8_t signal_number); void after_failure(int8_t signal_number);
private: private:
void child_test();
void child_valgrind(); void child_valgrind();
void child_test(util::pipestream & fmsg_pipe, util::pipestream & nums_pipe); void after_test_success();
void valgrind_test_exit(int8_t return_code); void after_valgrind_success(int8_t return_code);
void test_exit(util::pipestream & fmsg_pipe, util::pipestream & nums_pipe);
void test_signaled(int8_t signum);
void start_timeout(); void start_timeout();
long end_timeout(); long end_timeout();
......
...@@ -4,7 +4,7 @@ testcases="mp1 lab02 lab03 lab04 lab06 lab07 lab10 lab12" ...@@ -4,7 +4,7 @@ testcases="mp1 lab02 lab03 lab04 lab06 lab07 lab10 lab12"
#make #make
for assign in $testcases for assign in $testcases
do do
./monad $assign --newtests --solution --staff &>/dev/null ./monad $assign --newtests --solution --noupdate --staff &>/dev/null
score=$? score=$?
if [ $score -lt 100 ] || [ $score -eq 255 ] if [ $score -lt 100 ] || [ $score -eq 255 ]
then then
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment