diff options
Diffstat (limited to 'lib/test_printf.c')
| -rw-r--r-- | lib/test_printf.c | 32 | 
1 files changed, 28 insertions, 4 deletions
| diff --git a/lib/test_printf.c b/lib/test_printf.c index 2d9f520d2f27..7d60f24240a4 100644 --- a/lib/test_printf.c +++ b/lib/test_printf.c @@ -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 @@ -478,7 +494,7 @@ struct_va_format(void)  }  static void __init -struct_rtc_time(void) +time_and_date(void)  {  	/* 1543210543 */  	const struct rtc_time tm = { @@ -489,14 +505,21 @@ struct_rtc_time(void)  		.tm_mon = 10,  		.tm_year = 118,  	}; +	/* 2019-01-04T15:32:23 */ +	time64_t t = 1546615943; -	test("(%ptR?)", "%pt", &tm); +	test("(%pt?)", "%pt", &tm);  	test("2018-11-26T05:35:43", "%ptR", &tm);  	test("0118-10-26T05:35:43", "%ptRr", &tm);  	test("05:35:43|2018-11-26", "%ptRt|%ptRd", &tm, &tm);  	test("05:35:43|0118-10-26", "%ptRtr|%ptRdr", &tm, &tm);  	test("05:35:43|2018-11-26", "%ptRttr|%ptRdtr", &tm, &tm);  	test("05:35:43 tr|2018-11-26 tr", "%ptRt tr|%ptRd tr", &tm, &tm); + +	test("2019-01-04T15:32:23", "%ptT", &t); +	test("0119-00-04T15:32:23", "%ptTr", &t); +	test("15:32:23|2019-01-04", "%ptTt|%ptTd", &t, &t); +	test("15:32:23|0119-00-04", "%ptTtr|%ptTdr", &t, &t);  }  static void __init @@ -649,6 +672,7 @@ test_pointer(void)  {  	plain();  	null_pointer(); +	error_pointer();  	invalid_pointer();  	symbol_ptr();  	kernel_ptr(); @@ -661,7 +685,7 @@ test_pointer(void)  	uuid();  	dentry();  	struct_va_format(); -	struct_rtc_time(); +	time_and_date();  	struct_clk();  	bitmap();  	netdev_features(); |