OSDN Git Service

Merge git://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf
[tomoyo/tomoyo-test1.git] / lib / test_printf.c
index 2d9f520..6b1622f 100644 (file)
@@ -214,6 +214,7 @@ test_string(void)
 #define PTR_STR "ffff0123456789ab"
 #define PTR_VAL_NO_CRNG "(____ptrval____)"
 #define ZEROS "00000000"       /* hex 32 zero bits */
+#define ONES "ffffffff"                /* hex 32 one bits */
 
 static int __init
 plain_format(void)
@@ -245,6 +246,7 @@ plain_format(void)
 #define PTR_STR "456789ab"
 #define PTR_VAL_NO_CRNG "(ptrval)"
 #define ZEROS ""
+#define ONES ""
 
 static int __init
 plain_format(void)
@@ -330,14 +332,28 @@ test_hashed(const char *fmt, const void *p)
        test(buf, fmt, p);
 }
 
+/*
+ * NULL pointers aren't hashed.
+ */
 static void __init
 null_pointer(void)
 {
-       test_hashed("%p", NULL);
+       test(ZEROS "00000000", "%p", NULL);
        test(ZEROS "00000000", "%px", NULL);
        test("(null)", "%pE", NULL);
 }
 
+/*
+ * Error pointers aren't hashed.
+ */
+static void __init
+error_pointer(void)
+{
+       test(ONES "fffffff5", "%p", ERR_PTR(-11));
+       test(ONES "fffffff5", "%px", ERR_PTR(-11));
+       test("(efault)", "%pE", ERR_PTR(-11));
+}
+
 #define PTR_INVALID ((void *)0x000000ab)
 
 static void __init
@@ -649,6 +665,7 @@ test_pointer(void)
 {
        plain();
        null_pointer();
+       error_pointer();
        invalid_pointer();
        symbol_ptr();
        kernel_ptr();