Merge "liblog: don't return 0xFFFFFFFF as an invalid log id."
This commit is contained in:
commit
49a8eecc5f
2 changed files with 15 additions and 2 deletions
|
|
@ -50,8 +50,9 @@ log_id_t android_name_to_log_id(const char* logName) {
|
||||||
unsigned int ret;
|
unsigned int ret;
|
||||||
|
|
||||||
if (!logName) {
|
if (!logName) {
|
||||||
return static_cast<log_id_t>(0xFFFFFFFF);
|
return static_cast<log_id_t>(LOG_ID_MAX);
|
||||||
}
|
}
|
||||||
|
|
||||||
b = strrchr(logName, '/');
|
b = strrchr(logName, '/');
|
||||||
if (!b) {
|
if (!b) {
|
||||||
b = logName;
|
b = logName;
|
||||||
|
|
@ -65,5 +66,6 @@ log_id_t android_name_to_log_id(const char* logName) {
|
||||||
return static_cast<log_id_t>(ret);
|
return static_cast<log_id_t>(ret);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return static_cast<log_id_t>(0xFFFFFFFF); /* should never happen */
|
|
||||||
|
return static_cast<log_id_t>(LOG_ID_MAX);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,7 @@
|
||||||
#include <android-base/file.h>
|
#include <android-base/file.h>
|
||||||
#include <android-base/macros.h>
|
#include <android-base/macros.h>
|
||||||
#include <android-base/stringprintf.h>
|
#include <android-base/stringprintf.h>
|
||||||
|
#include <android-base/strings.h>
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
#include <log/event_tag_map.h>
|
#include <log/event_tag_map.h>
|
||||||
#include <log/log.h>
|
#include <log/log.h>
|
||||||
|
|
@ -1747,3 +1748,13 @@ TEST(logcat, help) {
|
||||||
EXPECT_EQ(logcatHelpTextSize * 2, logcatLastHelpTextSize);
|
EXPECT_EQ(logcatHelpTextSize * 2, logcatLastHelpTextSize);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(logcat, invalid_buffer) {
|
||||||
|
FILE* fp = popen("logcat -b foo 2>&1", "r");
|
||||||
|
ASSERT_NE(nullptr, fp);
|
||||||
|
std::string output;
|
||||||
|
ASSERT_TRUE(android::base::ReadFdToString(fileno(fp), &output));
|
||||||
|
pclose(fp);
|
||||||
|
|
||||||
|
ASSERT_TRUE(android::base::StartsWith(output, "unknown buffer foo\n"));
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue