diff --git a/.monadid b/.monadid index f0b83b5d6a9a77d9b36b808bdfce27236d2e23e1..38f99f9215f8b15a6b39fa5cb21268b1affeaf81 100644 --- a/.monadid +++ b/.monadid @@ -1,4 +1,4 @@ monad identification file This file is used for monad directory identification Built by toole1 on linux3.ews.illinois.edu -Build Date: Tue Nov 29 03:13:20 CST 2011 +Build Date: Sun Dec 4 23:21:46 CST 2011 diff --git a/monad b/monad index fde8937c4f1f26a398d46da6c68897e353d19688..74676464e98f84fcfe2606d6331e4efbe04ff716 100755 Binary files a/monad and b/monad differ diff --git a/monad.cpp b/monad.cpp index d8a1c4fe3cf008c7ad0e7e4ddf323f1b3f4834bc..727fbfe0c6e5eb3901b26b0d5422349ab43c5682 100644 --- a/monad.cpp +++ b/monad.cpp @@ -7,6 +7,7 @@ namespace monad { void find_base_dir(const char * argv0); +void create_mp_part_file(); void processArgs(int argc, const char * const * argv); void copyRequiredFiles(); void getLibs(const vector<string> & libs); @@ -108,13 +109,9 @@ int main(int argc, const char * const * argv) chdir(gradeFolder.c_str()); // #define MP_PART_NUMBER in proxy - ofstream mp_part_file; - mp_part_file.open("_mp_part_number.h"); - if (mp_part == no_mp_part) - mp_part_file << "#define MP_PART_NUMBER NO_MP_PART" << endl; - else - mp_part_file << "#define MP_PART_NUMBER " << (int)mp_part << endl; - mp_part_file.close(); + create_mp_part_file(); + // Change inclusion guards in proxy.h + exec("sed", "-i", "-e", "s/PROXY_H/PROXY_" + lexical_cast<string>(urand()) + "_H/g", "./proxy.h"); // run [Pre-Make Commands] config header const vector<string> & processing_commands = config["Pre-Make Commands"]; @@ -160,6 +157,16 @@ int main(int argc, const char * const * argv) return score; } +void monad::create_mp_part_file() +{ + ofstream mp_part_file("mp_part.h"); + mp_part_file << "#define NO_MP_PART " << static_cast<int>(no_mp_part) << endl; + mp_part_file << "#define MP_PART_NUMBER "; + if (mp_part == no_mp_part) mp_part_file << "NO_MP_PART"; else mp_part_file << static_cast<int>(mp_part); + mp_part_file << endl; + mp_part_file << "#define MP_PART(x) (MP_PART_NUMBER == (x) || MP_PART_NUMBER == NO_MP_PART)" << endl; + mp_part_file.close(); +} void monad::processArgs(int argc, const char * const * argv) { diff --git a/proxy.h b/proxy.h index 840bb5e4c1c53dd6db8d590d25796f88f62b1996..bd7096ecbcf7da76c2555af1a275c48973a74ea5 100644 --- a/proxy.h +++ b/proxy.h @@ -1,10 +1,11 @@ // proxy.h // NOTE: This is a generic file. Actual unit tests are located in // unit_tests.cpp. -// By Jack Toole for CS 225 spring 2011 +// By Jack Toole for CS 225 2011 -#ifndef MONAD_PROXY_H -#define MONAD_PROXY_H +// Randomized inclusion guards so that students can't hotswap the proxy +#ifndef PROXY_H +#define PROXY_H #include <math.h> #include <signal.h> @@ -20,10 +21,7 @@ #include "pipestream.h" #include "monad_shared.h" - -#define NO_MP_PART -1 -#include "_mp_part_number.h" -#define MP_PART(x) (MP_PART_NUMBER == (x) || MP_PART_NUMBER == NO_MP_PART) +#include "mp_part.h" namespace proxy { @@ -211,26 +209,33 @@ using std::cout; using std::cerr; using std::endl; -#define UNIT_TEST(func,pointsInPart,pointsInTotal,timeout) \ - void func(util::pipestream & ___monad_checkstream___); \ - proxy::add_unit_test \ - func##_adder(#func, func, pointsInPart, \ - pointsInTotal, timeout, false); \ - void func(util::pipestream & ___monad_checkstream___) - -#define VALGRIND_TEST(func,pointsInPart,pointsInTotal,timeout) \ - void func(util::pipestream & ___monad_checkstream___); \ - proxy::add_unit_test \ - func##_adder(#func, func, pointsInPart, \ - pointsInTotal, timeout, true); \ - void func(util::pipestream & ___monad_checkstream___) - -#define HELPER_TEST(func, ...) \ - void func(util::pipestream & ___monad_checkstream___, __VA_ARGS__) - -#define CALL_HELPER(func, ...) \ - do { \ - func(___monad_checkstream___, __VA_ARGS__); \ +#define UNIT_TEST(func,pointsInPart,pointsInTotal,timeout) \ + namespace proxy_test { \ + void func(util::pipestream & ___monad_checkstream___); \ + proxy::add_unit_test \ + func##_adder(#func, func, pointsInPart, \ + pointsInTotal, timeout, false); \ + } \ + void proxy_test::func(util::pipestream & ___monad_checkstream___) + +#define VALGRIND_TEST(func,pointsInPart,pointsInTotal,timeout) \ + namespace proxy_test { \ + void func(util::pipestream & ___monad_checkstream___); \ + proxy::add_unit_test \ + func##_adder(#func, func, pointsInPart, \ + pointsInTotal, timeout, true); \ + } \ + void proxy_test::func(util::pipestream & ___monad_checkstream___) + +#define HELPER_TEST(func, ...) \ + namespace proxy_test { \ + void func(util::pipestream & ___monad_checkstream___, __VA_ARGS__); \ + } \ + void proxy_test::func(util::pipestream & ___monad_checkstream___, __VA_ARGS__) + +#define CALL_HELPER(func, ...) \ + do { \ + func(___monad_checkstream___, __VA_ARGS__); \ } while (0) #define DECLARE_OUTPUT_CHECK(func) \ @@ -239,7 +244,7 @@ using std::endl; #define OUTPUT_CHECK(func) \ bool ___monad_output_check_##func(const std::string & output, const std::string & expected); \ proxy::add_output_check \ - ___monad_output_check_##func##_adder(#func, ___monad_output_check_##func); \ + ___monad_output_check_##func##_adder(#func, ___monad_output_check_##func); \ bool ___monad_output_check_##func(const std::string & output, const std::string & expected) #define STRINGIFY1(p) #p diff --git a/quotes.txt b/quotes.txt index 0f7b00d8089912678a2cc8d79571a6839c9f0009..842180872eeb8f825d3c21dcb296e8a20d291124 100644 --- a/quotes.txt +++ b/quotes.txt @@ -44,3 +44,4 @@ "A computer will do what you tell it to do, but that may be much different from what you had in mind" ~ Joseph Weizenbaum "Computers are like Old Testament gods; lots of rules and no mercy." ~ Joseph Campbell "Programs must be written for people to read, and only incidentally for machines to execute." ~ Abelson and Sussman +"If you just rely on one model, you tend to amputate reality to make it fit your model." ~ David Brooks diff --git a/util.cpp b/util.cpp index d1cc6992b53e1107de822ddb95e619f7534fb166..8fa26b26be1f0095fcecb5947e16fb13ae48a282 100644 --- a/util.cpp +++ b/util.cpp @@ -68,14 +68,10 @@ int8_t exec(int redirect_fd, const char * command, // For debugging: #if 0 - cerr << "exec(" << command << ' ' -//!! << ((arg1!=NULL)?arg1:"-") << ' ' -//!! << ((arg2!=NULL)?arg2:"-") << ' ' -//!! << ((arg3!=NULL)?arg3:"-") << ' ' -//!! << ((arg4!=NULL)?arg4:"-") << ' ' -//!! << ((arg5!=NULL)?arg5:"-") << ' ' -//!! << ((arg6!=NULL)?arg6:"-") << ' ' - << ')' << endl; + cerr << "exec(" << '\"' << command << '\"'; + for (size_t i = 0; i < args_count; i++) + if (args[i] != NULL) cerr << ", \"" << args[i] << "\""; + cerr << ")" << endl; #endif // avoid self destruction errors from closing then trying to duplicate output @@ -854,7 +850,7 @@ void rename_main(const string & file, const string & newname) exit(-2); } assertExists(file); - exec( "sed", "-i", + exec( "sed", "-i", "-e", ( "s/int[\\r\\n \\t][\\r\\n \\t]*main(.*)/int " + newname + "(int argc, char ** argv)/" ).c_str(), file.c_str() );