//===----------------------------------------------------------------------===//
#include "ExecuteFunction.h"
-#include "llvm/Support/raw_ostream.h"
#include <cassert>
#include <cstdlib>
+#include <cstring>
+#include <iostream>
#include <memory>
#include <poll.h>
#include <signal.h>
return ProcessStatus::Error("pipe(2) failed");
// Don't copy the buffers into the child process and print twice.
- llvm::outs().flush();
- llvm::errs().flush();
+ std::cout.flush();
+ std::cerr.flush();
pid_t Pid = ::fork();
if (Pid == -1)
return ProcessStatus::Error("fork(2) failed");
//===----------------------------------------------------------------------===//
#include "FDReader.h"
-#include "llvm/Support/MemoryBuffer.h"
#include <cassert>
#include <cstring>
+#include <iostream>
#include <unistd.h>
namespace __llvm_libc {
namespace testutils {
FDReader::FDReader() {
- if (::pipe(pipefd))
- llvm::report_fatal_error("pipe(2) failed");
+ if (::pipe(pipefd)) {
+ std::cerr << "pipe(2) failed";
+ abort();
+ }
}
FDReader::~FDReader() {
}
bool FDReader::matchWritten(const char *str) {
- llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> bufOrErr =
- llvm::MemoryBuffer::getOpenFile(pipefd[0], "<pipe>",
- /* FileSize (irrelevant) */ 0);
- if (!bufOrErr) {
- assert(0 && "Error reading from pipe");
- return false;
+
+ ::close(pipefd[1]);
+
+ constexpr ssize_t ChunkSize = 4096 * 4;
+
+ char Buffer[ChunkSize];
+ std::string PipeStr;
+ std::string InputStr(str);
+
+ for (int BytesRead; (BytesRead = ::read(pipefd[0], Buffer, ChunkSize));) {
+ if (BytesRead > 0) {
+ PipeStr.insert(PipeStr.size(), Buffer, BytesRead);
+ } else {
+ assert(0 && "Error reading from pipe");
+ return false;
+ }
}
- const llvm::MemoryBuffer &buf = **bufOrErr;
- return !std::strncmp(buf.getBufferStart(), str, buf.getBufferSize());
+
+ return PipeStr == InputStr;
}
} // namespace testutils
//===----------------------------------------------------------------------===//
#include "StreamWrapper.h"
-#include "llvm/Support/raw_ostream.h"
#include <cassert>
+#include <iostream>
#include <memory>
#include <string>
namespace __llvm_libc {
namespace testutils {
-StreamWrapper outs() { return {std::addressof(llvm::outs())}; }
+StreamWrapper outs() { return {std::addressof(std::cout)}; }
template <typename T> StreamWrapper &StreamWrapper::operator<<(T t) {
assert(OS);
- llvm::raw_ostream &Stream = *reinterpret_cast<llvm::raw_ostream *>(OS);
+ std::ostream &Stream = *reinterpret_cast<std::ostream *>(OS);
Stream << t;
return *this;
}