1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2016 RehiveTech. All rights reserved.
11 const char test_resource_dpdk_blob[] = {
12 '\x44', '\x50', '\x44', '\x4b', '\x00'
15 REGISTER_RESOURCE(test_resource_dpdk,
16 test_resource_dpdk_blob, test_resource_dpdk_blob + 4);
18 static int test_resource_dpdk(void)
20 const struct resource *r;
22 r = resource_find("test_resource_dpdk");
23 TEST_ASSERT_NOT_NULL(r, "Could not find test_resource_dpdk");
24 TEST_ASSERT(!strcmp(r->name, "test_resource_dpdk"),
25 "Found resource %s, expected test_resource_dpdk",
28 TEST_ASSERT(!strncmp("DPDK", r->begin, 4),
29 "Unexpected payload: %.4s...", r->begin);
34 REGISTER_LINKED_RESOURCE(test_resource_c);
36 static int test_resource_c(void)
38 const struct resource *r;
41 r = resource_find("test_resource_c");
42 TEST_ASSERT_NOT_NULL(r, "No test_resource_c found");
43 TEST_ASSERT(!strcmp(r->name, "test_resource_c"),
44 "Found resource %s, expected test_resource_c",
47 TEST_ASSERT_SUCCESS(resource_fwrite_file(r, "test_resource.c"),
48 "Failed to to write file %s", r->name);
50 f = fopen("test_resource.c", "r");
51 TEST_ASSERT_NOT_NULL(f,
52 "Missing extracted file resource.c");
54 remove("test_resource.c");
59 #ifdef RTE_APP_TEST_RESOURCE_TAR
60 REGISTER_LINKED_RESOURCE(test_resource_tar);
62 static int test_resource_tar(void)
64 const struct resource *r;
67 r = resource_find("test_resource_tar");
68 TEST_ASSERT_NOT_NULL(r, "No test_resource_tar found");
69 TEST_ASSERT(!strcmp(r->name, "test_resource_tar"),
70 "Found resource %s, expected test_resource_tar",
73 TEST_ASSERT_SUCCESS(resource_untar(r),
74 "Failed to to untar %s", r->name);
76 f = fopen("test_resource.c", "r");
77 TEST_ASSERT_NOT_NULL(f,
78 "Missing extracted file test_resource.c");
81 TEST_ASSERT_SUCCESS(resource_rm_by_tar(r),
82 "Failed to remove extracted contents of %s", r->name);
86 #endif /* RTE_APP_TEST_RESOURCE_TAR */
88 static int test_resource(void)
90 if (test_resource_dpdk())
93 if (test_resource_c())
96 #ifdef RTE_APP_TEST_RESOURCE_TAR
97 if (test_resource_tar())
99 #endif /* RTE_APP_TEST_RESOURCE_TAR */
104 REGISTER_TEST_COMMAND(resource_autotest, test_resource);