[kbuild:kunit 11/17] kunit/test-test.c:185:2: note: in expansion of macro 'KUNIT_EXPECT_EQ'

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



tree:   https://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild.git kunit
head:   c505c0b2e6237c729634327c178f5b0094f1c958
commit: 3ad04f25d34ca374d43673bb84ddad4196857320 [11/17] kunit: test: add test managed resource tests
config: openrisc-allmodconfig (attached as .config)
compiler: or1k-linux-gcc (GCC) 6.0.0 20160327 (experimental)
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        git checkout 3ad04f25d34ca374d43673bb84ddad4196857320
        # save the attached .config to linux build tree
        make.cross ARCH=openrisc 

If you fix the issue, kindly add following tag
Reported-by: kbuild test robot <lkp@xxxxxxxxx>

All warnings (new ones prefixed by >>):

   In file included from kunit/test-test.c:8:0:
   kunit/test-test.c: In function 'kunit_resource_test_alloc_resource':
>> include/kunit/test.h:444:8: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
           (long long) __left, #left,          \
           ^
>> include/kunit/test.h:473:3: note: in expansion of macro 'KUNIT_EXPECT_BINARY'
      KUNIT_EXPECT_BINARY(test, left, ==, right)
      ^~~~~~~~~~~~~~~~~~~
>> kunit/test-test.c:185:2: note: in expansion of macro 'KUNIT_EXPECT_EQ'
     KUNIT_EXPECT_EQ(test, &ctx->is_resource_initialized, res->allocation);
     ^~~~~~~~~~~~~~~
   include/kunit/test.h:445:8: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
           (long long) __right, #right,         \
           ^
>> include/kunit/test.h:473:3: note: in expansion of macro 'KUNIT_EXPECT_BINARY'
      KUNIT_EXPECT_BINARY(test, left, ==, right)
      ^~~~~~~~~~~~~~~~~~~
>> kunit/test-test.c:185:2: note: in expansion of macro 'KUNIT_EXPECT_EQ'
     KUNIT_EXPECT_EQ(test, &ctx->is_resource_initialized, res->allocation);
     ^~~~~~~~~~~~~~~
>> include/kunit/test.h:444:8: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
           (long long) __left, #left,          \
           ^
>> include/kunit/test.h:473:3: note: in expansion of macro 'KUNIT_EXPECT_BINARY'
      KUNIT_EXPECT_BINARY(test, left, ==, right)
      ^~~~~~~~~~~~~~~~~~~
   kunit/test-test.c:187:2: note: in expansion of macro 'KUNIT_EXPECT_EQ'
     KUNIT_EXPECT_EQ(test, free, res->free);
     ^~~~~~~~~~~~~~~
   include/kunit/test.h:445:8: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
           (long long) __right, #right,         \
           ^
>> include/kunit/test.h:473:3: note: in expansion of macro 'KUNIT_EXPECT_BINARY'
      KUNIT_EXPECT_BINARY(test, left, ==, right)
      ^~~~~~~~~~~~~~~~~~~
   kunit/test-test.c:187:2: note: in expansion of macro 'KUNIT_EXPECT_EQ'
     KUNIT_EXPECT_EQ(test, free, res->free);
     ^~~~~~~~~~~~~~~

vim +/KUNIT_EXPECT_EQ +185 kunit/test-test.c

   > 8	#include <kunit/test.h>
     9	
    10	struct kunit_try_catch_test_context {
    11		struct kunit_try_catch *try_catch;
    12		bool function_called;
    13	};
    14	
    15	void kunit_test_successful_try(void *data)
    16	{
    17		struct kunit *test = data;
    18		struct kunit_try_catch_test_context *ctx = test->priv;
    19	
    20		ctx->function_called = true;
    21	}
    22	
    23	void kunit_test_no_catch(void *data)
    24	{
    25		struct kunit *test = data;
    26	
    27		KUNIT_FAIL(test, "Catch should not be called.\n");
    28	}
    29	
    30	static void kunit_test_try_catch_successful_try_no_catch(struct kunit *test)
    31	{
    32		struct kunit_try_catch_test_context *ctx = test->priv;
    33		struct kunit_try_catch *try_catch = ctx->try_catch;
    34	
    35		kunit_try_catch_init(try_catch,
    36				     test,
    37				     kunit_test_successful_try,
    38				     kunit_test_no_catch);
    39		kunit_try_catch_run(try_catch, test);
    40	
    41		KUNIT_EXPECT_TRUE(test, ctx->function_called);
    42	}
    43	
    44	void kunit_test_unsuccessful_try(void *data)
    45	{
    46		struct kunit *test = data;
    47		struct kunit_try_catch_test_context *ctx = test->priv;
    48		struct kunit_try_catch *try_catch = ctx->try_catch;
    49	
    50		kunit_try_catch_throw(try_catch);
    51		KUNIT_FAIL(test, "This line should never be reached.\n");
    52	}
    53	
    54	void kunit_test_catch(void *data)
    55	{
    56		struct kunit *test = data;
    57		struct kunit_try_catch_test_context *ctx = test->priv;
    58	
    59		ctx->function_called = true;
    60	}
    61	
    62	static void kunit_test_try_catch_unsuccessful_try_does_catch(struct kunit *test)
    63	{
    64		struct kunit_try_catch_test_context *ctx = test->priv;
    65		struct kunit_try_catch *try_catch = ctx->try_catch;
    66	
    67		kunit_try_catch_init(try_catch,
    68				     test,
    69				     kunit_test_unsuccessful_try,
    70				     kunit_test_catch);
    71		kunit_try_catch_run(try_catch, test);
    72	
    73		KUNIT_EXPECT_TRUE(test, ctx->function_called);
    74	}
    75	
    76	static void kunit_test_generic_try_catch_successful_try_no_catch(
    77			struct kunit *test)
    78	{
    79		struct kunit_try_catch_test_context *ctx = test->priv;
    80		struct kunit_try_catch *try_catch = ctx->try_catch;
    81	
    82		try_catch->test = test;
    83		kunit_generic_try_catch_init(try_catch);
    84		try_catch->try = kunit_test_successful_try;
    85		try_catch->catch = kunit_test_no_catch;
    86	
    87		kunit_try_catch_run(try_catch, test);
    88	
    89		KUNIT_EXPECT_TRUE(test, ctx->function_called);
    90	}
    91	
    92	static void kunit_test_generic_try_catch_unsuccessful_try_does_catch(
    93			struct kunit *test)
    94	{
    95		struct kunit_try_catch_test_context *ctx = test->priv;
    96		struct kunit_try_catch *try_catch = ctx->try_catch;
    97	
    98		try_catch->test = test;
    99		kunit_generic_try_catch_init(try_catch);
   100		try_catch->try = kunit_test_unsuccessful_try;
   101		try_catch->catch = kunit_test_catch;
   102	
   103		kunit_try_catch_run(try_catch, test);
   104	
   105		KUNIT_EXPECT_TRUE(test, ctx->function_called);
   106	}
   107	
   108	static int kunit_try_catch_test_init(struct kunit *test)
   109	{
   110		struct kunit_try_catch_test_context *ctx;
   111	
   112		ctx = kunit_kzalloc(test, sizeof(*ctx), GFP_KERNEL);
   113		KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ctx);
   114		test->priv = ctx;
   115	
   116		ctx->try_catch = kunit_kmalloc(test,
   117					       sizeof(*ctx->try_catch),
   118					       GFP_KERNEL);
   119		KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ctx->try_catch);
   120	
   121		return 0;
   122	}
   123	
   124	static struct kunit_case kunit_try_catch_test_cases[] = {
   125		KUNIT_CASE(kunit_test_try_catch_successful_try_no_catch),
   126		KUNIT_CASE(kunit_test_try_catch_unsuccessful_try_does_catch),
   127		KUNIT_CASE(kunit_test_generic_try_catch_successful_try_no_catch),
   128		KUNIT_CASE(kunit_test_generic_try_catch_unsuccessful_try_does_catch),
   129		{},
   130	};
   131	
   132	static struct kunit_module kunit_try_catch_test_module = {
   133		.name = "kunit-try-catch-test",
   134		.init = kunit_try_catch_test_init,
   135		.test_cases = kunit_try_catch_test_cases,
   136	};
   137	module_test(kunit_try_catch_test_module);
   138	
   139	/*
   140	 * Context for testing test managed resources
   141	 * is_resource_initialized is used to test arbitrary resources
   142	 */
   143	struct kunit_test_resource_context {
   144		struct kunit test;
   145		bool is_resource_initialized;
   146	};
   147	
   148	static int fake_resource_init(struct kunit_resource *res, void *context)
   149	{
   150		struct kunit_test_resource_context *ctx = context;
   151	
   152		res->allocation = &ctx->is_resource_initialized;
   153		ctx->is_resource_initialized = true;
   154		return 0;
   155	}
   156	
   157	static void fake_resource_free(struct kunit_resource *res)
   158	{
   159		bool *is_resource_initialized = res->allocation;
   160	
   161		*is_resource_initialized = false;
   162	}
   163	
   164	static void kunit_resource_test_init_resources(struct kunit *test)
   165	{
   166		struct kunit_test_resource_context *ctx = test->priv;
   167	
   168		kunit_init_test(&ctx->test, "testing_test_init_test");
   169	
   170		KUNIT_EXPECT_TRUE(test, list_empty(&ctx->test.resources));
   171	}
   172	
   173	static void kunit_resource_test_alloc_resource(struct kunit *test)
   174	{
   175		struct kunit_test_resource_context *ctx = test->priv;
   176		struct kunit_resource *res;
   177		kunit_resource_free_t free = fake_resource_free;
   178	
   179		res = kunit_alloc_resource(&ctx->test,
   180					   fake_resource_init,
   181					   fake_resource_free,
   182					   ctx);
   183	
   184		KUNIT_ASSERT_NOT_ERR_OR_NULL(test, res);
 > 185		KUNIT_EXPECT_EQ(test, &ctx->is_resource_initialized, res->allocation);
   186		KUNIT_EXPECT_TRUE(test, list_is_last(&res->node, &ctx->test.resources));
   187		KUNIT_EXPECT_EQ(test, free, res->free);
   188	}
   189	

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

Attachment: .config.gz
Description: application/gzip


[Index of Archives]     [Linux&nblp;USB Development]     [Linux Media]     [Video for Linux]     [Linux Audio Users]     [Yosemite Secrets]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux