mirror of
https://github.com/darlinghq/darling.git
synced 2024-11-26 22:00:29 +00:00
Remove unused stuff from tests/
This commit is contained in:
parent
57a054ba4f
commit
31c98d3d52
@ -1,30 +0,0 @@
|
||||
project(runtest)
|
||||
|
||||
cmake_minimum_required(VERSION 2.4.0)
|
||||
if(COMMAND cmake_policy)
|
||||
cmake_policy(SET CMP0003 NEW)
|
||||
endif(COMMAND cmake_policy)
|
||||
|
||||
#if (NOT "${CMAKE_CXX_COMPILER} ${CMAKE_CXX_COMPILER_ARG1}" MATCHES ".*clang")
|
||||
# message(FATAL_ERROR "Clang is the only supported compiler.")
|
||||
#endif (NOT "${CMAKE_CXX_COMPILER} ${CMAKE_CXX_COMPILER_ARG1}" MATCHES ".*clang")
|
||||
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -fPIC")
|
||||
#set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99 -fPIC")
|
||||
|
||||
set(runtest_SRCS
|
||||
runtest.cpp
|
||||
termcolor.cpp
|
||||
pstream.cpp
|
||||
boostxml.cpp
|
||||
timer.cpp
|
||||
)
|
||||
|
||||
add_executable(runtest ${runtest_SRCS})
|
||||
target_link_libraries(runtest sshcxx)
|
||||
|
||||
add_subdirectory(libsshcxx)
|
||||
add_dependencies(runtest sshcxx)
|
||||
|
||||
#install(TARGETS runtest DESTINATION "lib${SUFFIX}/darling")
|
||||
|
@ -1,41 +0,0 @@
|
||||
#include "boostxml.h"
|
||||
|
||||
boostxml::boostxml()
|
||||
{
|
||||
m_xml << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
|
||||
m_xml << "<TestLog>\n";
|
||||
m_xml << "\t<TestSuite name=\"Darling\">\n";
|
||||
}
|
||||
|
||||
void boostxml::addOK(const std::string& path, int time)
|
||||
{
|
||||
m_xml << "\t\t<TestCase name=\"" << extractName(path) << "\">\n";
|
||||
m_xml << "\t\t\t<TestingTime>" << time << "</TestingTime>\n";
|
||||
m_xml << "\t\t</TestCase>\n";
|
||||
}
|
||||
|
||||
void boostxml::addFailure(const std::string& path, int time, const std::string& error)
|
||||
{
|
||||
m_xml << "\t\t<TestCase name=\"" << extractName(path) << "\">\n";
|
||||
m_xml << "\t\t\t<Error file=\"" << path << "\" line=\"0\">\n";
|
||||
m_xml << "<![CDATA[" << error << "]]>\n";
|
||||
m_xml << "\t\t\t</Error>\n";
|
||||
m_xml << "\t\t\t<TestingTime>" << time << "</TestingTime>\n";
|
||||
m_xml << "\t\t</TestCase>\n";
|
||||
}
|
||||
|
||||
std::string boostxml::str()
|
||||
{
|
||||
m_xml << "\t</TestSuite>\n</TestLog>\n";
|
||||
return m_xml.str();
|
||||
}
|
||||
|
||||
std::string boostxml::extractName(const std::string& path)
|
||||
{
|
||||
size_t pos = path.rfind('/');
|
||||
if (pos == std::string::npos)
|
||||
return path;
|
||||
else
|
||||
return path.substr(pos+1);
|
||||
}
|
||||
|
@ -1,21 +0,0 @@
|
||||
#ifndef BOOSTXML_H
|
||||
#define BOOSTXML_H
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
class boostxml
|
||||
{
|
||||
public:
|
||||
boostxml();
|
||||
std::string str();
|
||||
|
||||
void addOK(const std::string& path, int time);
|
||||
void addFailure(const std::string& path, int time, const std::string& error);
|
||||
private:
|
||||
static std::string extractName(const std::string& path);
|
||||
private:
|
||||
std::stringstream m_xml;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -1,64 +0,0 @@
|
||||
#ifndef __EXCEPTIONS_H
|
||||
#define __EXCEPTIONS_H
|
||||
#include <stdexcept>
|
||||
#include <sstream>
|
||||
|
||||
class compile_error : public std::runtime_error
|
||||
{
|
||||
public:
|
||||
compile_error(const std::string& err)
|
||||
: std::runtime_error(err)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
class different_output_error : public std::exception
|
||||
{
|
||||
public:
|
||||
different_output_error(const std::string& remote, const std::string& local)
|
||||
: m_remote(remote), m_local(local)
|
||||
{
|
||||
}
|
||||
|
||||
virtual const char* what() const throw() override
|
||||
{
|
||||
return "different_output_error";
|
||||
}
|
||||
|
||||
const std::string& local() const { return m_local; }
|
||||
const std::string& remote() const { return m_remote; }
|
||||
private:
|
||||
std::string m_local, m_remote;
|
||||
};
|
||||
|
||||
class nonzero_exit_error : public std::exception
|
||||
{
|
||||
public:
|
||||
nonzero_exit_error(bool remote, const std::string& output)
|
||||
: m_remote(remote), m_output(output)
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss << "Non-zero exit status from ";
|
||||
if (m_remote)
|
||||
ss << "remotely";
|
||||
else
|
||||
ss << "locally";
|
||||
ss << " run binary";
|
||||
m_msg = ss.str();
|
||||
}
|
||||
|
||||
bool remote() const { return m_remote; }
|
||||
const std::string& output() const { return m_output; }
|
||||
|
||||
virtual const char* what() const throw() override
|
||||
{
|
||||
return m_msg.c_str();
|
||||
}
|
||||
private:
|
||||
bool m_remote;
|
||||
std::string m_output, m_msg;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -1,39 +0,0 @@
|
||||
#include "pstream.h"
|
||||
#include <cstdio>
|
||||
|
||||
|
||||
pstream::pstream(FILE* pipe)
|
||||
: m_pipe(pipe)
|
||||
{
|
||||
}
|
||||
|
||||
pstream::~pstream()
|
||||
{
|
||||
if (m_pipe)
|
||||
wait();
|
||||
}
|
||||
|
||||
pstream* pstream::popen(const std::string& cmd)
|
||||
{
|
||||
FILE* pipe = ::popen(cmd.c_str(), "r");
|
||||
if (!pipe)
|
||||
return nullptr;
|
||||
return new pstream(pipe);
|
||||
}
|
||||
|
||||
std::istream* pstream::in()
|
||||
{
|
||||
return new std::istream(this);
|
||||
}
|
||||
|
||||
int pstream::wait()
|
||||
{
|
||||
int rv = pclose(m_pipe);
|
||||
m_pipe = nullptr;
|
||||
return rv;
|
||||
}
|
||||
|
||||
std::streamsize pstream::xsgetn(char* s, std::streamsize n)
|
||||
{
|
||||
return fread(s, 1, n, m_pipe);
|
||||
}
|
@ -1,20 +0,0 @@
|
||||
#include "libsshcxx/ssh_streambuf.h"
|
||||
#include <cstdio>
|
||||
#include <istream>
|
||||
#include <string>
|
||||
|
||||
class pstream : public ssh_streambuf
|
||||
{
|
||||
public:
|
||||
pstream(FILE* pipe);
|
||||
~pstream();
|
||||
|
||||
static pstream* popen(const std::string& cmd);
|
||||
|
||||
std::istream* in();
|
||||
int wait();
|
||||
protected:
|
||||
virtual std::streamsize xsgetn(char* s, std::streamsize n) override;
|
||||
private:
|
||||
FILE* m_pipe;
|
||||
};
|
118
tests/runtest
118
tests/runtest
@ -1,118 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
BUILDSERVER="osx"
|
||||
CPPFLAGS=""
|
||||
DYLD="dyld"
|
||||
|
||||
set -e
|
||||
|
||||
failure() {
|
||||
tput setaf 1
|
||||
tput bold
|
||||
echo "Test failure - the last command failed to execute"
|
||||
tput sgr0
|
||||
}
|
||||
|
||||
runtest() {
|
||||
trap failure ERR
|
||||
|
||||
source="$1"
|
||||
extension="${source##*.}"
|
||||
source_fn=$(echo "$source" | sed 's/\//_/g')
|
||||
|
||||
cflags="$(grep '// CFLAGS' "$source" || true)"
|
||||
cflags="$CPPFLAGS -w $(echo "$cflags" | cut -b 12-)"
|
||||
|
||||
case "$extension" in
|
||||
"cpp")
|
||||
darwin_tool="g++"
|
||||
native_tool="clang++"
|
||||
;;
|
||||
"c")
|
||||
darwin_tool="gcc"
|
||||
native_tool="clang"
|
||||
;;
|
||||
"m")
|
||||
darwin_tool="gcc"
|
||||
native_tool="clang"
|
||||
cflags_native="-l:libobjc.so.4 -lgnustep-base"
|
||||
cflags_darwin="-lobjc -framework foundation"
|
||||
;;
|
||||
*)
|
||||
echo "Unsupported file type: $extension"
|
||||
exit 1
|
||||
esac
|
||||
|
||||
tput bold
|
||||
echo "====="
|
||||
echo "Running test '$source'"
|
||||
echo "====="
|
||||
tput sgr0
|
||||
|
||||
cflags="$(grep '// CFLAGS' "$source" || true)"
|
||||
cflags="$CPPFLAGS -w $(echo "$cflags" | cut -b 12-)"
|
||||
|
||||
echo "Copying the source code to Darwin..."
|
||||
scp "$source" "$BUILDSERVER:/tmp/$$.$source_fn" >/dev/null
|
||||
echo "Building the source code for Darwin..."
|
||||
ssh "$BUILDSERVER" "$darwin_tool $cflags $cflags_darwin '/tmp/$$.$source_fn' -o '/tmp/$$.$source_fn.bin'"
|
||||
echo "Copying the binary over..."
|
||||
scp "$BUILDSERVER:/tmp/$$.$source_fn.bin" "/tmp" >/dev/null
|
||||
ssh "$BUILDSERVER" "rm -f /tmp/$$.$source_fn*"
|
||||
|
||||
echo "Running Darwin binary locally..."
|
||||
out_darwin=$($DYLD "/tmp/$$.$source_fn.bin")
|
||||
rm -f "/tmp/$$.$source_fn.bin"
|
||||
|
||||
echo "Compiling native..."
|
||||
$native_tool $cflags $cflags_native "$source" -o "/tmp/$$.$source_fn.bin"
|
||||
echo "Running native binary..."
|
||||
out_native=$("/tmp/$$.$source_fn.bin")
|
||||
|
||||
if [ "$out_darwin" != "$out_native" ]; then
|
||||
tput setaf 1
|
||||
tput bold
|
||||
echo "*** ERROR: Outputs do not match!"
|
||||
tput sgr0
|
||||
echo "---"
|
||||
tput setaf 3
|
||||
echo "Darwin build:"
|
||||
tput sgr0
|
||||
echo "---"
|
||||
echo "$out_darwin"
|
||||
echo "---"
|
||||
tput setaf 3
|
||||
echo "Native build:"
|
||||
tput sgr0
|
||||
echo "---"
|
||||
echo "$out_native"
|
||||
exit 1
|
||||
fi
|
||||
rm -f "/tmp/$$.$source_fn.bin"
|
||||
|
||||
tput setaf 2
|
||||
echo "Everything OK, outputs match"
|
||||
tput sgr0
|
||||
}
|
||||
|
||||
if [[ "$0" == *runtest32 ]]; then
|
||||
CPPFLAGS="-m32"
|
||||
DYLD="dyld32"
|
||||
echo "32-bit mode"
|
||||
fi
|
||||
if [[ "$0" == *runtest64 ]]; then
|
||||
DYLD="dyld64"
|
||||
echo "64-bit mode"
|
||||
fi
|
||||
|
||||
for test in "$@"; do
|
||||
runtest "$test"
|
||||
done
|
||||
|
||||
tput bold
|
||||
tput setaf 2
|
||||
echo '====='
|
||||
echo 'ALL GOOD'
|
||||
echo '====='
|
||||
tput sgr0
|
||||
|
@ -1,362 +0,0 @@
|
||||
#include <iostream>
|
||||
#include "libsshcxx/SSH.h"
|
||||
#include "libsshcxx/SFTP.h"
|
||||
#include "libsshcxx/SSHChannel.h"
|
||||
#include "termcolor.h"
|
||||
#include "pstream.h"
|
||||
#include "exceptions.h"
|
||||
#include "boostxml.h"
|
||||
#include "timer.h"
|
||||
#include <memory>
|
||||
#include <stdexcept>
|
||||
#include <sstream>
|
||||
#include <cstring>
|
||||
#include <fstream>
|
||||
#include <unistd.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
const char* DYLD_COMMAND = "dyld";
|
||||
const char* OSX_HOST = "osx";
|
||||
std::unique_ptr<SSH> g_ssh;
|
||||
std::unique_ptr<SFTP> g_sftp;
|
||||
std::unique_ptr<SSHChannel> g_shell;
|
||||
|
||||
void bits(const char* progname);
|
||||
void runTest(const char* path);
|
||||
std::string uniqueName(const std::string& path);
|
||||
std::string cflags(const char* path);
|
||||
const char* compiler(const char* path);
|
||||
std::string stripext(std::string file);
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
if (argc < 2)
|
||||
{
|
||||
std::cerr << "Specify the tests to run\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
bits(argv[0]);
|
||||
if (const char* cmd = getenv("DYLD"))
|
||||
DYLD_COMMAND = cmd;
|
||||
|
||||
try
|
||||
{
|
||||
std::cout << "Opening SSH connection...\n";
|
||||
g_ssh.reset(new SSH);
|
||||
g_ssh->setHost(OSX_HOST);
|
||||
g_ssh->connect();
|
||||
g_ssh->login();
|
||||
g_shell.reset(g_ssh->newChannel());
|
||||
g_shell->openNonInteractive();
|
||||
g_shell->startShell();
|
||||
g_sftp.reset(g_ssh->sftpChannel());
|
||||
|
||||
int failures = 0;
|
||||
int offset = 0;
|
||||
timer tm;
|
||||
std::ofstream xml;
|
||||
boostxml bxml;
|
||||
|
||||
if (argc >= 2 && strncmp(argv[1], "--xml=", 6) == 0)
|
||||
{
|
||||
xml.open(argv[1] + 6, std::ofstream::out);
|
||||
offset++;
|
||||
}
|
||||
|
||||
for (int i = offset+1; i < argc; i++)
|
||||
{
|
||||
time_t timeStart, timeEnd;
|
||||
try
|
||||
{
|
||||
termcolor::set(termcolor::WHITE, termcolor::BLACK, termcolor::BRIGHT);
|
||||
std::cout << "=======\n";
|
||||
std::cout << "Running test (" << i-offset << '/' << argc-1 << "): " << argv[i] << std::endl;
|
||||
std::cout << "=======\n";
|
||||
termcolor::reset();
|
||||
|
||||
tm.start();
|
||||
|
||||
runTest(argv[i]);
|
||||
bxml.addOK(argv[i], tm.stop());
|
||||
|
||||
termcolor::set(termcolor::GREEN, termcolor::BLACK, termcolor::BRIGHT);
|
||||
std::cout << "*** Test OK!\n";
|
||||
termcolor::reset();
|
||||
}
|
||||
catch (const std::runtime_error& e)
|
||||
{
|
||||
termcolor::setBright(termcolor::RED);
|
||||
std::cerr << "*** Test failure!\n";
|
||||
termcolor::reset();
|
||||
|
||||
std::cerr << e.what() << std::endl;
|
||||
bxml.addFailure(argv[i], tm.stop(), e.what());
|
||||
|
||||
failures++;
|
||||
}
|
||||
catch (const different_output_error& e)
|
||||
{
|
||||
termcolor::setBright(termcolor::RED);
|
||||
std::cerr << "*** Test failure!\n";
|
||||
termcolor::reset();
|
||||
|
||||
termcolor::setBright(termcolor::WHITE);
|
||||
std::cerr << "Remote output:\n";
|
||||
termcolor::reset();
|
||||
std::cerr << e.remote();
|
||||
|
||||
termcolor::setBright(termcolor::WHITE);
|
||||
std::cerr << "Local output:\n";
|
||||
termcolor::reset();
|
||||
std::cerr << e.local();
|
||||
|
||||
std::stringstream ss;
|
||||
ss << "Test outputs differ!\n\n";
|
||||
ss << "Remote output:\n";
|
||||
ss << e.remote() << "\n\n";
|
||||
ss << "Local output:\n";
|
||||
ss << e.local();
|
||||
bxml.addFailure(argv[i], tm.stop(), ss.str());
|
||||
|
||||
failures++;
|
||||
}
|
||||
catch (const nonzero_exit_error& e)
|
||||
{
|
||||
termcolor::setBright(termcolor::RED);
|
||||
std::cerr << "*** Non-zero exit status!\n";
|
||||
termcolor::reset();
|
||||
|
||||
termcolor::setBright(termcolor::WHITE);
|
||||
std::cerr << ((e.remote()) ? "remote" : "local" );
|
||||
std::cerr << " test output leading to the error:\n";
|
||||
termcolor::reset();
|
||||
std::cerr << e.output();
|
||||
|
||||
std::stringstream ss;
|
||||
ss << "Non-zero exit status (" << ((e.remote() ? "remote" : "local")) << ")\n";
|
||||
ss << e.output();
|
||||
|
||||
bxml.addFailure(argv[i], tm.stop(), ss.str());
|
||||
|
||||
failures++;
|
||||
}
|
||||
}
|
||||
|
||||
if (!failures)
|
||||
{
|
||||
termcolor::setBright(termcolor::GREEN);
|
||||
std::cout << "ALL OK!\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
termcolor::setBright(termcolor::YELLOW);
|
||||
std::cerr << failures << " test failures\n";
|
||||
}
|
||||
|
||||
termcolor::reset();
|
||||
xml << bxml.str();
|
||||
}
|
||||
catch (const compile_error& e)
|
||||
{
|
||||
termcolor::setBright(termcolor::RED);
|
||||
std::cerr << "*** Error compiling:\n" << e.what();
|
||||
termcolor::reset();
|
||||
return 1;
|
||||
}
|
||||
catch (const std::exception& e)
|
||||
{
|
||||
termcolor::setBright(termcolor::RED);
|
||||
std::cerr << e.what() << std::endl;
|
||||
termcolor::reset();
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void runTest(const char* path)
|
||||
{
|
||||
/*
|
||||
std::string line;
|
||||
g_shell->out() << "echo Hello world\n" << std::flush;
|
||||
std::getline(g_shell->in(), line);
|
||||
|
||||
termcolor::set(termcolor::RED);
|
||||
std::cout << line << std::endl;
|
||||
termcolor::reset();
|
||||
*/
|
||||
|
||||
std::stringstream cmd;
|
||||
std::string binary;
|
||||
std::string out, err;
|
||||
std::string dirname, filename = "/tmp/darlingtest-";
|
||||
int rv;
|
||||
|
||||
filename += getenv("USER");
|
||||
filename += '/';
|
||||
dirname = filename;
|
||||
filename += uniqueName(path);
|
||||
|
||||
mkdir(dirname.c_str(), 0700);
|
||||
|
||||
binary = stripext(filename);
|
||||
|
||||
termcolor::set(termcolor::WHITE, termcolor::BLACK, termcolor::DIM);
|
||||
|
||||
std::cout << "Uploading " << path << "...\n";
|
||||
try
|
||||
{
|
||||
g_sftp->mkdir(dirname.c_str(), 0700);
|
||||
} catch (...) {}
|
||||
// upload the source code
|
||||
g_sftp->upload(path, filename);
|
||||
|
||||
try
|
||||
{
|
||||
std::cout << "Compiling...\n";
|
||||
// compile the code remotely
|
||||
cmd << compiler(path) << ' ' << cflags(path) << filename << " -o " << binary;
|
||||
rv = g_ssh->runCommand(cmd.str(), out, err);
|
||||
|
||||
if (rv)
|
||||
throw compile_error(err);
|
||||
|
||||
std::cout << "Running remotely...\n";
|
||||
// run the program remotely
|
||||
rv = g_ssh->runCommand(binary, out, err);
|
||||
|
||||
if (rv)
|
||||
throw nonzero_exit_error(true, out);
|
||||
|
||||
std::cout << "Downloading...\n";
|
||||
// download the Mach-O executable
|
||||
g_sftp->download(binary, binary);
|
||||
|
||||
std::cout << "Running locally...\n";
|
||||
// run the executable via dyld
|
||||
std::stringstream locOut;
|
||||
pstream* loc = pstream::popen(std::string(DYLD_COMMAND) + " " + binary);
|
||||
|
||||
locOut << loc;
|
||||
|
||||
rv = loc->wait();
|
||||
|
||||
if (rv)
|
||||
throw nonzero_exit_error(false, locOut.str());
|
||||
|
||||
if (locOut.str() != out)
|
||||
throw different_output_error(out, locOut.str());
|
||||
|
||||
// clean up locally
|
||||
unlink(binary.c_str());
|
||||
|
||||
try
|
||||
{
|
||||
// clean up remotely
|
||||
g_sftp->unlink(binary);
|
||||
g_sftp->unlink(filename);
|
||||
}
|
||||
catch (...) {}
|
||||
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
// clean up locally
|
||||
unlink(binary.c_str());
|
||||
|
||||
try
|
||||
{
|
||||
// clean up remotely
|
||||
g_sftp->unlink(binary);
|
||||
g_sftp->unlink(filename);
|
||||
}
|
||||
catch (...) {}
|
||||
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
std::string cflags(const char* path)
|
||||
{
|
||||
std::string cflags;
|
||||
const char* suffix = strrchr(path, '.');
|
||||
if (!suffix)
|
||||
throw std::runtime_error("Unsupported file name");
|
||||
|
||||
if (!strcmp(DYLD_COMMAND, "dyld32") || sizeof(void*) == 4)
|
||||
cflags += "-m32 ";
|
||||
|
||||
if (!strcmp(suffix, ".m") || !strcmp(suffix, ".mm"))
|
||||
cflags += "-lobjc ";
|
||||
|
||||
std::ifstream f(path);
|
||||
std::string first;
|
||||
|
||||
std::getline(f, first);
|
||||
if (first.compare(0, 11, "// CFLAGS: ") == 0)
|
||||
{
|
||||
cflags += first.substr(11);
|
||||
cflags += ' ';
|
||||
}
|
||||
|
||||
return cflags;
|
||||
}
|
||||
|
||||
const char* compiler(const char* path)
|
||||
{
|
||||
const char* suffix = strrchr(path, '.');
|
||||
if (!suffix)
|
||||
throw std::runtime_error("Unsupported file name");
|
||||
|
||||
if (!strcmp(suffix, ".c") || !strcmp(suffix, ".m"))
|
||||
return "clang";
|
||||
else if (!strcmp(suffix, ".cpp") || !strcmp(suffix, ".mm"))
|
||||
return "clang++";
|
||||
else
|
||||
throw std::runtime_error("Unsupported file name");
|
||||
}
|
||||
|
||||
|
||||
std::string uniqueName(const std::string& path)
|
||||
{
|
||||
char* name = new char[path.size()+1];
|
||||
strcpy(name, path.c_str());
|
||||
|
||||
std::stringstream out;
|
||||
out << getpid() << '.';
|
||||
out << basename(name);
|
||||
|
||||
delete [] name;
|
||||
return out.str();
|
||||
}
|
||||
|
||||
void bits(const char* progname)
|
||||
{
|
||||
char* arg0 = strdup(progname);
|
||||
char* cmd = basename(arg0);
|
||||
|
||||
termcolor::set(termcolor::WHITE, termcolor::BLACK, termcolor::DIM);
|
||||
if (!strcmp(cmd, "runtest64"))
|
||||
{
|
||||
std::cout << "Running in 64-bit mode.\n";
|
||||
DYLD_COMMAND = "dyld64";
|
||||
}
|
||||
else if (!strcmp(cmd, "runtest32"))
|
||||
{
|
||||
std::cout << "Running in 32-bit mode.\n";
|
||||
DYLD_COMMAND = "dyld32";
|
||||
}
|
||||
termcolor::reset();
|
||||
|
||||
free(arg0);
|
||||
}
|
||||
|
||||
std::string stripext(std::string file)
|
||||
{
|
||||
size_t pos = file.rfind('.');
|
||||
if (pos == std::string::npos)
|
||||
return file;
|
||||
return file.substr(0, pos);
|
||||
}
|
||||
|
@ -1 +0,0 @@
|
||||
runtest
|
@ -1 +0,0 @@
|
||||
runtest
|
@ -1,14 +0,0 @@
|
||||
#include "termcolor.h"
|
||||
#include <unistd.h>
|
||||
#include <iostream>
|
||||
|
||||
const bool isTty = isatty(1) != 0;
|
||||
|
||||
void termcolor::set(int text, int bg, int attrib)
|
||||
{
|
||||
if (!isTty)
|
||||
return;
|
||||
|
||||
std::cout << "\x1b[" << attrib << ';' << (text + 30) << ';' << (bg + 40) << 'm' << std::flush;
|
||||
}
|
||||
|
@ -1,31 +0,0 @@
|
||||
#ifndef TERMCOLOR_H
|
||||
#define TERMCOLOR_H
|
||||
|
||||
namespace termcolor
|
||||
{
|
||||
|
||||
const int RESET = 0;
|
||||
const int BRIGHT = 1;
|
||||
const int DIM = 2;
|
||||
const int UNDERLINE = 3;
|
||||
const int BLINK = 4;
|
||||
const int REVERSE = 7;
|
||||
const int HIDDEN = 8;
|
||||
|
||||
const int BLACK = 0;
|
||||
const int RED = 1;
|
||||
const int GREEN = 2;
|
||||
const int YELLOW = 3;
|
||||
const int BLUE = 4;
|
||||
const int MAGENTA = 5;
|
||||
const int CYAN = 6;
|
||||
const int WHITE = 7;
|
||||
|
||||
void set(int text, int bg = BLACK, int attrib = RESET);
|
||||
inline void setBright(int text, int bg = BLACK) { set(text, bg, BRIGHT); }
|
||||
inline void reset() { set(WHITE); }
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -1,12 +0,0 @@
|
||||
#include "timer.h"
|
||||
|
||||
void timer::start()
|
||||
{
|
||||
m_start = ::time(nullptr);
|
||||
}
|
||||
|
||||
int timer::stop()
|
||||
{
|
||||
return ::time(nullptr) - m_start;
|
||||
}
|
||||
|
@ -1,15 +0,0 @@
|
||||
#ifndef TIMER_H
|
||||
#define TIMER_H
|
||||
#include <ctime>
|
||||
|
||||
class timer
|
||||
{
|
||||
public:
|
||||
void start();
|
||||
int stop();
|
||||
private:
|
||||
time_t m_start;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user