summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/utils/Errors.h4
-rwxr-xr-xinit/perfboot.py11
-rw-r--r--libutils/String8.cpp3
-rw-r--r--libutils/tests/BitSet_test.cpp16
-rw-r--r--libutils/tests/LruCache_test.cpp14
-rw-r--r--libutils/tests/Vector_test.cpp12
6 files changed, 35 insertions, 25 deletions
diff --git a/include/utils/Errors.h b/include/utils/Errors.h
index 9402614f6..08ddcd25c 100644
--- a/include/utils/Errors.h
+++ b/include/utils/Errors.h
@@ -23,7 +23,7 @@
namespace android {
// use this type to return error codes
-#ifdef HAVE_MS_C_RUNTIME
+#ifdef _WIN32
typedef int status_t;
#else
typedef int32_t status_t;
@@ -58,7 +58,7 @@ enum {
ALREADY_EXISTS = -EEXIST,
DEAD_OBJECT = -EPIPE,
FAILED_TRANSACTION = (UNKNOWN_ERROR + 2),
-#if !defined(HAVE_MS_C_RUNTIME)
+#if !defined(_WIN32)
BAD_INDEX = -EOVERFLOW,
NOT_ENOUGH_DATA = -ENODATA,
WOULD_BLOCK = -EWOULDBLOCK,
diff --git a/init/perfboot.py b/init/perfboot.py
index b0efb1183..2a17ab6f2 100755
--- a/init/perfboot.py
+++ b/init/perfboot.py
@@ -408,7 +408,10 @@ def parse_args():
parser.add_argument('-t', '--tags', help='Specify the filename from which '
'event tags are read. Every line contains one event '
'tag and the last event tag is used to detect that '
- 'the device has finished booting.')
+ 'the device has finished booting unless --end-tag is '
+ 'specified.')
+ parser.add_argument('--end-tag', help='An event tag on which the script '
+ 'stops measuring the boot time.')
parser.add_argument('--apk-dir', help='Specify the directory which contains '
'APK files to be installed before measuring boot time.')
return parser.parse_args()
@@ -439,10 +442,14 @@ def main():
record_list = []
event_tags = filter_event_tags(read_event_tags(args.tags), device)
+ end_tag = args.end_tag or event_tags[-1]
+ if end_tag not in event_tags:
+ sys.exit('%s is not a valid tag.' % end_tag)
+ event_tags = event_tags[0 : event_tags.index(end_tag) + 1]
init_perf(device, args.output, record_list, event_tags)
interval_adjuster = IntervalAdjuster(args.interval, device)
event_tags_re = make_event_tags_re(event_tags)
- end_tag = event_tags[-1]
+
for i in range(args.iterations):
print 'Run #%d ' % i
record = do_iteration(
diff --git a/libutils/String8.cpp b/libutils/String8.cpp
index 28be60fb5..69313ead7 100644
--- a/libutils/String8.cpp
+++ b/libutils/String8.cpp
@@ -79,6 +79,9 @@ void terminate_string8()
static char* allocFromUTF8(const char* in, size_t len)
{
if (len > 0) {
+ if (len == SIZE_MAX) {
+ return NULL;
+ }
SharedBuffer* buf = SharedBuffer::alloc(len+1);
ALOG_ASSERT(buf, "Unable to allocate shared buffer");
if (buf) {
diff --git a/libutils/tests/BitSet_test.cpp b/libutils/tests/BitSet_test.cpp
index 38b668aff..59d913e6b 100644
--- a/libutils/tests/BitSet_test.cpp
+++ b/libutils/tests/BitSet_test.cpp
@@ -138,11 +138,11 @@ TEST_F(BitSet32Test, FillAndClear) {
TEST_F(BitSet32Test, GetIndexOfBit) {
b1.markBit(1);
b1.markBit(4);
- EXPECT_EQ(b1.getIndexOfBit(1), 0);
- EXPECT_EQ(b1.getIndexOfBit(4), 1);
+ EXPECT_EQ(0U, b1.getIndexOfBit(1));
+ EXPECT_EQ(1U, b1.getIndexOfBit(4));
b1.markFirstUnmarkedBit();
- EXPECT_EQ(b1.getIndexOfBit(1), 1);
- EXPECT_EQ(b1.getIndexOfBit(4), 2);
+ EXPECT_EQ(1U, b1.getIndexOfBit(1));
+ EXPECT_EQ(2U, b1.getIndexOfBit(4));
}
class BitSet64Test : public testing::Test {
@@ -260,11 +260,11 @@ TEST_F(BitSet64Test, FillAndClear) {
TEST_F(BitSet64Test, GetIndexOfBit) {
b1.markBit(10);
b1.markBit(40);
- EXPECT_EQ(b1.getIndexOfBit(10), 0);
- EXPECT_EQ(b1.getIndexOfBit(40), 1);
+ EXPECT_EQ(0U, b1.getIndexOfBit(10));
+ EXPECT_EQ(1U, b1.getIndexOfBit(40));
b1.markFirstUnmarkedBit();
- EXPECT_EQ(b1.getIndexOfBit(10), 1);
- EXPECT_EQ(b1.getIndexOfBit(40), 2);
+ EXPECT_EQ(1U, b1.getIndexOfBit(10));
+ EXPECT_EQ(2U, b1.getIndexOfBit(40));
}
} // namespace android
diff --git a/libutils/tests/LruCache_test.cpp b/libutils/tests/LruCache_test.cpp
index 653421110..6155defd4 100644
--- a/libutils/tests/LruCache_test.cpp
+++ b/libutils/tests/LruCache_test.cpp
@@ -220,7 +220,7 @@ TEST_F(LruCacheTest, NoLeak) {
cache.put(ComplexKey(0), ComplexValue(0));
cache.put(ComplexKey(1), ComplexValue(1));
- EXPECT_EQ(2, cache.size());
+ EXPECT_EQ(2U, cache.size());
assertInstanceCount(2, 3); // the null value counts as an instance
}
@@ -229,7 +229,7 @@ TEST_F(LruCacheTest, Clear) {
cache.put(ComplexKey(0), ComplexValue(0));
cache.put(ComplexKey(1), ComplexValue(1));
- EXPECT_EQ(2, cache.size());
+ EXPECT_EQ(2U, cache.size());
assertInstanceCount(2, 3);
cache.clear();
assertInstanceCount(0, 1);
@@ -241,7 +241,7 @@ TEST_F(LruCacheTest, ClearNoDoubleFree) {
cache.put(ComplexKey(0), ComplexValue(0));
cache.put(ComplexKey(1), ComplexValue(1));
- EXPECT_EQ(2, cache.size());
+ EXPECT_EQ(2U, cache.size());
assertInstanceCount(2, 3);
cache.removeOldest();
cache.clear();
@@ -255,13 +255,13 @@ TEST_F(LruCacheTest, ClearReuseOk) {
cache.put(ComplexKey(0), ComplexValue(0));
cache.put(ComplexKey(1), ComplexValue(1));
- EXPECT_EQ(2, cache.size());
+ EXPECT_EQ(2U, cache.size());
assertInstanceCount(2, 3);
cache.clear();
assertInstanceCount(0, 1);
cache.put(ComplexKey(0), ComplexValue(0));
cache.put(ComplexKey(1), ComplexValue(1));
- EXPECT_EQ(2, cache.size());
+ EXPECT_EQ(2U, cache.size());
assertInstanceCount(2, 3);
}
@@ -273,7 +273,7 @@ TEST_F(LruCacheTest, Callback) {
cache.put(1, "one");
cache.put(2, "two");
cache.put(3, "three");
- EXPECT_EQ(3, cache.size());
+ EXPECT_EQ(3U, cache.size());
cache.removeOldest();
EXPECT_EQ(1, callback.callbackCount);
EXPECT_EQ(1, callback.lastKey);
@@ -288,7 +288,7 @@ TEST_F(LruCacheTest, CallbackOnClear) {
cache.put(1, "one");
cache.put(2, "two");
cache.put(3, "three");
- EXPECT_EQ(3, cache.size());
+ EXPECT_EQ(3U, cache.size());
cache.clear();
EXPECT_EQ(3, callback.callbackCount);
}
diff --git a/libutils/tests/Vector_test.cpp b/libutils/tests/Vector_test.cpp
index d29c05445..0ba7161aa 100644
--- a/libutils/tests/Vector_test.cpp
+++ b/libutils/tests/Vector_test.cpp
@@ -45,26 +45,26 @@ TEST_F(VectorTest, CopyOnWrite_CopyAndAddElements) {
vector.add(2);
vector.add(3);
- EXPECT_EQ(vector.size(), 3);
+ EXPECT_EQ(3U, vector.size());
// copy the vector
other = vector;
- EXPECT_EQ(other.size(), 3);
+ EXPECT_EQ(3U, other.size());
// add an element to the first vector
vector.add(4);
// make sure the sizes are correct
- EXPECT_EQ(vector.size(), 4);
- EXPECT_EQ(other.size(), 3);
+ EXPECT_EQ(4U, vector.size());
+ EXPECT_EQ(3U, other.size());
// add an element to the copy
other.add(5);
// make sure the sizes are correct
- EXPECT_EQ(vector.size(), 4);
- EXPECT_EQ(other.size(), 4);
+ EXPECT_EQ(4U, vector.size());
+ EXPECT_EQ(4U, other.size());
// make sure the content of both vectors are correct
EXPECT_EQ(vector[3], 4);