Commit 3c83ed5b by Dominic Hamon

Merge pull request #149 from DiracResearch/android-fix

Android fix
parents f7022075 8c71c307
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include "commandlineflags.h" #include "commandlineflags.h"
#include <cstdlib>
#include <cstring> #include <cstring>
#include <iostream> #include <iostream>
#include <limits> #include <limits>
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#include <array> #include <array>
#include <memory> #include <memory>
#include <sstream> #include <sstream>
#include <stdio.h>
#include "arraysize.h" #include "arraysize.h"
...@@ -127,7 +128,8 @@ std::string StringPrintFImp(const char *msg, va_list args) ...@@ -127,7 +128,8 @@ std::string StringPrintFImp(const char *msg, va_list args)
// allocation guess what the size might be // allocation guess what the size might be
std::array<char, 256> local_buff; std::array<char, 256> local_buff;
std::size_t size = local_buff.size(); std::size_t size = local_buff.size();
auto ret = std::vsnprintf(local_buff.data(), size, msg, args_cp); // 2015-10-08: vsnprintf is used instead of snd::vsnprintf due to a limitation in the android-ndk
auto ret = vsnprintf(local_buff.data(), size, msg, args_cp);
va_end(args_cp); va_end(args_cp);
...@@ -141,7 +143,8 @@ std::string StringPrintFImp(const char *msg, va_list args) ...@@ -141,7 +143,8 @@ std::string StringPrintFImp(const char *msg, va_list args)
// add 1 to size to account for null-byte in size cast to prevent overflow // add 1 to size to account for null-byte in size cast to prevent overflow
size = static_cast<std::size_t>(ret) + 1; size = static_cast<std::size_t>(ret) + 1;
auto buff_ptr = std::unique_ptr<char[]>(new char[size]); auto buff_ptr = std::unique_ptr<char[]>(new char[size]);
ret = std::vsnprintf(buff_ptr.get(), size, msg, args); // 2015-10-08: vsnprintf is used instead of snd::vsnprintf due to a limitation in the android-ndk
ret = vsnprintf(buff_ptr.get(), size, msg, args);
return std::string(buff_ptr.get()); return std::string(buff_ptr.get());
} }
......
...@@ -23,9 +23,11 @@ ...@@ -23,9 +23,11 @@
#include <fcntl.h> #include <fcntl.h>
#include <sys/resource.h> #include <sys/resource.h>
#include <sys/types.h> // this header must be included before 'sys/sysctl.h' to avoid compilation error on FreeBSD #include <sys/types.h> // this header must be included before 'sys/sysctl.h' to avoid compilation error on FreeBSD
#include <sys/sysctl.h>
#include <sys/time.h> #include <sys/time.h>
#include <unistd.h> #include <unistd.h>
#if defined BENCHMARK_OS_FREEBSD || defined BENCHMARK_OS_MACOSX
#include <sys/sysctl.h>
#endif
#endif #endif
#include <cerrno> #include <cerrno>
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include <math.h> #include <math.h>
#include <stdint.h> #include <stdint.h>
#include <cstdlib>
#include <iostream> #include <iostream>
#include <limits> #include <limits>
#include <list> #include <list>
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
#include <cassert> #include <cassert>
#include <cmath> #include <cmath>
#include <cstdint> #include <cstdint>
#include <cstdlib>
#include <iostream> #include <iostream>
#include <limits> #include <limits>
...@@ -73,12 +74,18 @@ int main(int argc, char* argv[]) { ...@@ -73,12 +74,18 @@ int main(int argc, char* argv[]) {
TestReporter test_reporter; TestReporter test_reporter;
benchmark::RunSpecifiedBenchmarks(&test_reporter); benchmark::RunSpecifiedBenchmarks(&test_reporter);
// Make sure we ran all of the tests if (argc == 2) {
const size_t count = test_reporter.GetCount(); // Make sure we ran all of the tests
const size_t expected = (argc == 2) ? std::stoul(argv[1]) : count; std::stringstream ss(argv[1]);
if (count != expected) { size_t expected;
std::cerr << "ERROR: Expected " << expected << " tests to be ran but only " ss >> expected;
<< count << " completed" << std::endl;
return -1; const size_t count = test_reporter.GetCount();
if (count != expected) {
std::cerr << "ERROR: Expected " << expected << " tests to be ran but only "
<< count << " completed" << std::endl;
return -1;
}
} }
return 0;
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment