hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cmcc...@apache.org
Subject svn commit: r1598774 - in /hadoop/common/branches/HADOOP-10388/hadoop-native-core: common/hadoop_err-unit.c common/hadoop_err.c common/hadoop_err.h rpc/messenger.c rpc/reactor.c
Date Fri, 30 May 2014 23:13:09 GMT
Author: cmccabe
Date: Fri May 30 23:13:08 2014
New Revision: 1598774

URL: http://svn.apache.org/r1598774
Log:
HADOOP-10624. Fix some minor typos and add more test cases for hadoop_err (pengwenwu2008 via
cmccabe)

Modified:
    hadoop/common/branches/HADOOP-10388/hadoop-native-core/common/hadoop_err-unit.c
    hadoop/common/branches/HADOOP-10388/hadoop-native-core/common/hadoop_err.c
    hadoop/common/branches/HADOOP-10388/hadoop-native-core/common/hadoop_err.h
    hadoop/common/branches/HADOOP-10388/hadoop-native-core/rpc/messenger.c
    hadoop/common/branches/HADOOP-10388/hadoop-native-core/rpc/reactor.c

Modified: hadoop/common/branches/HADOOP-10388/hadoop-native-core/common/hadoop_err-unit.c
URL: http://svn.apache.org/viewvc/hadoop/common/branches/HADOOP-10388/hadoop-native-core/common/hadoop_err-unit.c?rev=1598774&r1=1598773&r2=1598774&view=diff
==============================================================================
--- hadoop/common/branches/HADOOP-10388/hadoop-native-core/common/hadoop_err-unit.c (original)
+++ hadoop/common/branches/HADOOP-10388/hadoop-native-core/common/hadoop_err-unit.c Fri May
30 23:13:08 2014
@@ -17,24 +17,112 @@
  */
 
 #include "common/hadoop_err.h"
+
 #include "common/test.h"
 
+#include <string.h>
 #include <errno.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <uv.h>
 
-int main(void)
-{
-    struct hadoop_err *err;
-
-    err = hadoop_lerr_alloc(EINVAL, "foo bar baz %d", 101);
-    EXPECT_STR_EQ("org.apache.hadoop.native.HadoopCore.InvalidRequestException: "
-              "foo bar baz 101", hadoop_err_msg(err));
-    EXPECT_INT_EQ(EINVAL, hadoop_err_code(err));
-    hadoop_err_free(err);
+#define RUNTIME_EXCEPTION_ERROR_CODE EFAULT
+
+static int hadoop_lerr_alloc_test(int code, char *verMsg, char *fmt) {
+	struct hadoop_err *err;
+	err = hadoop_lerr_alloc(code, fmt);
+	EXPECT_STR_EQ(verMsg, hadoop_err_msg(err));
+	EXPECT_INT_EQ(code, hadoop_err_code(err));
+	hadoop_err_free(err);
+	return 0;
+}
+
+static int hadoop_lerr_alloc_test2(int code, char *verMsg) {
+	struct hadoop_err *err;
+	char msg[100];
+	memset(msg, 0, 100);
+	strcat(msg, verMsg);
+	err = hadoop_lerr_alloc(code, "foo bar baz %d", 101);
+	EXPECT_STR_EQ(strcat(msg, "foo bar baz 101"), hadoop_err_msg(err));
+	EXPECT_INT_EQ(code, hadoop_err_code(err));
+	hadoop_err_free(err);
+	return 0;
+}
+
+static int hadoop_uverr_alloc_test(int code, char *verMsg, char *fmt) {
+	struct hadoop_err *err;
+	err = hadoop_uverr_alloc(code, fmt);
+	EXPECT_STR_EQ(verMsg, hadoop_err_msg(err));
+	EXPECT_INT_EQ(code, hadoop_err_code(err));
+	hadoop_err_free(err);
+	return 0;
+}
+
+static int hadoop_uverr_alloc_test2(int code, char *verMsg) {
+	struct hadoop_err *err;
+	char msg[100];
+	memset(msg, 0, 100);
+	strcat(msg, verMsg);
+	err = hadoop_uverr_alloc(code, "foo bar baz %d", 101);
+	EXPECT_STR_EQ(strcat(msg, "foo bar baz 101"), hadoop_err_msg(err));
+	EXPECT_INT_EQ(code, hadoop_err_code(err));
+	hadoop_err_free(err);
+	return 0;
+}
 
-    return EXIT_SUCCESS;
+int main(void) {
+	hadoop_lerr_alloc_test(RUNTIME_EXCEPTION_ERROR_CODE,
+			"org.apache.hadoop.native.HadoopCore.RuntimeException: "
+					"test RUNTIME_EXCEPTION_ERROR_CODE",
+			"test RUNTIME_EXCEPTION_ERROR_CODE");
+	hadoop_lerr_alloc_test(EINVAL,
+			"org.apache.hadoop.native.HadoopCore.InvalidRequestException: "
+					"test EINVAL", "test EINVAL");
+	hadoop_lerr_alloc_test(ENOMEM,
+			"org.apache.hadoop.native.HadoopCore.OutOfMemoryException: "
+					"test ENOMEM", "test ENOMEM");
+	hadoop_lerr_alloc_test(0,
+			"org.apache.hadoop.native.HadoopCore.IOException: "
+					"test default", "test default");
+	hadoop_uverr_alloc_test(UV_EOF,
+			"org.apache.hadoop.native.HadoopCore.EOFException: end of file: "
+					"test UV_EOF", "test UV_EOF");
+	hadoop_uverr_alloc_test(UV_EINVAL,
+			"org.apache.hadoop.native.HadoopCore.InvalidRequestException: "
+					"invalid argument: test UV_EINVAL", "test UV_EINVAL");
+	hadoop_uverr_alloc_test(UV_ECONNREFUSED,
+			"org.apache.hadoop.native.HadoopCore.ConnectionRefusedException: "
+					"connection refused: test UV_ECONNREFUSED",
+			"test UV_ECONNREFUSED");
+	hadoop_uverr_alloc_test(UV_ENOMEM,
+			"org.apache.hadoop.native.HadoopCore.OutOfMemoryException: "
+					"not enough memory: test UV_ENOMEM", "test UV_ENOMEM");
+	hadoop_uverr_alloc_test(0,
+			"org.apache.hadoop.native.HadoopCore.IOException: "
+					"Unknown system error: test default", "test default");
+	hadoop_lerr_alloc_test2(EINVAL,
+			"org.apache.hadoop.native.HadoopCore.InvalidRequestException: ");
+	hadoop_lerr_alloc_test2(RUNTIME_EXCEPTION_ERROR_CODE,
+			"org.apache.hadoop.native.HadoopCore.RuntimeException: ");
+	hadoop_lerr_alloc_test2(ENOMEM,
+			"org.apache.hadoop.native.HadoopCore.OutOfMemoryException: ");
+	hadoop_lerr_alloc_test2(0,
+			"org.apache.hadoop.native.HadoopCore.IOException: ");
+	hadoop_uverr_alloc_test2(UV_EOF,
+			"org.apache.hadoop.native.HadoopCore.EOFException: end of file: ");
+	hadoop_uverr_alloc_test2(UV_EINVAL,
+			"org.apache.hadoop.native.HadoopCore.InvalidRequestException: "
+					"invalid argument: ");
+	hadoop_uverr_alloc_test2(UV_ECONNREFUSED,
+			"org.apache.hadoop.native.HadoopCore.ConnectionRefusedException: "
+					"connection refused: ");
+	hadoop_uverr_alloc_test2(UV_ENOMEM,
+			"org.apache.hadoop.native.HadoopCore.OutOfMemoryException: "
+					"not enough memory: ");
+	hadoop_uverr_alloc_test2(0,
+			"org.apache.hadoop.native.HadoopCore.IOException: "
+					"Unknown system error: ");
+	return EXIT_SUCCESS;
 }
 
 // vim: ts=4:sw=4:tw=79:et

Modified: hadoop/common/branches/HADOOP-10388/hadoop-native-core/common/hadoop_err.c
URL: http://svn.apache.org/viewvc/hadoop/common/branches/HADOOP-10388/hadoop-native-core/common/hadoop_err.c?rev=1598774&r1=1598773&r2=1598774&view=diff
==============================================================================
--- hadoop/common/branches/HADOOP-10388/hadoop-native-core/common/hadoop_err.c (original)
+++ hadoop/common/branches/HADOOP-10388/hadoop-native-core/common/hadoop_err.c Fri May 30
23:13:08 2014
@@ -60,7 +60,7 @@ static const char *errno_to_class(int co
     case EINVAL:
         return "org.apache.hadoop.native.HadoopCore.InvalidRequestException";
     case ENOMEM:
-        return "org.apache.hadoop.native.HadoopCore.OutOfMemory";
+        return "org.apache.hadoop.native.HadoopCore.OutOfMemoryException";
     default:
         return "org.apache.hadoop.native.HadoopCore.IOException";
     }

Modified: hadoop/common/branches/HADOOP-10388/hadoop-native-core/common/hadoop_err.h
URL: http://svn.apache.org/viewvc/hadoop/common/branches/HADOOP-10388/hadoop-native-core/common/hadoop_err.h?rev=1598774&r1=1598773&r2=1598774&view=diff
==============================================================================
--- hadoop/common/branches/HADOOP-10388/hadoop-native-core/common/hadoop_err.h (original)
+++ hadoop/common/branches/HADOOP-10388/hadoop-native-core/common/hadoop_err.h Fri May 30
23:13:08 2014
@@ -47,7 +47,7 @@ struct hadoop_err *hadoop_lerr_alloc(int
  *
  * @return              A new error message.  This will never be NULL.
  */
-struct hadoop_err *hadoop_uverr_alloc(int cod, const char *fmt, ...)
+struct hadoop_err *hadoop_uverr_alloc(int code, const char *fmt, ...)
     __attribute__((format(printf, 2, 3)));
 
 /**

Modified: hadoop/common/branches/HADOOP-10388/hadoop-native-core/rpc/messenger.c
URL: http://svn.apache.org/viewvc/hadoop/common/branches/HADOOP-10388/hadoop-native-core/rpc/messenger.c?rev=1598774&r1=1598773&r2=1598774&view=diff
==============================================================================
--- hadoop/common/branches/HADOOP-10388/hadoop-native-core/rpc/messenger.c (original)
+++ hadoop/common/branches/HADOOP-10388/hadoop-native-core/rpc/messenger.c Fri May 30 23:13:08
2014
@@ -31,7 +31,7 @@
 #define msgr_log_info(msgr, fmt, ...) \
     fprintf(stderr, "INFO: msgr %p: " fmt, msgr, __VA_ARGS__)
 #define msgr_log_debug(msgr, fmt, ...) \
-    fprintf(stderr, "DBUG: msgr %p: " fmt, msgr, __VA_ARGS__)
+    fprintf(stderr, "DEBUG: msgr %p: " fmt, msgr, __VA_ARGS__)
 
 struct hrpc_messenger_builder {
 };

Modified: hadoop/common/branches/HADOOP-10388/hadoop-native-core/rpc/reactor.c
URL: http://svn.apache.org/viewvc/hadoop/common/branches/HADOOP-10388/hadoop-native-core/rpc/reactor.c?rev=1598774&r1=1598773&r2=1598774&view=diff
==============================================================================
--- hadoop/common/branches/HADOOP-10388/hadoop-native-core/rpc/reactor.c (original)
+++ hadoop/common/branches/HADOOP-10388/hadoop-native-core/rpc/reactor.c Fri May 30 23:13:08
2014
@@ -35,7 +35,7 @@
 #define reactor_log_info(msgr, fmt, ...) \
     fprintf(stderr, "INFO: reactor %p: " fmt, reactor, __VA_ARGS__)
 #define reactor_log_debug(msgr, fmt, ...) \
-    fprintf(stderr, "DBUG: reactor %p: " fmt, reactor, __VA_ARGS__)
+    fprintf(stderr, "DEBUG: reactor %p: " fmt, reactor, __VA_ARGS__)
 
 RB_GENERATE(hrpc_conns, hrpc_conn, entry, hrpc_conn_compare);
 



Mime
View raw message