// boost compilation regression test // Usage: regrtest [*|compiler] [*|library/program] // // Default: regrtest * * // // Compilers: bcc = Borland 5.5.1 // cw = Metrowerks CodeWarrior // gcc = GNU GCC // gcc-stlport = GNU GCC with STLport library // como = Comeau C++ // vc = Microsoft Visual C++ // vcstlport = Microsoft Visual C++ with STLport library // // Examples: regrtest // regrtest // regrtest gcc // regrtest * smart_ptr/smart_ptr_test.cpp // regrtest gcc smart_ptr/smart_ptr_test.cpp // // If the program argument is * or left out, then the file // ./regrtest_files.txt will be used as the list of files to be // tested. Each line of regrtest_files.txt must have the form: // // file-name mode [input-file] // // Where mode is // C compile // F compile, expecting failure // R compile and run // // The path to the input-file should be relative to where regrtest is // running. // // Required environment variables: // BOOST_PATH The directory containing the "boost/" header file directory. // OSTYPE The operating system, should be one of ... // BOOST_STLPORT_PATH The directory containing STLport headers // BOOST_BCC55_PATH The directory container Borland headers // // Note: use the following command line syntax if output is to be redirected: // python regrtest.py [*|compiler] [*|library/program] >log 2>&1 // Revision history: // 17 Dec 00 Rewrote in C++ and retrieve file list from a file. (Jeremy Siek) // 21 Jun 00 Redesign to allow specifying compiler and program (Beman Dawes) // 18 Jun 00 Initial Version (Beman Dawes) // The Metrowerks and Microsoft compilers require various environment variables be set. // See mwcc -help // See http://msdn.microsoft.com/library/devprods/vs6/visualc/vccore/_core_building_on_the_command_line.3a_.overview.htm // Others: // See bcb4.hlp. Don't bother with bcb4tools.hlp; it has a bad link to the command line options #include #include #include #include // for getenv() #include // for ctime() #include // for sscanf() #include // for strtok() // Enumerated Types // Global variables std::string path, compiler_arg, program_arg, exe_suffix, exe_invoke_prefix; std::ofstream outfile; //----------------------------------------------------------------------------- std::string platform() { char* os_ptr = getenv("OS"); if (os_ptr == 0) { std::cerr << "The \"OS\" environment variable is not defined" << std::endl; exit(1); return "unknown"; } else { std::string os = os_ptr; if (os == "linux") return "linux"; else if (os == "solaris2.7") return "sunos"; else if (os == "Windows_NT") return "windows"; else return "unknown"; } } //----------------------------------------------------------------------------- void invoke(std::string desc, std::string command, char invoke_mode, std::string invoke_args, std::string program_name) { std::cout << " " << desc << std::endl; std::cout << " invoke mode: " << invoke_mode << std::endl; std::cout << " " << command << std::endl; outfile << ""; int rs = system(command.c_str()); std::cout << " compile return status: " << rs << std::endl; switch (invoke_mode) { case 'C': // compile if (rs==0) outfile << "yes"; else outfile << "failed to compile"; break; case 'F': // compile, fail expected if (rs==0) outfile << "failed to cause error"; else outfile << "yes"; break; case 'R': // run if (rs==0) { //script debugging aid std::cout << " executing: " << exe_invoke_prefix << program_name << " " << invoke_args << std::endl; std::string cmd_line = exe_invoke_prefix + program_name + " " + invoke_args; rs = system(cmd_line.c_str()); if (rs==0) outfile << "yes"; else outfile << "exited with code " << rs << ""; } else outfile << "failed to compile"; break; default: outfile << "scripting error"; } // switch (invoke_mode) outfile << "" << std::endl; } //----------------------------------------------------------------------------- void compile(std::string program, char invoke_mode, std::string invoke_args, std::string program_name) { std::string fullpath = path + "/libs/" + program; std::cout << std::endl << "*****" << program << "*****" << std::endl; outfile << "" << std::endl << "" << program << "" << std::endl; std::string gcc_flags = "-Wall -pedantic -ftemplate-depth-30 -Wno-long-long"; // should add -Werror std::string kcc_flags // = "--strict"; = "--strict_warnings"; std::string mwcc_flags = "-maxerrors 10 -cwd source"; //John Maddock says use /Zm400 switch; it increases compiler memory std::string msvc_flags = "/nologo /Zm400 /MDd /W3 /GR /GX /GZ /D \"WIN32\" /D \"_DEBUG\" /D \"_MBCS\" /D \"_CONSOLE\""; if (platform() == "linux") { if (compiler_arg == "*" || compiler_arg == "gcc") invoke("GCC 2.95.2", "g++ " + gcc_flags + " -o " + program_name + " -I" + path + " " + fullpath, invoke_mode, invoke_args, program_name); if (compiler_arg == "*" || compiler_arg == "gcc-stlport") invoke( "GCC 2.95.2 STLport 4.0", "g++ -V 2.95.2-stlport " + gcc_flags + " -o " + program_name + " -I" + path + " " + fullpath, invoke_mode, invoke_args, program_name ); if (compiler_arg == "*" || compiler_arg == "como") invoke( "Comeau C++ 4.2.44 beta3", "como -o " + program_name + " -I" + path + " " + fullpath, invoke_mode, invoke_args, program_name); } else if (platform() == "sunos") { if (compiler_arg == "*" || compiler_arg == "gcc") invoke("GCC 2.95.2", "g++ " + gcc_flags + " -o " + program_name + " -I" + path + " " + fullpath, invoke_mode, invoke_args, program_name); if (compiler_arg == "*" || compiler_arg == "kcc") invoke("KCC 3.4g", "KCC " + kcc_flags + " -o " + program_name + " -I" + path + " " + fullpath, invoke_mode, invoke_args, program_name); } else if (platform() == "beos") { if (compiler_arg=="*" || compiler_arg=="gcc") invoke( "GNU GCC", "c++ " + gcc_flags +" -o " + program_name + " -I" + path + " " + fullpath, invoke_mode, invoke_args, program_name ); // shouldn't this next one be called gcc-stlport instead of gcc-sgi? if (compiler_arg=="*" || compiler_arg=="gcc-sgi") invoke("GNU GCC", "c++ " + gcc_flags + " -o " + program_name + " -I/boot/home/config/stlport/stl330 -I" + path + " " + fullpath, invoke_mode, invoke_args, program_name ); } else { if (compiler_arg=="*" || compiler_arg=="bcc") { char* path_ptr = getenv("BOOST_BCC55_PATH"); if (path_ptr == 0) { std::cerr << "Environment variable BOOST_BCC55_PATH not defined" << std::endl; exit(1); } std::string bcc55_path = path_ptr; invoke( "Borland C++ 5.5.1", "\"" + bcc55_path + "/bcc32\" -e" + program_name + " -I" + path + " -j10 -q -Ve" + fullpath, invoke_mode, invoke_args, program_name ); } if (compiler_arg=="gcc") { // TODO: fix the absolute STLport paths invoke( "GNU GCC", "c++ " + gcc_flags + " -o " + program_name + " -I" + path + " -IC:/stl/STLport-4.0b8/stlport " + fullpath + " c:/stl/STLport-4.0b8/lib/libstlport_gcc.a", invoke_mode, invoke_args, program_name ); } if (compiler_arg=="*" || compiler_arg=="cw") invoke( "Metrowerks CodeWarrior", "mwcc " + mwcc_flags + " -I- -o " + program_name + " -I" + path + " " + fullpath, invoke_mode, invoke_args, program_name ); if (compiler_arg=="*" || compiler_arg=="vc") invoke( "VC++ with MS library", "cl -o " + program_name + " " + msvc_flags + " /I " + path + " " + fullpath + " user32.lib", invoke_mode, invoke_args, program_name ); if (compiler_arg=="*" || compiler_arg=="vcstlport") { char* path_ptr = getenv("BOOST_STLPORT_PATH"); if (path_ptr == 0) { std::cerr << "Environment variable BOOST_STLPORT_PATH not defined" << std::endl; exit(1); } std::string stlport = path_ptr; invoke( "VC++ with STLport library", "cl -o " + program_name + msvc_flags + "/I " + stlport + " /I " + path + fullpath + " user32.lib", invoke_mode, invoke_args, program_name ); } } outfile << "" << std::endl; } //----------------------------------------------------------------------------- void library() { std::cout << std::endl << "***** Boost Library *****" << std::endl; outfile << "" << std::endl << "Boost library build" << std::endl; // ... outfile << "" << std::endl; } //----------------------------------------------------------------------------- int main(int argc, char* argv[]) { char* path_ptr = getenv("BOOST_PATH"); if (path_ptr == 0) { std::cerr << "Environment variable BOOST_PATH not defined" << std::endl; return -1; } path = path_ptr; compiler_arg = "*"; if (argc > 1) compiler_arg = argv[1]; program_arg = "*"; if (argc > 2) program_arg = argv[2]; if (platform() == "unkown") { std::cerr << "**** Error: unknown platform ****" << std::endl; return 1; } if (platform() == "windows") { exe_suffix = ".exe"; exe_invoke_prefix = ""; } else { exe_suffix = ""; exe_invoke_prefix = "./"; } std::string filename = "cs-" + platform() + ".htm"; outfile.open(filename.c_str()); time_t today; time(&today); outfile << "\n\n\nCompiler Status: " << platform() << "\n\n" << "" << std::endl << "

" << std::endl << "

Compiler Status: " << platform() << "

" << std::endl << "

Run Date: " << ctime(&today) << "

" << std::endl << "

" << std::endl << "" << std::endl << "" << std::endl << "" << std::endl; if (platform() == "linux") { if (compiler_arg == "*" || compiler_arg == "gcc") outfile << "" << std::endl; if (compiler_arg == "*" || compiler_arg == "gcc-stlport") outfile << "" << std::endl; #if 0 if (compiler_arg == "*" || compiler_arg == "gcc-exp") outfile << "" << std::endl; #endif if (compiler_arg == "*" || compiler_arg == "como") outfile << "" << std::endl; #if 0 if (compiler_arg == "*" || compiler_arg == "occ") outfile << "" << std::endl; #endif } else if (platform() == "sunos") { if (compiler_arg == "*" || compiler_arg == "suncc") outfile << "" << std::endl; if (compiler_arg == "*" || compiler_arg == "gcc") outfile << "" << std::endl; if (compiler_arg == "*" || compiler_arg == "kcc") outfile << "" << std::endl; } else if (platform() == "beos") { if (compiler_arg == "*" || compiler_arg == "gcc") outfile << "" << std::endl; if (compiler_arg == "*" || compiler_arg == "gcc-sgi") outfile << "" << std::endl; } else { #if 0 if (compiler_arg=="*" || compiler_arg=="bcc54") outfile << "" << std::endl; #endif if (compiler_arg=="*" || compiler_arg=="bcc") outfile << "" << std::endl; // GCC 2.95.2 is looping on some tests, so only invoke if asked // for by name if (compiler_arg=="gcc") outfile << "" << std::endl; if (compiler_arg=="*" || compiler_arg=="cw") outfile << "" << std::endl; if (compiler_arg=="*" || compiler_arg=="vc") outfile << "" << std::endl; if (compiler_arg=="*" || compiler_arg=="vcstlport") outfile << "" << std::endl; } outfile << "" << std::endl; if (program_arg == "*") { std::string filelist = "regrtest_files.txt"; std::ifstream regr_files(filelist.c_str()); if (regr_files) { const int max_line = 1000; char line[max_line]; while (regr_files.getline(line, max_line)) { char *program_ptr, *mode_ptr, *arg_ptr; program_ptr = strtok(line, " "); if (program_ptr == 0) { std::cerr << "file format error, no program file name" << std::endl; return -1; } mode_ptr = strtok(0, " \n"); if (mode_ptr == 0) { std::cerr << "file format error, no mode character" << std::endl; return -1; } arg_ptr = strtok(0, " \n"); char* empty_string = ""; if (arg_ptr == 0) arg_ptr = empty_string; compile(program_ptr, *mode_ptr, arg_ptr, "regress" + exe_suffix); } } else { std::cerr << "Could not open regression test file list: " << filelist << std::endl; return -1; } } else compile(program_arg, 'C', "", "regress" + exe_suffix); outfile << "
ProgramGNU
GCC
2.95.2
GNU
GCC
2.95.2
STLport
4.0
GNU
GCC
pre-2.97 experimental
Comeau C++
4.2.44 beta3
STLport
4.0
OpenC++
2.5.9
Sun C++
Sun WorkShop 6, C++ 5.1
GNU
GCC
2.95.2
KAI
KCC
3.4g
GNUPro
GCC 2.9
GNUPro
GCC 2.9
+
SGI STL 3.3
Borland
BCC
5.4 up2
Borland
BCC
5.5.1
GNU
GCC
2.95.2
STLport
4.0 beta 8
Metrowerks
CodeWarrior
6.0
Microsoft
VC++
6.0 SP4
Microsoft
VC++
6.0 SP4
STLport
4.0
" << std::endl; if (platform() == "linux") outfile << "

\nNote: A hand-crafted <limits> " << "Standard header has been applied to all configurations." << std::endl; outfile << "\n" << std::endl; return 0; }