You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@orc.apache.org by om...@apache.org on 2016/07/09 04:25:18 UTC
[2/2] orc git commit: ORC-82. Compilation fix for ubuntu 12.
ORC-82. Compilation fix for ubuntu 12.
Signed-off-by: Owen O'Malley <om...@apache.org>
Project: http://git-wip-us.apache.org/repos/asf/orc/repo
Commit: http://git-wip-us.apache.org/repos/asf/orc/commit/24bf8e52
Tree: http://git-wip-us.apache.org/repos/asf/orc/tree/24bf8e52
Diff: http://git-wip-us.apache.org/repos/asf/orc/diff/24bf8e52
Branch: refs/heads/master
Commit: 24bf8e528b2d94710db2b91d380079307c1a939b
Parents: 2356c7c
Author: Owen O'Malley <om...@apache.org>
Authored: Thu Jul 7 22:44:11 2016 -0700
Committer: Owen O'Malley <om...@apache.org>
Committed: Fri Jul 8 21:24:43 2016 -0700
----------------------------------------------------------------------
CMakeLists.txt | 7 ++--
tools/test/TestFileScan.cc | 77 ++++++++++++++++++++++++++++++++++-------
2 files changed, 67 insertions(+), 17 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/orc/blob/24bf8e52/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 0b3d831..3c75ce0 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -71,6 +71,7 @@ set (ZLIB_LIBRARIES zlib)
set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O3 -g -DNDEBUG")
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG")
+message(STATUS "compiler ${CMAKE_CXX_COMPILER_ID} version ${CMAKE_CXX_COMPILER_VERSION}")
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
set (CXX11_FLAGS "-std=c++11")
set (WARN_FLAGS "-Weverything -Wno-c++98-compat -Wno-missing-prototypes")
@@ -80,10 +81,8 @@ if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
set (WARN_FLAGS "${WARN_FLAGS} -Wconversion -Werror")
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set (WARN_FLAGS "-Wall -Wno-unknown-pragmas -Wconversion -Werror")
- if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS "4.3")
- set (CXX11_FLAGS "")
- set (WARN_FLAGS "-Wformat -Werror")
- elseif (CMAKE_CXX_COMPILER_VERSION VERSION_LESS "4.7")
+ if (CMAKE_CXX_COMPILER_VERSION STREQUAL "" OR
+ CMAKE_CXX_COMPILER_VERSION VERSION_LESS "4.7")
set (CXX11_FLAGS "-std=c++0x")
else ()
set (CXX11_FLAGS "-std=c++11")
http://git-wip-us.apache.org/repos/asf/orc/blob/24bf8e52/tools/test/TestFileScan.cc
----------------------------------------------------------------------
diff --git a/tools/test/TestFileScan.cc b/tools/test/TestFileScan.cc
index 586102c..c8b5fe8 100644
--- a/tools/test/TestFileScan.cc
+++ b/tools/test/TestFileScan.cc
@@ -34,53 +34,104 @@ TEST (TestFileScan, testNominal) {
EXPECT_EQ("Rows: 32768\nBatches: 33\n", output);
EXPECT_EQ("", error);
- EXPECT_EQ(0, runProgram({pgm, "-b", "256", file}, output, error));
+ EXPECT_EQ(0, runProgram({pgm, std::string("-b"), std::string("256"), file},
+ output, error));
EXPECT_EQ("Rows: 32768\nBatches: 131\n", output);
EXPECT_EQ("", error);
- EXPECT_EQ(0, runProgram({pgm, "-b256", file}, output, error));
+ EXPECT_EQ(0, runProgram({pgm, std::string("-b256"), file}, output, error));
EXPECT_EQ("Rows: 32768\nBatches: 131\n", output);
EXPECT_EQ("", error);
- EXPECT_EQ(0, runProgram({pgm, "--batch", "256", file}, output, error));
+ EXPECT_EQ(0, runProgram({pgm, std::string("--batch"), std::string("256"),
+ file}, output, error));
EXPECT_EQ("Rows: 32768\nBatches: 131\n", output);
EXPECT_EQ("", error);
- EXPECT_EQ(0, runProgram({pgm, "--batch=256", file}, output, error));
+ EXPECT_EQ(0, runProgram({pgm, std::string("--batch=256"), file},
+ output, error));
EXPECT_EQ("Rows: 32768\nBatches: 131\n", output);
EXPECT_EQ("", error);
}
+/**
+ * This function locates the goal substring in the input and removes
+ * everything before it.
+ * stripPrefix("abcdef", "cd") -> "cdef"
+ * stripPrefix("abcdef", "xx") -> "abcdef"
+ */
+std::string stripPrefix(const std::string& input, const std::string goal) {
+ size_t loc = input.find(goal);
+ if (loc == std::string::npos) {
+ return input;
+ } else {
+ return input.substr(loc);
+ }
+}
+
+std::string removeChars(const std::string &input,
+ const std::string& chars) {
+ std::string result;
+ size_t prev = 0;
+ size_t pos = input.find_first_of(chars);
+ while (pos != std::string::npos) {
+ if (pos > prev) {
+ result += input.substr(prev, pos - prev);
+ }
+ prev = pos + 1;
+ pos = input.find_first_of(chars, prev);
+ }
+ pos = input.length();
+ if (pos > prev) {
+ result += input.substr(prev, pos - prev);
+ }
+ return result;
+}
+
+TEST (TestFileScan, testRemoveChars) {
+ EXPECT_EQ("abcdef", removeChars("abcdef", "xyz"));
+ EXPECT_EQ("bbbddd", removeChars("aaabbbcccddd", "ca"));
+ EXPECT_EQ("aaaccc", removeChars("aaabbbcccddd", "bd"));
+ EXPECT_EQ("abcde", removeChars("axbxcxdxe", "x"));
+}
+
TEST (TestFileScan, testBadCommand) {
const std::string pgm = findProgram("tools/src/orc-scan");
const std::string file = findExample("TestOrcFile.testSeek.orc");
std::string output;
std::string error;
- EXPECT_EQ(1, runProgram({pgm, file, "-b"}, output, error));
+ EXPECT_EQ(1, runProgram({pgm, file, std::string("-b")}, output, error));
EXPECT_EQ("", output);
EXPECT_EQ("orc-scan: option requires an argument -- b\n"
"Usage: orc-scan [-h] [--help]\n"
- " [-b<size>] [--batch=<size>] <filename>\n", error);
+ " [-b<size>] [--batch=<size>] <filename>\n",
+ removeChars(stripPrefix(error, "orc-scan: "),"'`"));
- EXPECT_EQ(1, runProgram({pgm, file, "-b", "20x"}, output, error));
+ EXPECT_EQ(1, runProgram({pgm, file, std::string("-b"),
+ std::string("20x")}, output, error));
EXPECT_EQ("", output);
EXPECT_EQ("The --batch parameter requires an integer option.\n", error);
- EXPECT_EQ(1, runProgram({pgm, file, "-b", "x30"}, output, error));
+ EXPECT_EQ(1, runProgram({pgm, file, std::string("-b"),
+ std::string("x30")}, output, error));
EXPECT_EQ("", output);
EXPECT_EQ("The --batch parameter requires an integer option.\n", error);
- EXPECT_EQ(1, runProgram({pgm, file, "--batch"}, output, error));
+ EXPECT_EQ(1, runProgram({pgm, file, std::string("--batch")},
+ output, error));
EXPECT_EQ("", output);
- EXPECT_EQ("orc-scan: option `--batch' requires an argument\n"
+ EXPECT_EQ("orc-scan: option --batch requires an argument\n"
"Usage: orc-scan [-h] [--help]\n"
- " [-b<size>] [--batch=<size>] <filename>\n", error);
+ " [-b<size>] [--batch=<size>] <filename>\n",
+ removeChars(stripPrefix(error, "orc-scan: "), "'`"));
- EXPECT_EQ(1, runProgram({pgm, file, "--batch", "20x"}, output, error));
+ EXPECT_EQ(1, runProgram({pgm, file, std::string("--batch"),
+ std::string("20x")}, output, error));
EXPECT_EQ("", output);
EXPECT_EQ("The --batch parameter requires an integer option.\n", error);
- EXPECT_EQ(1, runProgram({pgm, file, "--batch", "x30"}, output, error));
+ EXPECT_EQ(1, runProgram({pgm, file, std::string("--batch"),
+ std::string("x30")}, output, error));
EXPECT_EQ("", output);
EXPECT_EQ("The --batch parameter requires an integer option.\n", error);
}