logcat: Add logcat test suite

(cherry picked from commit 2807db9a269baaa7b3f67c337d3312877ba90aa0)

Change-Id: Ic4c84b88b8d899965c9765bdc3ee223ef73ba7d1
diff --git a/logcat/logcat.cpp b/logcat/logcat.cpp
index b6ca171..a54167e 100644
--- a/logcat/logcat.cpp
+++ b/logcat/logcat.cpp
@@ -1,25 +1,26 @@
-// Copyright 2006-2013 The Android Open Source Project
+// Copyright 2006-2014 The Android Open Source Project
 
+#include <assert.h>
+#include <ctype.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdarg.h>
+#include <string.h>
+#include <signal.h>
+#include <time.h>
+#include <unistd.h>
+#include <sys/socket.h>
+#include <sys/stat.h>
+#include <arpa/inet.h>
+
+#include <cutils/sockets.h>
 #include <log/log.h>
 #include <log/logger.h>
 #include <log/logd.h>
 #include <log/logprint.h>
 #include <log/event_tag_map.h>
-#include <cutils/sockets.h>
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <stdarg.h>
-#include <string.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <time.h>
-#include <errno.h>
-#include <assert.h>
-#include <ctype.h>
-#include <sys/socket.h>
-#include <sys/stat.h>
-#include <arpa/inet.h>
 
 #define DEFAULT_LOG_ROTATE_SIZE_KBYTES 16
 #define DEFAULT_MAX_ROTATED_LOGS 4
@@ -284,6 +285,8 @@
     struct logger_list *logger_list;
     int tail_lines = 0;
 
+    signal(SIGPIPE, exit);
+
     g_logformat = android_log_format_new();
 
     if (argc == 2 && 0 == strcmp(argv[1], "--test")) {