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

monad update

git-svn-id: https://subversion.cs.illinois.edu/svn/cs225@5613 6fbd10e7-183d-0410-a318-cb416676e4f2
parent ef03b14f
No related branches found
No related tags found
No related merge requests found
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
No preview for this file type
......@@ -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)
{
......
// 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
......
......@@ -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
......@@ -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() );
......
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